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 """Generic interface VSPERF uses for controlling a vSwitch
19 class IVSwitch(object):
20 """Interface class that is implemented by vSwitch-specific classes
22 Other methods are called only between start() and stop()
25 """Initialization of vswitch class
29 self._logger = logging.getLogger(__name__)
31 self._vswitch_args = []
34 def get_version(self):
35 """Return version of vSwitch and DPDK (if used by vSwitch)
36 This method should be implemented in case, that version
37 of vswitch or DPDK can be read only during vSwitch runtime.
38 Otherwise it can be implemented inside tools/systeminfo.py.
40 raise NotImplementedError()
45 If vSwitch is split to multiple processes, has kernel modules etc.,
46 this is expected to set them all up in correct sequence
48 raise NotImplementedError()
53 Restart of vSwitch is required for failover testcases.
55 raise NotImplementedError()
60 If vSwitch is split to multiple processes, has kernel modules etc.,
61 this is expected to terminate and clean all of them in correct sequence
63 raise NotImplementedError()
65 def add_switch(self, switch_name, params):
66 """Create a new logical switch with no ports
68 :param switch_name: The name of the new logical switch
69 :param params: Optional parameters to configure switch
73 raise NotImplementedError()
75 def del_switch(self, switch_name):
76 """Destroy the given logical switch
78 :param switch_name: The name of the logical switch to be destroyed
81 raise NotImplementedError()
83 def add_phy_port(self, switch_name):
84 """Create a new port to the logical switch that is attached to a
87 :param switch_name: The switch where the port is attached to
88 :returns: (port name, OpenFlow port number)
90 raise NotImplementedError()
92 def add_vport(self, switch_name):
93 """Create a new port to the logical switch for VM connections
95 :param switch_name: The switch where the port is attached to
96 :returns: (port name, OpenFlow port number)
98 raise NotImplementedError()
100 def add_tunnel_port(self, switch_name, remote_ip, tunnel_type, params=None):
101 """Create a new port to the logical switch for tunneling
103 :param switch_name: The switch where the port is attached to
104 :returns: (port name, OpenFlow port number)
106 raise NotImplementedError()
108 def get_ports(self, switch_name):
109 """Return a list of tuples describing the ports of the logical switch
111 :param switch_name: The switch whose ports to return
112 :returns: [(port name, OpenFlow port number), ...]
114 raise NotImplementedError()
116 def del_port(self, switch_name, port_name):
117 """Delete the port from the logical switch
119 The port can be either physical or virtual
121 :param switch_name: The switch on which to operate
122 :param port_name: The port to delete
124 raise NotImplementedError()
126 def add_connection(self, switch_name, port1, port2, traffic=None):
127 """Creates connection between given ports.
129 :param switch_name: switch on which to operate
130 :param port1: port to be used in connection
131 :param port2: port to be used in connection
133 :raises: RuntimeError
135 raise NotImplementedError()
137 def del_connection(self, switch_name, port1=None, port2=None):
138 """Remove connection between two interfaces.
140 :param switch_name: switch on which to operate
141 :param port1: port to be used in connection
142 :param port2: port to be used in connection
144 :raises: RuntimeError
146 raise NotImplementedError()
148 def dump_connections(self, switch_name):
149 """Dump connections between interfaces.
151 :param switch_name: switch on which to operate
153 :raises: RuntimeError
155 raise NotImplementedError()
157 def add_route(self, switch_name, network, destination):
158 """Add a route for tunneling routing table
160 :param switch_name: The switch on which to operate
161 :param network: Target destination network
162 :param destination: Gateway IP
164 raise NotImplementedError()
166 def set_tunnel_arp(self, ip_addr, mac_addr, switch_name):
167 """Add arp entry for tunneling
169 :param ip_addr: IP of bridge
170 :param mac_addr: MAC address of the bridge
171 :param switch_name: Name of the bridge
173 raise NotImplementedError()