Commit cab667cc authored by David Knowles's avatar David Knowles Committed by Iustin Pop

Fix RAPI client methods return values

Ensure that all RAPI client methods that should return job ids actually
return job ids.
Signed-off-by: default avatarDavid Knowles <dknowles@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
Signed-off-by: default avatarIustin Pop <iustin@google.com>
parent 4e9dcb8a
......@@ -137,7 +137,7 @@ class GanetiRapiClient(object):
@param query: query arguments to pass to urllib.urlencode
@type prepend_version: bool
@param prepend_version: whether to automatically fetch and prepend the
Ganeti version to the URL path
Ganeti RAPI version to the URL path
@rtype: str
@return: URL path
......@@ -171,7 +171,7 @@ class GanetiRapiClient(object):
@param content: HTTP body content
@type prepend_version: bool
@param prepend_version: whether to automatically fetch and prepend the
Ganeti version to the URL path
Ganeti RAPI version to the URL path
@rtype: str
@return: JSON-Decoded response
......@@ -213,7 +213,7 @@ class GanetiRapiClient(object):
return self._version
def GetVersion(self):
"""Gets the ganeti version running on the cluster.
"""Gets the Remote API version running on the cluster.
@rtype: int
@return: Ganeti version
......@@ -266,7 +266,7 @@ class GanetiRapiClient(object):
if dry_run:
query.append(("dry-run", 1))
self._SendRequest(HTTP_PUT, "/tags", query)
return self._SendRequest(HTTP_PUT, "/tags", query)
def DeleteClusterTags(self, tags, dry_run=False):
"""Deletes tags from the cluster.
......@@ -339,12 +339,15 @@ class GanetiRapiClient(object):
@type instance: str
@param instance: the instance to delete
@rtype: int
@return: job id
"""
query = []
if dry_run:
query.append(("dry-run", 1))
self._SendRequest(HTTP_DELETE, "/instances/%s" % instance, query)
return self._SendRequest(HTTP_DELETE, "/instances/%s" % instance, query)
def GetInstanceTags(self, instance):
"""Gets tags for an instance.
......@@ -376,7 +379,7 @@ class GanetiRapiClient(object):
if dry_run:
query.append(("dry-run", 1))
self._SendRequest(HTTP_PUT, "/instances/%s/tags" % instance, query)
return self._SendRequest(HTTP_PUT, "/instances/%s/tags" % instance, query)
def DeleteInstanceTags(self, instance, tags, dry_run=False):
"""Deletes tags from an instance.
......
......@@ -192,7 +192,9 @@ class GanetiRapiClientTests(unittest.TestCase):
self.assertHandler(rlib2.R_2_tags)
def testAddClusterTags(self):
self.client.AddClusterTags(["awesome"], dry_run=True)
self.rapi.AddResponse("1234")
self.assertEqual(1234,
self.client.AddClusterTags(["awesome"], dry_run=True))
self.assertHandler(rlib2.R_2_tags)
self.assertDryRun()
self.assertQuery("tag", ["awesome"])
......@@ -227,7 +229,8 @@ class GanetiRapiClientTests(unittest.TestCase):
self.assertDryRun()
def testDeleteInstance(self):
self.client.DeleteInstance("instance", dry_run=True)
self.rapi.AddResponse("1234")
self.assertEqual(1234, self.client.DeleteInstance("instance", dry_run=True))
self.assertHandler(rlib2.R_2_instances_name)
self.assertItems(["instance"])
self.assertDryRun()
......@@ -239,7 +242,9 @@ class GanetiRapiClientTests(unittest.TestCase):
self.assertItems(["fooinstance"])
def testAddInstanceTags(self):
self.client.AddInstanceTags("fooinstance", ["awesome"], dry_run=True)
self.rapi.AddResponse("1234")
self.assertEqual(1234,
self.client.AddInstanceTags("fooinstance", ["awesome"], dry_run=True))
self.assertHandler(rlib2.R_2_instances_name_tags)
self.assertItems(["fooinstance"])
self.assertDryRun()
......@@ -425,7 +430,9 @@ class GanetiRapiClientTests(unittest.TestCase):
self.assertItems(["node-k"])
def testAddNodeTags(self):
self.client.AddNodeTags("node-v", ["awesome"], dry_run=True)
self.rapi.AddResponse("1234")
self.assertEqual(1234,
self.client.AddNodeTags("node-v", ["awesome"], dry_run=True))
self.assertHandler(rlib2.R_2_nodes_name_tags)
self.assertItems(["node-v"])
self.assertDryRun()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment