Commit fcee9675 authored by David Knowles's avatar David Knowles Committed by Michael Hanselmann
Browse files

RAPI client: The os argument for instance reinstalls is optional


Signed-off-by: default avatarDavid Knowles <dknowles@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 938bde86
......@@ -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,
......
......@@ -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"])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment