root / doc / rapi.sgml @ c54784d9
History | View | Annotate | Download (2.8 kB)
1 | 4cbd4462 | Oleksiy Mishchenko | <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.2//EN" [ |
---|---|---|---|
2 | 4cbd4462 | Oleksiy Mishchenko | <!ENTITY JsonLink "http://www.json.org/"> |
3 | 4cbd4462 | Oleksiy Mishchenko | <!ENTITY WikipediaRESTLink |
4 | 4cbd4462 | Oleksiy Mishchenko | "http://en.wikipedia.org/wiki/Representational_State_Transfer"> |
5 | 4cbd4462 | Oleksiy Mishchenko | ]> |
6 | 4cbd4462 | Oleksiy Mishchenko | <article class="specification"> |
7 | 4cbd4462 | Oleksiy Mishchenko | <articleinfo> |
8 | 4cbd4462 | Oleksiy Mishchenko | <title>Ganeti remote API</title> |
9 | 4cbd4462 | Oleksiy Mishchenko | </articleinfo> |
10 | 4cbd4462 | Oleksiy Mishchenko | |
11 | 4cbd4462 | Oleksiy Mishchenko | <para>Documents Ganeti version 1.2</para> |
12 | 4cbd4462 | Oleksiy Mishchenko | |
13 | 4cbd4462 | Oleksiy Mishchenko | <sect1> |
14 | 4cbd4462 | Oleksiy Mishchenko | <title>Introduction</title> |
15 | 4cbd4462 | Oleksiy Mishchenko | |
16 | 4cbd4462 | Oleksiy Mishchenko | <para>Ganeti supports a remote API for enable external tools to easily |
17 | 4cbd4462 | Oleksiy Mishchenko | retrieve information about a cluster's state. The remote API daemon, |
18 | 4cbd4462 | Oleksiy Mishchenko | <computeroutput>ganeti-rapi</computeroutput>, is automatically started on |
19 | 4cbd4462 | Oleksiy Mishchenko | the master node if the <computeroutput>--enable-rapi</computeroutput> |
20 | 4cbd4462 | Oleksiy Mishchenko | parameter is passed to the <computeroutput>configure</computeroutput> |
21 | 4cbd4462 | Oleksiy Mishchenko | script. Alternatively you can start it manually. By default it runs on TCP |
22 | 4cbd4462 | Oleksiy Mishchenko | port 5080, but this can be changed either in |
23 | 4cbd4462 | Oleksiy Mishchenko | <filename>…/constants.py</filename> or via the command line |
24 | 4cbd4462 | Oleksiy Mishchenko | parameter <computeroutput>-p</computeroutput>. SSL support can also be |
25 | 4cbd4462 | Oleksiy Mishchenko | enabled by passing command line parameters.</para> |
26 | 4cbd4462 | Oleksiy Mishchenko | |
27 | 4cbd4462 | Oleksiy Mishchenko | <note> |
28 | 4cbd4462 | Oleksiy Mishchenko | <para>Ganeti 1.2 only supports a limited set of calls, all of them |
29 | 4cbd4462 | Oleksiy Mishchenko | read-only. The next major version will have support for write |
30 | 4cbd4462 | Oleksiy Mishchenko | operations.</para> |
31 | 4cbd4462 | Oleksiy Mishchenko | </note> |
32 | 4cbd4462 | Oleksiy Mishchenko | </sect1> |
33 | 4cbd4462 | Oleksiy Mishchenko | |
34 | 4cbd4462 | Oleksiy Mishchenko | <sect1> |
35 | 4cbd4462 | Oleksiy Mishchenko | <title>Protocol</title> |
36 | 4cbd4462 | Oleksiy Mishchenko | |
37 | 4cbd4462 | Oleksiy Mishchenko | <para>The protocol used is <ulink url="&JsonLink;">JSON</ulink> over HTTP |
38 | 4cbd4462 | Oleksiy Mishchenko | designed after the <ulink url="&WikipediaRESTLink;">REST</ulink> principle. |
39 | 4cbd4462 | Oleksiy Mishchenko | </para> |
40 | 4cbd4462 | Oleksiy Mishchenko | </sect1> |
41 | 4cbd4462 | Oleksiy Mishchenko | |
42 | 4cbd4462 | Oleksiy Mishchenko | <sect1> |
43 | 4cbd4462 | Oleksiy Mishchenko | <title>Usage examples</title> |
44 | 4cbd4462 | Oleksiy Mishchenko | |
45 | 4cbd4462 | Oleksiy Mishchenko | <para>You can access the API using your favorite programming language as long |
46 | 4cbd4462 | Oleksiy Mishchenko | as it supports network connections.</para> |
47 | 4cbd4462 | Oleksiy Mishchenko | |
48 | 4cbd4462 | Oleksiy Mishchenko | <sect2> |
49 | 4cbd4462 | Oleksiy Mishchenko | <title>Shell</title> |
50 | 4cbd4462 | Oleksiy Mishchenko | <screen>wget -q -O - http://<replaceable>CLUSTERNAME</replaceable>:5080/info</screen> |
51 | 4cbd4462 | Oleksiy Mishchenko | </sect2> |
52 | 4cbd4462 | Oleksiy Mishchenko | |
53 | 4cbd4462 | Oleksiy Mishchenko | <sect2> |
54 | 4cbd4462 | Oleksiy Mishchenko | <title>Python</title> |
55 | 4cbd4462 | Oleksiy Mishchenko | <screen>import urllib2 |
56 | 4cbd4462 | Oleksiy Mishchenko | f = urllib2.urlopen('http://<replaceable>CLUSTERNAME</replaceable>:5080/info') |
57 | 4cbd4462 | Oleksiy Mishchenko | print f.read()</screen> |
58 | 4cbd4462 | Oleksiy Mishchenko | </sect2> |
59 | 4cbd4462 | Oleksiy Mishchenko | |
60 | 4cbd4462 | Oleksiy Mishchenko | <sect2> |
61 | 4cbd4462 | Oleksiy Mishchenko | <title>JavaScript</title> |
62 | 4cbd4462 | Oleksiy Mishchenko | <note> |
63 | 4cbd4462 | Oleksiy Mishchenko | <para>While it's possible to use JavaScript, it poses several potential |
64 | 4cbd4462 | Oleksiy Mishchenko | problems, including browser blocking request due to non-standard ports |
65 | 4cbd4462 | Oleksiy Mishchenko | or different domain names. Fetching the data on the webserver is |
66 | 4cbd4462 | Oleksiy Mishchenko | easier.</para> |
67 | 4cbd4462 | Oleksiy Mishchenko | </note> |
68 | 4cbd4462 | Oleksiy Mishchenko | <screen>var url = 'http://<replaceable>CLUSTERNAME</replaceable>:5080/info'; |
69 | 4cbd4462 | Oleksiy Mishchenko | var info; |
70 | 4cbd4462 | Oleksiy Mishchenko | |
71 | 4cbd4462 | Oleksiy Mishchenko | var xmlreq = new XMLHttpRequest(); |
72 | 4cbd4462 | Oleksiy Mishchenko | xmlreq.onreadystatechange = function () { |
73 | 4cbd4462 | Oleksiy Mishchenko | if (xmlreq.readyState != 4) return; |
74 | 4cbd4462 | Oleksiy Mishchenko | if (xmlreq.status == 200) { |
75 | 4cbd4462 | Oleksiy Mishchenko | info = eval("(" + xmlreq.responseText + ")"); |
76 | 4cbd4462 | Oleksiy Mishchenko | alert(info); |
77 | 4cbd4462 | Oleksiy Mishchenko | } else { |
78 | 4cbd4462 | Oleksiy Mishchenko | alert('Error fetching cluster info'); |
79 | 4cbd4462 | Oleksiy Mishchenko | } |
80 | 4cbd4462 | Oleksiy Mishchenko | xmlreq = null; |
81 | 4cbd4462 | Oleksiy Mishchenko | }; |
82 | 4cbd4462 | Oleksiy Mishchenko | xmlreq.open('GET', url, true); |
83 | 4cbd4462 | Oleksiy Mishchenko | xmlreq.send(null);</screen> |
84 | 4cbd4462 | Oleksiy Mishchenko | </sect2> |
85 | 4cbd4462 | Oleksiy Mishchenko | |
86 | 4cbd4462 | Oleksiy Mishchenko | </sect1> |
87 | 4cbd4462 | Oleksiy Mishchenko | |
88 | 4cbd4462 | Oleksiy Mishchenko | <sect1> |
89 | 4cbd4462 | Oleksiy Mishchenko | <title>Resources</title> |
90 | 081242d8 | Michael Hanselmann | @INCLUDE_RAPI_RESOURCES@ |
91 | 4cbd4462 | Oleksiy Mishchenko | </sect1> |
92 | 4cbd4462 | Oleksiy Mishchenko | |
93 | 4cbd4462 | Oleksiy Mishchenko | </article> |