RAPI client: Wrap /2/redistribute-config resource
authorMichael Hanselmann <hansmi@google.com>
Wed, 26 Jan 2011 18:09:28 +0000 (19:09 +0100)
committerMichael Hanselmann <hansmi@google.com>
Thu, 27 Jan 2011 11:04:59 +0000 (12:04 +0100)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: RenĂ© Nussbaumer <rn@google.com>

lib/rapi/client.py
test/ganeti.rapi.client_unittest.py

index 467dec9..51582ca 100644 (file)
@@ -236,7 +236,7 @@ def GenericCurlConfig(verbose=False, use_signal=False,
   return _ConfigCurl
 
 
-class GanetiRapiClient(object):
+class GanetiRapiClient(object): # pylint: disable-msg=R0904
   """Ganeti RAPI client.
 
   """
@@ -481,6 +481,16 @@ class GanetiRapiClient(object):
     return self._SendRequest(HTTP_GET, "/%s/info" % GANETI_RAPI_VERSION,
                              None, None)
 
+  def RedistributeConfig(self):
+    """Tells the cluster to redistribute its configuration files.
+
+    @return: job id
+
+    """
+    return self._SendRequest(HTTP_PUT,
+                             "/%s/redistribute-config" % GANETI_RAPI_VERSION,
+                             None, None)
+
   def ModifyCluster(self, **kwargs):
     """Modifies cluster parameters.
 
index d03b393..fc63d00 100755 (executable)
@@ -1078,6 +1078,13 @@ class GanetiRapiClientTests(testutils.GanetiTestCase):
       self.assertEqual(data["maintain_node_health"], mnh)
       self.assertEqual(self.rapi.CountPending(), 0)
 
+  def testRedistributeConfig(self):
+    self.rapi.AddResponse("3364")
+    job_id = self.client.RedistributeConfig()
+    self.assertEqual(job_id, 3364)
+    self.assertItems([])
+    self.assertHandler(rlib2.R_2_redist_config)
+
   def testGrowInstanceDisk(self):
     for idx, wait_for_sync in enumerate([None, False, True]):
       amount = 128 + (512 * idx)