Revision 591e5103
b/lib/rapi/client.py | ||
---|---|---|
552 | 552 |
else: |
553 | 553 |
return [i["id"] for i in instances] |
554 | 554 |
|
555 |
def GetInstanceInfo(self, instance):
|
|
555 |
def GetInstance(self, instance): |
|
556 | 556 |
"""Gets information about an instance. |
557 | 557 |
|
558 | 558 |
@type instance: str |
... | ... | |
566 | 566 |
("/%s/instances/%s" % |
567 | 567 |
(GANETI_RAPI_VERSION, instance)), None, None) |
568 | 568 |
|
569 |
def GetInstanceInfo(self, instance, static=None): |
|
570 |
"""Gets information about an instance. |
|
571 |
|
|
572 |
@type instance: string |
|
573 |
@param instance: Instance name |
|
574 |
@rtype: string |
|
575 |
@return: Job ID |
|
576 |
|
|
577 |
""" |
|
578 |
if static is not None: |
|
579 |
query = [("static", static)] |
|
580 |
else: |
|
581 |
query = None |
|
582 |
|
|
583 |
return self._SendRequest(HTTP_GET, |
|
584 |
("/%s/instances/%s/info" % |
|
585 |
(GANETI_RAPI_VERSION, instance)), query, None) |
|
586 |
|
|
569 | 587 |
def CreateInstance(self, mode, name, disk_template, disks, nics, |
570 | 588 |
**kwargs): |
571 | 589 |
"""Creates a new instance. |
... | ... | |
902 | 920 |
else: |
903 | 921 |
return [n["id"] for n in nodes] |
904 | 922 |
|
905 |
def GetNodeInfo(self, node):
|
|
923 |
def GetNode(self, node): |
|
906 | 924 |
"""Gets information about a node. |
907 | 925 |
|
908 | 926 |
@type node: str |
b/test/ganeti.rapi.client_unittest.py | ||
---|---|---|
233 | 233 |
self.assertHandler(rlib2.R_2_instances) |
234 | 234 |
self.assertBulk() |
235 | 235 |
|
236 |
def testGetInstanceInfo(self):
|
|
236 |
def testGetInstance(self): |
|
237 | 237 |
self.rapi.AddResponse("[]") |
238 |
self.assertEqual([], self.client.GetInstanceInfo("instance"))
|
|
238 |
self.assertEqual([], self.client.GetInstance("instance")) |
|
239 | 239 |
self.assertHandler(rlib2.R_2_instances_name) |
240 | 240 |
self.assertItems(["instance"]) |
241 | 241 |
|
242 |
def testGetInstanceInfo(self): |
|
243 |
self.rapi.AddResponse("21291") |
|
244 |
self.assertEqual(21291, self.client.GetInstanceInfo("inst3")) |
|
245 |
self.assertHandler(rlib2.R_2_instances_name_info) |
|
246 |
self.assertItems(["inst3"]) |
|
247 |
self.assertQuery("static", None) |
|
248 |
|
|
249 |
self.rapi.AddResponse("3428") |
|
250 |
self.assertEqual(3428, self.client.GetInstanceInfo("inst31", static=False)) |
|
251 |
self.assertHandler(rlib2.R_2_instances_name_info) |
|
252 |
self.assertItems(["inst31"]) |
|
253 |
self.assertQuery("static", ["0"]) |
|
254 |
|
|
255 |
self.rapi.AddResponse("15665") |
|
256 |
self.assertEqual(15665, self.client.GetInstanceInfo("inst32", static=True)) |
|
257 |
self.assertHandler(rlib2.R_2_instances_name_info) |
|
258 |
self.assertItems(["inst32"]) |
|
259 |
self.assertQuery("static", ["1"]) |
|
260 |
|
|
242 | 261 |
def testCreateInstanceOldVersion(self): |
243 | 262 |
self.rapi.AddResponse(serializer.DumpJson([])) |
244 | 263 |
self.assertRaises(NotImplementedError, self.client.CreateInstance, |
... | ... | |
424 | 443 |
self.assertHandler(rlib2.R_2_nodes) |
425 | 444 |
self.assertBulk() |
426 | 445 |
|
427 |
def testGetNodeInfo(self):
|
|
446 |
def testGetNode(self): |
|
428 | 447 |
self.rapi.AddResponse("{}") |
429 |
self.assertEqual({}, self.client.GetNodeInfo("node-foo"))
|
|
448 |
self.assertEqual({}, self.client.GetNode("node-foo")) |
|
430 | 449 |
self.assertHandler(rlib2.R_2_nodes_name) |
431 | 450 |
self.assertItems(["node-foo"]) |
432 | 451 |
|
Also available in: Unified diff