Search This Blog

Tuesday, May 20, 2014

How to install ipython on XenServer and test XAPI

We've been using the more user friendly shell to interact with python before: ipython. The example below are showing first how to install and enable EPEL repository to be able to install ipython. Next we are going to write a simple XAPI demo program.

Install ipython
  • Find the distro your XenServer is based on
cat /etc/issue.net
CentOS release 5.7 (Final)
Kernel \r on an \m
  • Check enabled repository 
yum repolist
  • From the EPEL install the relevant rpm packets that will add new repository to your yum
# http://fedoraproject.org/wiki/EPEL
# http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/5/i386/repoview/epel-release.html

rpm --force -i http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
  • Update the repo info
yum list 
yum list | grep ipython
  • Install ipython
yum install ipython.noarch
  • Start and verify that ipython is working fine
ipython

In [3]: import sys
In [4]: sys.version
Out[4]: '2.4.3 (#1, Sep 21 2011, 20:06:00) \n[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)]'

Xapi example using ipython

import XenAPI
s=XenAPI.Session('http://localhost/')
s.login_with_password('root', 'password')
s.xenapi.VM.get_all()
Out[30]:
['OpaqueRef:fed9f387-359c-5e34-04b3-7e9de0271e9b',
'OpaqueRef:f21c711b-5de7-fb1f-5320-ea4b8fbbdac2',
...
'OpaqueRef:0032adf3-04d3-6cf7-94fe-9d06af09bec7']
s.xenapi.session.logout()
view raw xapi-demo.py hosted with ❤ by GitHub
References

XAPI:
http://blogs.citrix.com/2011/05/18/so-what-is-xenserver-xapi/
http://docs.vmd.citrix.com/XenServer/6.2.0/1.0/en_gb/sdk.html#language_bindings-python

Packages:
http://xmodulo.com/2012/05/how-to-install-additional-packages-in.html
http://thomas-cokelaer.info/blog/2012/01/installing-repositories-under-centos-6-2-to-get-ipython-r-and-other-packages/
http://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F


No comments:

Post a Comment