Commit 095e71aa authored by René Nussbaumer's avatar René Nussbaumer
Browse files

Adding oob_program in the same style as beparams


Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 972a114f
......@@ -634,6 +634,15 @@ BES_PARAMETER_TYPES = {
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
# Node parameter names
ND_OOB_PROGRAM = "oob_program"
NDS_PARAMETER_TYPES = {
ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
}
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
# Instance Parameters Profile
PP_DEFAULT = "default"
......@@ -1010,6 +1019,10 @@ BEC_DEFAULTS = {
BE_AUTO_BALANCE: True,
}
NDC_DEFAULTS = {
ND_OOB_PROGRAM: None,
}
NICC_DEFAULTS = {
NIC_MODE: NIC_MODE_BRIDGED,
NIC_LINK: DEFAULT_BRIDGE,
......
......@@ -942,6 +942,7 @@ class Node(TaggableObject):
"group",
"master_capable",
"vm_capable",
"ndparams",
] + _TIMESTAMPS + _UUID
def UpgradeConfig(self):
......@@ -956,12 +957,16 @@ class Node(TaggableObject):
if self.vm_capable is None:
self.vm_capable = True
if self.ndparams is None:
self.ndparams = {}
class NodeGroup(ConfigObject):
"""Config object representing a node group."""
__slots__ = [
"name",
"members",
"ndparams",
] + _TIMESTAMPS + _UUID
def ToDict(self):
......@@ -986,6 +991,35 @@ class NodeGroup(ConfigObject):
obj.members = []
return obj
def UpgradeConfig(self):
"""Fill defaults for missing configuration values.
"""
if self.ndparams is None:
self.ndparams = {}
def FillND(self, node):
"""Return filled out ndparams for L{object.Node}
@type node: L{objects.Node}
@param node: A Node object to fill
@return a copy of the node's ndparams with defaults filled
"""
return self.SimpleFillND(node.ndparams)
def SimpleFillND(self, ndparams):
"""Fill a given ndparams dict with defaults.
@type ndparams: dict
@param ndparams: the dict to fill
@rtype: dict
@return: a copy of the passed in ndparams with missing keys filled
from the cluster defaults
"""
return FillDict(self.ndparams, ndparams)
class Cluster(TaggableObject):
"""Config object representing the cluster."""
......@@ -1011,6 +1045,7 @@ class Cluster(TaggableObject):
"beparams",
"osparams",
"nicparams",
"ndparams",
"candidate_pool_size",
"modify_etc_hosts",
"modify_ssh_setup",
......@@ -1043,6 +1078,9 @@ class Cluster(TaggableObject):
if self.osparams is None:
self.osparams = {}
if self.ndparams is None:
self.ndparams = constants.NDC_DEFAULTS
self.beparams = UpgradeGroupedParams(self.beparams,
constants.BEC_DEFAULTS)
migrate_default_bridge = not self.nicparams
......@@ -1236,6 +1274,30 @@ class Cluster(TaggableObject):
# specified params
return FillDict(result, os_params)
def FillND(self, node, nodegroup):
"""Return filled out ndparams for L{objects.NodeGroup} and L{object.Node}
@type node: L{objects.Node}
@param node: A Node object to fill
@type nodegroup: L{objects.NodeGroup}
@param nodegroup: A Node object to fill
@return a copy of the node's ndparams with defaults filled
"""
return self.SimpleFillND(nodegroup.FillND(node))
def SimpleFillND(self, ndparams):
"""Fill a given ndparams dict with defaults.
@type ndparams: dict
@param ndparams: the dict to fill
@rtype: dict
@return: a copy of the passed in ndparams with missing keys filled
from the cluster defaults
"""
return FillDict(self.ndparams, ndparams)
class BlockDevStatus(ConfigObject):
"""Config object representing the status of a block device."""
......
......@@ -76,7 +76,12 @@ class TestClusterObject(unittest.TestCase):
"ubuntu-hardy": {
},
}
self.fake_cl = objects.Cluster(hvparams=hvparams, os_hvp=os_hvp)
ndparams = {
constants.ND_OOB_PROGRAM: "/bin/cluster-oob"
}
self.fake_cl = objects.Cluster(hvparams=hvparams, os_hvp=os_hvp,
ndparams=ndparams)
self.fake_cl.UpgradeConfig()
def testGetHVDefaults(self):
......@@ -141,6 +146,54 @@ class TestClusterObject(unittest.TestCase):
self.assertEqual(self.fake_cl.os_hvp[os][constants.HT_XEN_PVM],
self.fake_cl.FillHV(fake_inst))
def testFillNdParamsCluster(self):
fake_node = objects.Node(name="test",
ndparams={},
group="testgroup")
fake_group = objects.NodeGroup(name="testgroup",
ndparams={})
self.assertEqual(self.fake_cl.ndparams,
self.fake_cl.FillND(fake_node, fake_group))
def testFillNdParamsNodeGroup(self):
fake_node = objects.Node(name="test",
ndparams={},
group="testgroup")
group_ndparams = {
constants.ND_OOB_PROGRAM: "/bin/group-oob"
}
fake_group = objects.NodeGroup(name="testgroup",
ndparams=group_ndparams)
self.assertEqual(group_ndparams,
self.fake_cl.FillND(fake_node, fake_group))
def testFillNdParamsNode(self):
node_ndparams = {
constants.ND_OOB_PROGRAM: "/bin/node-oob"
}
fake_node = objects.Node(name="test",
ndparams=node_ndparams,
group="testgroup")
fake_group = objects.NodeGroup(name="testgroup",
ndparams={})
self.assertEqual(node_ndparams,
self.fake_cl.FillND(fake_node, fake_group))
def testFillNdParamsAll(self):
node_ndparams = {
constants.ND_OOB_PROGRAM: "/bin/node-oob"
}
fake_node = objects.Node(name="test",
ndparams=node_ndparams,
group="testgroup")
group_ndparams = {
constants.ND_OOB_PROGRAM: "/bin/group-oob"
}
fake_group = objects.NodeGroup(name="testgroup",
ndparams=group_ndparams)
self.assertEqual(node_ndparams,
self.fake_cl.FillND(fake_node, fake_group))
class TestOS(unittest.TestCase):
ALL_DATA = [
......
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