| 1 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 |
# not use this file except in compliance with the License. You may obtain |
| 3 |
# a copy of the License at |
| 4 |
# |
| 5 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 |
# |
| 7 |
# Unless required by applicable law or agreed to in writing, software |
| 8 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 |
# License for the specific language governing permissions and limitations |
| 11 |
# under the License. |
| 12 |
|
| 13 |
import abc |
| 14 |
|
| 15 |
from neutron_lib.agent import extension |
| 16 |
|
| 17 |
|
| 18 |
class L2AgentExtension(extension.AgentExtension, metaclass=abc.ABCMeta): |
| 19 |
"""Define stable abstract interface for l2 agent extensions. |
| 20 |
|
| 21 |
An agent extension extends the agent core functionality. |
| 22 |
""" |
| 23 |
|
| 24 |
def initialize(self, connection, driver_type): |
| 25 |
"""Initialize agent extension. |
| 26 |
|
| 27 |
:param connection: RPC connection that can be reused by the extension |
| 28 |
to define its RPC endpoints |
| 29 |
:param driver_type: String that defines the agent type to the |
| 30 |
extension. Can be used to choose the right backend |
| 31 |
implementation. |
| 32 |
""" |
| 33 |
|
| 34 |
@abc.abstractmethod |
| 35 |
def handle_port(self, context, data): |
| 36 |
"""Handle a port add/update event. |
| 37 |
|
| 38 |
This can be called on either create or update, depending on the |
| 39 |
code flow. Thus, it's this function's responsibility to check what |
| 40 |
actually changed. |
| 41 |
|
| 42 |
:param context: RPC context. |
| 43 |
:param data: Port data. |
| 44 |
""" |
| 45 |
|
| 46 |
@abc.abstractmethod |
| 47 |
def delete_port(self, context, data): |
| 48 |
"""Handle a port delete event. |
| 49 |
|
| 50 |
:param context: RPC context. |
| 51 |
:param data: Port data. |
| 52 |
""" |