# HG changeset patch # User atton # Date 1446814303 -32400 # Node ID 16840a2375aeaee62966634305b41bd897b71fef # Parent 3b8858a63694ce53f4035d5a47c383c99d24d9b4 Adapt to CentOS7 diff -r 3b8858a63694 -r 16840a2375ae newvm.py --- a/newvm.py Fri Nov 06 20:30:26 2015 +0900 +++ b/newvm.py Fri Nov 06 21:51:43 2015 +0900 @@ -67,6 +67,15 @@ ie_mkdir1('/var/lib/libvirt/qemu/'+dir) os.system("/bin/chown "+os.getlogin()+" "+ mount_point+dir) +# virtinst.utils.randomMac is omitted from RHEL 7. +import random +def randomMAC(): + mac = [ 0x52, 0x54, 0x00, + random.randint(0x00, 0xff), + random.randint(0x00, 0xff), + random.randint(0x00, 0xff) ] + return ':'.join(map(lambda x: "%02x" % x, mac)) + parser = OptionParser(); parser.add_option("-n", "--name", dest="name", help="VM name"); @@ -95,9 +104,9 @@ name.text = new_name uuid = config.find('uuid') -uuid.text = uuidToString(randomUUID()) +uuid.text = randomUUID(0) mac = config.find('devices/interface/mac') -mac.attrib['address'] = randomMAC(type='qemu') +mac.attrib['address'] = randomMAC() disk = config.find('devices/disk/source') disk_old = disk.attrib['file'] disk_path = os.path.dirname(disk_old)