diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/component_factory.py | 7 | ||||
-rw-r--r-- | core/vnf_controller.py | 2 | ||||
-rw-r--r-- | core/vswitch_controller_op2p.py | 74 |
3 files changed, 78 insertions, 5 deletions
diff --git a/core/component_factory.py b/core/component_factory.py index 1e5f2266..cb5af211 100644 --- a/core/component_factory.py +++ b/core/component_factory.py @@ -49,7 +49,8 @@ def create_traffic(traffic_type, trafficgen_class): return TrafficControllerRFC2544(trafficgen_class) -def create_vswitch(deployment_scenario, vswitch_class, traffic): +def create_vswitch(deployment_scenario, vswitch_class, traffic, + tunnel_operation=None): """Return a new IVSwitchController for the deployment_scenario. The returned controller is configured with the given vSwitch class. @@ -59,6 +60,7 @@ def create_vswitch(deployment_scenario, vswitch_class, traffic): :param deployment_scenario: The deployment scenario name :param vswitch_class: Reference to vSwitch class to be used. :param traffic: Dictionary with traffic specific details + :param tunnel_operation encapsulation/decapsulation or None :return: IVSwitchController for the deployment_scenario """ deployment_scenario = deployment_scenario.lower() @@ -69,7 +71,8 @@ def create_vswitch(deployment_scenario, vswitch_class, traffic): elif deployment_scenario.find("pvvp") >= 0: return VswitchControllerPVVP(vswitch_class, traffic) elif deployment_scenario.find("op2p") >= 0: - return VswitchControllerOP2P(vswitch_class, traffic) + return VswitchControllerOP2P(vswitch_class, traffic, tunnel_operation) + def create_vnf(deployment_scenario, vnf_class): """Return a new VnfController for the deployment_scenario. diff --git a/core/vnf_controller.py b/core/vnf_controller.py index e973bc51..39a63044 100644 --- a/core/vnf_controller.py +++ b/core/vnf_controller.py @@ -49,6 +49,8 @@ class VnfController(object): self._vnfs = [vnf_class(), vnf_class()] elif self._deployment_scenario == 'OP2P': self._vnfs = [] + else: + self._vnfs = [] self._logger.debug('__init__ ' + str(len(self._vnfs)) + ' VNF[s] with ' + ' '.join(map(str, self._vnfs))) diff --git a/core/vswitch_controller_op2p.py b/core/vswitch_controller_op2p.py index 69c88c35..ac817153 100644 --- a/core/vswitch_controller_op2p.py +++ b/core/vswitch_controller_op2p.py @@ -35,7 +35,7 @@ class VswitchControllerOP2P(IVswitchController): _deployment_scenario: A string describing the scenario to set-up in the constructor. """ - def __init__(self, vswitch_class, traffic): + 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. @@ -45,10 +45,20 @@ class VswitchControllerOP2P(IVswitchController): self._vswitch = vswitch_class() self._deployment_scenario = "OP2P" self._traffic = traffic.copy() + self._tunnel_operation = tunnel_operation self._logger.debug('Creation using ' + str(self._vswitch_class)) def setup(self): - """ Sets up the switch for overlay P2P + """ Sets up the switch for overlay P2P (tunnel encap or decap) + """ + self._logger.debug('Setting up ' + str(self._tunnel_operation)) + if self._tunnel_operation == "encapsulation": + self._setup_encap() + else: + self._setup_decap() + + def _setup_encap(self): + """ Sets up the switch for overlay P2P encapsulation test Create 2 bridges br0 (integration bridge) and br-ext and a VXLAN port for encapsulation. @@ -95,7 +105,7 @@ class VswitchControllerOP2P(IVswitchController): if settings.getValue('VSWITCH').endswith('Vanilla'): tasks.run_task(['sudo', 'arp', '-s', vtep_ip2, tg_port2_mac], self._logger, - 'Set ' + bridge_ext + 'status to up') + 'Set ' + bridge_ext + ' status to up') else: self._vswitch.set_tunnel_arp(vtep_ip2, tg_port2_mac, @@ -111,6 +121,64 @@ class VswitchControllerOP2P(IVswitchController): self._vswitch.stop() raise + def _setup_decap(self): + """ Sets up the switch for overlay P2P decapsulation test + """ + self._logger.debug('Setup using ' + str(self._vswitch_class)) + + try: + self._vswitch.start() + bridge = settings.getValue('TUNNEL_INTEGRATION_BRIDGE') + bridge_ext = settings.getValue('TUNNEL_EXTERNAL_BRIDGE') + bridge_ext_ip = settings.getValue('TUNNEL_EXTERNAL_BRIDGE_IP') + tgen_ip1 = settings.getValue('TRAFFICGEN_PORT1_IP') + self._vswitch.add_switch(bridge) + + tasks.run_task(['sudo', 'ifconfig', bridge, + settings.getValue('VTEP_IP1')], + self._logger, 'Assign ' + + settings.getValue('VTEP_IP1') + ' to ' + bridge, False) + + tunnel_type = self._traffic['tunnel_type'] + + self._vswitch.add_switch(bridge_ext) + self._vswitch.add_phy_port(bridge) + (_, phy2_number) = self._vswitch.add_phy_port(bridge_ext) + vxlan_vni = 'options:key=' + settings.getValue('VXLAN_VNI') + (_, phy3_number) = self._vswitch.add_tunnel_port(bridge_ext, + tgen_ip1, + tunnel_type, + params=[vxlan_vni]) + + tasks.run_task(['sudo', 'ip', 'addr', 'add', + bridge_ext_ip, + 'dev', bridge_ext], + self._logger, 'Assign ' + + bridge_ext_ip + + ' to ' + bridge_ext) + + tasks.run_task(['sudo', 'ip', 'link', 'set', 'dev', bridge_ext, + 'up'], + self._logger, + 'Set ' + bridge_ext + ' status to up') + + self._vswitch.set_tunnel_arp(tgen_ip1, + settings.getValue('TRAFFICGEN_PORT1_MAC'), + bridge) + self._vswitch.set_tunnel_arp(bridge_ext_ip.split('/')[0], + settings.getValue('DUT_NIC1_MAC'), + bridge_ext) + + # Test is unidirectional for now + self._vswitch.del_flow(bridge_ext) + flow1 = add_ports_to_flow(_FLOW_TEMPLATE, phy3_number, + phy2_number) + self._vswitch.add_flow(bridge_ext, flow1) + + except: + self._vswitch.stop() + raise + def stop(self): """Tears down the switch created in setup(). """ |