Skip to content
Snippets Groups Projects
Commit 5768e6a6 authored by René Nussbaumer's avatar René Nussbaumer
Browse files

Adding convenience getter for ndparams


Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 04a8865b
No related branches found
No related tags found
No related merge requests found
......@@ -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(node.group)
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):
volume_group_name="xenvg",
drbd_usermode_helper="/bin/true",
nicparams={constants.PP_DEFAULT: constants.NICC_DEFAULTS},
ndparams=constants.NDC_DEFAULTS,
tcpudp_port_pool=set(),
enabled_hypervisors=[constants.HT_FAKE],
master_node=me.name,
......@@ -187,6 +188,22 @@ class TestConfigRunner(unittest.TestCase):
self.assertRaises(errors.ConfigurationError,
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment