LGTM
On Wed, Jul 30, 2014 at 11:31 AM, 'Helga Velroyen' via ganeti-devel < ganeti-devel@googlegroups.com> wrote: > This patch adds a function to retrieve a map of group UUIDs > to SSH ports to the configuration module. Fixes Issue 773. > > Besides that, this patch adds another function to retrieve > the list of potential master candidates. > > Signed-off-by: Helga Velroyen <hel...@google.com> > --- > lib/config.py | 42 +++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 41 insertions(+), 1 deletion(-) > > diff --git a/lib/config.py b/lib/config.py > index e0f3dd8..6be2814 100644 > --- a/lib/config.py > +++ b/lib/config.py > @@ -332,7 +332,33 @@ class ConfigWriter(object): > @return: A dict with the filled in node group params > > """ > - return self._ConfigData().cluster.FillNDGroup(nodegroup) > + return self._UnlockedGetNdGroupParams(nodegroup) > + > + def _UnlockedGetNdGroupParams(self, group): > + """Get the ndparams of the group. > + > + @type group: L{objects.NodeGroup} > + @param group: The group we want to know the params for > + @rtype: dict of str to int > + @return: A dict with the filled in node group params > + > + """ > + return self._ConfigData().cluster.FillNDGroup(group) > + > + @_ConfigSync(shared=1) > + def GetGroupSshPorts(self): > + """Get a map of group UUIDs to SSH ports. > + > + @rtype: dict of str to int > + @return: a dict mapping the UUIDs to the SSH ports > + > + """ > + port_map = {} > + for uuid, group in self._config_data.nodegroups.items(): > + ndparams = self._UnlockedGetNdGroupParams(group) > + port = ndparams.get(constants.ND_SSH_PORT) > + port_map[uuid] = port > + return port_map > > @_ConfigSync(shared=1) > def GetInstanceDiskParams(self, instance): > @@ -695,6 +721,20 @@ class ConfigWriter(object): > assert isinstance(data, dict), "Not a dictionary: " + str(data) > return data > > + @_ConfigSync(shared=1) > + def GetPotentialMasterCandidates(self): > + """Gets the list of node names of potential master candidates. > + > + @rtype: list of str > + @return: list of node names of potential master candidates > + > + """ > + # FIXME: Note that currently potential master candidates are nodes > + # but this definition will be extended once RAPI-unmodifiable > + # parameters are introduced. > + nodes = self._UnlockedGetAllNodesInfo() > + return [node_info.name for node_info in nodes.values()] > + > def GenerateMAC(self, net_uuid, _ec_id): > """Generate a MAC for an instance. > > -- > 2.0.0.526.g5318336 > >