File: api.py

package info (click to toggle)
python-ovsdbapp 2.13.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,040 kB
  • sloc: python: 9,222; sh: 138; makefile: 21
file content (222 lines) | stat: -rw-r--r-- 7,885 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import abc

from ovsdbapp import api


class API(api.API, metaclass=abc.ABCMeta):
    """An API based off of the vtep-ctl CLI interface

    This API basically mirrors the vtep-ctl operations with these changes:
    1. Methods that create objects will return a read-only view of the object
    2. Methods which list objects will return a list of read-only view objects
    """

    @abc.abstractmethod
    def add_ps(self, pswitch, may_exist=False, **columns):
        """Create a physical switch named 'pswitch'

        :param pswitch:   The name of the switch
        :type pswitch:    string or uuid.UUID
        :param may_exist: If True, don't fail if the switch already exists
        :type may_exist:  boolean
        :param columns:   Additional columns to directly set on the switch
        :returns:         :class:`Command` with RowView result
        """

    @abc.abstractmethod
    def del_ps(self, pswitch, if_exists=False):
        """Delete physical switch 'pswitch' and all its ports

        :param pswitch:  The name or uuid of the switch
        :type pswitch:   string or uuid.UUID
        :type if_exists: If True, don't fail if the switch doesn't exist
        :type if_exists: boolean
        :returns:        :class:`Command` with no result
        """

    @abc.abstractmethod
    def list_ps(self):
        """Get all physical switches

        :returns: :class:`Command` with RowView list result
        """

    @abc.abstractmethod
    def get_ps(self, pswitch):
        """Get physical switch for 'pswitch'

        :param pswitch: The name of the pswitch
        :type pswitch:  string or uuid.UUID
        :returns:       :class:`Command` with RowView result
        """

    @abc.abstractmethod
    def add_port(self, pswitch, port, may_exist=False):
        """Add a port named 'port' to physical switch named 'pswitch'

        :param pswitch:   The name of the switch
        :type pswitch:    string or uuid.UUID
        :param port:      The name of the port
        :type port:       string or uuid.UUID
        :param may_exist: If True, don't fail if the port already exists in
                          physical switch
        :type may_exist:  boolean
        :returns:         :class:`Command` with RowView result
        """

    @abc.abstractmethod
    def del_port(self, pswitch, port, if_exists=False):
        """Delete a port named 'port' from physical switch named 'pswitch'

        :param pswitch:  The name or uuid of the switch
        :type pswitch:   string or uuid.UUID
        :param port:     The name of the port
        :type port:      string or uuid.UUID
        :type if_exists: If True, don't fail if the switch doesn't exist in
                         physical switch
        :type if_exists: boolean
        :returns:        :class:`Command` with no result
        """

    @abc.abstractmethod
    def list_ports(self, pswitch):
        """Get all ports of physical switch 'pswitch'

        :param pswitch: The name of the pswitch
        :type pswitch:  string or uuid.UUID
        :returns:       :class:`Command` with RowView list result
        """

    @abc.abstractmethod
    def get_port(self, port):
        """Get physical port for 'port'

        :param port: The name of the port
        :type port:  string or uuid.UUID
        :returns:    :class:`Command` with RowView result
        """

    @abc.abstractmethod
    def add_ls(self, switch, may_exist=False, **columns):
        """Create a logical switch named 'switch'

        :param switch:    The name of the switch
        :type switch:     string or uuid.UUID
        :param may_exist: If True, don't fail if the switch already exists
        :type may_exist:  boolean
        :param columns:   Additional columns to directly set on the switch
        :returns:         :class:`Command` with RowView result
        """

    @abc.abstractmethod
    def del_ls(self, switch, if_exists=False):
        """Delete logical switch 'switch' and all its ports

        :param switch:   The name or uuid of the switch
        :type switch:    string or uuid.UUID
        :type if_exists: If True, don't fail if the switch doesn't exist
        :type if_exists: boolean
        :returns:        :class:`Command` with no result
        """

    @abc.abstractmethod
    def list_ls(self):
        """Get all logical switches

        :returns: :class:`Command` with RowView list result
        """

    @abc.abstractmethod
    def get_ls(self, switch):
        """Get logical switch for 'switch'

        :returns: :class:`Command` with RowView result
        """

    @abc.abstractmethod
    def bind_ls(self, pswitch, port, vlan, switch):
        """Bind 'switch' to 'pswitch'

        Bind logical switch to the port/vlan combination on the
        physical switch 'pswitch'.

        :param pswitch: The name or uuid of the physical switch
        :type pswitch:  string or uuid.UUID
        :param port:    name of port
        :type port:     string
        :param vlan:    number of VLAN
        :type vlan:     int
        :param switch:  The name or uuid of the switch
        :type switch:   string or uuid.UUID
        :returns:       :class:`Command` with no result
        """

    @abc.abstractmethod
    def unbind_ls(self, pswitch, port, vlan):
        """Unbind 'switch' from 'pswitch'

        Remove the logical switch binding from the port/vlan combination on
        the  physical switch pswitch.

        :param pswitch:  The name or uuid of the physical switch
        :type pswitch:   string or uuid.UUID
        :param port:     name of port
        :type port:      string
        :param vlan:     number of VLAN
        :type vlan:      int
        :param switch:   The name or uuid of the switch
        :type switch:    string or uuid.UUID
        :returns:        :class:`Command` with no result
        """

    @abc.abstractmethod
    def list_local_macs(self, switch):
        """Get all local MACs for 'switch'

        :param switch: The name of the switch
        :type switch:  string or uuid.UUID
        :returns:      :class:`Command` with list of RowView lists result.
                       First list contains 'Ucast_Macs_Local' table records,
                       second list contains 'Mcast_Macs_Local' table records.
        """

    @abc.abstractmethod
    def list_remote_macs(self, switch):
        """Get all remote MACs for 'switch'

        :param switch: The name of the switch
        :type switch:  string or uuid.UUID
        :returns:      :class:`Command` with list of RowView lists result.
                       First list contains 'Ucast_Macs_Remote' table records,
                       second list contains 'Mcast_Macs_Remote' table records.
        """

    @abc.abstractmethod
    def clear_local_macs(self, switch):
        """Clear the local MAC bindings for 'switch'

        :param switch: The name of the switch
        :type switch:  string or uuid.UUID
        :returns:      :class:`Command` with RowView result
        """

    @abc.abstractmethod
    def clear_remote_macs(self, switch):
        """Clear the remote MAC bindings for 'switch'

        :param switch: The name of the switch
        :type switch:  string or uuid.UUID
        :returns:      :class:`Command` with RowView result
        """