(2.10) RAPI: Make use of request_body in Reboot/Remove
authorDimitris Aragiorgis <dimara@grnet.gr>
Thu, 14 Nov 2013 12:10:53 +0000 (14:10 +0200)
committerDimitris Aragiorgis <dimara@grnet.gr>
Tue, 17 Dec 2013 10:46:43 +0000 (12:46 +0200)
Until now, the shutdown_timeout parameter could only be passed to
ShutdownInstance() inside kwargs, causing it to be included in the
request body. Based on that, extend RebootInstance() and
RemoveInstance() so that they can take extra arguments (e.g.
shutdown_timeout) and pass them eventually to the corresponding opcode.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Hrvoje Ribicic <riba@google.com>

lib/rapi/client.py
lib/rapi/rlib2.py

index 35b1191..c2bc03d 100644 (file)
@@ -831,7 +831,7 @@ class GanetiRapiClient(object): # pylint: disable=R0904
     return self._SendRequest(HTTP_POST, "/%s/instances" % GANETI_RAPI_VERSION,
                              query, body)
 
-  def DeleteInstance(self, instance, dry_run=False):
+  def DeleteInstance(self, instance, dry_run=False, **kwargs):
     """Deletes an instance.
 
     @type instance: str
@@ -842,11 +842,13 @@ class GanetiRapiClient(object): # pylint: disable=R0904
 
     """
     query = []
+    body = kwargs
+
     _AppendDryRunIf(query, dry_run)
 
     return self._SendRequest(HTTP_DELETE,
                              ("/%s/instances/%s" %
-                              (GANETI_RAPI_VERSION, instance)), query, None)
+                              (GANETI_RAPI_VERSION, instance)), query, body)
 
   def ModifyInstance(self, instance, **kwargs):
     """Modifies an instance.
@@ -1001,7 +1003,7 @@ class GanetiRapiClient(object): # pylint: disable=R0904
                               (GANETI_RAPI_VERSION, instance)), query, None)
 
   def RebootInstance(self, instance, reboot_type=None, ignore_secondaries=None,
-                     dry_run=False, reason=None):
+                     dry_run=False, reason=None, **kwargs):
     """Reboots an instance.
 
     @type instance: str
@@ -1020,6 +1022,8 @@ class GanetiRapiClient(object): # pylint: disable=R0904
 
     """
     query = []
+    body = kwargs
+
     _AppendDryRunIf(query, dry_run)
     _AppendIf(query, reboot_type, ("type", reboot_type))
     _AppendIf(query, ignore_secondaries is not None,
@@ -1028,7 +1032,7 @@ class GanetiRapiClient(object): # pylint: disable=R0904
 
     return self._SendRequest(HTTP_POST,
                              ("/%s/instances/%s/reboot" %
-                              (GANETI_RAPI_VERSION, instance)), query, None)
+                              (GANETI_RAPI_VERSION, instance)), query, body)
 
   def ShutdownInstance(self, instance, dry_run=False, no_remember=False,
                        reason=None, **kwargs):
index 9b3dbaa..ef87f4f 100644 (file)
@@ -995,7 +995,7 @@ class R_2_instances_name(baserlib.OpcodeResource):
 
     """
     assert len(self.items) == 1
-    return ({}, {
+    return (self.request_body, {
       "instance_name": self.items[0],
       "ignore_failures": False,
       "dry_run": self.dryRun(),
@@ -1034,7 +1034,7 @@ class R_2_instances_name_reboot(baserlib.OpcodeResource):
     ignore_secondaries=[False|True] parameters.
 
     """
-    return ({}, {
+    return (self.request_body, {
       "instance_name": self.items[0],
       "reboot_type":
         self.queryargs.get("type", [constants.INSTANCE_REBOOT_HARD])[0],