WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] trying to get some data out of XenAPI

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] trying to get some data out of XenAPI
From: "Henning Sprang" <henning_sprang@xxxxxx>
Date: Sun, 27 May 2007 20:48:31 +0200
Delivery-date: Sun, 27 May 2007 11:46:38 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
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

<Prev in Thread] Current Thread [Next in Thread>