This patch introduces the needed fields for OpenvSwitch parameters
into ndparams and also provides the default values.
The parameters are:
ND_OVS: boolean, to show whether OpenvSwitch is enabled or not
ND_OVS_NAME: the name of the OpenvSwitch to create
ND_OVS_LINK: the physical link to the OpenvSwitch
While ND_OVS and ND_OVS_NAME are mandatory and default to FALSE and
constants.DEFAULT_OVS respectively, ND_OVS_LINK is optional and can
be left empty.
Adding a new node with OpenvSwitch and no physical interface might
or might not be what the user wants, so this case will result in a
warning to inform the user (see later patch in this series).
This patch also fixes unittests which are using these parameters.
---
lib/constants.py | 11 +++++++++++
test/py/ganeti.config_unittest.py | 9 +++++++++
test/py/ganeti.objects_unittest.py | 9 +++++++++
3 files changed, 29 insertions(+)
diff --git a/lib/constants.py b/lib/constants.py
index 84b5fac..7b1308e 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -1200,11 +1200,17 @@ IPOLICY_ALL_KEYS = (IPOLICY_PARAMETERS |
ND_OOB_PROGRAM = "oob_program"
ND_SPINDLE_COUNT = "spindle_count"
ND_EXCLUSIVE_STORAGE = "exclusive_storage"
+ND_OVS = "ovs"
+ND_OVS_NAME = "ovs_name"
+ND_OVS_LINK = "ovs_link"
NDS_PARAMETER_TYPES = {
ND_OOB_PROGRAM: VTYPE_STRING,
ND_SPINDLE_COUNT: VTYPE_INT,
ND_EXCLUSIVE_STORAGE: VTYPE_BOOL,
+ ND_OVS: VTYPE_BOOL,
+ ND_OVS_NAME: VTYPE_MAYBE_STRING,
+ ND_OVS_LINK: VTYPE_MAYBE_STRING,
}
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
@@ -1213,6 +1219,8 @@ NDS_PARAMETER_TITLES = {
ND_OOB_PROGRAM: "OutOfBandProgram",
ND_SPINDLE_COUNT: "SpindleCount",
ND_EXCLUSIVE_STORAGE: "ExclusiveStorage",
+ ND_OVS_NAME: "OpenvSwitchName",
+ ND_OVS_LINK: "OpenvSwitchLink",
}
# Logical Disks parameters
@@ -2206,6 +2214,9 @@ NDC_DEFAULTS = {
ND_OOB_PROGRAM: "",
ND_SPINDLE_COUNT: 1,
ND_EXCLUSIVE_STORAGE: False,
+ ND_OVS: False,
+ ND_OVS_NAME: DEFAULT_OVS,
+ ND_OVS_LINK: ""
}
NDC_GLOBALS = compat.UniqueFrozenset([
diff --git a/test/py/ganeti.config_unittest.py
b/test/py/ganeti.config_unittest.py
index 381db00..c45d768 100755
--- a/test/py/ganeti.config_unittest.py
+++ b/test/py/ganeti.config_unittest.py
@@ -242,6 +242,9 @@ class TestConfigRunner(unittest.TestCase):
constants.ND_OOB_PROGRAM: "/bin/node-oob",
constants.ND_SPINDLE_COUNT: 1,
constants.ND_EXCLUSIVE_STORAGE: False,
+ constants.ND_OVS: True,
+ constants.ND_OVS_NAME: "openvswitch",
+ constants.ND_OVS_LINK: "eth1"
}
cfg = self._get_object()
@@ -253,15 +256,21 @@ class TestConfigRunner(unittest.TestCase):
def testGetNdParamsInheritance(self):
node_ndparams = {
constants.ND_OOB_PROGRAM: "/bin/node-oob",
+ constants.ND_OVS_LINK: "eth3"
}
group_ndparams = {
constants.ND_SPINDLE_COUNT: 10,
+ constants.ND_OVS: True,
+ constants.ND_OVS_NAME: "openvswitch",
}
expected_ndparams = {
constants.ND_OOB_PROGRAM: "/bin/node-oob",
constants.ND_SPINDLE_COUNT: 10,
constants.ND_EXCLUSIVE_STORAGE:
constants.NDC_DEFAULTS[constants.ND_EXCLUSIVE_STORAGE],
+ constants.ND_OVS: True,
+ constants.ND_OVS_NAME: "openvswitch",
+ constants.ND_OVS_LINK: "eth3"
}
cfg = self._get_object()
node = cfg.GetNodeInfo(cfg.GetNodeList()[0])
diff --git a/test/py/ganeti.objects_unittest.py
b/test/py/ganeti.objects_unittest.py
index 5ba7901..79a9024 100755
--- a/test/py/ganeti.objects_unittest.py
+++ b/test/py/ganeti.objects_unittest.py
@@ -167,6 +167,9 @@ class TestClusterObject(unittest.TestCase):
constants.ND_OOB_PROGRAM: "/bin/group-oob",
constants.ND_SPINDLE_COUNT: 10,
constants.ND_EXCLUSIVE_STORAGE: True,
+ constants.ND_OVS: True,
+ constants.ND_OVS_LINK: "eth2",
+ constants.ND_OVS_NAME: "openvswitch",
}
fake_group = objects.NodeGroup(name="testgroup",
ndparams=group_ndparams)
@@ -178,6 +181,9 @@ class TestClusterObject(unittest.TestCase):
constants.ND_OOB_PROGRAM: "/bin/node-oob",
constants.ND_SPINDLE_COUNT: 2,
constants.ND_EXCLUSIVE_STORAGE: True,
+ constants.ND_OVS: True,
+ constants.ND_OVS_LINK: "eth2",
+ constants.ND_OVS_NAME: "openvswitch",
}
fake_node = objects.Node(name="test",
ndparams=node_ndparams,
@@ -192,6 +198,9 @@ class TestClusterObject(unittest.TestCase):
constants.ND_OOB_PROGRAM: "/bin/node-oob",
constants.ND_SPINDLE_COUNT: 5,
constants.ND_EXCLUSIVE_STORAGE: True,
+ constants.ND_OVS: True,
+ constants.ND_OVS_LINK: "eth2",
+ constants.ND_OVS_NAME: "openvswitch",
}
fake_node = objects.Node(name="test",
ndparams=node_ndparams,
--
1.8.1.2