1 # Copyright 2015-2016 Intel Corporation.
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
18 class IVSwitch(object):
19 """Interface class that is implemented by vSwitch-specific classes
21 Other methods are called only between start() and stop()
23 def get_version(self):
24 """Return version of vSwitch and DPDK (if used by vSwitch)
25 This method should be implemented in case, that version
26 of vswitch or DPDK can be read only during vSwitch runtime.
27 Otherwise it can be implemented inside tools/systeminfo.py.
29 raise NotImplementedError()
34 If vSwitch is split to multiple processes, has kernel modules etc.,
35 this is expected to set them all up in correct sequence
37 raise NotImplementedError()
42 Restart of vSwitch is required for failover testcases.
44 raise NotImplementedError()
49 If vSwitch is split to multiple processes, has kernel modules etc.,
50 this is expected to terminate and clean all of them in correct sequence
52 raise NotImplementedError()
54 def add_switch(self, switch_name, params):
55 """Create a new logical switch with no ports
57 :param switch_name: The name of the new logical switch
58 :param params: Optional parameters to configure switch
62 raise NotImplementedError()
64 def del_switch(self, switch_name):
65 """Destroy the given logical switch
67 :param switch_name: The name of the logical switch to be destroyed
70 raise NotImplementedError()
72 def add_phy_port(self, switch_name):
73 """Create a new port to the logical switch that is attached to a
76 :param switch_name: The switch where the port is attached to
77 :returns: (port name, OpenFlow port number)
79 raise NotImplementedError()
81 def add_vport(self, switch_name):
82 """Create a new port to the logical switch for VM connections
84 :param switch_name: The switch where the port is attached to
85 :returns: (port name, OpenFlow port number)
87 raise NotImplementedError()
89 def add_tunnel_port(self, switch_name, remote_ip, tunnel_type, params=None):
90 """Create a new port to the logical switch for tunneling
92 :param switch_name: The switch where the port is attached to
93 :returns: (port name, OpenFlow port number)
95 raise NotImplementedError()
97 def get_ports(self, switch_name):
98 """Return a list of tuples describing the ports of the logical switch
100 :param switch_name: The switch whose ports to return
101 :returns: [(port name, OpenFlow port number), ...]
103 raise NotImplementedError()
105 def del_port(self, switch_name, port_name):
106 """Delete the port from the logical switch
108 The port can be either physical or virtual
110 :param switch_name: The switch on which to operate
111 :param port_name: The port to delete
113 raise NotImplementedError()
115 def add_flow(self, switch_name, flow, cache='off'):
116 """Add a flow rule to the logical switch
118 :param switch_name: The switch on which to operate
119 :param flow: Flow description as a dictionary
120 :param cache: Optional. Specifies if flow should be inserted
121 to the switch or cached to increase performance during manipulation
122 with large number of flows.
124 'off' - cache is off and flow is inserted directly to the switch
125 'on' - cache is on and flow is inserted into the cache
126 'flush' - cache content will be inserted into the switch
128 Example flow dictionary:
132 'actions': ['output:3']
135 raise NotImplementedError()
137 def del_flow(self, switch_name, flow=None):
138 """Delete the flow rule from the logical switch
140 :param switch_name: The switch on which to operate
141 :param flow: Flow description as a dictionary
143 For flow dictionary description, see add_flow
144 For flow==None, all flows are deleted
146 raise NotImplementedError()
148 def add_connection(self, switch_name, port1, port2, bidir=False):
149 """Creates connection between given ports.
151 :param switch_name: switch on which to operate
152 :param port1: port to be used in connection
153 :param port2: port to be used in connection
154 :param bidir: switch between uni and bidirectional traffic
156 :raises: RuntimeError
158 raise NotImplementedError()
160 def del_connection(self, switch_name, port1, port2, bidir=False):
161 """Remove connection between two interfaces.
163 :param switch_name: switch on which to operate
164 :param port1: port to be used in connection
165 :param port2: port to be used in connection
166 :param bidir: switch between uni and bidirectional traffic
168 :raises: RuntimeError
170 raise NotImplementedError()
172 def dump_connections(self, switch_name):
173 """Dump connections between interfaces.
175 :param switch_name: switch on which to operate
177 :raises: RuntimeError
179 raise NotImplementedError()
181 def dump_flows(self, switch_name):
182 """Dump flows from the logical switch
184 :param switch_name: The switch on which to operate
186 raise NotImplementedError()
188 def add_route(self, switch_name, network, destination):
189 """Add a route for tunneling routing table
191 :param switch_name: The switch on which to operate
192 :param network: Target destination network
193 :param destination: Gateway IP
195 raise NotImplementedError()
197 def set_tunnel_arp(self, ip_addr, mac_addr, switch_name):
198 """Add arp entry for tunneling
200 :param ip_addr: IP of bridge
201 :param mac_addr: MAC address of the bridge
202 :param switch_name: Name of the bridge
204 raise NotImplementedError()