d77ea84ebf2d14d481d31adae4f36ac37e4eda42
[openstack-build/neutron-build.git] / neutron / agent / l2 / agent_extension.py
1 # Copyright (c) 2015 Mellanox Technologies, Ltd
2 # All Rights Reserved.
3 #
4 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
5 #    not use this file except in compliance with the License. You may obtain
6 #    a copy of the License at
7 #
8 #         http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #    Unless required by applicable law or agreed to in writing, software
11 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 #    License for the specific language governing permissions and limitations
14 #    under the License.
15
16 import abc
17
18 import six
19
20
21 @six.add_metaclass(abc.ABCMeta)
22 class AgentCoreResourceExtension(object):
23     """Define stable abstract interface for agent extensions.
24
25     An agent extension extends the agent core functionality.
26     """
27
28     def initialize(self, connection, driver_type):
29         """Perform agent core resource extension initialization.
30
31         :param connection: RPC connection that can be reused by the extension
32                            to define its RPC endpoints
33         :param driver_type: a string that defines the agent type to the
34                             extension. Can be used to choose the right backend
35                             implementation.
36
37         Called after all extensions have been loaded.
38         No port handling will be called before this method.
39         """
40
41     @abc.abstractmethod
42     def handle_port(self, context, data):
43         """Handle agent extension for port.
44
45         This can be called on either create or update, depending on the
46         code flow. Thus, it's this function's responsibility to check what
47         actually changed.
48
49         :param context: rpc context
50         :param data: port data
51         """
52
53     @abc.abstractmethod
54     def delete_port(self, context, data):
55         """Delete port from agent extension.
56
57         :param context: rpc context
58         :param data: port data
59         """