| 
Hi there
The python bindings 'magically' put in the session variable for you.   
Give it a try without passing the session variable to VM.get_record. 
Also, print out the vm_list variable and check its a list of uuids.
Cheers
Tom
On 27 May 2007, at 19:48, Henning Sprang wrote:
 
Hi,
I wanted to try to get some data out of the XenAPI for monitoring a  
Xen host. 
So, in the end I want ro read some of the host and vm metrics
(hints on how to get total cpu usage and vm cpu usage would be  
great - but I guess when i have the first steps this will be  
obvious). From what I heard and read about the API, this must be  
very easy. 
But there are no simple examples to get started using the api. The  
xenapi_create.py seems to operate in a totally different  
environment - I actually don't really see how it uses the API itself. 
Now I try to get started with the code from Ewan's presenbtation at  
the Xen summit, and I end up getting this: 
The code I run:
import sys
sys.path.append('/usr/lib/python')
from xen.xm.XenAPI import Session
 
session = Session('http://localhost:9363/')
session.login_with_password('henning', 'test')
print session
vm_list = session.xenapi.VM.get_all()
for vm_ref in vm_list:
        vm_record = session.xenapi.VM.get_record(session, vm_ref)
        print "VM name:" + vm_record.name_label
        VM.start(session, vm_ref, false)
        vbd_list = VM.get_VBDs(session, vm_ref)
But all I get is
<ServerProxy for localhost:9363/>
Traceback (most recent call last):
  File "xenapi-test.py", line 28, in ?
    vm_record = session.xenapi.VM.get_record(session, vm_ref)
  File "/usr/lib/python/xen/xm/XenAPI.py", line 213, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python/xen/xm/XenAPI.py", line 141, in xenapi_request
    result = _parse_result(getattr(self, methodname)(*full_params))
  File "/usr/lib/python/xen/xm/XenAPI.py", line 188, in _parse_result
    raise Failure(result['ErrorDescription'])
xen.xm.XenAPI.Failure: The VM handle {'last_login_method':  
'login_with_password', '_ServerProxy__transport': {'verbose': 0},  
'_ServerProxy__handler': '/', '_ServerProxy__host': 'localhost: 
9363', '_ServerProxy__verbose': 0, '_ServerProxy__allow_none': 1,  
'_session': 'b11780a0-0bd1-a60d-7537-be5da410fb3a',  
'_ServerProxy__encoding': None, 'last_login_params': ['henning',  
'test']} is invalid.
My authentication is set to "none" in the xend config - so any  
login should be working. I also tried if there is a method login()  
without any password, but failed, I also tried using two emtpy  
strings for logging in, and, last but not least, I tried to use pam  
authentication, but always got wrong password errors. There seem to  
be missing something here. 
Henning
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api
 
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api
 |