Commit 622444e5 authored by Iustin Pop's avatar Iustin Pop
Browse files

Export node group data in iallocator


Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent acd34ea7
......@@ -171,6 +171,14 @@ request
nodes
the names of the nodes to be evacuated
nodegroups
a dictionary with the data for the cluster's node groups; it is keyed
on the group UUID, and the values are a dictionary with the following
keys:
name
the node group name
instances
a dictionary with the data for the current existing instance on the
cluster, indexed by instance name; the contents are similar to the
......
......@@ -10200,12 +10200,24 @@ class IAllocator(object):
self.rpc.call_all_instances_info(node_list,
cluster_info.enabled_hypervisors)
data["nodegroups"] = self._ComputeNodeGroupData(cfg)
data["nodes"] = self._ComputeNodeData(cfg, node_data, node_iinfo, i_list)
data["instances"] = self._ComputeInstanceData(cluster_info, i_list)
self.in_data = data
@staticmethod
def _ComputeNodeGroupData(cfg):
"""Compute node groups data.
"""
ng = {}
for guuid, gdata in cfg.GetAllNodeGroupsInfo().items():
ng[guuid] = { "name": gdata.name }
return ng
@staticmethod
def _ComputeNodeData(cfg, node_data, node_iinfo, i_list):
"""Compute global node data.
......
......@@ -876,6 +876,13 @@ class ConfigWriter:
return nodegroup.uuid
raise errors.OpPrereqError("Nodegroup '%s' not found", target)
@locking.ssynchronized(_config_lock, shared=1)
def GetAllNodeGroupsInfo(self):
"""Get the configuration of all node groups.
"""
return dict(self._config_data.nodegroups)
@locking.ssynchronized(_config_lock)
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