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 If vSwitch is split to multiple processes, has kernel modules etc.,
43 this is expected to terminate and clean all of them in correct sequence
45 raise NotImplementedError()
47 def add_switch(self, switch_name, params):
48 """Create a new logical switch with no ports
50 :param switch_name: The name of the new logical switch
51 :param params: Optional parameters to configure switch
55 raise NotImplementedError()
57 def del_switch(self, switch_name):
58 """Destroy the given logical switch
60 :param switch_name: The name of the logical switch to be destroyed
63 raise NotImplementedError()
65 def add_phy_port(self, switch_name):
66 """Create a new port to the logical switch that is attached to a
69 :param switch_name: The switch where the port is attached to
70 :returns: (port name, OpenFlow port number)
72 raise NotImplementedError()
74 def add_vport(self, switch_name):
75 """Create a new port to the logical switch for VM connections
77 :param switch_name: The switch where the port is attached to
78 :returns: (port name, OpenFlow port number)
80 raise NotImplementedError()
82 def add_tunnel_port(self, switch_name, remote_ip, tunnel_type, params=None):
83 """Create a new port to the logical switch for tunneling
85 :param switch_name: The switch where the port is attached to
86 :returns: (port name, OpenFlow port number)
88 raise NotImplementedError()
90 def get_ports(self, switch_name):
91 """Return a list of tuples describing the ports of the logical switch
93 :param switch_name: The switch whose ports to return
94 :returns: [(port name, OpenFlow port number), ...]
96 raise NotImplementedError()
98 def del_port(self, switch_name, port_name):
99 """Delete the port from the logical switch
101 The port can be either physical or virtual
103 :param switch_name: The switch on which to operate
104 :param port_name: The port to delete
106 raise NotImplementedError()
108 def add_flow(self, switch_name, flow, cache='off'):
109 """Add a flow rule to the logical switch
111 :param switch_name: The switch on which to operate
112 :param flow: Flow description as a dictionary
113 :param cache: Optional. Specifies if flow should be inserted
114 to the switch or cached to increase performance during manipulation
115 with large number of flows.
117 'off' - cache is off and flow is inserted directly to the switch
118 'on' - cache is on and flow is inserted into the cache
119 'flush' - cache content will be inserted into the switch
121 Example flow dictionary:
125 'actions': ['output:3']
128 raise NotImplementedError()
130 def del_flow(self, switch_name, flow=None):
131 """Delete the flow rule from the logical switch
133 :param switch_name: The switch on which to operate
134 :param flow: Flow description as a dictionary
136 For flow dictionary description, see add_flow
137 For flow==None, all flows are deleted
139 raise NotImplementedError()
141 def add_connection(self, switch_name, port1, port2, bidir=False):
142 """Creates connection between given ports.
144 :param switch_name: switch on which to operate
145 :param port1: port to be used in connection
146 :param port2: port to be used in connection
147 :param bidir: switch between uni and bidirectional traffic
149 :raises: RuntimeError
151 raise NotImplementedError()
153 def del_connection(self, switch_name, port1, port2, bidir=False):
154 """Remove connection between two interfaces.
156 :param switch_name: switch on which to operate
157 :param port1: port to be used in connection
158 :param port2: port to be used in connection
159 :param bidir: switch between uni and bidirectional traffic
161 :raises: RuntimeError
163 raise NotImplementedError()
165 def dump_connections(self, switch_name):
166 """Dump connections between interfaces.
168 :param switch_name: switch on which to operate
170 :raises: RuntimeError
172 raise NotImplementedError()
174 def dump_flows(self, switch_name):
175 """Dump flows from the logical switch
177 :param switch_name: The switch on which to operate
179 raise NotImplementedError()
181 def add_route(self, switch_name, network, destination):
182 """Add a route for tunneling routing table
184 :param switch_name: The switch on which to operate
185 :param network: Target destination network
186 :param destination: Gateway IP
188 raise NotImplementedError()
190 def set_tunnel_arp(self, ip_addr, mac_addr, switch_name):
191 """Add arp entry for tunneling
193 :param ip_addr: IP of bridge
194 :param mac_addr: MAC address of the bridge
195 :param switch_name: Name of the bridge
197 raise NotImplementedError()