This is the functionality to create the OpenvSwitches on the nodes.
Parameters are given via opcode and checked as well as extended with
the defaults.
---
lib/backend.py | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/lib/backend.py b/lib/backend.py
index 466578c..fc3315a 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -28,12 +28,14 @@
"""
-# pylint: disable=E1103
+# pylint: disable=E1103,C0302
# E1103: %s %r has no %r member (but some types could not be
# inferred), because the _TryOSFromDisk returns either (True, os_obj)
# or (False, "string") which confuses pylint
+# C0302: This module has become too big and should be split up
+
import os
import os.path
@@ -4259,6 +4261,33 @@ def SetWatcherPause(until,
_filename=pathutils.WATCHER_PAUSEFILE):
utils.WriteFile(_filename, data="%d\n" % (until, ), mode=0644)
+def ConfigureOVS(ovs_name, ovs_link):
+ """Creates a OpenvSwitch on the node.
+
+ This function sets up a OpenvSwitch on the node with given name nad
+ connects it via a given eth device.
+
+ @type ovs_name: string
+ @param ovs_name: Name of the OpenvSwitch to create.
+ @type ovs_link: None or string
+ @param ovs_link: Ethernet device for outside connection (can be missing)
+
+ """
+ # Initialize the OpenvSwitch
+ result = utils.RunCmd(["ovs-vsctl", "add-br", ovs_name])
+ if result.failed:
+ _Fail("Failed to create openvswitch %s. Script return value: %s, output:"
+ " '%s'" % result.exit_code, result.output, log=True)
+
+ # And connect it to a physical interface, if given
+ if ovs_link:
+ result = utils.RunCmd(["ovs-vsctl", "add-port", ovs_name, ovs_link])
+ if result.failed:
+ _Fail("Failed to connect openvswitch to interface %s. Script return"
+ " value: %s, output: '%s'" % ovs_link, result.exit_code,
+ result.output, log=True)
+
+
class HooksRunner(object):
"""Hook runner.
--
1.8.1.2