From 22001b7894bd406e2180bd6aafc0ca987c40cb6b Mon Sep 17 00:00:00 2001 From: Dimitris Aragiorgis Date: Thu, 14 Nov 2013 14:10:53 +0200 Subject: [PATCH] (2.10) RAPI: Make use of request_body in Reboot/Remove 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 Reviewed-by: Hrvoje Ribicic --- lib/rapi/client.py | 12 ++++++++---- lib/rapi/rlib2.py | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/rapi/client.py b/lib/rapi/client.py index 35b1191..c2bc03d 100644 --- a/lib/rapi/client.py +++ b/lib/rapi/client.py @@ -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): diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py index 9b3dbaa..ef87f4f 100644 --- a/lib/rapi/rlib2.py +++ b/lib/rapi/rlib2.py @@ -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], -- 1.7.10.4