1 # Copyright 2015-2018 Intel Corporation., Tieto
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 """VSwitch controller for Physical to Physical deployment
17 from core.vswitch_controller import IVswitchController
18 from conf import settings
20 class VswitchControllerP2P(IVswitchController):
21 """VSwitch controller for P2P deployment scenario.
24 _vswitch_class: The vSwitch class to be used.
25 _vswitch: The vSwitch object controlled by this controller
26 _deployment_scenario: A string describing the scenario to set-up in the
29 def __init__(self, deployment, vswitch_class, traffic):
30 """See IVswitchController for general description
32 super().__init__(deployment, vswitch_class, traffic)
33 self._bridge = settings.getValue('VSWITCH_BRIDGE_NAME')
36 """Sets up the switch for p2p.
38 self._logger.debug('Setup using %s', str(self._vswitch_class))
43 self._vswitch.add_switch(self._bridge)
45 (port1, _) = self._vswitch.add_phy_port(self._bridge)
46 (port2, _) = self._vswitch.add_phy_port(self._bridge)
48 self._vswitch.add_connection(self._bridge, port1, port2, self._traffic)
49 self._vswitch.add_connection(self._bridge, port2, port1, self._traffic)
56 """Tears down the switch created in setup().
58 self._logger.debug('Stop using %s', str(self._vswitch_class))
61 def get_ports_info(self):
62 """See IVswitchController for description
64 self._logger.debug('get_ports_info using %s', str(self._vswitch_class))
65 return self._vswitch.get_ports(self._bridge)
67 def dump_vswitch_connections(self):
68 """See IVswitchController for description
70 self._vswitch.dump_connections(self._bridge)