vnfs: Enable PVP using vhost-user
[vswitchperf.git] / vswitches / vswitch.py
1 # Copyright 2015 Intel Corporation.
2 #
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
6 #
7 #   http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 """Generic interface VSPERF uses for controlling a vSwitch
16 """
17
18 class IVSwitch(object):
19     """Interface class that is implemented by vSwitch-specific classes
20
21     Other methods are called only between start() and stop()
22     """
23     def start(self):
24         """Start the vSwitch
25
26         If vSwitch is split to multiple processes, has kernel modules etc.,
27         this is expected to set them all up in correct sequence
28         """
29         raise NotImplementedError()
30
31     def stop(self):
32         """Stop the vSwitch
33
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
36         """
37         raise NotImplementedError()
38
39     def add_switch(self, switch_name):
40         """Create a new logical switch with no ports
41
42         :param switch_name: The name of the new logical switch
43         :returns: None
44         """
45         raise NotImplementedError()
46
47     def del_switch(self, switch_name):
48         """Destroy the given logical switch
49
50         :param switch_name: The name of the logical switch to be destroyed
51         :returns: None
52         """
53         raise NotImplementedError()
54
55     def add_phy_port(self, switch_name):
56         """Create a new port to the logical switch that is attached to a
57         physical port
58
59         :param switch_name: The switch where the port is attached to
60         :returns: (port name, OpenFlow port number)
61         """
62         raise NotImplementedError()
63
64     def add_vport(self, switch_name):
65         """Create a new port to the logical switch for VM connections
66
67         :param switch_name: The switch where the port is attached to
68         :returns: (port name, OpenFlow port number)
69         """
70         raise NotImplementedError()
71
72     def get_ports(self, switch_name):
73         """Return a list of tuples describing the ports of the logical switch
74
75         :param switch_name: The switch whose ports to return
76         :returns: [(port name, OpenFlow port number), ...]
77         """
78         raise NotImplementedError()
79
80     def del_port(self, switch_name, port_name):
81         """Delete the port from the logical switch
82
83         The port can be either physical or virtual
84
85         :param switch_name: The switch on which to operate
86         :param port_name: The port to delete
87         """
88         raise NotImplementedError()
89
90     def add_flow(self, switch_name, flow):
91         """Add a flow rule to the logical switch
92
93         :param switch_name: The switch on which to operate
94         :param flow: Flow description as a dictionary
95
96         Example flow dictionary:
97             flow = {
98                 'in_port': '1',
99                 'idle_timeout': '0',
100                 'actions': ['output:3']
101             }
102         """
103         raise NotImplementedError()
104
105     def del_flow(self, switch_name, flow=None):
106         """Delete the flow rule from the logical switch
107
108         :param switch_name: The switch on which to operate
109         :param flow: Flow description as a dictionary
110
111         For flow dictionary description, see add_flow
112         For flow==None, all flows are deleted
113         """
114         raise NotImplementedError()