6 There are several places to view documentation detailing how to
7 interface with the python RAPI, though none of them are comprehensive.
9 The following is a list of five different sources where information
10 relating to the RAPI can be found.
12 #. The Ganeti RAPI PyDocs_
13 #. The Ganeti RAPI `HTML Docs`_
14 #. The gnt-instance man-page_
15 #. The rapi client_ code contained in the upstream_ ganeti project
16 #. The rapi-tests_ which are also contained in the upstream_ ganeti project
18 .. _PyDocs: http://docs.ganeti.org/ganeti/current/api/py/ganeti.rapi.client.GanetiRapiClient-class.html
19 .. _`HTML Docs`: http://docs.ganeti.org/ganeti/current/html/rapi.html
20 .. _man-page: http://docs.ganeti.org/ganeti/current/man/gnt-instance.html
21 .. _client: http://git.ganeti.org/?p=ganeti.git;a=blob;f=lib/rapi/client.py;hb=HEAD
22 .. _upstream: http://git.ganeti.org/?p=ganeti.git;a=summary
23 .. _rapi-tests: http://git.ganeti.org/?p=ganeti.git;a=blob;f=test/ganeti.rapi.client_unittest.py;hb=HEAD
25 RAPI in a Python Shell
26 ----------------------
28 Start up a python shell using the ``manage`` django script.
33 In the python shell import ``client.py`` from ``util``.
36 >>> from util import client
38 Assign a variable to the rapi client and pass in the name of the cluster
39 as a string to the GanetiRapiClient object.
42 >>> rapi = client.GanetiRapiClient('my.test.cluster')
44 - Note - For R/W access to the cluster you need to pass in 'username'
45 and 'password' as kwargs to the GanetiRapiClient object. Replace
46 USERNAME and PASSWORD with the correct cluster R/W credentials
49 >>> rapi = client.GanetiRapiClient('my.test.cluster', username='USERNAME', password='PASSWORD')
51 - Optional - Setup PrettyPrinter to prettify the output of RAPI
52 functions that return dictionaries.
56 >>> pp = pprint.PrettyPrinter(indent=4).pprint
58 Now you are able to prettify output like this:
61 >>> pp(rapi.GetInfo())
63 - RAPI commands can now be accessed as functions of the rapi variable.
66 >>> rapi.GetInstance('my.test.instance')