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

RAPI client: Fix behaviour of “allocatable” storage flag



When modifying a storage unit, the “allocatable” flag should default
to “no modification”. This replicates the behaviour of the command
line interface.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 10f5ab6c
......@@ -987,7 +987,7 @@ class GanetiRapiClient(object):
("/%s/nodes/%s/storage" %
(GANETI_RAPI_VERSION, node)), query, None)
def ModifyNodeStorageUnits(self, node, storage_type, name, allocatable=True):
def ModifyNodeStorageUnits(self, node, storage_type, name, allocatable=None):
"""Modifies parameters of storage units on the node.
@type node: str
......@@ -996,8 +996,9 @@ class GanetiRapiClient(object):
@param storage_type: storage type whose units to modify
@type name: str
@param name: name of the storage unit
@type allocatable: bool
@param allocatable: TODO: Document me
@type allocatable: bool or None
@param allocatable: Whether to set the "allocatable" flag on the storage
unit (None=no modification, True=set, False=unset)
@rtype: int
@return: job id
......@@ -1006,9 +1007,11 @@ class GanetiRapiClient(object):
query = [
("storage_type", storage_type),
("name", name),
("allocatable", allocatable),
]
if allocatable is not None:
query.append(("allocatable", allocatable))
return self._SendRequest(HTTP_PUT,
("/%s/nodes/%s/storage/modify" %
(GANETI_RAPI_VERSION, node)), query, None)
......
......@@ -450,6 +450,18 @@ class GanetiRapiClientTests(testutils.GanetiTestCase):
self.assertItems(["node-z"])
self.assertQuery("storage_type", ["lvm-pv"])
self.assertQuery("name", ["hda"])
self.assertQuery("allocatable", None)
for allocatable, query_allocatable in [(True, "1"), (False, "0")]:
self.rapi.AddResponse("7205")
job_id = self.client.ModifyNodeStorageUnits("node-z", "lvm-pv", "hda",
allocatable=allocatable)
self.assertEqual(7205, job_id)
self.assertHandler(rlib2.R_2_nodes_name_storage_modify)
self.assertItems(["node-z"])
self.assertQuery("storage_type", ["lvm-pv"])
self.assertQuery("name", ["hda"])
self.assertQuery("allocatable", [query_allocatable])
def testRepairNodeStorageUnits(self):
self.rapi.AddResponse("99")
......
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