VirtualBox

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

Last change on this file since 27647 was 27647, checked in by vboxsync, 15 years ago

vboxshell: hotplug VM info

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 42.9 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# This program is a simple interactive shell for VirtualBox. You can query #
19# information and issue commands from a simple command line. #
20# #
21# It also provides you with examples on how to use VirtualBox's Python API. #
22# This shell is even somewhat documented and supports TAB-completion and #
23# history if you have Python readline installed. #
24# #
25# Enjoy. #
26################################################################################
27
28import os,sys
29import traceback
30import shlex
31import time
32
33# Simple implementation of IConsoleCallback, one can use it as skeleton
34# for custom implementations
35class GuestMonitor:
36 def __init__(self, mach):
37 self.mach = mach
38
39 def onMousePointerShapeChange(self, visible, alpha, xHot, yHot, width, height, shape):
40 print "%s: onMousePointerShapeChange: visible=%d" %(self.mach.name, visible)
41 def onMouseCapabilityChange(self, supportsAbsolute, supportsRelative, needsHostCursor):
42 print "%s: onMouseCapabilityChange: supportsAbsolute = %d, supportsRelative = %d, needsHostCursor = %d" %(self.mach.name, supportsAbsolute, supportsRelative, needsHostCursor)
43
44 def onKeyboardLedsChange(self, numLock, capsLock, scrollLock):
45 print "%s: onKeyboardLedsChange capsLock=%d" %(self.mach.name, capsLock)
46
47 def onStateChange(self, state):
48 print "%s: onStateChange state=%d" %(self.mach.name, state)
49
50 def onAdditionsStateChange(self):
51 print "%s: onAdditionsStateChange" %(self.mach.name)
52
53 def onNetworkAdapterChange(self, adapter):
54 print "%s: onNetworkAdapterChange" %(self.mach.name)
55
56 def onSerialPortChange(self, port):
57 print "%s: onSerialPortChange" %(self.mach.name)
58
59 def onParallelPortChange(self, port):
60 print "%s: onParallelPortChange" %(self.mach.name)
61
62 def onStorageControllerChange(self):
63 print "%s: onStorageControllerChange" %(self.mach.name)
64
65 def onMediumChange(self, attachment):
66 print "%s: onMediumChange" %(self.mach.name)
67
68 def onVRDPServerChange(self):
69 print "%s: onVRDPServerChange" %(self.mach.name)
70
71 def onUSBControllerChange(self):
72 print "%s: onUSBControllerChange" %(self.mach.name)
73
74 def onUSBDeviceStateChange(self, device, attached, error):
75 print "%s: onUSBDeviceStateChange" %(self.mach.name)
76
77 def onSharedFolderChange(self, scope):
78 print "%s: onSharedFolderChange" %(self.mach.name)
79
80 def onRuntimeError(self, fatal, id, message):
81 print "%s: onRuntimeError fatal=%d message=%s" %(self.mach.name, fatal, message)
82
83 def onCanShowWindow(self):
84 print "%s: onCanShowWindow" %(self.mach.name)
85 return True
86
87 def onShowWindow(self, winId):
88 print "%s: onShowWindow: %d" %(self.mach.name, winId)
89
90class VBoxMonitor:
91 def __init__(self, params):
92 self.vbox = params[0]
93 self.isMscom = params[1]
94 pass
95
96 def onMachineStateChange(self, id, state):
97 print "onMachineStateChange: %s %d" %(id, state)
98
99 def onMachineDataChange(self,id):
100 print "onMachineDataChange: %s" %(id)
101
102 def onExtraDataCanChange(self, id, key, value):
103 print "onExtraDataCanChange: %s %s=>%s" %(id, key, value)
104 # Witty COM bridge thinks if someone wishes to return tuple, hresult
105 # is one of values we want to return
106 if self.isMscom:
107 return "", 0, True
108 else:
109 return True, ""
110
111 def onExtraDataChange(self, id, key, value):
112 print "onExtraDataChange: %s %s=>%s" %(id, key, value)
113
114 def onMediaRegistered(self, id, type, registered):
115 print "onMediaRegistered: %s" %(id)
116
117 def onMachineRegistered(self, id, registred):
118 print "onMachineRegistered: %s" %(id)
119
120 def onSessionStateChange(self, id, state):
121 print "onSessionStateChange: %s %d" %(id, state)
122
123 def onSnapshotTaken(self, mach, id):
124 print "onSnapshotTaken: %s %s" %(mach, id)
125
126 def onSnapshotDiscarded(self, mach, id):
127 print "onSnapshotDiscarded: %s %s" %(mach, id)
128
129 def onSnapshotChange(self, mach, id):
130 print "onSnapshotChange: %s %s" %(mach, id)
131
132 def onGuestPropertyChange(self, id, name, newValue, flags):
133 print "onGuestPropertyChange: %s: %s=%s" %(id, name, newValue)
134
135g_hasreadline = 1
136try:
137 import readline
138 import rlcompleter
139except:
140 g_hasreadline = 0
141
142
143if g_hasreadline:
144 class CompleterNG(rlcompleter.Completer):
145 def __init__(self, dic, ctx):
146 self.ctx = ctx
147 return rlcompleter.Completer.__init__(self,dic)
148
149 def complete(self, text, state):
150 """
151 taken from:
152 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496812
153 """
154 if text == "":
155 return ['\t',None][state]
156 else:
157 return rlcompleter.Completer.complete(self,text,state)
158
159 def global_matches(self, text):
160 """
161 Compute matches when text is a simple name.
162 Return a list of all names currently defined
163 in self.namespace that match.
164 """
165
166 matches = []
167 n = len(text)
168
169 for list in [ self.namespace ]:
170 for word in list:
171 if word[:n] == text:
172 matches.append(word)
173
174
175 try:
176 for m in getMachines(self.ctx):
177 # although it has autoconversion, we need to cast
178 # explicitly for subscripts to work
179 word = str(m.name)
180 if word[:n] == text:
181 matches.append(word)
182 word = str(m.id)
183 if word[0] == '{':
184 word = word[1:-1]
185 if word[:n] == text:
186 matches.append(word)
187 except Exception,e:
188 traceback.print_exc()
189 print e
190
191 return matches
192
193
194def autoCompletion(commands, ctx):
195 if not g_hasreadline:
196 return
197
198 comps = {}
199 for (k,v) in commands.items():
200 comps[k] = None
201 completer = CompleterNG(comps, ctx)
202 readline.set_completer(completer.complete)
203 readline.parse_and_bind("tab: complete")
204
205g_verbose = True
206
207def split_no_quotes(s):
208 return shlex.split(s)
209
210def progressBar(ctx,p,wait=1000):
211 try:
212 while not p.completed:
213 print "%d %%\r" %(p.percent),
214 sys.stdout.flush()
215 p.waitForCompletion(wait)
216 ctx['global'].waitForEvents(0)
217 except KeyboardInterrupt:
218 print "Interrupted."
219
220
221def reportError(ctx,session,rc):
222 if not ctx['remote']:
223 print session.QueryErrorObject(rc)
224
225
226def createVm(ctx,name,kind,base):
227 mgr = ctx['mgr']
228 vb = ctx['vb']
229 mach = vb.createMachine(name, kind, base, "")
230 mach.saveSettings()
231 print "created machine with UUID",mach.id
232 vb.registerMachine(mach)
233 # update cache
234 getMachines(ctx, True)
235
236def removeVm(ctx,mach):
237 mgr = ctx['mgr']
238 vb = ctx['vb']
239 id = mach.id
240 print "removing machine ",mach.name,"with UUID",id
241 session = ctx['global'].openMachineSession(id)
242 try:
243 mach = session.machine
244 for d in ctx['global'].getArray(mach, 'mediumAttachments'):
245 mach.detachDevice(d.controller, d.port, d.device)
246 except:
247 traceback.print_exc()
248 mach.saveSettings()
249 ctx['global'].closeMachineSession(session)
250 mach = vb.unregisterMachine(id)
251 if mach:
252 mach.deleteSettings()
253 # update cache
254 getMachines(ctx, True)
255
256def startVm(ctx,mach,type):
257 mgr = ctx['mgr']
258 vb = ctx['vb']
259 perf = ctx['perf']
260 session = mgr.getSessionObject(vb)
261 uuid = mach.id
262 progress = vb.openRemoteSession(session, uuid, type, "")
263 progressBar(ctx, progress, 100)
264 completed = progress.completed
265 rc = int(progress.resultCode)
266 print "Completed:", completed, "rc:",hex(rc&0xffffffff)
267 if rc == 0:
268 # we ignore exceptions to allow starting VM even if
269 # perf collector cannot be started
270 if perf:
271 try:
272 perf.setup(['*'], [mach], 10, 15)
273 except Exception,e:
274 print e
275 if g_verbose:
276 traceback.print_exc()
277 pass
278 # if session not opened, close doesn't make sense
279 session.close()
280 else:
281 reportError(ctx,session,rc)
282
283def getMachines(ctx, invalidate = False):
284 if ctx['vb'] is not None:
285 if ctx['_machlist'] is None or invalidate:
286 ctx['_machlist'] = ctx['global'].getArray(ctx['vb'], 'machines')
287 return ctx['_machlist']
288 else:
289 return []
290
291def asState(var):
292 if var:
293 return 'on'
294 else:
295 return 'off'
296
297def perfStats(ctx,mach):
298 if not ctx['perf']:
299 return
300 for metric in ctx['perf'].query(["*"], [mach]):
301 print metric['name'], metric['values_as_string']
302
303def guestExec(ctx, machine, console, cmds):
304 exec cmds
305
306def monitorGuest(ctx, machine, console, dur):
307 cb = ctx['global'].createCallback('IConsoleCallback', GuestMonitor, machine)
308 console.registerCallback(cb)
309 if dur == -1:
310 # not infinity, but close enough
311 dur = 100000
312 try:
313 end = time.time() + dur
314 while time.time() < end:
315 ctx['global'].waitForEvents(500)
316 # We need to catch all exceptions here, otherwise callback will never be unregistered
317 except:
318 pass
319 console.unregisterCallback(cb)
320
321
322def monitorVBox(ctx, dur):
323 vbox = ctx['vb']
324 isMscom = (ctx['global'].type == 'MSCOM')
325 cb = ctx['global'].createCallback('IVirtualBoxCallback', VBoxMonitor, [vbox, isMscom])
326 vbox.registerCallback(cb)
327 if dur == -1:
328 # not infinity, but close enough
329 dur = 100000
330 try:
331 end = time.time() + dur
332 while time.time() < end:
333 ctx['global'].waitForEvents(500)
334 # We need to catch all exceptions here, otherwise callback will never be unregistered
335 except:
336 pass
337 vbox.unregisterCallback(cb)
338
339
340def takeScreenshot(ctx,console,args):
341 from PIL import Image
342 display = console.display
343 if len(args) > 0:
344 f = args[0]
345 else:
346 f = "/tmp/screenshot.png"
347 if len(args) > 1:
348 w = args[1]
349 else:
350 w = console.display.width
351 if len(args) > 2:
352 h = args[2]
353 else:
354 h = console.display.height
355 print "Saving screenshot (%d x %d) in %s..." %(w,h,f)
356 data = display.takeScreenShotSlow(w,h)
357 size = (w,h)
358 mode = "RGBA"
359 im = Image.frombuffer(mode, size, data, "raw", mode, 0, 1)
360 im.save(f, "PNG")
361
362
363def 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 maxDowntime = 250
375 print "Teleporting to %s:%d..." %(host,port)
376 progress = console.teleport(host, port, passwd, maxDowntime)
377 progressBar(ctx, progress, 100)
378 completed = progress.completed
379 rc = int(progress.resultCode)
380 if rc == 0:
381 print "Success!"
382 else:
383 reportError(ctx,session,rc)
384
385
386def guestStats(ctx,console,args):
387 guest = console.guest
388 # we need to set up guest statistics
389 if len(args) > 0 :
390 update = args[0]
391 else:
392 update = 1
393 if guest.statisticsUpdateInterval != update:
394 guest.statisticsUpdateInterval = update
395 try:
396 time.sleep(float(update)+0.1)
397 except:
398 # to allow sleep interruption
399 pass
400 all_stats = ctx['ifaces'].all_values('GuestStatisticType')
401 cpu = 0
402 for s in all_stats.keys():
403 try:
404 val = guest.getStatistic( cpu, all_stats[s])
405 print "%s: %d" %(s, val)
406 except:
407 # likely not implemented
408 pass
409
410def plugCpu(ctx,machine,session,args):
411 cpu = int(args)
412 print "Adding CPU %d..." %(cpu)
413 machine.hotPlugCPU(cpu)
414
415def unplugCpu(ctx,machine,session,args):
416 cpu = int(args)
417 print "Removing CPU %d..." %(cpu)
418 machine.hotUnplugCPU(cpu)
419
420def cmdExistingVm(ctx,mach,cmd,args):
421 mgr=ctx['mgr']
422 vb=ctx['vb']
423 session = mgr.getSessionObject(vb)
424 uuid = mach.id
425 try:
426 progress = vb.openExistingSession(session, uuid)
427 except Exception,e:
428 print "Session to '%s' not open: %s" %(mach.name,e)
429 if g_verbose:
430 traceback.print_exc()
431 return
432 if str(session.state) != str(ctx['ifaces'].SessionState_Open):
433 print "Session to '%s' in wrong state: %s" %(mach.name, session.state)
434 return
435 # this could be an example how to handle local only (i.e. unavailable
436 # in Webservices) functionality
437 if ctx['remote'] and cmd == 'some_local_only_command':
438 print 'Trying to use local only functionality, ignored'
439 return
440 console=session.console
441 ops={'pause': lambda: console.pause(),
442 'resume': lambda: console.resume(),
443 'powerdown': lambda: console.powerDown(),
444 'powerbutton': lambda: console.powerButton(),
445 'stats': lambda: perfStats(ctx, mach),
446 'guest': lambda: guestExec(ctx, mach, console, args),
447 'monitorGuest': lambda: monitorGuest(ctx, mach, console, args),
448 'save': lambda: progressBar(ctx,console.saveState()),
449 'screenshot': lambda: takeScreenshot(ctx,console,args),
450 'teleport': lambda: teleport(ctx,session,console,args),
451 'gueststats': lambda: guestStats(ctx, console, args),
452 'plugcpu': lambda: plugCpu(ctx, session.machine, session, args),
453 'unplugcpu': lambda: unplugCpu(ctx, session.machine, session, args),
454 }
455 try:
456 ops[cmd]()
457 except Exception, e:
458 print 'failed: ',e
459 if g_verbose:
460 traceback.print_exc()
461
462 session.close()
463
464def machById(ctx,id):
465 mach = None
466 for m in getMachines(ctx):
467 if m.name == id:
468 mach = m
469 break
470 mid = str(m.id)
471 if mid[0] == '{':
472 mid = mid[1:-1]
473 if mid == id:
474 mach = m
475 break
476 return mach
477
478def argsToMach(ctx,args):
479 if len(args) < 2:
480 print "usage: %s [vmname|uuid]" %(args[0])
481 return None
482 id = args[1]
483 m = machById(ctx, id)
484 if m == None:
485 print "Machine '%s' is unknown, use list command to find available machines" %(id)
486 return m
487
488def helpSingleCmd(cmd,h,sp):
489 if sp != 0:
490 spec = " [ext from "+sp+"]"
491 else:
492 spec = ""
493 print " %s: %s%s" %(cmd,h,spec)
494
495def helpCmd(ctx, args):
496 if len(args) == 1:
497 print "Help page:"
498 names = commands.keys()
499 names.sort()
500 for i in names:
501 helpSingleCmd(i, commands[i][0], commands[i][2])
502 else:
503 cmd = args[1]
504 c = commands.get(cmd)
505 if c == None:
506 print "Command '%s' not known" %(cmd)
507 else:
508 helpSingleCmd(cmd, c[0], c[2])
509 return 0
510
511def listCmd(ctx, args):
512 for m in getMachines(ctx, True):
513 if m.teleporterEnabled:
514 tele = "[T] "
515 else:
516 tele = " "
517 print "%sMachine '%s' [%s], state=%s" %(tele,m.name,m.id,m.sessionState)
518 return 0
519
520def getControllerType(type):
521 if type == 0:
522 return "Null"
523 elif type == 1:
524 return "LsiLogic"
525 elif type == 2:
526 return "BusLogic"
527 elif type == 3:
528 return "IntelAhci"
529 elif type == 4:
530 return "PIIX3"
531 elif type == 5:
532 return "PIIX4"
533 elif type == 6:
534 return "ICH6"
535 else:
536 return "Unknown"
537
538def getFirmwareType(type):
539 if type == 0:
540 return "invalid"
541 elif type == 1:
542 return "bios"
543 elif type == 2:
544 return "efi"
545 elif type == 3:
546 return "efi64"
547 elif type == 4:
548 return "efidual"
549 else:
550 return "Unknown"
551
552
553def asEnumElem(ctx,enum,elem):
554 all = ctx['ifaces'].all_values(enum)
555 for e in all.keys():
556 if elem == all[e]:
557 return e
558 return "<unknown>"
559
560def infoCmd(ctx,args):
561 if (len(args) < 2):
562 print "usage: info [vmname|uuid]"
563 return 0
564 mach = argsToMach(ctx,args)
565 if mach == None:
566 return 0
567 os = ctx['vb'].getGuestOSType(mach.OSTypeId)
568 print " One can use setvar <mach> <var> <value> to change variable, using name in []."
569 print " Name [name]: %s" %(mach.name)
570 print " ID [n/a]: %s" %(mach.id)
571 print " OS Type [n/a]: %s" %(os.description)
572 print " Firmware [firmwareType]: %s (%s)" %(asEnumElem(ctx,"FirmwareType", mach.firmwareType),mach.firmwareType)
573 print
574 print " CPUs [CPUCount]: %d" %(mach.CPUCount)
575 print " RAM [memorySize]: %dM" %(mach.memorySize)
576 print " VRAM [VRAMSize]: %dM" %(mach.VRAMSize)
577 print " Monitors [monitorCount]: %d" %(mach.monitorCount)
578 print
579 print " Clipboard mode [clipboardMode]: %d" %(mach.clipboardMode)
580 print " Machine status [n/a]: %d" % (mach.sessionState)
581 print
582 if mach.teleporterEnabled:
583 print " Teleport target on port %d (%s)" %(mach.teleporterPort, mach.teleporterPassword)
584 print
585 bios = mach.BIOSSettings
586 print " ACPI [BIOSSettings.ACPIEnabled]: %s" %(asState(bios.ACPIEnabled))
587 print " APIC [BIOSSettings.IOAPICEnabled]: %s" %(asState(bios.IOAPICEnabled))
588 hwVirtEnabled = mach.getHWVirtExProperty(ctx['global'].constants.HWVirtExPropertyType_Enabled)
589 print " Hardware virtualization [mach.setHWVirtExProperty(ctx['global'].constants.HWVirtExPropertyType_Enabled,value)]: " + asState(hwVirtEnabled)
590 hwVirtVPID = mach.getHWVirtExProperty(ctx['global'].constants.HWVirtExPropertyType_VPID)
591 print " VPID support [mach.setHWVirtExProperty(ctx['global'].constants.HWVirtExPropertyType_VPID,value)]: " + asState(hwVirtVPID)
592 hwVirtNestedPaging = mach.getHWVirtExProperty(ctx['global'].constants.HWVirtExPropertyType_NestedPaging)
593 print " Nested paging [mach.setHWVirtExProperty(ctx['global'].constants.HWVirtExPropertyType_NestedPaging,value)]: " + asState(hwVirtNestedPaging)
594
595 print " Hardware 3d acceleration[accelerate3DEnabled]: " + asState(mach.accelerate3DEnabled)
596 print " Hardware 2d video acceleration[accelerate2DVideoEnabled]: " + asState(mach.accelerate2DVideoEnabled)
597
598 print " HPET [hpetEnabled]: %s" %(asState(mach.hpetEnabled))
599 print " CPU hotplugging [CPUHotPlugEnabled]: %s" %(asState(mach.CPUHotPlugEnabled))
600
601 print " Keyboard [keyboardHidType]: %s (%s)" %(asEnumElem(ctx,"KeyboardHidType", mach.keyboardHidType), mach.keyboardHidType)
602 print " Pointing device [pointingHidType]: %s (%s)" %(asEnumElem(ctx,"PointingHidType", mach.pointingHidType), mach.pointingHidType)
603 print " Last changed [n/a]: " + time.asctime(time.localtime(long(mach.lastStateChange)/1000))
604 print " VRDP server [VRDPServer.enabled]: %s" %(asState(mach.VRDPServer.enabled))
605
606 controllers = ctx['global'].getArray(mach, 'storageControllers')
607 if controllers:
608 print
609 print " Controllers:"
610 for controller in controllers:
611 print " %s %s bus: %d" % (controller.name, getControllerType(controller.controllerType), controller.bus)
612
613 attaches = ctx['global'].getArray(mach, 'mediumAttachments')
614 if attaches:
615 print
616 print " Mediums:"
617 for a in attaches:
618 print " Controller: %s port: %d device: %d type: %s:" % (a.controller, a.port, a.device, a.type)
619 m = a.medium
620 if a.type == ctx['global'].constants.DeviceType_HardDisk:
621 print " HDD:"
622 print " Id: %s" %(m.id)
623 print " Location: %s" %(m.location)
624 print " Name: %s" %(m.name)
625 print " Format: %s" %(m.format)
626
627 if a.type == ctx['global'].constants.DeviceType_DVD:
628 print " DVD:"
629 if m:
630 print " Id: %s" %(m.id)
631 print " Name: %s" %(m.name)
632 if m.hostDrive:
633 print " Host DVD %s" %(m.location)
634 if a.passthrough:
635 print " [passthrough mode]"
636 else:
637 print " Virtual image at %s" %(m.location)
638 print " Size: %s" %(m.size)
639
640 if a.type == ctx['global'].constants.DeviceType_Floppy:
641 print " Floppy:"
642 if m:
643 print " Id: %s" %(m.id)
644 print " Name: %s" %(m.name)
645 if m.hostDrive:
646 print " Host floppy %s" %(m.location)
647 else:
648 print " Virtual image at %s" %(m.location)
649 print " Size: %s" %(m.size)
650
651 return 0
652
653def startCmd(ctx, args):
654 mach = argsToMach(ctx,args)
655 if mach == None:
656 return 0
657 if len(args) > 2:
658 type = args[2]
659 else:
660 type = "gui"
661 startVm(ctx, mach, type)
662 return 0
663
664def createCmd(ctx, args):
665 if (len(args) < 3 or len(args) > 4):
666 print "usage: create name ostype <basefolder>"
667 return 0
668 name = args[1]
669 oskind = args[2]
670 if len(args) == 4:
671 base = args[3]
672 else:
673 base = ''
674 try:
675 ctx['vb'].getGuestOSType(oskind)
676 except Exception, e:
677 print 'Unknown OS type:',oskind
678 return 0
679 createVm(ctx, name, oskind, base)
680 return 0
681
682def removeCmd(ctx, args):
683 mach = argsToMach(ctx,args)
684 if mach == None:
685 return 0
686 removeVm(ctx, mach)
687 return 0
688
689def pauseCmd(ctx, args):
690 mach = argsToMach(ctx,args)
691 if mach == None:
692 return 0
693 cmdExistingVm(ctx, mach, 'pause', '')
694 return 0
695
696def powerdownCmd(ctx, args):
697 mach = argsToMach(ctx,args)
698 if mach == None:
699 return 0
700 cmdExistingVm(ctx, mach, 'powerdown', '')
701 return 0
702
703def powerbuttonCmd(ctx, args):
704 mach = argsToMach(ctx,args)
705 if mach == None:
706 return 0
707 cmdExistingVm(ctx, mach, 'powerbutton', '')
708 return 0
709
710def resumeCmd(ctx, args):
711 mach = argsToMach(ctx,args)
712 if mach == None:
713 return 0
714 cmdExistingVm(ctx, mach, 'resume', '')
715 return 0
716
717def saveCmd(ctx, args):
718 mach = argsToMach(ctx,args)
719 if mach == None:
720 return 0
721 cmdExistingVm(ctx, mach, 'save', '')
722 return 0
723
724def statsCmd(ctx, args):
725 mach = argsToMach(ctx,args)
726 if mach == None:
727 return 0
728 cmdExistingVm(ctx, mach, 'stats', '')
729 return 0
730
731def guestCmd(ctx, args):
732 if (len(args) < 3):
733 print "usage: guest name commands"
734 return 0
735 mach = argsToMach(ctx,args)
736 if mach == None:
737 return 0
738 cmdExistingVm(ctx, mach, 'guest', ' '.join(args[2:]))
739 return 0
740
741def screenshotCmd(ctx, args):
742 if (len(args) < 3):
743 print "usage: screenshot name file <width> <height>"
744 return 0
745 mach = argsToMach(ctx,args)
746 if mach == None:
747 return 0
748 cmdExistingVm(ctx, mach, 'screenshot', args[2:])
749 return 0
750
751def teleportCmd(ctx, args):
752 if (len(args) < 3):
753 print "usage: teleport name host:port <password>"
754 return 0
755 mach = argsToMach(ctx,args)
756 if mach == None:
757 return 0
758 cmdExistingVm(ctx, mach, 'teleport', args[2:])
759 return 0
760
761def openportalCmd(ctx, args):
762 if (len(args) < 3):
763 print "usage: openportal name port <password>"
764 return 0
765 mach = argsToMach(ctx,args)
766 if mach == None:
767 return 0
768 port = int(args[2])
769 if (len(args) > 3):
770 passwd = args[3]
771 else:
772 passwd = ""
773 if not mach.teleporterEnabled or mach.teleporterPort != port or passwd:
774 session = ctx['global'].openMachineSession(mach.id)
775 mach1 = session.machine
776 mach1.teleporterEnabled = True
777 mach1.teleporterPort = port
778 mach1.teleporterPassword = passwd
779 mach1.saveSettings()
780 session.close()
781 startVm(ctx, mach, "gui")
782 return 0
783
784def closeportalCmd(ctx, args):
785 if (len(args) < 2):
786 print "usage: closeportal name"
787 return 0
788 mach = argsToMach(ctx,args)
789 if mach == None:
790 return 0
791 if mach.teleporterEnabled:
792 session = ctx['global'].openMachineSession(mach.id)
793 mach1 = session.machine
794 mach1.teleporterEnabled = False
795 mach1.saveSettings()
796 session.close()
797 return 0
798
799def gueststatsCmd(ctx, args):
800 if (len(args) < 2):
801 print "usage: gueststats name <check interval>"
802 return 0
803 mach = argsToMach(ctx,args)
804 if mach == None:
805 return 0
806 cmdExistingVm(ctx, mach, 'gueststats', args[2:])
807 return 0
808
809def plugcpuCmd(ctx, args):
810 if (len(args) < 2):
811 print "usage: plugcpu name cpuid"
812 return 0
813 mach = argsToMach(ctx,args)
814 if mach == None:
815 return 0
816 cmdExistingVm(ctx, mach, 'plugcpu', args[2])
817 return 0
818
819def unplugcpuCmd(ctx, args):
820 if (len(args) < 2):
821 print "usage: unplugcpu name cpuid"
822 return 0
823 mach = argsToMach(ctx,args)
824 if mach == None:
825 return 0
826 cmdExistingVm(ctx, mach, 'unplugcpu', args[2])
827 return 0
828
829def setvarCmd(ctx, args):
830 if (len(args) < 4):
831 print "usage: setvar [vmname|uuid] expr value"
832 return 0
833 mach = argsToMach(ctx,args)
834 if mach == None:
835 return 0
836 session = ctx['global'].openMachineSession(mach.id)
837 mach = session.machine
838 expr = 'mach.'+args[2]+' = '+args[3]
839 print "Executing",expr
840 try:
841 exec expr
842 except Exception, e:
843 print 'failed: ',e
844 if g_verbose:
845 traceback.print_exc()
846 mach.saveSettings()
847 session.close()
848 return 0
849
850
851def setExtraDataCmd(ctx, args):
852 if (len(args) < 3):
853 print "usage: setextra [vmname|uuid|global] key <value>"
854 return 0
855 key = args[2]
856 if len(args) == 4:
857 value = args[3]
858 else:
859 value = None
860 if args[1] == 'global':
861 ctx['vb'].setExtraData(key, value)
862 return 0
863
864 mach = argsToMach(ctx,args)
865 if mach == None:
866 return 0
867 session = ctx['global'].openMachineSession(mach.id)
868 mach = session.machine
869 mach.setExtraData(key, value)
870 mach.saveSettings()
871 session.close()
872 return 0
873
874def printExtraKey(obj, key, value):
875 print "%s: '%s' = '%s'" %(obj, key, value)
876
877def getExtraDataCmd(ctx, args):
878 if (len(args) < 2):
879 print "usage: getextra [vmname|uuid|global] <key>"
880 return 0
881 if len(args) == 3:
882 key = args[2]
883 else:
884 key = None
885
886 if args[1] == 'global':
887 obj = ctx['vb']
888 else:
889 obj = argsToMach(ctx,args)
890 if obj == None:
891 return 0
892
893 if key == None:
894 keys = obj.getExtraDataKeys()
895 else:
896 keys = [ key ]
897 for k in keys:
898 printExtraKey(args[1], k, ctx['vb'].getExtraData(k))
899
900 return 0
901
902def quitCmd(ctx, args):
903 return 1
904
905def aliasCmd(ctx, args):
906 if (len(args) == 3):
907 aliases[args[1]] = args[2]
908 return 0
909
910 for (k,v) in aliases.items():
911 print "'%s' is an alias for '%s'" %(k,v)
912 return 0
913
914def verboseCmd(ctx, args):
915 global g_verbose
916 g_verbose = not g_verbose
917 return 0
918
919def getUSBStateString(state):
920 if state == 0:
921 return "NotSupported"
922 elif state == 1:
923 return "Unavailable"
924 elif state == 2:
925 return "Busy"
926 elif state == 3:
927 return "Available"
928 elif state == 4:
929 return "Held"
930 elif state == 5:
931 return "Captured"
932 else:
933 return "Unknown"
934
935def hostCmd(ctx, args):
936 host = ctx['vb'].host
937 cnt = host.processorCount
938 print "Processor count:",cnt
939 for i in range(0,cnt):
940 print "Processor #%d speed: %dMHz %s" %(i,host.getProcessorSpeed(i), host.getProcessorDescription(i))
941
942 print "RAM: %dM (free %dM)" %(host.memorySize, host.memoryAvailable)
943 print "OS: %s (%s)" %(host.operatingSystem, host.OSVersion)
944 if host.Acceleration3DAvailable:
945 print "3D acceleration available"
946 else:
947 print "3D acceleration NOT available"
948
949 print "Network interfaces:"
950 for ni in ctx['global'].getArray(host, 'networkInterfaces'):
951 print " %s (%s)" %(ni.name, ni.IPAddress)
952
953 print "DVD drives:"
954 for dd in ctx['global'].getArray(host, 'DVDDrives'):
955 print " %s - %s" %(dd.name, dd.description)
956
957 print "USB devices:"
958 for ud in ctx['global'].getArray(host, 'USBDevices'):
959 print " %s (vendorId=%d productId=%d serial=%s) %s" %(ud.product, ud.vendorId, ud.productId, ud.serialNumber, getUSBStateString(ud.state))
960
961 if ctx['perf']:
962 for metric in ctx['perf'].query(["*"], [host]):
963 print metric['name'], metric['values_as_string']
964
965 return 0
966
967def monitorGuestCmd(ctx, args):
968 if (len(args) < 2):
969 print "usage: monitorGuest name (duration)"
970 return 0
971 mach = argsToMach(ctx,args)
972 if mach == None:
973 return 0
974 dur = 5
975 if len(args) > 2:
976 dur = float(args[2])
977 cmdExistingVm(ctx, mach, 'monitorGuest', dur)
978 return 0
979
980def monitorVBoxCmd(ctx, args):
981 if (len(args) > 2):
982 print "usage: monitorVBox (duration)"
983 return 0
984 dur = 5
985 if len(args) > 1:
986 dur = float(args[1])
987 monitorVBox(ctx, dur)
988 return 0
989
990def getAdapterType(ctx, type):
991 if (type == ctx['global'].constants.NetworkAdapterType_Am79C970A or
992 type == ctx['global'].constants.NetworkAdapterType_Am79C973):
993 return "pcnet"
994 elif (type == ctx['global'].constants.NetworkAdapterType_I82540EM or
995 type == ctx['global'].constants.NetworkAdapterType_I82545EM or
996 type == ctx['global'].constants.NetworkAdapterType_I82543GC):
997 return "e1000"
998 elif (type == ctx['global'].constants.NetworkAdapterType_Virtio):
999 return "virtio"
1000 elif (type == ctx['global'].constants.NetworkAdapterType_Null):
1001 return None
1002 else:
1003 raise Exception("Unknown adapter type: "+type)
1004
1005
1006def portForwardCmd(ctx, args):
1007 if (len(args) != 5):
1008 print "usage: portForward <vm> <adapter> <hostPort> <guestPort>"
1009 return 0
1010 mach = argsToMach(ctx,args)
1011 if mach == None:
1012 return 0
1013 adapterNum = int(args[2])
1014 hostPort = int(args[3])
1015 guestPort = int(args[4])
1016 proto = "TCP"
1017 session = ctx['global'].openMachineSession(mach.id)
1018 mach = session.machine
1019
1020 adapter = mach.getNetworkAdapter(adapterNum)
1021 adapterType = getAdapterType(ctx, adapter.adapterType)
1022
1023 profile_name = proto+"_"+str(hostPort)+"_"+str(guestPort)
1024 config = "VBoxInternal/Devices/" + adapterType + "/"
1025 config = config + str(adapter.slot) +"/LUN#0/Config/" + profile_name
1026
1027 mach.setExtraData(config + "/Protocol", proto)
1028 mach.setExtraData(config + "/HostPort", str(hostPort))
1029 mach.setExtraData(config + "/GuestPort", str(guestPort))
1030
1031 mach.saveSettings()
1032 session.close()
1033
1034 return 0
1035
1036
1037def showLogCmd(ctx, args):
1038 if (len(args) < 2):
1039 print "usage: showLog <vm> <num>"
1040 return 0
1041 mach = argsToMach(ctx,args)
1042 if mach == None:
1043 return 0
1044
1045 log = "VBox.log"
1046 if (len(args) > 2):
1047 log += "."+args[2]
1048 fileName = os.path.join(mach.logFolder, log)
1049
1050 try:
1051 lf = open(fileName, 'r')
1052 except IOError,e:
1053 print "cannot open: ",e
1054 return 0
1055
1056 for line in lf:
1057 print line,
1058 lf.close()
1059
1060 return 0
1061
1062def evalCmd(ctx, args):
1063 expr = ' '.join(args[1:])
1064 try:
1065 exec expr
1066 except Exception, e:
1067 print 'failed: ',e
1068 if g_verbose:
1069 traceback.print_exc()
1070 return 0
1071
1072def reloadExtCmd(ctx, args):
1073 # maybe will want more args smartness
1074 checkUserExtensions(ctx, commands, getHomeFolder(ctx))
1075 autoCompletion(commands, ctx)
1076 return 0
1077
1078
1079def runScriptCmd(ctx, args):
1080 if (len(args) != 2):
1081 print "usage: runScript <script>"
1082 return 0
1083 try:
1084 lf = open(args[1], 'r')
1085 except IOError,e:
1086 print "cannot open:",args[1], ":",e
1087 return 0
1088
1089 try:
1090 for line in lf:
1091 done = runCommand(ctx, line)
1092 if done != 0: break
1093 except Exception,e:
1094 print "error:",e
1095 if g_verbose:
1096 traceback.print_exc()
1097 lf.close()
1098 return 0
1099
1100def sleepCmd(ctx, args):
1101 if (len(args) != 2):
1102 print "usage: sleep <secs>"
1103 return 0
1104
1105 try:
1106 time.sleep(float(args[1]))
1107 except:
1108 # to allow sleep interrupt
1109 pass
1110 return 0
1111
1112
1113def shellCmd(ctx, args):
1114 if (len(args) < 2):
1115 print "usage: shell <commands>"
1116 return 0
1117 cmd = ' '.join(args[1:])
1118 try:
1119 os.system(cmd)
1120 except KeyboardInterrupt:
1121 # to allow shell command interruption
1122 pass
1123 return 0
1124
1125
1126def connectCmd(ctx, args):
1127 if (len(args) > 4):
1128 print "usage: connect [url] [username] [passwd]"
1129 return 0
1130
1131 if ctx['vb'] is not None:
1132 print "Already connected, disconnect first..."
1133 return 0
1134
1135 if (len(args) > 1):
1136 url = args[1]
1137 else:
1138 url = None
1139
1140 if (len(args) > 2):
1141 user = args[2]
1142 else:
1143 user = ""
1144
1145 if (len(args) > 3):
1146 passwd = args[3]
1147 else:
1148 passwd = ""
1149
1150 vbox = ctx['global'].platform.connect(url, user, passwd)
1151 ctx['vb'] = vbox
1152 print "Running VirtualBox version %s" %(vbox.version)
1153 ctx['perf'] = ctx['global'].getPerfCollector(ctx['vb'])
1154 return 0
1155
1156def disconnectCmd(ctx, args):
1157 if (len(args) != 1):
1158 print "usage: disconnect"
1159 return 0
1160
1161 if ctx['vb'] is None:
1162 print "Not connected yet."
1163 return 0
1164
1165 try:
1166 ctx['global'].platform.disconnect()
1167 except:
1168 ctx['vb'] = None
1169 raise
1170
1171 ctx['vb'] = None
1172 return 0
1173
1174def exportVMCmd(ctx, args):
1175 import sys
1176
1177 if len(args) < 3:
1178 print "usage: exportVm <machine> <path> <format> <license>"
1179 return 0
1180 mach = ctx['machById'](args[1])
1181 if mach is None:
1182 return 0
1183 path = args[2]
1184 if (len(args) > 3):
1185 format = args[3]
1186 else:
1187 format = "ovf-1.0"
1188 if (len(args) > 4):
1189 license = args[4]
1190 else:
1191 license = "GPL"
1192
1193 app = ctx['vb'].createAppliance()
1194 desc = mach.export(app)
1195 desc.addDescription(ctx['global'].constants.VirtualSystemDescriptionType_License, license, "")
1196 p = app.write(format, path)
1197 progressBar(ctx, p)
1198 print "Exported to %s in format %s" %(path, format)
1199 return 0
1200
1201aliases = {'s':'start',
1202 'i':'info',
1203 'l':'list',
1204 'h':'help',
1205 'a':'alias',
1206 'q':'quit', 'exit':'quit',
1207 'v':'verbose'}
1208
1209commands = {'help':['Prints help information', helpCmd, 0],
1210 'start':['Start virtual machine by name or uuid: start Linux', startCmd, 0],
1211 'create':['Create virtual machine', createCmd, 0],
1212 'remove':['Remove virtual machine', removeCmd, 0],
1213 'pause':['Pause virtual machine', pauseCmd, 0],
1214 'resume':['Resume virtual machine', resumeCmd, 0],
1215 'save':['Save execution state of virtual machine', saveCmd, 0],
1216 'stats':['Stats for virtual machine', statsCmd, 0],
1217 'powerdown':['Power down virtual machine', powerdownCmd, 0],
1218 'powerbutton':['Effectively press power button', powerbuttonCmd, 0],
1219 'list':['Shows known virtual machines', listCmd, 0],
1220 'info':['Shows info on machine', infoCmd, 0],
1221 'alias':['Control aliases', aliasCmd, 0],
1222 'verbose':['Toggle verbosity', verboseCmd, 0],
1223 'setvar':['Set VMs variable: setvar Fedora BIOSSettings.ACPIEnabled True', setvarCmd, 0],
1224 'eval':['Evaluate arbitrary Python construction: eval \'for m in getMachines(ctx): print m.name,"has",m.memorySize,"M"\'', evalCmd, 0],
1225 'quit':['Exits', quitCmd, 0],
1226 'host':['Show host information', hostCmd, 0],
1227 'guest':['Execute command for guest: guest Win32 \'console.mouse.putMouseEvent(20, 20, 0, 0)\'', guestCmd, 0],
1228 'monitorGuest':['Monitor what happens with the guest for some time: monitorGuest Win32 10', monitorGuestCmd, 0],
1229 'monitorVBox':['Monitor what happens with Virtual Box for some time: monitorVBox 10', monitorVBoxCmd, 0],
1230 'portForward':['Setup permanent port forwarding for a VM, takes adapter number host port and guest port: portForward Win32 0 8080 80', portForwardCmd, 0],
1231 'showLog':['Show log file of the VM, : showLog Win32', showLogCmd, 0],
1232 'reloadExt':['Reload custom extensions: reloadExt', reloadExtCmd, 0],
1233 'runScript':['Run VBox script: runScript script.vbox', runScriptCmd, 0],
1234 'sleep':['Sleep for specified number of seconds: sleep 3.14159', sleepCmd, 0],
1235 'shell':['Execute external shell command: shell "ls /etc/rc*"', shellCmd, 0],
1236 'exportVm':['Export VM in OVF format: export Win /tmp/win.ovf', exportVMCmd, 0],
1237 'screenshot':['Take VM screenshot to a file: screenshot Win /tmp/win.png 1024 768', screenshotCmd, 0],
1238 'teleport':['Teleport VM to another box (see openportal): teleport Win anotherhost:8000 <passwd>', teleportCmd, 0],
1239 'openportal':['Open portal for teleportation of VM from another box (see teleport): openportal Win 8000 <passwd>', openportalCmd, 0],
1240 'closeportal':['Close teleportation portal (see openportal,teleport): closeportal Win', closeportalCmd, 0],
1241 'getextra':['Get extra data, empty key lists all: getextra <vm|global> <key>', getExtraDataCmd, 0],
1242 'setextra':['Set extra data, empty value removes key: setextra <vm|global> <key> <value>', setExtraDataCmd, 0],
1243 'gueststats':['Print available guest stats (only Windows guests with additions so far): gueststats Win32', gueststatsCmd, 0],
1244 'plugcpu':['Add a CPU to a running VM: plugcpu Win 1', plugcpuCmd, 0],
1245 'unplugcpu':['Remove a CPU from a running VM: plugcpu Win 1', unplugcpuCmd, 0],
1246 }
1247
1248def runCommandArgs(ctx, args):
1249 c = args[0]
1250 if aliases.get(c, None) != None:
1251 c = aliases[c]
1252 ci = commands.get(c,None)
1253 if ci == None:
1254 print "Unknown command: '%s', type 'help' for list of known commands" %(c)
1255 return 0
1256 return ci[1](ctx, args)
1257
1258
1259def runCommand(ctx, cmd):
1260 if len(cmd) == 0: return 0
1261 args = split_no_quotes(cmd)
1262 if len(args) == 0: return 0
1263 return runCommandArgs(ctx, args)
1264
1265#
1266# To write your own custom commands to vboxshell, create
1267# file ~/.VirtualBox/shellext.py with content like
1268#
1269# def runTestCmd(ctx, args):
1270# print "Testy test", ctx['vb']
1271# return 0
1272#
1273# commands = {
1274# 'test': ['Test help', runTestCmd]
1275# }
1276# and issue reloadExt shell command.
1277# This file also will be read automatically on startup or 'reloadExt'.
1278#
1279# Also one can put shell extensions into ~/.VirtualBox/shexts and
1280# they will also be picked up, so this way one can exchange
1281# shell extensions easily.
1282def addExtsFromFile(ctx, cmds, file):
1283 if not os.path.isfile(file):
1284 return
1285 d = {}
1286 try:
1287 execfile(file, d, d)
1288 for (k,v) in d['commands'].items():
1289 if g_verbose:
1290 print "customize: adding \"%s\" - %s" %(k, v[0])
1291 cmds[k] = [v[0], v[1], file]
1292 except:
1293 print "Error loading user extensions from %s" %(file)
1294 traceback.print_exc()
1295
1296
1297def checkUserExtensions(ctx, cmds, folder):
1298 folder = str(folder)
1299 name = os.path.join(folder, "shellext.py")
1300 addExtsFromFile(ctx, cmds, name)
1301 # also check 'exts' directory for all files
1302 shextdir = os.path.join(folder, "shexts")
1303 if not os.path.isdir(shextdir):
1304 return
1305 exts = os.listdir(shextdir)
1306 for e in exts:
1307 addExtsFromFile(ctx, cmds, os.path.join(shextdir,e))
1308
1309def getHomeFolder(ctx):
1310 if ctx['remote'] or ctx['vb'] is None:
1311 return os.path.join(os.path.expanduser("~"), ".VirtualBox")
1312 else:
1313 return ctx['vb'].homeFolder
1314
1315def interpret(ctx):
1316 if ctx['remote']:
1317 commands['connect'] = ["Connect to remote VBox instance", connectCmd, 0]
1318 commands['disconnect'] = ["Disconnect from remote VBox instance", disconnectCmd, 0]
1319
1320 vbox = ctx['vb']
1321
1322 if vbox is not None:
1323 print "Running VirtualBox version %s" %(vbox.version)
1324 ctx['perf'] = ctx['global'].getPerfCollector(vbox)
1325 else:
1326 ctx['perf'] = None
1327
1328 home = getHomeFolder(ctx)
1329 checkUserExtensions(ctx, commands, home)
1330
1331 autoCompletion(commands, ctx)
1332
1333 # to allow to print actual host information, we collect info for
1334 # last 150 secs maximum, (sample every 10 secs and keep up to 15 samples)
1335 if ctx['perf']:
1336 try:
1337 ctx['perf'].setup(['*'], [vbox.host], 10, 15)
1338 except:
1339 pass
1340
1341 while True:
1342 try:
1343 cmd = raw_input("vbox> ")
1344 done = runCommand(ctx, cmd)
1345 if done != 0: break
1346 except KeyboardInterrupt:
1347 print '====== You can type quit or q to leave'
1348 break
1349 except EOFError:
1350 break;
1351 except Exception,e:
1352 print e
1353 if g_verbose:
1354 traceback.print_exc()
1355 ctx['global'].waitForEvents(0)
1356 try:
1357 # There is no need to disable metric collection. This is just an example.
1358 if ct['perf']:
1359 ctx['perf'].disable(['*'], [vbox.host])
1360 except:
1361 pass
1362
1363def runCommandCb(ctx, cmd, args):
1364 args.insert(0, cmd)
1365 return runCommandArgs(ctx, args)
1366
1367def main(argv):
1368 style = None
1369 autopath = False
1370 argv.pop(0)
1371 while len(argv) > 0:
1372 if argv[0] == "-w":
1373 style = "WEBSERVICE"
1374 if argv[0] == "-a":
1375 autopath = True
1376 argv.pop(0)
1377
1378 if autopath:
1379 cwd = os.getcwd()
1380 vpp = os.environ.get("VBOX_PROGRAM_PATH")
1381 if vpp is None and (os.path.isfile(os.path.join(cwd, "VirtualBox")) or os.path.isfile(os.path.join(cwd, "VirtualBox.exe"))) :
1382 vpp = cwd
1383 print "Autodetected VBOX_PROGRAM_PATH as",vpp
1384 os.environ["VBOX_PROGRAM_PATH"] = cwd
1385 sys.path.append(os.path.join(vpp, "sdk", "installer"))
1386
1387 from vboxapi import VirtualBoxManager
1388 g_virtualBoxManager = VirtualBoxManager(style, None)
1389 ctx = {'global':g_virtualBoxManager,
1390 'mgr':g_virtualBoxManager.mgr,
1391 'vb':g_virtualBoxManager.vbox,
1392 'ifaces':g_virtualBoxManager.constants,
1393 'remote':g_virtualBoxManager.remote,
1394 'type':g_virtualBoxManager.type,
1395 'run': lambda cmd,args: runCommandCb(ctx, cmd, args),
1396 'machById': lambda id: machById(ctx,id),
1397 'argsToMach': lambda args: argsToMach(ctx,args),
1398 'progressBar': lambda p: progressBar(ctx,p),
1399 '_machlist':None
1400 }
1401 interpret(ctx)
1402 g_virtualBoxManager.deinit()
1403 del g_virtualBoxManager
1404
1405if __name__ == '__main__':
1406 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