Commit f18fab7d authored by Adeodato Simo's avatar Adeodato Simo
Browse files

Expose OpSetGroupParams in RAPI and RAPI client

This creates the /2/groups/<name>/modify resource; at the moment, only the
"alloc_policy" attribute can be modified.
Signed-off-by: default avatarAdeodato Simo <>
Reviewed-by: default avatarMichael Hanselmann <>
parent 90e99856
......@@ -420,6 +420,24 @@ Deletes a node group.
It supports the ``dry-run`` argument.
Modifies the parameters of a node group.
Supports the following commands: ``PUT``.
Returns a job ID.
Body parameters:
``alloc_policy`` (string)
If present, the new allocation policy for the node group.
......@@ -1434,6 +1434,21 @@ class GanetiRapiClient(object):
return self._SendRequest(HTTP_POST, "/%s/groups" % GANETI_RAPI_VERSION,
query, body)
def ModifyGroup(self, group, **kwargs):
"""Modifies a node group.
More details for parameters can be found in the RAPI documentation.
@type group: string
@param group: Node group name
@rtype: int
@return: job id
return self._SendRequest(HTTP_PUT,
("/%s/groups/%s/modify" %
(GANETI_RAPI_VERSION, group)), None, kwargs)
def DeleteGroup(self, group, dry_run=False):
"""Deletes a node group.
......@@ -215,6 +215,8 @@ def GetHandlers(node_name_pattern, instance_name_pattern,
"/2/groups": rlib2.R_2_groups,
re.compile(r'^/2/groups/(%s)$' % group_name_pattern):
re.compile(r'^/2/groups/(%s)/modify$' % group_name_pattern):
re.compile(r'^/2/groups/(%s)/rename$' % group_name_pattern):
......@@ -604,6 +604,34 @@ class R_2_groups_name(baserlib.R_Generic):
return baserlib.SubmitJob([op])
def _ParseModifyGroupRequest(name, data):
"""Parses a request for modifying a node group.
@rtype: L{opcodes.OpSetGroupParams}
@return: Group modify opcode
alloc_policy = baserlib.CheckParameter(data, "alloc_policy", default=None)
return opcodes.OpSetGroupParams(group_name=name, alloc_policy=alloc_policy)
class R_2_groups_name_modify(baserlib.R_Generic):
"""/2/groups/[group_name]/modify resource.
def PUT(self):
"""Changes some parameters of node group.
@return: a job id
baserlib.CheckType(self.request_body, dict, "Body contents")
op = _ParseModifyGroupRequest(self.items[0], self.request_body)
return baserlib.SubmitJob([op])
def _ParseRenameGroupRequest(name, data, dry_run):
"""Parses a request for renaming a node group.
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