Revision c8e0a534 lib/rapi/rlib2.py
b/lib/rapi/rlib2.py | ||
---|---|---|
55 | 55 |
to adapt clients accordingly. |
56 | 56 |
|
57 | 57 |
""" |
58 |
DOC_URI = "/version" |
|
59 |
|
|
60 | 58 |
def GET(self): |
61 | 59 |
"""Returns the remote API version. |
62 | 60 |
|
... | ... | |
68 | 66 |
"""Cluster info. |
69 | 67 |
|
70 | 68 |
""" |
71 |
DOC_URI = "/2/info" |
|
72 |
|
|
73 | 69 |
def GET(self): |
74 | 70 |
"""Returns cluster information. |
75 | 71 |
|
76 |
Example:: |
|
77 |
|
|
78 |
{ |
|
79 |
"config_version": 2000000, |
|
80 |
"name": "cluster", |
|
81 |
"software_version": "2.0.0~beta2", |
|
82 |
"os_api_version": 10, |
|
83 |
"export_version": 0, |
|
84 |
"candidate_pool_size": 10, |
|
85 |
"enabled_hypervisors": [ |
|
86 |
"fake" |
|
87 |
], |
|
88 |
"hvparams": { |
|
89 |
"fake": {} |
|
90 |
}, |
|
91 |
"default_hypervisor": "fake", |
|
92 |
"master": "node1.example.com", |
|
93 |
"architecture": [ |
|
94 |
"64bit", |
|
95 |
"x86_64" |
|
96 |
], |
|
97 |
"protocol_version": 20, |
|
98 |
"beparams": { |
|
99 |
"default": { |
|
100 |
"auto_balance": true, |
|
101 |
"vcpus": 1, |
|
102 |
"memory": 128 |
|
103 |
} |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 | 72 |
""" |
108 | 73 |
client = luxi.Client() |
109 | 74 |
return client.QueryClusterInfo() |
... | ... | |
113 | 78 |
"""/2/os resource. |
114 | 79 |
|
115 | 80 |
""" |
116 |
DOC_URI = "/2/os" |
|
117 |
|
|
118 | 81 |
def GET(self): |
119 | 82 |
"""Return a list of all OSes. |
120 | 83 |
|
... | ... | |
137 | 100 |
"""/2/jobs resource. |
138 | 101 |
|
139 | 102 |
""" |
140 |
DOC_URI = "/2/jobs" |
|
141 |
|
|
142 | 103 |
def GET(self): |
143 | 104 |
"""Returns a dictionary of jobs. |
144 | 105 |
|
... | ... | |
156 | 117 |
"""/2/jobs/[job_id] resource. |
157 | 118 |
|
158 | 119 |
""" |
159 |
DOC_URI = "/2/jobs/[job_id]" |
|
160 |
|
|
161 | 120 |
def GET(self): |
162 | 121 |
"""Returns a job status. |
163 | 122 |
|
... | ... | |
194 | 153 |
"""/2/nodes resource. |
195 | 154 |
|
196 | 155 |
""" |
197 |
DOC_URI = "/2/nodes" |
|
198 |
|
|
199 | 156 |
def GET(self): |
200 | 157 |
"""Returns a list of all nodes. |
201 | 158 |
|
202 |
Example:: |
|
203 |
|
|
204 |
[ |
|
205 |
{ |
|
206 |
"id": "node1.example.com", |
|
207 |
"uri": "\/instances\/node1.example.com" |
|
208 |
}, |
|
209 |
{ |
|
210 |
"id": "node2.example.com", |
|
211 |
"uri": "\/instances\/node2.example.com" |
|
212 |
} |
|
213 |
] |
|
214 |
|
|
215 |
If the optional 'bulk' argument is provided and set to 'true' |
|
216 |
value (i.e '?bulk=1'), the output contains detailed |
|
217 |
information about nodes as a list. |
|
218 |
|
|
219 |
Example:: |
|
220 |
|
|
221 |
[ |
|
222 |
{ |
|
223 |
"pinst_cnt": 1, |
|
224 |
"mfree": 31280, |
|
225 |
"mtotal": 32763, |
|
226 |
"name": "www.example.com", |
|
227 |
"tags": [], |
|
228 |
"mnode": 512, |
|
229 |
"dtotal": 5246208, |
|
230 |
"sinst_cnt": 2, |
|
231 |
"dfree": 5171712, |
|
232 |
"offline": false |
|
233 |
}, |
|
234 |
... |
|
235 |
] |
|
236 |
|
|
237 |
@return: a dictionary with 'name' and 'uri' keys for each of them |
|
238 |
|
|
239 | 159 |
""" |
240 | 160 |
client = luxi.Client() |
241 | 161 |
|
... | ... | |
253 | 173 |
"""/2/nodes/[node_name] resources. |
254 | 174 |
|
255 | 175 |
""" |
256 |
DOC_URI = "/nodes/[node_name]" |
|
257 |
|
|
258 | 176 |
def GET(self): |
259 | 177 |
"""Send information about a node. |
260 | 178 |
|
... | ... | |
271 | 189 |
"""/2/instances resource. |
272 | 190 |
|
273 | 191 |
""" |
274 |
DOC_URI = "/2/instances" |
|
275 |
|
|
276 | 192 |
def GET(self): |
277 | 193 |
"""Returns a list of all available instances. |
278 | 194 |
|
279 |
|
|
280 |
Example:: |
|
281 |
|
|
282 |
[ |
|
283 |
{ |
|
284 |
"name": "web.example.com", |
|
285 |
"uri": "\/instances\/web.example.com" |
|
286 |
}, |
|
287 |
{ |
|
288 |
"name": "mail.example.com", |
|
289 |
"uri": "\/instances\/mail.example.com" |
|
290 |
} |
|
291 |
] |
|
292 |
|
|
293 |
If the optional 'bulk' argument is provided and set to 'true' |
|
294 |
value (i.e '?bulk=1'), the output contains detailed |
|
295 |
information about instances as a list. |
|
296 |
|
|
297 |
Example:: |
|
298 |
|
|
299 |
[ |
|
300 |
{ |
|
301 |
"status": "running", |
|
302 |
"disk_usage": 20480, |
|
303 |
"nic.bridges": [ |
|
304 |
"xen-br0" |
|
305 |
], |
|
306 |
"name": "web.example.com", |
|
307 |
"tags": ["tag1", "tag2"], |
|
308 |
"beparams": { |
|
309 |
"vcpus": 2, |
|
310 |
"memory": 512 |
|
311 |
}, |
|
312 |
"disk.sizes": [ |
|
313 |
20480 |
|
314 |
], |
|
315 |
"pnode": "node1.example.com", |
|
316 |
"nic.macs": ["01:23:45:67:89:01"], |
|
317 |
"snodes": ["node2.example.com"], |
|
318 |
"disk_template": "drbd", |
|
319 |
"admin_state": true, |
|
320 |
"os": "debian-etch", |
|
321 |
"oper_state": true |
|
322 |
}, |
|
323 |
... |
|
324 |
] |
|
325 |
|
|
326 |
@return: a dictionary with 'name' and 'uri' keys for each of them. |
|
327 |
|
|
328 | 195 |
""" |
329 | 196 |
client = luxi.Client() |
330 | 197 |
|
... | ... | |
396 | 263 |
"""/2/instances/[instance_name] resources. |
397 | 264 |
|
398 | 265 |
""" |
399 |
DOC_URI = "/2/instances/[instance_name]" |
|
400 |
|
|
401 | 266 |
def GET(self): |
402 | 267 |
"""Send information about an instance. |
403 | 268 |
|
... | ... | |
425 | 290 |
Implements an instance reboot. |
426 | 291 |
|
427 | 292 |
""" |
428 |
|
|
429 |
DOC_URI = "/2/instances/[instance_name]/reboot" |
|
430 |
|
|
431 | 293 |
def POST(self): |
432 | 294 |
"""Reboot an instance. |
433 | 295 |
|
... | ... | |
456 | 318 |
Implements an instance startup. |
457 | 319 |
|
458 | 320 |
""" |
459 |
|
|
460 |
DOC_URI = "/2/instances/[instance_name]/startup" |
|
461 |
|
|
462 | 321 |
def PUT(self): |
463 | 322 |
"""Startup an instance. |
464 | 323 |
|
... | ... | |
482 | 341 |
Implements an instance shutdown. |
483 | 342 |
|
484 | 343 |
""" |
485 |
|
|
486 |
DOC_URI = "/2/instances/[instance_name]/shutdown" |
|
487 |
|
|
488 | 344 |
def PUT(self): |
489 | 345 |
"""Shutdown an instance. |
490 | 346 |
|
... | ... | |
500 | 356 |
class _R_Tags(baserlib.R_Generic): |
501 | 357 |
""" Quasiclass for tagging resources |
502 | 358 |
|
503 |
Manages tags. Inheriting this class you suppose to define DOC_URI and
|
|
359 |
Manages tags. When inheriting this class you must define the
|
|
504 | 360 |
TAG_LEVEL for it. |
505 | 361 |
|
506 | 362 |
""" |
... | ... | |
563 | 419 |
Manages per-instance tags. |
564 | 420 |
|
565 | 421 |
""" |
566 |
DOC_URI = "/2/instances/[instance_name]/tags" |
|
567 | 422 |
TAG_LEVEL = constants.TAG_INSTANCE |
568 | 423 |
|
569 | 424 |
|
... | ... | |
573 | 428 |
Manages per-node tags. |
574 | 429 |
|
575 | 430 |
""" |
576 |
DOC_URI = "/2/nodes/[node_name]/tags" |
|
577 | 431 |
TAG_LEVEL = constants.TAG_NODE |
578 | 432 |
|
579 | 433 |
|
... | ... | |
583 | 437 |
Manages cluster tags. |
584 | 438 |
|
585 | 439 |
""" |
586 |
DOC_URI = "/2/tags" |
|
587 | 440 |
TAG_LEVEL = constants.TAG_CLUSTER |
Also available in: Unified diff