Commit 2674690b authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

config: Add function to determine instance's groups



This will be used for locking only the necessary node group(s)
for per-instance operations.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 54bd7d76
......@@ -1242,6 +1242,25 @@ class ConfigWriter:
"""
return self._UnlockedGetInstanceInfo(instance_name)
@locking.ssynchronized(_config_lock, shared=1)
def GetInstanceNodeGroups(self, instance_name, primary_only=False):
"""Returns set of node group UUIDs for instance's nodes.
@rtype: frozenset
"""
instance = self._UnlockedGetInstanceInfo(instance_name)
if not instance:
raise errors.ConfigurationError("Unknown instance '%s'" % instance_name)
if primary_only:
nodes = [instance.primary_node]
else:
nodes = instance.all_nodes
return frozenset(self._UnlockedGetNodeInfo(node_name).group
for node_name in nodes)
@locking.ssynchronized(_config_lock, shared=1)
def GetAllInstancesInfo(self):
"""Get the configuration of all instances.
......
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