Check-in [4eed41b225]
Not logged in
Overview
Comment:Improved help messages
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4eed41b225001fa77d829ed65ad3f5d80f3b1288
User & Date: vitus on 2015-12-11 20:50:05
Other Links: manifest | tags
Context
2015-12-11
21:21
Added stop --hard, written some usb-related code check-in: 2cc90f6c24 user: vitus tags: trunk
20:50
Improved help messages check-in: 4eed41b225 user: vitus tags: trunk
20:21
Moved create functionality into main vws script check-in: 8f4a02281b user: vitus tags: trunk
Changes

Modified vws from [f90e02c1ac] to [c892d664ab].

185
186
187
188
189
190
191


192






193
194
195
196
197
198
199
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207







+
+

+
+
+
+
+
+







            else:
                print f[0]
    if not count:
        sys.exit(1)
def cmd_version(options):
    print VERSION

def validate_size(size):
    return re.match('\d+[KMG]',size) is not None
def cmd_create(parsed_args):
    if not parsed_args.image and not validate_size(parsed_args.size):
        print >>sys.stderr,"Invalid size of disk specifed %s. Should have K, M or G suffix"%parsed_args.size
        sys.exit(1)
    if not validate_size(parsed_args.mem):    
        print >>sys.stderr,"Invalid size of memory specifed %s. Should have K, M or G suffix"%parsed_args.size
        sys.exit(1)
    libdir="/usr/local/lib/vws"
    drivename="drive0.qcow2"
    options={'qemubinary':'qemu-system-x86_64',
    "accel":"-enable-kvm",
    "memory":"1024M",
    "vga":'qxl',
    "drive":"-drive media=disk,index=0,if={interface},file={image}",
290
291
292
293
294
295
296
297

298
299
300
301


302
303
304


305
306
307

308
309
310
311
312








313
314


315
316
317
318
319

320
321
322
323
324
325
326
298
299
300
301
302
303
304

305
306
307
308
309
310
311
312
313

314
315
316
317

318
319
320



321
322
323
324
325
326
327
328
329

330
331
332
333
334
335

336
337
338
339
340
341
342
343







-
+




+
+


-
+
+


-
+


-
-
-
+
+
+
+
+
+
+
+

-
+
+




-
+







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()
cmds=args.add_subparsers(dest='command',help="sub-command help")
p=cmds.add_parser("list",help="List existing VWs")
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,
                dest='usb',help='Show connected USB devices')
p=cmds.add_parser("version",help="show vws version")
# Power management
p=new_command(cmds,'start',help='Start VM and connect to console')
p=new_command(cmds,'start',help='Start VW and connect to console',
    description="Start VW if not running and connect to the console")
p.add_argument('--no-gui',dest='gui',action='store_const',const=False,
               default=True,help='do not open console window')
p.add_argument('--cdrom',dest='cdrom',nargs=1,
p.add_argument('--cdrom',metavar='filename.iso',dest='cdrom',nargs=1,
               help='connect specified iso image to VMs cdrom on start')
# Following commands don't need extra args
new_command(cmds,'stop',help='Shut down virtual machine')
new_command(cmds,'save',help='Save VM state and stop emulation')
new_command(cmds,'reset',help='Reboot a guest OS')
p=new_command(cmds,'stop',help='Shut down virtual machine',
         description="Terminate the VW, gracefully or ungracefully")
p.add_argument('--hard',help='Power off immediately', action='store_const',dest='hard',const=True,default=False)

new_command(cmds,'save',help='Save VW state and stop emulation',
    description="Save VW state and stop emulation")
new_command(cmds,'reset',help='Reboot a guest OS',
    description="Reboot othe guuest OS")
# Removable devices management
p=new_command(cmds,'cdrom',help='manage CDROM Drive')
p=new_command(cmds,'cdrom',help='manage CDROM Drive',
    description='"insert" an ISO image into emulated CD-ROM or eject it')
p.add_argument('--id',type=str,default=None,
               help='Identifier of CDROM drive if VM has more than one')
p.add_argument('file',nargs="?",default='',help='ISO image or special file to connect to drive')
p.add_argument('--eject',dest='file',action='store_const',const=None)
usb=cmds.add_parser('usb').add_subparsers(dest='subcommand',help='manage USB devices')
usb=cmds.add_parser('usb',help='manage USB devices').add_subparsers(dest='subcommand',help='manage USB devices')
p=new_command(usb,'insert',help='attach device to the virtual machine')
p.add_argument('pattern',help='Pattern of device name to look up in lsusb')
p.add_argument('--address',type=str,dest='address',nargs=1,help='exact address bus:device')
p=new_command(usb,'remove',help='detach connected usb device')
p.add_argument('pattern',help='Pattern of device name to look up in lsusb')
p.add_argument('--address',type=str,dest='address',nargs=1,help='exact address bus:device')
p=new_command(usb,'attached',help='list devices attached to vm')
335
336
337
338
339
340
341
342
343


344
345
346


347
348
349


350
351
352


353
354
355
356
357
358
359
352
353
354
355
356
357
358


359
360
361


362
363
364


365
366
367


368
369
370
371
372
373
374
375
376







-
-
+
+

-
-
+
+

-
-
+
+

-
-
+
+







p.add_argument('filename',help='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.add_argument("--no-usb",help="Disable USB controller",action='store_const', const = False, default=True, dest="usb")
p.add_argument("--size",help="Size of primary disk images",dest="size",default="20G");
p.add_argument("--arch",help="Emulated architecture",dest="arch",default='x86_64');
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",help="Specify sound card type",dest='sound',default='hda')
p.add_argument("--vga",help="specify video card type (cirrus,std,vmwae,qxl) default qxl",dest="vga",default="qxl")
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",help="Size of memory",dest="mem",default="1024M")
p.add_argument("--diskif",help="Disk interface",dest="diskif",default="virtio")
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('--image',help='Existing disk image to import',dest='image',default=None)
p.add_argument('--install',help='ISO image to install OS from',dest='install',default=None)
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:])

# Create command is totally different, so it is handled separately