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

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

To: "Henning Sprang" <henning_sprang@xxxxxx>
Subject: Re: [Xen-API] trying to get some data out of XenAPI
From: Tom Wilkie <tom.wilkie@xxxxxxxxx>
Date: Sun, 27 May 2007 21:44:42 +0100
Cc: xen-api@xxxxxxxxxxxxxxxxxxx
Delivery-date: Sun, 27 May 2007 13:42:42 -0700
Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:in-reply-to:references:mime-version:x-priority:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=FlUSVyIVCGZETlWWwtsT0XS5r5wR9aJE95uK3DO4GtNtpOI4LupFP4iS0ELmBOJzBTLJ6xMnofblxfzj8cG5+HcWTVzh/nQ4C/HigbR/QJb44FmlAXh+/H/fB6DJSP18S26nC6q1mgxuh0SyYqZ6mWwz4vN699SpRqWDNxz8aog=
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=gjVudk5k0WPU6fOt0fMkKxIAuEpVond3oZsFaEWNbZv0T2eWoScPdvcmMIeuzsopqkPE1nECBXA8jXlbAo8RAln2gfGEf4o957Zy2aLqWOAZ0kA3nPK3t7DNIBIZdsTBxS8XEhYZjsb58fS+WNP391lX36UPIKG6Vl98a5X3Ur0=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20070527203710.56390@xxxxxxx>
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>
References: <20070527184831.219870@xxxxxxx> <EF8F5294-F347-4C89-8855-52294D691969@xxxxxxxxx> <20070527203710.56390@xxxxxxx>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
The python bindings 'magically' put in the session variable for you.

Is the Python API documented somewhere? I can't find all the stuff from the RPC docs in the Python sources. And it's quite hard to figure the python stuff out from the xml rpc descriptions.

The python API works reflectively, so it doesn't actually declare any of the api. I don't think theres any documentation, but if you look in tools/python/xen/xm/main.py it should show see how xm sets up its xenapi connection. And theres the language independent XenAPI docs in docs/xen-api or on the wiki.

If you want to get started quickly I wrote some java bindings with a simple example and javadocs which might help - http:// www.cl.cam.ac.uk/~tw275/

Cheers

Tom

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.

Now I have:

#!/usr/bin/python

import sys
sys.path.append('/usr/lib/python')
from xen.xm.XenAPI import Session
session = Session('http://localhost:9363/')
session.login_with_password(' ', ' ')
print session
host_ref = session.get_this_host
vm_list = session.xenapi.VM.get_all()
print vm_list
for vm_ref in vm_list:
        vm_record = session.xenapi.VM.get_record(vm_ref)
        print vm_record
        print "VM name:" + vm_record["name_label"]


I'll see how far I can come with this. I guess it will take me some fiddling to find the measures I want to have. It's quite hard to get through this currently...

Henning


_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api