Changeset 24581 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 11, 2009 2:35:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r24450 r24581 219 219 220 220 221 def reportError(ctx,session,rc): 222 if not ctx['remote']: 223 print session.QueryErrorObject(rc) 224 225 221 226 def createVm(ctx,name,kind,base): 222 227 mgr = ctx['mgr'] … … 274 279 session.close() 275 280 else: 276 # Not yet implemented error string query API for remote API 277 if not ctx['remote']: 278 print session.QueryErrorObject(rc) 281 reportError(ctx,session,rc) 279 282 280 283 def getMachines(ctx, invalidate = False): … … 353 356 data = display.takeScreenShotSlow(w,h) 354 357 size = (w,h) 355 mode = "RGBA" 358 mode = "RGBA" 356 359 im = Image.frombuffer(mode, size, data, "raw", mode, 0, 1) 357 360 im.save(f, "PNG") 358 361 362 363 def teleport(ctx,session,console,args): 364 if args[0].find(":") == -1: 365 print "Use host:port format for teleport target" 366 return 367 (host,port) = args[0].split(":") 368 if len(args) > 1: 369 passwd = args[1] 370 else: 371 passwd = "" 372 373 port = int(port) 374 print "Teleporting to %s:%d..." %(host,port) 375 progress = console.teleport(host, port, passwd) 376 progressBar(ctx, progress, 100) 377 completed = progress.completed 378 rc = int(progress.resultCode) 379 if rc == 0: 380 print "Success!" 381 else: 382 reportError(ctx,session,rc) 359 383 360 384 def cmdExistingVm(ctx,mach,cmd,args): … … 387 411 'monitorGuest': lambda: monitorGuest(ctx, mach, console, args), 388 412 'save': lambda: progressBar(ctx,console.saveState()), 389 'screenshot': lambda: takeScreenshot(ctx,console,args) 413 'screenshot': lambda: takeScreenshot(ctx,console,args), 414 'teleport': lambda: teleport(ctx,session,console,args) 390 415 } 391 416 try: … … 650 675 cmdExistingVm(ctx, mach, 'screenshot', args[2:]) 651 676 return 0 677 678 def teleportCmd(ctx, args): 679 if (len(args) < 3): 680 print "usage: teleport name host:port <password>" 681 return 0 682 mach = argsToMach(ctx,args) 683 if mach == None: 684 return 0 685 cmdExistingVm(ctx, mach, 'teleport', args[2:]) 686 return 0 687 688 def makeportalCmd(ctx, args): 689 if (len(args) < 3): 690 print "usage: makeportal name port <password>" 691 return 0 692 mach = argsToMach(ctx,args) 693 if mach == None: 694 return 0 695 port = int(args[2]) 696 if (len(args) > 3): 697 passwd = args[3] 698 else: 699 passwd = "" 700 if not mach.teleporterEnabled or mach.teleporterPort != port: 701 session = ctx['global'].openMachineSession(mach.id) 702 mach1 = session.machine 703 mach1.teleporterEnabled = True 704 mach1.teleporterPort = port 705 mach1.saveSettings() 706 session.close() 707 startVm(ctx, mach, "gui") 708 return 0 709 710 def closeportalCmd(ctx, args): 711 if (len(args) < 2): 712 print "usage: closeportal name" 713 return 0 714 mach = argsToMach(ctx,args) 715 if mach == None: 716 return 0 717 if mach.teleporterEnabled: 718 session = ctx['global'].openMachineSession(mach.id) 719 mach1 = session.machine 720 mach1.teleporterEnabled = False 721 mach1.saveSettings() 722 session.close() 723 return 0 724 652 725 653 726 def setvarCmd(ctx, args): … … 1007 1080 'shell':['Execute external shell command: shell "ls /etc/rc*"', shellCmd, 0], 1008 1081 'exportVm':['Export VM in OVF format: export Win /tmp/win.ovf', exportVMCmd, 0], 1009 'screenshot':['Take VM screenshot to a file: screenshot Win /tmp/win.png 1024 768', screenshotCmd, 0] 1082 'screenshot':['Take VM screenshot to a file: screenshot Win /tmp/win.png 1024 768', screenshotCmd, 0], 1083 'teleport':['Teleport VM to another box (see makeportal): teleport Win anotherhost:8000 <passwd>', teleportCmd, 0], 1084 'makeportal':['Make portal for teleportation of VM from another box (see teleport): makeportal Win 8000 <passwd>', makeportalCmd, 0], 1085 'closeportal':['Close portal for teleportation of VM from another box (see teleport): closeportal Win', closeportalCmd, 0] 1010 1086 } 1011 1087
Note:
See TracChangeset
for help on using the changeset viewer.