Allright, I'll resend it together with the code that uses it.
On Tue, Mar 25, 2014 at 10:43 AM, Petr Pudlák <[email protected]> wrote: > I'd suggest to also update GetNdGroupParams to > use _UnlockedGetNdGroupParams so that we don't have duplicate code. > > I'll be slightly inclined to include the patch together with code that > uses the new function, such as refactoring *node_verify* and > *node_verify_light* RPC calls a to use this port map instead of the whole > groups configuration. But I don't mind submitting the patch, if it's > already prepared, and just adding an issue for the refactoring. > > Otherwise LGTM > > > On Tue, Mar 25, 2014 at 10:19 AM, Helga Velroyen <[email protected]>wrote: > >> This patch adds a function to retrieve a map of group UUIDs >> to SSH ports to the configuration module. Fixes Issue 773. >> >> Signed-off-by: Helga Velroyen <[email protected]> >> --- >> lib/config.py | 26 ++++++++++++++++++++++++++ >> 1 file changed, 26 insertions(+) >> >> diff --git a/lib/config.py b/lib/config.py >> index 981130e..d63a208 100644 >> --- a/lib/config.py >> +++ b/lib/config.py >> @@ -248,6 +248,21 @@ class ConfigWriter(object): >> return self._config_data.cluster.FillNDGroup(nodegroup) >> >> @locking.ssynchronized(_config_lock, 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 >> + >> + @locking.ssynchronized(_config_lock, shared=1) >> def GetInstanceDiskParams(self, instance): >> """Get the disk params populated with inherit chain. >> >> @@ -281,6 +296,17 @@ class ConfigWriter(object): >> """ >> return self._config_data.cluster.SimpleFillDP(group.diskparams) >> >> + 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._config_data.cluster.FillNDGroup(group) >> + >> def _UnlockedGetNetworkMACPrefix(self, net_uuid): >> """Return the network mac prefix if it exists or the cluster level >> default. >> >> -- >> 1.9.1.423.g4596e3a >> >> > -- -- Helga Velroyen | Software Engineer | [email protected] | Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
