[vbox-dev] getStatistic method issues
Igor Shkodyrev
mobspot at gmail.com
Thu Jan 28 20:09:43 GMT 2010
Hello,
my Vbox v3.1.2 is running on Linux Ubuntu Desktop 9.10 as a host
system, as a guest system i use Ubuntu Server 9.10 with Guest
Additions installed.
I tried to write a function on Python which returns information about
the OS running inside the virtual machine, for this purpose i was
going to use methods of IGuest interface.
At first i tried to modify existing vboxshell.py script in order to
implement own function 'stats3':
----
def stats3Cmd(ctx, args):
print args
vers = ctx['vb'].version
print "Version is", vers
if (len(args) < 2):
print "usage: stats3 [vmname|uuid]"
return 0
mach = argsToMach(ctx,args)
if mach == None:
return 0
os = ctx['vb'].getGuestOSType(mach.OSTypeId)
print " Name [name]: %s" %(mach.name)
print " ID [n/a]: %s" %(mach.id)
print " OS Type [n/a]: %s" %(os.description)
manager = ctx['mgr']
vb = ctx['vb']
session = manager.getSessionObject(vb)
if mach.sessionState == ctx['ifaces'].SessionState_Open:
vb.openExistingSession(session, mach.id )
else:
vb.openSession(session, mach.id )
console = session.console
guest = console.guest
guestadd_ver1 = guest.additionsVersion
print guestadd_ver1
cpu = 0
threads = guest.getStatistic( cpu, 4 )
print threads
return 0
----
after execution this function i've got the following traceback:
----
$ python vboxshell2.py
Running VirtualBox version 3.1.2
vbox> stats3 ubuntusrv1
['stats3', 'ubuntusrv1']
Version is 3.1.2
Name [name]: ubuntusrv1
ID [n/a]: 1c58fc27-ed25-4e82-b041-47c312296b82
OS Type [n/a]: Ubuntu
65540
0x80070057 (Invalid argument value (NS_ERROR_INVALID_ARG))
Traceback (most recent call last):
File "vboxshell2.py", line 1258, in interpret
done = runCommand(ctx, cmd)
File "vboxshell2.py", line 1177, in runCommand
return runCommandArgs(ctx, args)
File "vboxshell2.py", line 1170, in runCommandArgs
return ci[1](ctx, args)
File "vboxshell2.py", line 642, in stats3Cmd
threads = guest.getStatistic( cpu, 4 )
File "<XPCOMObject method 'getStatistic'>", line 3, in getStatistic
Exception: 0x80070057 (Invalid argument value (NS_ERROR_INVALID_ARG))
vbox>
----
after this i tried to implement this function to work over vboxwebsrv,
but .. no luck again:
----
$ python vboxtests.py
Version is 3.1.2
revision is 56127
host is Linux
home folder /home/isv/.VirtualBox
machs_list:ubuntusrv1
Traceback (most recent call last):
File "vboxtests.py", line 90, in <module>
main()
File "vboxtests.py", line 85, in main
machineInfo(manager, machine)
File "vboxtests.py", line 61, in machineInfo
memory_available = guest.getStatistic( cpu, 4 )
File "/home/isv/home/diplom/src/VirtualBox_wrappers.py", line 4114,
in getStatistic
val=self.mgr.getPort().IGuest_getStatistic(req)
File "/home/isv/home/diplom/src/VirtualBox_services.py", line 3746,
in IGuest_getStatistic
response = self.binding.Receive(IGuest_getStatisticResultMsg.typecode)
File "/usr/lib/pymodules/python2.6/ZSI/client.py", line 536, in Receive
return _Binding.Receive(self, replytype, **kw)
File "/usr/lib/pymodules/python2.6/ZSI/client.py", line 455, in Receive
raise FaultException(msg)
ZSI.FaultException: VirtualBox error: (0x0)
<VirtualBox_services_types.RuntimeFault_Holder object at 0xa9fa28c>
----
the following output fragment in vboxwebsrv was printed while
executing the getStatistic method:
---
25: accepted connection from IP=127.0.0.1 socket=9...
-- entering __vbox__IGuest_USCOREgetStatistic
findRefFromId(): looking up objref 41f8a9570158f2dd-0000000000000007
findRefFromId(): sessid 41F8A9570158F2DD, objid 7
calling COM method GetStatistic
error, raising SOAP exception
API return code: 0x80070057 (NS_ERROR_INVALID_ARG)
COM error info result code: 0x0
COM error info text: <NULL>
-- leaving __vbox__IGuest_USCOREgetStatistic, rc: 0x80070057 (-2147024809)
#### SOAP FAULT: VirtualBox error: (0x0) [SOAP-ENV:Client]
Request served
---
was anyone able to implement any function with use of getStatistic method?
if yes, any example of getStatistic use will be very appreciated.
Thanks.
More information about the vbox-dev
mailing list