497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
|
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
|
-
+
|
config=ConfigParser({'SharedVMs':'/var/cache/vws/shared',
'AutoStartVMs':'/var/cache/vws/autostart'})
config.add_section('directories')
config.read(['/etc/vws.conf',os.environ['HOME']+'/.vwsrc'])
args=ArgumentParser()
args=ArgumentParser(description="Manage Virtual Workstations")
cmds=args.add_subparsers(dest='command',help="sub-command help")
p=cmds.add_parser("list",help="List existing VWs",description="List existing VWs")
p.add_argument("--state",action='store_const',const=True,default=False,
dest='state',help='Show state of the machine')
p.add_argument("--addr",action='store_const',const=True,default=False,
dest='addr',help='Show mac address and spice port')
p.add_argument("--usb",action='store_const',const=True,default=False,
|
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
|
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
|
-
+
-
+
|
# Screenshoits and recording
p=new_command(cmds,'screenshot',help='take a screenshot')
p.add_argument('filename',help='PPM image filename to write screenshot to')
p=new_command(cmds,'record',help='Record audio output from VM')
p.add_argument('filename',help='wav file to record autdio to')
new_command(cmds,'stoprecord',help='stop recording audio')
# Create new VM
p=new_command(cmds,'create',help="Create new VM")
p=new_command(cmds,'create',help="Create new VW")
p.add_argument("--no-usb",help="Disable USB controller",action='store_const', const = False, default=True, dest="usb")
p.add_argument("--size",metavar='size',help="Size of primary disk images",dest="size",default="20G");
p.add_argument("--arch",metavar='cputype',help="Emulated architecture",dest="arch",default='x86_64');
p.add_argument("--no-sound",help="Disable sound card",action='store_const',const = None,default='hda', dest="sound")
p.add_argument("--sound",metavar='cardtype',help="Specify sound card type",dest='sound',default='hda')
p.add_argument("--vga",metavar='cardtype',help="specify video card type (cirrus,std,vmwae,qxl) default qxl",dest="vga",default="qxl")
p.add_argument("--net",help="Network - 'user' or bridge name",dest='net',default="user")
p.add_argument("--mem",metavar='size',help="Size of memory",dest="mem",default="1024M")
p.add_argument("--diskif",metavar='interface-type',help="Disk interface (virtio, scsi, ide)",choices=['virtio','scsi','ide'],dest="diskif",default="virtio")
p.add_argument('--shared',help='Create shared VM instead of private one',action='store_const',const= True,dest='shared',default=False)
p.add_argument('--shared',help='Create shared VW instead of private one',action='store_const',const= True,dest='shared',default=False)
p.add_argument('--image',metavar='filename',help='Existing disk image to import',dest='image',default=None)
p.add_argument('--install',metavar='filename.iso',help='ISO image to install OS from',dest='install',default=None)
# Miscellenia
p=new_command(cmds,'monitor',help='connect stdin/stdout to monitor of VM')
p=new_command(cmds,'spiceuri',help='Output spice URI of machine')
parsed_args=args.parse_args(sys.argv[1:])
|
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
|
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
|
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
|
print >>sys.stderr, "Virtual machine %s is not running."%parsed_args.machine
sys.exit(1)
else:
parsed_args.stopped = True
funcname="cmd_"+parsed_args.command
try:
if hasattr(parsed_args,"subcommand"):
funcname+="_"+parsed_args.subcommand
try:
func=globals()[funcname]
except KeyError:
print >>sys.stderr,"Operation %s is not implemented"%funcname
sys.exit(3)
func(parsed_args)
if hasattr(parsed_args,'sock') and parsed_args.sock is not None:
parsed_args.sock.shutdown(socket.SHUT_RDWR)
parsed_args.sock.close()
if hasattr(parsed_args,"subcommand"):
funcname+="_"+parsed_args.subcommand
try:
func=globals()[funcname]
except KeyError:
print >>sys.stderr,"Operation %s is not implemented"%funcname
sys.exit(3)
func(parsed_args)
finally:
if hasattr(parsed_args,'sock') and parsed_args.sock is not None:
parsed_args.sock.shutdown(socket.SHUT_RDWR)
parsed_args.sock.close()
|