Commit 4daa5eb9 authored by Sebastian Gebhard's avatar Sebastian Gebhard Committed by Klaus Aehlig
Browse files

Backend: Create openvswitches on the nodes



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.
Signed-off-by: default avatarSebastian Gebhard <sege@fs.ei.tum.de>
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 807d8853
......@@ -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.
......
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