diff options
author | Martin Klozik <martin.klozik@tieto.com> | 2018-06-18 18:40:11 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-06-18 18:40:11 +0000 |
commit | 7e3db8dbc23d91484cc608bd8cb1d42ea7729396 (patch) | |
tree | 60d5fff01020b365779079ce1b9c60defdf69bcf /core/vswitch_controller_op2p.py | |
parent | 89018d21b6383f853a01c57a2270153d266fe087 (diff) | |
parent | 63b56ed1d74657129006f066a3f118c4c369d23c (diff) |
Merge "connections: Introduction of generic API"
Diffstat (limited to 'core/vswitch_controller_op2p.py')
-rw-r--r-- | core/vswitch_controller_op2p.py | 56 |
1 files changed, 14 insertions, 42 deletions
diff --git a/core/vswitch_controller_op2p.py b/core/vswitch_controller_op2p.py index 3f879f9f..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,39 +14,19 @@ """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 %s', str(self._vswitch_class)) def setup(self): """ Sets up the switch for overlay P2P (tunnel encap or decap) @@ -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 @@ -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) @@ -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: @@ -264,17 +247,6 @@ class VswitchControllerOP2P(IVswitchController): 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')) |