Commit 62e999a5 authored by Michael Hanselmann's avatar Michael Hanselmann

RAPI: Add resource to modify cluster

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent cfaeaaf7
......@@ -332,6 +332,69 @@ features:
Instance reinstall supports body parameters.
``/2/modify``
++++++++++++++++++++++++++++++++++++++++
Modifies cluster parameters.
Supports the following commands: ``PUT``.
``PUT``
~~~~~~~
Returns a job ID.
Body parameters:
``vg_name`` (string)
Volume group name.
``enabled_hypervisors`` (list)
List of enabled hypervisors.
``hvparams`` (dict)
Cluster-wide hypervisor parameter defaults, hypervisor-dependent.
``beparams`` (dict)
Cluster-wide backend parameter defaults.
``os_hvp`` (dict)
Cluster-wide per-OS hypervisor parameter defaults.
``osparams`` (dict)
Dictionary with OS parameters.
``candidate_pool_size`` (int)
Master candidate pool size.
``uid_pool`` (list)
Set UID pool. Must be list of lists describing UID ranges (two items,
start and end inclusive).
``add_uids``
Extend UID pool. Must be list of lists describing UID ranges (two
items, start and end inclusive) to be added.
``remove_uids``
Shrink UID pool. Must be list of lists describing UID ranges (two
items, start and end inclusive) to be removed.
``maintain_node_health`` (bool)
Whether to automatically maintain node health.
``prealloc_wipe_disks`` (bool)
Whether to wipe disks before allocating them to instances.
``nicparams`` (dict)
Cluster-wide NIC parameter defaults.
``ndparams`` (dict)
Cluster-wide node parameter defaults.
``drbd_helper`` (string)
DRBD helper program.
``default_iallocator`` (string)
Default iallocator for cluster.
``master_netdev`` (string)
Master network device.
``reserved_lvs`` (list)
List of reserved LVs (strings).
``hidden_os`` (list)
List of modifications as lists. Each modification must have two items,
the operation and the OS name. The operation can be ``add`` or
``remove``.
``blacklisted_os`` (list)
List of modifications as lists. Each modification must have two items,
the operation and the OS name. The operation can be ``add`` or
``remove``.
``/2/groups``
+++++++++++++
......
......@@ -481,6 +481,20 @@ class GanetiRapiClient(object):
return self._SendRequest(HTTP_GET, "/%s/info" % GANETI_RAPI_VERSION,
None, None)
def ModifyCluster(self, **kwargs):
"""Modifies cluster parameters.
More details for parameters can be found in the RAPI documentation.
@rtype: int
@return: job id
"""
body = kwargs
return self._SendRequest(HTTP_PUT,
"/%s/modify" % GANETI_RAPI_VERSION, None, body)
def GetClusterTags(self):
"""Gets the cluster tags.
......
......@@ -231,6 +231,7 @@ def GetHandlers(node_name_pattern, instance_name_pattern,
"/2/os": rlib2.R_2_os,
"/2/redistribute-config": rlib2.R_2_redist_config,
"/2/features": rlib2.R_2_features,
"/2/modify": rlib2.R_2_cluster_modify,
}
......
......@@ -188,6 +188,22 @@ class R_2_redist_config(baserlib.R_Generic):
return baserlib.SubmitJob([opcodes.OpRedistributeConfig()])
class R_2_cluster_modify(baserlib.R_Generic):
"""/2/modify resource.
"""
def PUT(self):
"""Modifies cluster parameters.
@return: a job id
"""
op = baserlib.FillOpcode(opcodes.OpSetClusterParams, self.request_body,
None)
return baserlib.SubmitJob([op])
class R_2_jobs(baserlib.R_Generic):
"""/2/jobs resource.
......
......@@ -1039,6 +1039,18 @@ class GanetiRapiClientTests(testutils.GanetiTestCase):
self.assertEqual(job_id, 12347)
self.assertHandler(rlib2.R_2_groups_name_rename)
def testModifyCluster(self):
for mnh in [None, False, True]:
self.rapi.AddResponse("14470")
self.assertEqual(14470,
self.client.ModifyCluster(maintain_node_health=mnh))
self.assertHandler(rlib2.R_2_cluster_modify)
self.assertItems([])
data = serializer.LoadJson(self.rapi.GetLastRequestData())
self.assertEqual(len(data), 1)
self.assertEqual(data["maintain_node_health"], mnh)
self.assertEqual(self.rapi.CountPending(), 0)
if __name__ == '__main__':
client.UsesRapiClient(testutils.GanetiTestProgram)()
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