Statistics
| Branch: | Tag: | Revision:

root / doc / design-2.0-rapi-changes.rst @ c2b05d85

History | View | Annotate | Download (3.8 kB)

1
Ganeti Remote API
2
=================
3

    
4
.. contents::
5

    
6
Objective
7
---------
8
The Ganeti RAPI provides limited remote control over Ganeti-cluster for
9
third-party applications, exposing internal Ganeti functionality via RESTful
10
API.
11

    
12

    
13
Goals
14
~~~~~
15

    
16
- Provide functionality for remote cluster management.
17

    
18
- Expose current cluster state
19

    
20
- Must be extensible and revolvable in design
21

    
22
- Restrict access
23

    
24

    
25
Requirements
26
~~~~~~~~~~~~
27

    
28
- Authentication
29

    
30
- Encryption
31

    
32
- Language independent
33

    
34
- Reliable and easy to use
35

    
36

    
37
Background
38
----------
39

    
40
A growing amount of installations can shortly put ganeti based infrastructure
41
on manageable edge. Therefore the is strong need to centralize clusters
42
management, provide information for the "best placement" and cluster
43
rebalancing decisions.
44

    
45
The first Ganeti RAPI was designed and deployed with the Ganeti 1.2.5 release.
46
That version provide Read-Only access to a cluster state. Fully functional
47
read-write API demand significant internal changes which are in a pipeline for
48
Ganeti 2.0 release.
49

    
50
Overview
51
--------
52

    
53
We decided to go with implementing the Ganeti RAPI in a RESTful way, which is
54
aligned with key features we looking. It is simple, stateless, scalable and
55
extensible paradigm of API implementation. As transport it uses HTTP over SSL,
56
and we are implementing it in JSON encoding, but in a way it possible to extend
57
and provide any other one.
58

    
59
Design
60
-------
61

    
62
The Ganeti API implemented as independent daemon, running on the same node
63
with the same permission level as Ganeti master daemon. Communication done
64
through unix socket protocol provided by Ganeti luxi library.
65
In order to keep communication asynchronous RAPI process two types of client
66
requests:
67

    
68
- queries: sever able to answer immediately
69
- jobs: some time needed.
70

    
71
In the query case requested data send back to client in http body. Typical
72
examples of queries would be list of nodes, instances, cluster info, etc.
73
Dealing with jobs client instead of waiting until job completes receive a job
74
id, the identifier which allows to query the job progress in the job queue.
75
(See job queue design doc for details)
76

    
77
Internally, each exported object has an version identifier, which is used as a
78
state stamp in the http header E-Tag field for request/response to avoid a race
79
condition.
80

    
81

    
82
Resource representation
83
~~~~~~~~~~~~~~~~~~~~~~~
84
The key difference of REST approach from others API is instead having one URI
85
for all our requests, REST demand separate service by resources with unique
86
URI. Each of them should have limited amount of stateless and standard HTTP
87
methods: GET, POST, DELETE, PUT.
88

    
89
For example in Ganeti case we can have a set of URI:
90
 - /{clustername}/instances
91
 - /{clustername}/instances/{instancename}
92
 - /{clustername}/instances/{instancename}/tag
93
 - /{clustername}/tag
94

    
95
A GET request to /{clustername}/instances will return list of instances, a POST
96
to /{clustername}/instances should create new instance, a DELETE
97
/{clustername}/instances/{instancename} should delete instance, a GET
98
/{clustername}/tag get cluster tag
99

    
100
Each resource URI has a version prefix. The complete list of resources id TBD.
101

    
102
Internal encoding might be JSON, XML, or any other. The JSON encoding fits
103
nicely in Ganeti RAPI needs. Specific representation client can request with
104
Accept field in the HTTP header.
105

    
106
The REST uses standard HTTP as application protocol (not just as a transport)
107
for resources access. Set of possible result codes is a subset of standard HTTP
108
results. The stateless provide additional reliability and transparency to
109
operations.
110

    
111

    
112
Security
113
~~~~~~~~
114
With the write functionality security becomes much bigger an issue.  The Ganeti
115
RAPI uses basic HTTP authentication on top of SSL connection to grant access to
116
an exported resource. The password stores locally in Apache-style .htpasswd
117
file. Only one level of privileges is supported.