Index: vws ================================================================== --- vws +++ vws @@ -1,8 +1,8 @@ #!/usr/bin/python from ConfigParser import ConfigParser -from argparse import ArgumentParser +from argparse import ArgumentParser,Namespace import fcntl import socket,select import errno import re import os,sys,time @@ -441,26 +441,25 @@ "sound":"-soundhw hda", "usb":"-usb"} macaddr=":".join(map(lambda x: "%02x"%ord(x),chr(0x52)+os.urandom(5))) if parsed_args.shared: - machinedir = config.get("directories","SharedVMs")+"/"+parsed_args.name + machinedir = config.get("directories","SharedVMs")+"/"+parsed_args.machine dirmode = 0755 else: - machinedir = os.environ["HOME"]+"/VWs/"+parsed_args.name + machinedir = os.environ["HOME"]+"/VWs/"+parsed_args.machine dirmode = 0775 if parsed_args.net != 'user': bridges = list_bridges() if not parsed_args.net in bridges: print >>sys.stderr,"No such bridge %s. Available ones %s"%(parsed_args.net,", ".join(bridges)) sys.exit(1) - options["net"]="-net nic,macaddr=%s -net bridge,br=%s"%(macaddr,parsed_args.net), + options["net"]="-net nic,macaddr=%s -net bridge,br=%s"%(macaddr,parsed_args.net) else: options["net"]="-net nic,macaddr=%s -net user"%(macaddr,) - options["qemubinary"] = 'qemu-system-'+parsed_args.arch options["vga"]=parsed_args.vga if not parsed_args.arch in ('i386','x86_64'): print >>sys.stderr,"KVM acceleration disabled due to target architecture" options.accel = '' @@ -478,11 +477,11 @@ options["memory"]=parsed_args.mem if os.path.exists(machinedir): if os.path.exists(machinedir+"/start"): - print >> sys.stderr,"Virtual Worstation %s already exists"%parsed_args.name + print >> sys.stderr,"Virtual Worstation %s already exists"%parsed_args.machine else: print >> sys.stderr,"Cannot create VW directory, something on the way" sys.exit(1) # Creating directory for VM os.makedirs(machinedir,dirmode) @@ -496,21 +495,25 @@ print >>sys.stderr,"Creating new image file" os.chdir(machinedir) os.system("qemu-img create -f qcow2 %s %s"%(drivename,parsed_args.size)) options["drive"]=options["drive"].format(**driveopts) - if parsed_args.debug: + if hasattr(parsed_args,"debug") and parsed_args.debug: print repr(driveopts),repr(options["drive"]) print repr(options) with open("start","w") as script: script.write(template.format(**options)) os.chmod('start',0755) # If installation media is specified vws start for new vm if parsed_args.install: - start_opts=Namespace(command='start',cdrom=parsed_args.install,stopped=True) + start_opts=Namespace(machine=parsed_args.machine, + command='start', cdrom=[parsed_args.install], + dir=machinedir, stopped=True, snapshot=False, + args="", gui=True + ) cmd_start(start_opts)