Changeset 21640 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jul 16, 2009 11:21:47 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r21584 r21640 258 258 print session.QueryErrorObject(rc) 259 259 260 def getMachines(ctx): 261 return ctx['global'].getArray(ctx['vb'], 'machines') 260 def getMachines(ctx, invalidate = False): 261 if ctx['vb'] is not None: 262 if ctx['_machlist'] is None or invalidate: 263 ctx['_machlist'] = ctx['global'].getArray(ctx['vb'], 'machines') 264 return ctx['_machlist'] 265 else: 266 return [] 262 267 263 268 def asState(var): … … 389 394 390 395 def listCmd(ctx, args): 391 for m in getMachines(ctx ):396 for m in getMachines(ctx, True): 392 397 print "Machine '%s' [%s], state=%s" %(m.name,m.id,m.sessionState) 393 398 return 0 … … 420 425 os = ctx['vb'].getGuestOSType(mach.OSTypeId) 421 426 print " One can use setvar <mach> <var> <value> to change variable, using name in []." 422 print " Name [name]: " + mach.name423 print " ID [n/a]: " + mach.id424 print " OS Type [n/a]: " + os.description427 print " Name [name]: %s" %(mach.name) 428 print " ID [n/a]: %s" %(mach.id) 429 print " OS Type [n/a]: %s" %(os.description) 425 430 print 426 431 print " CPUs [CPUCount]: %d" %(mach.CPUCount) … … 435 440 print " ACPI [BIOSSettings.ACPIEnabled]: %s" %(asState(bios.ACPIEnabled)) 436 441 print " APIC [BIOSSettings.IOAPICEnabled]: %s" %(asState(bios.IOAPICEnabled)) 437 print " PAE [PAEEnabled]: %s" %(asState( mach.PAEEnabled))442 print " PAE [PAEEnabled]: %s" %(asState(int(mach.PAEEnabled))) 438 443 print " Hardware virtualization [HWVirtExEnabled]: " + asState(mach.HWVirtExEnabled) 439 444 print " VPID support [HWVirtExVPIDEnabled]: " + asState(mach.HWVirtExVPIDEnabled) … … 457 462 print " Controller: %s port: %d device: %d:" % (disk.controller, disk.port, disk.device) 458 463 hd = disk.hardDisk 459 print " id: " + hd.id460 print " location: " + hd.location461 print " name: " + hd.name462 print " format: " + hd.format464 print " id: %s" %(hd.id) 465 print " location: %s" %(hd.location) 466 print " name: %s" %(hd.name) 467 print " format: %s" %(hd.format) 463 468 print 464 469 465 470 dvd = mach.DVDDrive 466 if dvd.getHostDrive() is not None:471 if dvd.getHostDrive(): 467 472 hdvd = dvd.getHostDrive() 468 473 print " DVD:" 469 print " Host disk: ",hdvd.name474 print " Host disk: %s" %(hdvd.name) 470 475 print 471 476 472 if dvd.getImage() is not None:477 if dvd.getImage(): 473 478 vdvd = dvd.getImage() 474 479 print " DVD:" 475 print " Image at: ",vdvd.location476 print " Size: ",vdvd.size480 print " Image at: %s" %(vdvd.location) 481 print " Size: %s" %(vdvd.size) 477 482 print 478 483 479 484 floppy = mach.floppyDrive 480 if floppy.getHostDrive() is not None:485 if floppy.getHostDrive(): 481 486 hfloppy = floppy.getHostDrive() 482 487 print " Floppy:" 483 print " Host disk: ",hfloppy.name488 print " Host disk: %s" %(hfloppy.name) 484 489 print 485 490 486 if floppy.getImage() is not None:491 if floppy.getImage(): 487 492 vfloppy = floppy.getImage() 488 493 print " Floppy:" 489 print " Image at: ",vfloppy.location490 print " Size: ",vfloppy.size494 print " Image at: %s" %(vfloppy.location) 495 print " Size: %s" %(vfloppy.size) 491 496 print 492 497 … … 769 774 770 775 time.sleep(float(args[1])) 776 return 0 777 778 779 def connectCmd(ctx, args): 780 if (len(args) > 4): 781 print "usage: connect [url] [username] [passwd]" 782 return 0 783 784 if ctx['vb'] is not None: 785 print "Already connected, disconnect first..." 786 return 0 787 788 if (len(args) > 1): 789 url = args[1] 790 else: 791 url = None 792 793 if (len(args) > 2): 794 user = args[1] 795 else: 796 user = "" 797 798 if (len(args) > 3): 799 passwd = args[2] 800 else: 801 passwd = "" 802 803 vbox = ctx['global'].platform.connect(url, user, passwd) 804 ctx['vb'] = vbox 805 print "Running VirtualBox version %s" %(vbox.version) 806 ctx['perf'] = ctx['global'].getPerfCollector(ctx['vb']) 807 return 0 808 809 def disconnectCmd(ctx, args): 810 if (len(args) != 1): 811 print "usage: disconnect" 812 return 0 813 814 if ctx['vb'] is None: 815 print "Not connected yet." 816 return 0 817 818 try: 819 ctx['global'].platform.disconnect() 820 except: 821 ctx['vb'] = None 822 raise 823 824 ctx['vb'] = None 825 return 0 771 826 772 827 aliases = {'s':'start', … … 852 907 traceback.print_exc() 853 908 854 def interpret(ctx): 909 def interpret(ctx): 910 if ctx['remote']: 911 commands['connect'] = ["Connect to remote VBox instance", connectCmd, 0] 912 commands['disconnect'] = ["Disconnect from remote VBox instance", disconnectCmd, 0] 913 855 914 vbox = ctx['vb'] 856 print "Running VirtualBox version %s" %(vbox.version) 857 ctx['perf'] = ctx['global'].getPerfCollector(ctx['vb']) 858 859 checkUserExtensions(ctx, commands, vbox.homeFolder) 915 916 if vbox is not None: 917 print "Running VirtualBox version %s" %(vbox.version) 918 ctx['perf'] = ctx['global'].getPerfCollector(ctx['vb']) 919 home = vbox.homeFolder 920 else: 921 ctx['perf'] = None 922 home = os.path.join(os.path.expanduser("~"), ".VirtualBox") 923 924 print "h", home 925 checkUserExtensions(ctx, commands, home) 860 926 861 927 autoCompletion(commands, ctx) … … 923 989 'remote':g_virtualBoxManager.remote, 924 990 'type':g_virtualBoxManager.type, 925 'run':runCommandCb 991 'run':runCommandCb, 992 '_machlist':None 926 993 } 927 994 interpret(ctx)
Note:
See TracChangeset
for help on using the changeset viewer.