[vbox-dev] How-to get network statistics and guest IP addresses from python API ?

Nikolay Igotti igotti at gmail.com
Wed May 18 17:29:00 GMT 2011


      Hi,

  From vboxshell.py both commands are trivial.

On 5/18/11 8:19 PM, Alexey Eromenko wrote:
> I need the python equivalents of those:
> 1.
> $ VBoxManage debugvm "Windows XP VM01" statistics
> <Counter c="14785402" unit="bytes" name="/Drivers/IntNet-0/Bytes/Received"/>
  vbox> guest "Windows XP VM01" 'print 
console.debugger.getStats("/Drivers/IntNet-*/Bytes/Received", False)'
> 2.
> $ VBoxManage guestproperty enumerate "Windows XP VM01"
> Name: /VirtualBox/GuestInfo/Net/2/V4/IP, value: 192.168.247.1, timestamp:...
>
   vbox> guest "Windows XP VM01" 'print 
machine.getGuestProperty("/VirtualBox/GuestInfo/Net/0/V4/IP")'

And

   vbox> guest "Windows XP VM01"  'print 
machine.enumerateGuestProperties("/VirtualBox/GuestInfo/Net/*/V4/IP")'

to print IP addresses for all interfaces.

Not sure why it was complicated - all API methods invoked the same way.

In generic Python code - you can just reuse the way guestCmd() in 
vboxshell.py is written.

   Nikolay

> Unfortunately, those functions are poorly documented (in SDK), and I
> have no idea from which classes they are inherited, and how-to call
> them.
> vboxshell doesn't help either.
> --------------------------------------------------------------
> Example code:
>
> from vboxapi import VirtualBoxManager
> mgr = VirtualBoxManager(None, None)
> vbox = mgr.vbox
> name = "Windows XP VM01"
> mach = vbox.findMachine(name)
> session = mgr.mgr.getSessionObject(vbox)
>
> progress = mach.launchVMProcess(session, "gui", "")
> progress.waitForCompletion(-1)
> --------------------------------------------------------------
>
> 1.
> IMachineDebugger::dumpStats() ??? Is this correct ?
> How to do this in python ?
>
> 2.
> session.enumerateGuestProperties("") ??? (this doesn't work)
> How to do this in python ?
>
> Thanks in advance,





More information about the vbox-dev mailing list