diff options
Diffstat (limited to 'core/vswitch_controller_op2p.py')
-rw-r--r-- | core/vswitch_controller_op2p.py | 66 |
1 files changed, 19 insertions, 47 deletions
diff --git a/core/vswitch_controller_op2p.py b/core/vswitch_controller_op2p.py index 85bf79bd..072a690a 100644 --- a/core/vswitch_controller_op2p.py +++ b/core/vswitch_controller_op2p.py @@ -1,4 +1,4 @@ -# Copyright 2015-2017 Intel Corporation. +# Copyright 2015-2018 Intel Corporation., Tieto # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,44 +14,24 @@ """VSwitch controller for Physical to Tunnel Endpoint to Physical deployment """ - -import logging - from core.vswitch_controller import IVswitchController from vswitches.utils import add_ports_to_flow from conf import settings as S from tools import tasks -_FLOW_TEMPLATE = { - 'idle_timeout': '0' -} - class VswitchControllerOP2P(IVswitchController): """VSwitch controller for OP2P deployment scenario. - - Attributes: - _vswitch_class: The vSwitch class to be used. - _vswitch: The vSwitch object controlled by this controller - _deployment_scenario: A string describing the scenario to set-up in the - constructor. """ - def __init__(self, vswitch_class, traffic, tunnel_operation=None): - """Initializes up the prerequisites for the OP2P deployment scenario. - - :vswitch_class: the vSwitch class to be used. + def __init__(self, deployment, vswitch_class, traffic, tunnel_operation=None): + """See IVswitchController for general description """ - self._logger = logging.getLogger(__name__) - self._vswitch_class = vswitch_class - self._vswitch = vswitch_class() - self._deployment_scenario = "OP2P" - self._traffic = traffic.copy() + super().__init__(deployment, vswitch_class, traffic) self._tunnel_operation = tunnel_operation - self._logger.debug('Creation using ' + str(self._vswitch_class)) def setup(self): """ Sets up the switch for overlay P2P (tunnel encap or decap) """ - self._logger.debug('Setting up ' + str(self._tunnel_operation)) + self._logger.debug('Setting up %s', str(self._tunnel_operation)) if self._tunnel_operation == "encapsulation": self._setup_encap() else: @@ -66,7 +46,7 @@ class VswitchControllerOP2P(IVswitchController): Create 2 bridges br0 (integration bridge) and br-ext and a VXLAN port for encapsulation. """ - self._logger.debug('Setup using ' + str(self._vswitch_class)) + self._logger.debug('Setup using %s', str(self._vswitch_class)) try: self._vswitch.start() @@ -118,10 +98,13 @@ class VswitchControllerOP2P(IVswitchController): # Test is unidirectional for now self._vswitch.del_flow(bridge) - flow1 = add_ports_to_flow(_FLOW_TEMPLATE, phy1_number, + flow1 = add_ports_to_flow(S.getValue('OVS_FLOW_TEMPLATE'), phy1_number, phy2_number) self._vswitch.add_flow(bridge, flow1) - + # enable MAC learning mode at external bridge + flow_ext = S.getValue('OVS_FLOW_TEMPLATE').copy() + flow_ext.update({'actions': ['NORMAL']}) + self._vswitch.add_flow(bridge_ext, flow_ext) except: self._vswitch.stop() raise @@ -129,7 +112,7 @@ class VswitchControllerOP2P(IVswitchController): def _setup_decap(self): """ Sets up the switch for overlay P2P decapsulation test """ - self._logger.debug('Setup using ' + str(self._vswitch_class)) + self._logger.debug('Setup using %s', str(self._vswitch_class)) try: self._vswitch.start() @@ -178,7 +161,7 @@ class VswitchControllerOP2P(IVswitchController): bridge) # Test is unidirectional for now self._vswitch.del_flow(bridge_ext) - flow1 = add_ports_to_flow(_FLOW_TEMPLATE, phy3_number, + flow1 = add_ports_to_flow(S.getValue('OVS_FLOW_TEMPLATE'), phy3_number, phy2_number) self._vswitch.add_flow(bridge_ext, flow1) @@ -189,7 +172,7 @@ class VswitchControllerOP2P(IVswitchController): def _setup_decap_vanilla(self): """ Sets up the switch for overlay P2P decapsulation test """ - self._logger.debug('Setup decap vanilla ' + str(self._vswitch_class)) + self._logger.debug('Setup decap vanilla %s', str(self._vswitch_class)) try: self._vswitch.start() @@ -251,7 +234,7 @@ class VswitchControllerOP2P(IVswitchController): # Test is unidirectional for now self._vswitch.del_flow(bridge_ext) - flow1 = add_ports_to_flow(_FLOW_TEMPLATE, phy2_number, 'LOCAL') + flow1 = add_ports_to_flow(S.getValue('OVS_FLOW_TEMPLATE'), phy2_number, 'LOCAL') self._vswitch.add_flow(bridge_ext, flow1) except: @@ -261,20 +244,9 @@ class VswitchControllerOP2P(IVswitchController): def stop(self): """Tears down the switch created in setup(). """ - self._logger.debug('Stop using ' + str(self._vswitch_class)) + self._logger.debug('Stop using %s', str(self._vswitch_class)) self._vswitch.stop() - def __enter__(self): - self.setup() - - def __exit__(self, type_, value, traceback): - self.stop() - - def get_vswitch(self): - """See IVswitchController for description - """ - return self._vswitch - def get_ports_info(self): """See IVswitchController for description """ @@ -286,8 +258,8 @@ class VswitchControllerOP2P(IVswitchController): self._vswitch.get_ports( S.getValue('TUNNEL_EXTERNAL_BRIDGE')) - def dump_vswitch_flows(self): + def dump_vswitch_connections(self): """See IVswitchController for description """ - self._vswitch.dump_flows(S.getValue('TUNNEL_INTEGRATION_BRIDGE')) - self._vswitch.dump_flows(S.getValue('TUNNEL_EXTERNAL_BRIDGE')) + self._vswitch.dump_connections(S.getValue('TUNNEL_INTEGRATION_BRIDGE')) + self._vswitch.dump_connections(S.getValue('TUNNEL_EXTERNAL_BRIDGE')) |