VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxShell/vboxshell.py@ 20926

Last change on this file since 20926 was 20926, checked in by vboxsync, 16 years ago

Python: fixed typo, improvments for the shell

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.1 KB
Line 
1#!/usr/bin/python
2#
3# Copyright (C) 2009 Sun Microsystems, Inc.
4#
5# This file is part of VirtualBox Open Source Edition (OSE), as
6# available from http://www.215389.xyz. This file is free software;
7# you can redistribute it and/or modify it under the terms of the GNU
8# General Public License (GPL) as published by the Free Software
9# Foundation, in version 2 as it comes in the "COPYING" file of the
10# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
11# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
12#
13# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
14# Clara, CA 95054 USA or visit http://www.sun.com if you need
15# additional information or have any questions.
16#
17#
18#################################################################################
19# This program is a simple interactive shell for VirtualBox. You can query #
20# information and issue commands from a simple command line. #
21# #
22# It also provides you with examples on how to use VirtualBox's Python API. #
23# This shell is even somewhat documented and supports TAB-completion and #
24# history if you have Python readline installed. #
25# #
26# Enjoy. #
27################################################################################
28
29import os,sys
30import traceback
31
32# Simple implementation of IConsoleCallback, one can use it as skeleton
33# for custom implementations
34class GuestMonitor:
35 def __init__(self, mach):
36 self.mach = mach
37
38 def onMousePointerShapeChange(self, visible, alpha, xHot, yHot, width, height, shape):
39 print "%s: onMousePointerShapeChange: visible=%d" %(self.mach.name, visible)
40 def onMouseCapabilityChange(self, supportsAbsolute, needsHostCursor):
41 print "%s: onMouseCapabilityChange: needsHostCursor=%d" %(self.mach.name, needsHostCursor)
42
43 def onKeyboardLedsChange(self, numLock, capsLock, scrollLock):
44 print "%s: onKeyboardLedsChange capsLock=%d" %(self.mach.name, capsLock)
45
46 def onStateChange(self, state):
47 print "%s: onStateChange state=%d" %(self.mach.name, state)
48
49 def onAdditionsStateChange(self):
50 print "%s: onAdditionsStateChange" %(self.mach.name)
51
52 def onDVDDriveChange(self):
53 print "%s: onDVDDriveChange" %(self.mach.name)
54
55 def onFloppyDriveChange(self):
56 print "%s: onFloppyDriveChange" %(self.mach.name)
57
58 def onNetworkAdapterChange(self, adapter):
59 print "%s: onNetworkAdapterChange" %(self.mach.name)
60
61 def onSerialPortChange(self, port):
62 print "%s: onSerialPortChange" %(self.mach.name)
63
64 def onParallelPortChange(self, port):
65 print "%s: onParallelPortChange" %(self.mach.name)
66
67 def onStorageControllerChange(self):
68 print "%s: onStorageControllerChange" %(self.mach.name)
69
70 def onVRDPServerChange(self):
71 print "%s: onVRDPServerChange" %(self.mach.name)
72
73 def onUSBControllerChange(self):
74 print "%s: onUSBControllerChange" %(self.mach.name)
75
76 def onUSBDeviceStateChange(self, device, attached, error):
77 print "%s: onUSBDeviceStateChange" %(self.mach.name)
78
79 def onSharedFolderChange(self, scope):
80 print "%s: onSharedFolderChange" %(self.mach.name)
81
82 def onRuntimeError(self, fatal, id, message):
83 print "%s: onRuntimeError fatal=%d message=%s" %(self.mach.name, fatal, message)
84
85 def onCanShowWindow(self):
86 print "%s: onCanShowWindow" %(self.mach.name)
87 return True
88
89 def onShowWindow(self, winId):
90 print "%s: onShowWindow: %d" %(self.mach.name, winId)
91
92class VBoxMonitor:
93 def __init__(self, vbox):
94 self.vbox = vbox
95 pass
96
97 def onMachineStateChange(self, id, state):
98 print "onMachineStateChange: %s %d" %(id, state)
99
100 def onMachineDataChange(self,id):
101 print "onMachineDataChange: %s" %(id)
102
103 def onExtraDataCanChange(self, id, key, value):
104 print "onExtraDataCanChange: %s %s=>%s" %(id, key, value)
105 return True, ""
106
107 def onExtraDataChange(self, id, key, value):
108 print "onExtraDataChange: %s %s=>%s" %(id, key, value)
109
110 def onMediaRegistred(self, id, type, registred):
111 print "onMediaRegistred: %s" %(id)
112
113 def onMachineRegistred(self, id, registred):
114 print "onMachineRegistred: %s" %(id)
115
116 def onSessionStateChange(self, id, state):
117 print "onSessionStateChange: %s %d" %(id, state)
118
119 def onSnapshotTaken(self, mach, id):
120 print "onSnapshotTaken: %s %s" %(mach, id)
121
122 def onSnapshotDiscarded(self, mach, id):
123 print "onSnapshotDiscarded: %s %s" %(mach, id)
124
125 def onSnapshotChange(self, mach, id):
126 print "onSnapshotChange: %s %s" %(mach, id)
127
128 def onGuestPropertyChange(self, id, name, newValue, flags):
129 print "onGuestPropertyChange: %s: %s=%s" %(id, name, newValue)
130
131g_hasreadline = 1
132try:
133 import readline
134 import rlcompleter
135except:
136 g_hasreadline = 0
137
138
139if g_hasreadline:
140 class CompleterNG(rlcompleter.Completer):
141 def __init__(self, dic, ctx):
142 self.ctx = ctx
143 return rlcompleter.Completer.__init__(self,dic)
144
145 def complete(self, text, state):
146 """
147 taken from:
148 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496812
149 """
150 if text == "":
151 return ['\t',None][state]
152 else:
153 return rlcompleter.Completer.complete(self,text,state)
154
155 def global_matches(self, text):
156 """
157 Compute matches when text is a simple name.
158 Return a list of all names currently defined
159 in self.namespace that match.
160 """
161
162 matches = []
163 n = len(text)
164
165 for list in [ self.namespace ]:
166 for word in list:
167 if word[:n] == text:
168 matches.append(word)
169
170
171 try:
172 for m in getMachines(self.ctx):
173 # although it has autoconversion, we need to cast
174 # explicitly for subscripts to work
175 word = str(m.name)
176 if word[:n] == text:
177 matches.append(word)
178 word = str(m.id)
179 if word[0] == '{':
180 word = word[1:-1]
181 if word[:n] == text:
182 matches.append(word)
183 except Exception,e:
184 traceback.print_exc()
185 print e
186
187 return matches
188
189
190def autoCompletion(commands, ctx):
191 if not g_hasreadline:
192 return
193
194 comps = {}
195 for (k,v) in commands.items():
196 comps[k] = None
197 completer = CompleterNG(comps, ctx)
198 readline.set_completer(completer.complete)
199 readline.parse_and_bind("tab: complete")
200
201g_verbose = True
202
203def split_no_quotes(s):
204 return s.split()
205
206def createVm(ctx,name,kind,base):
207 mgr = ctx['mgr']
208 vb = ctx['vb']
209 mach = vb.createMachine(name, kind, base,
210 "00000000-0000-0000-0000-000000000000")
211 mach.saveSettings()
212 print "created machine with UUID",mach.id
213 vb.registerMachine(mach)
214
215def removeVm(ctx,mach):
216 mgr = ctx['mgr']
217 vb = ctx['vb']
218 id = mach.id
219 print "removing machine ",mach.name,"with UUID",id
220 session = ctx['global'].openMachineSession(id)
221 mach=session.machine
222 for d in mach.getHardDiskAttachments():
223 mach.detachHardDisk(d.controller, d.port, d.device)
224 ctx['global'].closeMachineSession(session)
225 mach = vb.unregisterMachine(id)
226 if mach:
227 mach.deleteSettings()
228
229def startVm(ctx,mach,type):
230 mgr = ctx['mgr']
231 vb = ctx['vb']
232 perf = ctx['perf']
233 session = mgr.getSessionObject(vb)
234 uuid = mach.id
235 progress = vb.openRemoteSession(session, uuid, type, "")
236 progress.waitForCompletion(-1)
237 completed = progress.completed
238 rc = int(progress.resultCode)
239 print "Completed:", completed, "rc:",hex(rc&0xffffffff)
240 if rc == 0:
241 # we ignore exceptions to allow starting VM even if
242 # perf collector cannot be started
243 if perf:
244 try:
245 perf.setup(['*'], [mach], 10, 15)
246 except Exception,e:
247 print e
248 if g_verbose:
249 traceback.print_exc()
250 pass
251 # if session not opened, close doesn't make sense
252 session.close()
253 else:
254 # Not yet implemented error string query API for remote API
255 if not ctx['remote']:
256 print session.QueryErrorObject(rc)
257
258def getMachines(ctx):
259 return ctx['global'].getArray(ctx['vb'], 'machines')
260
261def asState(var):
262 if var:
263 return 'on'
264 else:
265 return 'off'
266
267def guestStats(ctx,mach):
268 if not ctx['perf']:
269 return
270 for metric in ctx['perf'].query(["*"], [mach]):
271 print metric['name'], metric['values_as_string']
272
273def guestExec(ctx, machine, console, cmds):
274 exec cmds
275
276def monitorGuest(ctx, machine, console, dur):
277 import time
278 cb = ctx['global'].createCallback('IConsoleCallback', GuestMonitor, machine)
279 console.registerCallback(cb)
280 if dur == -1:
281 # not infinity, but close enough
282 dur = 100000
283 try:
284 end = time.time() + dur
285 while time.time() < end:
286 ctx['global'].waitForEvents(500)
287 # We need to catch all exceptions here, otherwise callback will never be unregistered
288 except:
289 pass
290 console.unregisterCallback(cb)
291
292
293def monitorVbox(ctx, dur):
294 import time
295 vbox = ctx['vb']
296 cb = ctx['global'].createCallback('IVirtualBoxCallback', VBoxMonitor, vbox)
297 vbox.registerCallback(cb)
298 if dur == -1:
299 # not infinity, but close enough
300 dur = 100000
301 try:
302 end = time.time() + dur
303 while time.time() < end:
304 ctx['global'].waitForEvents(500)
305 # We need to catch all exceptions here, otherwise callback will never be unregistered
306 except:
307 if g_verbose:
308 traceback.print_exc()
309 vbox.unregisterCallback(cb)
310
311def cmdExistingVm(ctx,mach,cmd,args):
312 mgr=ctx['mgr']
313 vb=ctx['vb']
314 session = mgr.getSessionObject(vb)
315 uuid = mach.id
316 try:
317 progress = vb.openExistingSession(session, uuid)
318 except Exception,e:
319 print "Session to '%s' not open: %s" %(mach.name,e)
320 if g_verbose:
321 traceback.print_exc()
322 return
323 if session.state != ctx['ifaces'].SessionState_Open:
324 print "Session to '%s' in wrong state: %s" %(mach.name, session.state)
325 return
326 # unfortunately IGuest is suppressed, thus WebServices knows not about it
327 # this is an example how to handle local only functionality
328 if ctx['remote'] and cmd == 'stats2':
329 print 'Trying to use local only functionality, ignored'
330 return
331 console=session.console
332 ops={'pause' : lambda: console.pause(),
333 'resume': lambda: console.resume(),
334 'powerdown': lambda: console.powerDown(),
335 'stats': lambda: guestStats(ctx, mach),
336 'guest': lambda: guestExec(ctx, mach, console, args),
337 'monitorGuest': lambda: monitorGuest(ctx, mach, console, args)
338 }
339 try:
340 ops[cmd]()
341 except Exception, e:
342 print 'failed: ',e
343 if g_verbose:
344 traceback.print_exc()
345
346 session.close()
347
348# can cache known machines, if needed
349def machById(ctx,id):
350 mach = None
351 for m in getMachines(ctx):
352 if m.name == id:
353 mach = m
354 break
355 mid = str(m.id)
356 if mid[0] == '{':
357 mid = mid[1:-1]
358 if mid == id:
359 mach = m
360 break
361 return mach
362
363def argsToMach(ctx,args):
364 if len(args) < 2:
365 print "usage: %s [vmname|uuid]" %(args[0])
366 return None
367 id = args[1]
368 m = machById(ctx, id)
369 if m == None:
370 print "Machine '%s' is unknown, use list command to find available machines" %(id)
371 return m
372
373def helpCmd(ctx, args):
374 if len(args) == 1:
375 print "Help page:"
376 names = commands.keys()
377 names.sort()
378 for i in names:
379 print " ",i,":", commands[i][0]
380 else:
381 c = commands.get(args[1], None)
382 if c == None:
383 print "Command '%s' not known" %(args[1])
384 else:
385 print " ",args[1],":", c[0]
386 return 0
387
388def listCmd(ctx, args):
389 for m in getMachines(ctx):
390 print "Machine '%s' [%s], state=%s" %(m.name,m.id,m.sessionState)
391 return 0
392
393def infoCmd(ctx,args):
394 import time
395 if (len(args) < 2):
396 print "usage: info [vmname|uuid]"
397 return 0
398 mach = argsToMach(ctx,args)
399 if mach == None:
400 return 0
401 os = ctx['vb'].getGuestOSType(mach.OSTypeId)
402 print " One can use setvar <mach> <var> <value> to change variable, using name in []."
403 print " Name [name]: ",mach.name
404 print " ID [id]: ",mach.id
405 print " OS Type [n/a]: ",os.description
406 print " CPUs [CPUCount]: %d" %(mach.CPUCount)
407 print " RAM [memorySize]: %dM" %(mach.memorySize)
408 print " VRAM [VRAMSize]: %dM" %(mach.VRAMSize)
409 print " Monitors [monitorCount]: %d" %(mach.monitorCount)
410 print " Clipboard mode [clipboardMode]: %d" %(mach.clipboardMode)
411 print " Machine status [n/a]: " ,mach.sessionState
412 bios = mach.BIOSSettings
413 print " ACPI [BIOSSettings.ACPIEnabled]: %s" %(asState(bios.ACPIEnabled))
414 print " APIC [BIOSSettings.IOAPICEnabled]: %s" %(asState(bios.IOAPICEnabled))
415 print " PAE [PAEEnabled]: %s" %(asState(mach.PAEEnabled))
416 print " Hardware virtualization [HWVirtExEnabled]: ",asState(mach.HWVirtExEnabled)
417 print " VPID support [HWVirtExVPIDEnabled]: ",asState(mach.HWVirtExVPIDEnabled)
418 print " Hardware 3d acceleration[accelerate3DEnabled]: ",asState(mach.accelerate3DEnabled)
419 print " Nested paging [HWVirtExNestedPagingEnabled]: ",asState(mach.HWVirtExNestedPagingEnabled)
420 print " Last changed [n/a]: ",time.asctime(time.localtime(mach.lastStateChange/1000))
421
422 return 0
423
424def startCmd(ctx, args):
425 mach = argsToMach(ctx,args)
426 if mach == None:
427 return 0
428 if len(args) > 2:
429 type = args[2]
430 else:
431 type = "gui"
432 startVm(ctx, mach, type)
433 return 0
434
435def createCmd(ctx, args):
436 if (len(args) < 3 or len(args) > 4):
437 print "usage: create name ostype <basefolder>"
438 return 0
439 name = args[1]
440 oskind = args[2]
441 if len(args) == 4:
442 base = args[3]
443 else:
444 base = ''
445 try:
446 ctx['vb'].getGuestOSType(oskind)
447 except Exception, e:
448 print 'Unknown OS type:',oskind
449 return 0
450 createVm(ctx, name, oskind, base)
451 return 0
452
453def removeCmd(ctx, args):
454 mach = argsToMach(ctx,args)
455 if mach == None:
456 return 0
457 removeVm(ctx, mach)
458 return 0
459
460def pauseCmd(ctx, args):
461 mach = argsToMach(ctx,args)
462 if mach == None:
463 return 0
464 cmdExistingVm(ctx, mach, 'pause', '')
465 return 0
466
467def powerdownCmd(ctx, args):
468 mach = argsToMach(ctx,args)
469 if mach == None:
470 return 0
471 cmdExistingVm(ctx, mach, 'powerdown', '')
472 return 0
473
474def resumeCmd(ctx, args):
475 mach = argsToMach(ctx,args)
476 if mach == None:
477 return 0
478 cmdExistingVm(ctx, mach, 'resume', '')
479 return 0
480
481def statsCmd(ctx, args):
482 mach = argsToMach(ctx,args)
483 if mach == None:
484 return 0
485 cmdExistingVm(ctx, mach, 'stats', '')
486 return 0
487
488def guestCmd(ctx, args):
489 if (len(args) < 3):
490 print "usage: guest name commands"
491 return 0
492 mach = argsToMach(ctx,args)
493 if mach == None:
494 return 0
495 cmdExistingVm(ctx, mach, 'guest', ' '.join(args[2:]))
496 return 0
497
498def setvarCmd(ctx, args):
499 if (len(args) < 4):
500 print "usage: setvar [vmname|uuid] expr value"
501 return 0
502 mach = argsToMach(ctx,args)
503 if mach == None:
504 return 0
505 session = ctx['global'].openMachineSession(mach.id)
506 mach = session.machine
507 expr = 'mach.'+args[2]+' = '+args[3]
508 print "Executing",expr
509 try:
510 exec expr
511 except Exception, e:
512 print 'failed: ',e
513 if g_verbose:
514 traceback.print_exc()
515 mach.saveSettings()
516 session.close()
517 return 0
518
519def quitCmd(ctx, args):
520 return 1
521
522def aliasesCmd(ctx, args):
523 for (k,v) in aliases.items():
524 print "'%s' is an alias for '%s'" %(k,v)
525 return 0
526
527def verboseCmd(ctx, args):
528 global g_verbose
529 g_verbose = not g_verbose
530 return 0
531
532def hostCmd(ctx, args):
533 host = ctx['vb'].host
534 cnt = host.processorCount
535 print "Processor count:",cnt
536 for i in range(0,cnt):
537 print "Processor #%d speed: %dMHz" %(i,host.getProcessorSpeed(i))
538
539 if ctx['perf']:
540 for metric in ctx['perf'].query(["*"], [host]):
541 print metric['name'], metric['values_as_string']
542
543 return 0
544
545
546def monitorGuestCmd(ctx, args):
547 if (len(args) < 2):
548 print "usage: monitorGuest name (duration)"
549 return 0
550 mach = argsToMach(ctx,args)
551 if mach == None:
552 return 0
553 dur = 5
554 if len(args) > 2:
555 dur = float(args[2])
556 cmdExistingVm(ctx, mach, 'monitorGuest', dur)
557 return 0
558
559def monitorVboxCmd(ctx, args):
560 if (len(args) > 2):
561 print "usage: monitorVbox (duration)"
562 return 0
563 dur = 5
564 if len(args) > 1:
565 dur = float(args[1])
566 monitorVbox(ctx, dur)
567 return 0
568
569def getAdapterType(ctx, type):
570 if (type == ctx['global'].constants.NetworkAdapterType_Am79C970A or
571 type == ctx['global'].constants.NetworkAdapterType_Am79C973):
572 return "pcnet"
573 elif (type == ctx['global'].constants.NetworkAdapterType_I82540EM or
574 type == ctx['global'].constants.NetworkAdapterType_I82545EM or
575 type == ctx['global'].constants.NetworkAdapterType_I82543GC):
576 return "e1000"
577 elif (type == ctx['global'].constants.NetworkAdapterType_Null):
578 return None
579 else:
580 raise Exception("Unknown adapter type: "+type)
581
582
583def portForwardCmd(ctx, args):
584 if (len(args) != 5):
585 print "usage: portForward <vm> <adapter> <hostPort> <guestPort>"
586 return 0
587 mach = argsToMach(ctx,args)
588 if mach == None:
589 return 0
590 adapterNum = int(args[2])
591 hostPort = int(args[3])
592 guestPort = int(args[4])
593 proto = "TCP"
594 session = ctx['global'].openMachineSession(mach.id)
595 mach = session.machine
596
597 adapter = mach.getNetworkAdapter(adapterNum)
598 adapterType = getAdapterType(ctx, adapter.adapterType)
599
600 profile_name = proto+"_"+str(hostPort)+"_"+str(guestPort)
601 config = "VBoxInternal/Devices/" + adapterType + "/"
602 config = config + str(adapter.slot) +"/LUN#0/Config/" + profile_name
603
604 mach.setExtraData(config + "/Protocol", proto)
605 mach.setExtraData(config + "/HostPort", str(hostPort))
606 mach.setExtraData(config + "/GuestPort", str(guestPort))
607
608 mach.saveSettings()
609 session.close()
610
611 return 0
612
613
614def showLogCmd(ctx, args):
615 if (len(args) < 2):
616 print "usage: showLog <vm> <num>"
617 return 0
618 mach = argsToMach(ctx,args)
619 if mach == None:
620 return 0
621
622 log = "VBox.log"
623 if (len(args) > 2):
624 log += "."+args[2]
625 fileName = os.path.join(mach.logFolder, log)
626
627 try:
628 lf = open(fileName, 'r')
629 except IOError,e:
630 print "cannot open: ",e
631 return 0
632
633 for line in lf:
634 print line,
635 lf.close()
636
637 return 0
638
639def evalCmd(ctx, args):
640 expr = ' '.join(args[1:])
641 try:
642 exec expr
643 except Exception, e:
644 print 'failed: ',e
645 if g_verbose:
646 traceback.print_exc()
647 return 0
648
649aliases = {'s':'start',
650 'i':'info',
651 'l':'list',
652 'h':'help',
653 'a':'aliases',
654 'q':'quit', 'exit':'quit',
655 'v':'verbose'}
656
657commands = {'help':['Prints help information', helpCmd],
658 'start':['Start virtual machine by name or uuid', startCmd],
659 'create':['Create virtual machine', createCmd],
660 'remove':['Remove virtual machine', removeCmd],
661 'pause':['Pause virtual machine', pauseCmd],
662 'resume':['Resume virtual machine', resumeCmd],
663 'stats':['Stats for virtual machine', statsCmd],
664 'powerdown':['Power down virtual machine', powerdownCmd],
665 'list':['Shows known virtual machines', listCmd],
666 'info':['Shows info on machine', infoCmd],
667 'aliases':['Shows aliases', aliasesCmd],
668 'verbose':['Toggle verbosity', verboseCmd],
669 'setvar':['Set VMs variable: setvar Fedora BIOSSettings.ACPIEnabled True', setvarCmd],
670 'eval':['Evaluate arbitrary Python construction: eval for m in getMachines(ctx): print m.name,"has",m.memorySize,"M"', evalCmd],
671 'quit':['Exits', quitCmd],
672 'host':['Show host information', hostCmd],
673 'guest':['Execute command for guest: guest Win32 console.mouse.putMouseEvent(20, 20, 0, 0)', guestCmd],
674 'monitorGuest':['Monitor what happens with the guest for some time: monitorGuest Win32 10', monitorGuestCmd],
675 'monitorVbox':['Monitor what happens with Virtual Box for some time: monitorVbox 10', monitorVboxCmd],
676 'portForward':['Setup permanent port forwarding for a VM, takes adapter number host port and guest port: portForward Win32 0 8080 80', portForwardCmd],
677 'showLog':['Show log file of the VM, : showLog Win32', showLogCmd],
678 }
679
680def runCommand(ctx, cmd):
681 if len(cmd) == 0: return 0
682 args = split_no_quotes(cmd)
683 if len(args) == 0: return 0
684 c = args[0]
685 if aliases.get(c, None) != None:
686 c = aliases[c]
687 ci = commands.get(c,None)
688 if ci == None:
689 print "Unknown command: '%s', type 'help' for list of known commands" %(c)
690 return 0
691 return ci[1](ctx, args)
692
693
694def interpret(ctx):
695 vbox = ctx['vb']
696 print "Running VirtualBox version %s" %(vbox.version)
697 ctx['perf'] = ctx['global'].getPerfCollector(ctx['vb'])
698
699 autoCompletion(commands, ctx)
700
701 # to allow to print actual host information, we collect info for
702 # last 150 secs maximum, (sample every 10 secs and keep up to 15 samples)
703 if ctx['perf']:
704 try:
705 ctx['perf'].setup(['*'], [vbox.host], 10, 15)
706 except:
707 pass
708
709 while True:
710 try:
711 cmd = raw_input("vbox> ")
712 done = runCommand(ctx, cmd)
713 if done != 0: break
714 except KeyboardInterrupt:
715 print '====== You can type quit or q to leave'
716 break
717 except EOFError:
718 break;
719 except Exception,e:
720 print e
721 if g_verbose:
722 traceback.print_exc()
723
724 try:
725 # There is no need to disable metric collection. This is just an example.
726 if ct['perf']:
727 ctx['perf'].disable(['*'], [vbox.host])
728 except:
729 pass
730
731
732from vboxapi import VirtualBoxManager
733
734def main(argv):
735 style = None
736 if len(argv) > 1:
737 if argv[1] == "-w":
738 style = "WEBSERVICE"
739
740 g_virtualBoxManager = VirtualBoxManager(style, None)
741 ctx = {'global':g_virtualBoxManager,
742 'mgr':g_virtualBoxManager.mgr,
743 'vb':g_virtualBoxManager.vbox,
744 'ifaces':g_virtualBoxManager.constants,
745 'remote':g_virtualBoxManager.remote,
746 'type':g_virtualBoxManager.type
747 }
748 interpret(ctx)
749 g_virtualBoxManager.deinit()
750 del g_virtualBoxManager
751
752if __name__ == '__main__':
753 main(sys.argv)
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette