Overview
Comment: | Expanded config handling. Fixes [00962e4d5d] and [381a103023] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
30d9fa306e4480efd0d617e065d3bf4d |
User & Date: | vitus on 2015-12-18 13:14:37 |
Other Links: | manifest | tags |
Context
2015-12-18
| ||
14:42 | Added checks for snapshots into cmd_commit. Fixes [b5f7b7a1e8] check-in: 34605c20d1 user: vitus tags: trunk | |
13:14 | Expanded config handling. Fixes [00962e4d5d] and [381a103023] check-in: 30d9fa306e user: vitus tags: trunk | |
08:32 | Added function list_briges which disappeared somewhere when create command was incorporated in vws script check-in: 155c39c9b5 user: vitus tags: trunk | |
Changes
Modified vws from [394f213744] to [47bc1de06d].
︙ | ︙ | |||
67 68 69 70 71 72 73 | return None return "spice://"+url.rstrip('\r') def list_bridges(): lst=[] | | | | | | | | | | | < | > | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | return None return "spice://"+url.rstrip('\r') def list_bridges(): lst=[] with os.popen(config.get('tools','bridge_list'), "r") as f: for line in f: n = line.find('\t'); if n <= 0: continue name = line[:n] if name == "bridge name": continue lst.append(name) return lst # # command implementation # def cmd_spiceuri(options): print spiceurl(options) def cmd_start(options): if options.stopped: arg="" if options.cdrom: arg=" -cdrom "+options.cdrom[0] if options.snapshot: arg=arg+" -snapshot" if options.args: arg=arg+" "+"".join(options.args) print arg cwd=os.getcwd() os.chdir(options.dir) os.system("./start%s" % arg) os.chdir(cwd) time.sleep(2) options.sock = connect_vm(options.dir) else: if options.snapshot or options.args: print >>sys.stderr, "Cannot change qemu options. VM is already running" if options.cdrom: options.file = options.cdrom[0] cmd_cdrom(options) if options.gui: uri = spiceurl(options) os.system((config.get('tools','viewer')+"&") % uri) elif not options.stopped: print >>sys.stderr,"VM already running" def cmd_stop(options): if options.hard: print send_command(options.sock,'quit') else: print send_command(options.sock,'system_powerdown') |
︙ | ︙ | |||
173 174 175 176 177 178 179 | break elif not hasattr("address",options): print >>sys.stderr,"Addess or search pattern for device is not specified" sys.exit(1) else: return options.address def get_host_devices(): | > | > > | > | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | break elif not hasattr("address",options): print >>sys.stderr,"Addess or search pattern for device is not specified" sys.exit(1) else: return options.address def get_host_devices(): global config f=os.popen(config.get('tools',"lsusb"),"r") l=[] for dev in f: m=re.match('Bus (\d+) Device (\d+): (.*)$',dev) if m: if m.group(3).endswith("root hub"): continue l.append((m.group(1)+"."+m.group(2),m.group(3))) f.close() return l def get_vm_devices(sock): answer=send_command(sock,"info usb") l=[] for dev in answer.split("\n"): m=re.match('Device (\d+\.\d), .*?, Product (.*)$',dev) if m: l.append((m.group(1),m.group(2))) return l def cmd_usb_insert(options): address=find_usb(options,get_host_devices()) answer=send_command(options.sock,"usb_add host:%s" % address) print answer def cmd_usb_list(options): for addr,descr in get_host_devices(): print addr,": ",descr def cmd_usb_remove(options): address=find_usb(options,get_vm_devices(options.sock)) answer=send_command(options.sock,"usb_del %s" % address) print answer def cmd_usb_attached(options): for t in get_vm_devices(options.sock): |
︙ | ︙ | |||
252 253 254 255 256 257 258 259 260 261 262 263 264 265 | print send_command(options.sock,"wavcapture "+filename) def cmd_stoprecord(options): answer = send_command(options.sock,"info capture") m=re.search('\[(\d+)\]: ',answer) if not m: print >>sys.stderr,"No sound recording in progress" else: print send_command(options.sock,"stopcapture "+m.group(1)) def cmd_version(options): print VERSION def validate_size(size): return re.match('\d+[KMG]',size) is not None | > | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | print send_command(options.sock,"wavcapture "+filename) def cmd_stoprecord(options): answer = send_command(options.sock,"info capture") m=re.search('\[(\d+)\]: ',answer) if not m: print >>sys.stderr,"No sound recording in progress" sys.exit(1) else: print send_command(options.sock,"stopcapture "+m.group(1)) def cmd_version(options): print VERSION def validate_size(size): return re.match('\d+[KMG]',size) is not None |
︙ | ︙ | |||
508 509 510 511 512 513 514 | p=cmds.add_parser(name,**kwargs) p.add_argument('machine',type=str,help='name of vm to operate on') return p # # arg parsing # | | | > > > > > > > > > > > > | | 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | p=cmds.add_parser(name,**kwargs) p.add_argument('machine',type=str,help='name of vm to operate on') return p # # arg parsing # arch=os.uname()[4] if re.match("i[3-9]86",arch): arch="i386" elif arch.startswith("arm"): arch="arm" config=ConfigParser({'SharedVMs':'/var/cache/vws/shared', 'AutoStartVMs':'/var/cache/vws/autostart'}) config.add_section('directories') config.add_section('create options') for option,value in [('net','user'),('size','20G'),('mem','1G'), ('diskif','virtio'),('sound','hda'),('arch',arch), ('vga','qxl')]: config.set('create options',option,value) config.add_section('tools') config.set('tools','viewer','remote-viewer %s') config.set('tools','bridge_list','/sbin/brctl show') config.set('tools','lsusb','lsusb') config.read(['/etc/vws.conf',os.environ['HOME']+'/.vwsrc']) print config 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') |
︙ | ︙ | |||
577 578 579 580 581 582 583 | 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 VW") p.add_argument("--no-usb",help="Disable USB controller",action='store_const', const = False, default=True, dest="usb") | | > | > | > | > | > > | > | > | > > | > | > | > | 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | 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 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=config.get('create options','size')); p.add_argument("--arch",metavar='cputype',help="Emulated architecture", dest="arch", default=config.get('create options','arch')); p.add_argument("--no-sound",help="Disable sound card", action='store_const', const=None, default=config.get('create options', 'sound'), dest="sound") p.add_argument("--sound",metavar='cardtype',help="Specify sound card type", dest='sound',default=config.get('create options','sound')) p.add_argument("--vga",metavar='cardtype', help="specify video card type (cirrus,std,vmwae,qxl) default qxl", dest="vga",default=config.get('create options','vga')) p.add_argument("--net",help="Network - 'user' or bridge name", dest='net',default=config.get('create options','net')) p.add_argument("--mem",metavar='size',help="Size of memory", dest="mem",default=config.get('create options','mem')) p.add_argument("--diskif",metavar='interface-type', help="Disk interface (virtio, scsi, ide)",choices=['virtio','scsi','ide'], dest="diskif",default=config.get('create options','diskif')) 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:]) # Create command is totally different, so it is handled separately |
︙ | ︙ |
Modified vws.conf from [39dcfcb6d9] to [696381eb23].
1 2 3 | [directories] SharedVMs=/home/virtual/vws/shared AutostartVMs=/home/virtual/vws/autostart | > > > > > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | [directories] SharedVMs=/home/virtual/vws/shared AutostartVMs=/home/virtual/vws/autostart [tools] viewer=remote-viewer %s bridge_list=/sbin/brigectl show lsusbh=lsusb [create options] net=user size=20G mem=1G # vws would compute default arch for at least i385, x86_64 and arm # arch=i386 sound=hda vga=qxl diskif=virtio |