changeset 55:2aa12d6f79e0 default tip

2to3
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Thu, 22 Oct 2020 14:27:23 +0900
parents d2e05ee14974
children
files newvm.py
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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!")