# HG changeset patch # User anatofuz # Date 1603344443 -32400 # Node ID 2aa12d6f79e09c8a44da2b8f547c4fab71c751df # Parent d2e05ee14974ef422fbcac801f6bb73fd947a332 2to3 diff -r d2e05ee14974 -r 2aa12d6f79e0 newvm.py --- a/newvm.py Sat Oct 03 15:42:02 2020 +0900 +++ b/newvm.py Thu Oct 22 14:27:23 2020 +0900 @@ -81,7 +81,7 @@ random.randint(0x00, 0xff), random.randint(0x00, 0xff), random.randint(0x00, 0xff) ] - return ':'.join(map(lambda x: "%02x" % x, mac)) + return ':'.join(["%02x" % x for x in mac]) # def randomUUID(): # u = [random.randint(0, 255) for ignore in range(0, 16)] @@ -114,14 +114,14 @@ (options, args) = parser.parse_args(); if not options.name or not options.config: - print "Usage %s -n name -c template_xml [-d debug_port]" % sys.argv[0] + print(("Usage %s -n name -c template_xml [-d debug_port]" % sys.argv[0])) sys.exit(1) config = ET.parse(options.config) vm_name = options.name -print(options.config) +print((options.config)) if ie_check_name(vm_name): - print "Can't make new vm. Bad vmname %s. Try 01 - 04" % vm_name + print(("Can't make new vm. Bad vmname %s. Try 01 - 04" % vm_name)) sys.exit(1) ie_mkdir(vm_name) @@ -142,7 +142,7 @@ disk.attrib['file'] = disk_image vnc = config.find('devices/graphics') vnc.attrib['passwd'] = genPassword() -print "vnc password : %s" % vnc.attrib['passwd'] +print(("vnc password : %s" % vnc.attrib['passwd'])) if (options.debug): # http://wiki.libvirt.org/page/QEMUSwitchToLibvirt @@ -155,11 +155,11 @@ domain.append(qemu_elem) if os.path.exists(vm_name + '.xml'): - print "File %s.xml exists, abort" % vm_name + print(("File %s.xml exists, abort" % vm_name)) sys.exit(1) # config.write('/usr/local/etc/libvirt/qemu/' + vm_name + '.xml') -print("VM_NAME:" + new_name) +print(("VM_NAME:" + new_name)) config.write('/etc/libvirt/qemu/' + vm_name + '.xml') -print "Created vm config file %s.xml" % vm_name -print "Use disk image %s" % disk_image -print "Done!" +print(("Created vm config file %s.xml" % vm_name)) +print(("Use disk image %s" % disk_image)) +print("Done!")