Commit 5768e6a6 authored by René Nussbaumer's avatar René Nussbaumer
Browse files

Adding convenience getter for ndparams

Signed-off-by: default avatarRené Nussbaumer <>
Reviewed-by: default avatarIustin Pop <>
parent 04a8865b
......@@ -178,6 +178,18 @@ class ConfigWriter:
mac = "%s:%02x:%02x:%02x" % (prefix, byte1, byte2, byte3)
return mac
@locking.ssynchronized(_config_lock, shared=1)
def GetNdParams(self, node):
"""Get the node params populated with cluster defaults.
@type node: L{object.Node}
@param node: The node we want to know the params for
@return: A dict with the filled in node params
nodegroup = self._UnlockedGetNodeGroup(
return self._config_data.cluster.FillND(node, nodegroup)
@locking.ssynchronized(_config_lock, shared=1)
def GenerateMAC(self, ec_id):
"""Generate a MAC for an instance.
......@@ -876,8 +888,7 @@ class ConfigWriter:
return nodegroup.uuid
raise errors.OpPrereqError("Nodegroup '%s' not found", target)
@locking.ssynchronized(_config_lock, shared=1)
def GetNodeGroup(self, uuid):
def _UnlockedGetNodeGroup(self, uuid):
"""Lookup a node group.
@type uuid: string
......@@ -891,6 +902,18 @@ class ConfigWriter:
return self._config_data.nodegroups[uuid]
@locking.ssynchronized(_config_lock, shared=1)
def GetNodeGroup(self, uuid):
"""Lookup a node group.
@type uuid: string
@param uuid: group UUID
@rtype: L{objects.NodeGroup} or None
@return: nodegroup object, or None if not found
return self._UnlockedGetNodeGroup(uuid)
@locking.ssynchronized(_config_lock, shared=1)
def GetAllNodeGroupsInfo(self):
"""Get the configuration of all node groups.
......@@ -79,6 +79,7 @@ class TestConfigRunner(unittest.TestCase):
nicparams={constants.PP_DEFAULT: constants.NICC_DEFAULTS},
......@@ -187,6 +188,22 @@ class TestConfigRunner(unittest.TestCase):
CheckSyntax, {mode: m_bridged, link: ''})
def testGetNdParamsDefault(self):
cfg = self._get_object()
node = cfg.GetNodeInfo(cfg.GetNodeList()[0])
self.assertEqual(cfg.GetNdParams(node), constants.NDC_DEFAULTS)
def testGetNdParamsModifiedNode(self):
my_ndparams = {
constants.ND_OOB_PROGRAM: "/bin/node-oob",
cfg = self._get_object()
node = cfg.GetNodeInfo(cfg.GetNodeList()[0])
node.ndparams = my_ndparams
cfg.Update(node, None)
self.assertEqual(cfg.GetNdParams(node), my_ndparams)
class TestTRM(unittest.TestCase):
EC_ID = 1
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