1 # Copyright 2015 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()
26 If vSwitch is split to multiple processes, has kernel modules etc.,
27 this is expected to set them all up in correct sequence
29 raise NotImplementedError()
34 If vSwitch is split to multiple processes, has kernel modules etc.,
35 this is expected to terminate and clean all of them in correct sequence
37 raise NotImplementedError()
39 def add_switch(self, switch_name, params):
40 """Create a new logical switch with no ports
42 :param switch_name: The name of the new logical switch
43 :param params: Optional parameters to configure switch
47 raise NotImplementedError()
49 def del_switch(self, switch_name):
50 """Destroy the given logical switch
52 :param switch_name: The name of the logical switch to be destroyed
55 raise NotImplementedError()
57 def add_phy_port(self, switch_name):
58 """Create a new port to the logical switch that is attached to a
61 :param switch_name: The switch where the port is attached to
62 :returns: (port name, OpenFlow port number)
64 raise NotImplementedError()
66 def add_vport(self, switch_name):
67 """Create a new port to the logical switch for VM connections
69 :param switch_name: The switch where the port is attached to
70 :returns: (port name, OpenFlow port number)
72 raise NotImplementedError()
74 def get_ports(self, switch_name):
75 """Return a list of tuples describing the ports of the logical switch
77 :param switch_name: The switch whose ports to return
78 :returns: [(port name, OpenFlow port number), ...]
80 raise NotImplementedError()
82 def del_port(self, switch_name, port_name):
83 """Delete the port from the logical switch
85 The port can be either physical or virtual
87 :param switch_name: The switch on which to operate
88 :param port_name: The port to delete
90 raise NotImplementedError()
92 def add_flow(self, switch_name, flow):
93 """Add a flow rule to the logical switch
95 :param switch_name: The switch on which to operate
96 :param flow: Flow description as a dictionary
98 Example flow dictionary:
102 'actions': ['output:3']
105 raise NotImplementedError()
107 def del_flow(self, switch_name, flow=None):
108 """Delete the flow rule from the logical switch
110 :param switch_name: The switch on which to operate
111 :param flow: Flow description as a dictionary
113 For flow dictionary description, see add_flow
114 For flow==None, all flows are deleted
116 raise NotImplementedError()
118 def dump_flows(self, switch_name):
119 """Dump flows from the logical switch
121 :param switch_name: The switch on which to operate
123 raise NotImplementedError()