From fcee9675f7f32374a044539920ec2af0679d3dfe Mon Sep 17 00:00:00 2001 From: David Knowles <dknowles@google.com> Date: Tue, 20 Jul 2010 17:46:13 -0400 Subject: [PATCH] RAPI client: The os argument for instance reinstalls is optional Signed-off-by: David Knowles <dknowles@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/rapi/client.py | 15 +++++++++------ test/ganeti.rapi.client_unittest.py | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/rapi/client.py b/lib/rapi/client.py index b7f8dda1d..444a1d233 100644 --- a/lib/rapi/client.py +++ b/lib/rapi/client.py @@ -820,18 +820,21 @@ class GanetiRapiClient(object): ("/%s/instances/%s/startup" % (GANETI_RAPI_VERSION, instance)), query, None) - def ReinstallInstance(self, instance, os, no_startup=False): + def ReinstallInstance(self, instance, os=None, no_startup=False): """Reinstalls an instance. @type instance: str - @param instance: the instance to reinstall - @type os: str - @param os: the os to reinstall + @param instance: The instance to reinstall + @type os: str or None + @param os: The operating system to reinstall. If None, the instance's + current operating system will be installed again @type no_startup: bool - @param no_startup: whether to start the instance automatically + @param no_startup: Whether to start the instance automatically """ - query = [("os", os)] + query = [] + if os: + query.append(("os", os)) if no_startup: query.append(("nostartup", 1)) return self._SendRequest(HTTP_POST, diff --git a/test/ganeti.rapi.client_unittest.py b/test/ganeti.rapi.client_unittest.py index b835ccec0..c97b384e6 100755 --- a/test/ganeti.rapi.client_unittest.py +++ b/test/ganeti.rapi.client_unittest.py @@ -644,7 +644,8 @@ class GanetiRapiClientTests(testutils.GanetiTestCase): def testReinstallInstance(self): self.rapi.AddResponse("19119") - self.assertEqual(19119, self.client.ReinstallInstance("baz-instance", "DOS", + self.assertEqual(19119, self.client.ReinstallInstance("baz-instance", + os="DOS", no_startup=True)) self.assertHandler(rlib2.R_2_instances_name_reinstall) self.assertItems(["baz-instance"]) -- GitLab