Commit b680c8be authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

RAPI client: De-/activating instance disks


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 54d4c13b
......@@ -767,6 +767,36 @@ class GanetiRapiClient(object): # pylint: disable-msg=R0904
("/%s/instances/%s/modify" %
(GANETI_RAPI_VERSION, instance)), None, body)
def ActivateInstanceDisks(self, instance, ignore_size=None):
"""Activates an instance's disks.
@type instance: string
@param instance: Instance name
@type ignore_size: bool
@param ignore_size: Whether to ignore recorded size
@return: job id
"""
query = []
if ignore_size:
query.append(("ignore_size", 1))
return self._SendRequest(HTTP_PUT,
("/%s/instances/%s/activate-disks" %
(GANETI_RAPI_VERSION, instance)), query, None)
def DeactivateInstanceDisks(self, instance):
"""Deactivates an instance's disks.
@type instance: string
@param instance: Instance name
@return: job id
"""
return self._SendRequest(HTTP_PUT,
("/%s/instances/%s/deactivate-disks" %
(GANETI_RAPI_VERSION, instance)), None, None)
def GrowInstanceDisk(self, instance, disk, amount, wait_for_sync=None):
"""Grows a disk of an instance.
......
......@@ -1085,6 +1085,30 @@ class GanetiRapiClientTests(testutils.GanetiTestCase):
self.assertItems([])
self.assertHandler(rlib2.R_2_redist_config)
def testActivateInstanceDisks(self):
self.rapi.AddResponse("23547")
job_id = self.client.ActivateInstanceDisks("inst28204")
self.assertEqual(job_id, 23547)
self.assertItems(["inst28204"])
self.assertHandler(rlib2.R_2_instances_name_activate_disks)
self.assertFalse(self.rapi.GetLastHandler().queryargs)
def testActivateInstanceDisksIgnoreSize(self):
self.rapi.AddResponse("11044")
job_id = self.client.ActivateInstanceDisks("inst28204", ignore_size=True)
self.assertEqual(job_id, 11044)
self.assertItems(["inst28204"])
self.assertHandler(rlib2.R_2_instances_name_activate_disks)
self.assertQuery("ignore_size", ["1"])
def testDeactivateInstanceDisks(self):
self.rapi.AddResponse("14591")
job_id = self.client.DeactivateInstanceDisks("inst28234")
self.assertEqual(job_id, 14591)
self.assertItems(["inst28234"])
self.assertHandler(rlib2.R_2_instances_name_deactivate_disks)
self.assertFalse(self.rapi.GetLastHandler().queryargs)
def testGrowInstanceDisk(self):
for idx, wait_for_sync in enumerate([None, False, True]):
amount = 128 + (512 * idx)
......
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