Commit eaa98a04 authored by Guido Trotter's avatar Guido Trotter
Browse files


This function allows a node group to be looked up by name or uuid.
If no nodegroup is specified and only one exists, that one is returned.
Signed-off-by: default avatarGuido Trotter <>
Reviewed-by: default avatarMichael Hanselmann <>
parent 6520ba14
......@@ -845,6 +845,30 @@ class ConfigWriter:
return self._config_data.cluster.primary_ip_family
@locking.ssynchronized(_config_lock, shared=1)
def LookupNodeGroup(self, target):
"""Lookup a node group.
@type target: string or None
@param target: group name or uuid or None to look for the default
@rtype: string
@return: nodegroup uuid
@raises errors.OpPrereqError: when the target group cannot be found
if target is None:
if len(self._config_data.nodegroups) != 1:
raise errors.OpPrereqError("More than one nodegroup exists. Target"
" group must be specified explicitely.")
return self._config_data.nodegroups.keys()[0]
if target in self._config_data.nodegroups:
return target
for nodegroup in self._config_data.nodegroups.values():
if == target:
return nodegroup.uuid
raise errors.OpPrereqError("Nodegroup '%s' not found", target)
def AddInstance(self, instance, ec_id):
"""Add an instance to the config.
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