diff --git a/doc/iallocator.rst b/doc/iallocator.rst index de2759c1e48986fa3981ad4ce73352ee69674c1c..248a9dfc66049f0c3cf0d40293e7181dce7fbb1a 100644 --- a/doc/iallocator.rst +++ b/doc/iallocator.rst @@ -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 diff --git a/lib/cmdlib.py b/lib/cmdlib.py index e881e6745398c8fb02149a4eaf7c5a43d28bf3f4..4496f161c9c91e5e1ca544d81a97e3f8beb24165 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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. diff --git a/lib/config.py b/lib/config.py index 21a362ae25df1e7eb7cccb43f45fe8b3e4260825..156f1deabac92da39c2f54054886d38560a03177 100644 --- a/lib/config.py +++ b/lib/config.py @@ -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.