[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • To: Henning Sprang <henning_sprang@xxxxxx>
  • From: Tom Wilkie <tom.wilkie@xxxxxxxxx>
  • Date: Sun, 27 May 2007 20:20:24 +0100
  • Cc: xen-api@xxxxxxxxxxxxxxxxxxx
  • Delivery-date: Sun, 27 May 2007 12:18:24 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:in-reply-to:references:mime-version:x-priority:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=BrB3W39pe1pnqu3wUTSXJB1CVKhRe5I4RJlLu7/5ny2qksPKd6FxORbAN4/ndb4cjXgVWr9Y9W5EcAr1aA8BJnXdM6t+ti4DE4oLQ6q3vwYT3fQ2zigCi8bdO+EF5zxf+VaaKV3h4kl47W6WPhaAeDoCXEIKX6CGgMOwySbYT38=
  • List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.