RAPI client: The os argument for instance reinstalls is optional
authorDavid Knowles <dknowles@google.com>
Tue, 20 Jul 2010 21:46:13 +0000 (17:46 -0400)
committerMichael Hanselmann <hansmi@google.com>
Thu, 29 Jul 2010 13:05:58 +0000 (15:05 +0200)
Signed-off-by: David Knowles <dknowles@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

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

index b7f8dda..444a1d2 100644 (file)
@@ -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,
index b835cce..c97b384 100755 (executable)
@@ -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"])