Debian Codegraph @

neutron_taas/services/taas/agents/extensions/taas.py

raw
1 # Copyright 2017 FUJITSU LABORATORIES LTD.
2 # Copyright 2016 NEC Technologies India Pvt. Ltd.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain 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,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 import abc
17
18 from neutron_lib.agent import l2_extension
19
20 from neutron_taas.services.taas.agents.common import taas_agent
21
22 from oslo_config import cfg
23 from oslo_log import log as logging
24
25 LOG = logging.getLogger(__name__)
26
27 OPTS = [
28 cfg.IntOpt(
29 'taas_agent_periodic_interval',
30 default=5,
31 help=_('Seconds between periodic task runs')
32 )
33 ]
34 cfg.CONF.register_opts(OPTS)
35
36
37 class TaasAgentDriver(metaclass=abc.ABCMeta):
38 """Defines stable abstract interface for TaaS Agent Driver."""
39
40 @abc.abstractmethod
41 def initialize(self):
42 """Perform Taas agent driver initialization."""
43
44 def consume_api(self, agent_api):
45 """Consume the AgentAPI instance from the TaasAgentExtension class
46
47 :param agent_api: An instance of an agent specific API
48 """
49
50 @abc.abstractmethod
51 def create_tap_service(self, tap_service_msg):
52 """Create a Tap Service request in driver."""
53
54 @abc.abstractmethod
55 def create_tap_flow(self, tap_flow_msg):
56 """Create a tap flow request in driver."""
57
58 @abc.abstractmethod
59 def delete_tap_service(self, tap_service_msg):
60 """delete a Tap Service request in driver."""
61
62 @abc.abstractmethod
63 def delete_tap_flow(self, tap_flow_msg):
64 """Delete a tap flow request in driver."""
65
66
67 class TaasAgentExtension(l2_extension.L2AgentExtension):
68
69 def initialize(self, connection, driver_type):
70 """Initialize agent extension."""
71 self.taas_agent = taas_agent.TaasAgentRpcCallback(
72 cfg.CONF, driver_type)
73 self.taas_agent.consume_api(self.agent_api)
74 self.taas_agent.initialize()
75
76 def consume_api(self, agent_api):
77 """Receive neutron agent API object
78
79 Allows an extension to gain access to resources internal to the
80 neutron agent and otherwise unavailable to the extension.
81 """
82 self.agent_api = agent_api
83
84 def handle_port(self, context, data):
85 pass
86
87 def delete_port(self, context, data):
88 pass