But does the getStatistic method work for python bindings at all? I already spent a bunch of time trying to get this method working for all kinds of hosts/guests combinations (Ubuntu/WinXP as host + Ubuntu/WinXP as guest) and couldn't succeed in it, i get the mentioned errors.
2010/1/29 Klaus Espenlaub <[email protected]>: > Igor Shkodyrev schrieb: >> >> 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. > > The statistics stuff was only implemented for Windows guests. For others > it's still on the todo list (low priority). > > So the behavior you see is about as good as it gets. The only thing I can't > explain is the odd error code you get. > > Klaus > >> >> 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. >> >> _______________________________________________ >> vbox-dev mailing list >> [email protected] >> http://vbox.innotek.de/mailman/listinfo/vbox-dev > > > -- > Dr. Klaus Espenlaub > Sun Microsystems GmbH > Werkstrasse 24 > 71384 Weinstadt > Germany > > ===================================================================== > Sitz der Gesellschaft: > Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten > Amtsgericht Muenchen: HRB 161028 > Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel > Vorsitzender des Aufsichtsrates: Martin Haering > ===================================================================== > _______________________________________________ vbox-dev mailing list [email protected] http://vbox.innotek.de/mailman/listinfo/vbox-dev
