Debian Codegraph @

networking_l2gw/services/l2gateway/common/tunnel_calls.py

raw symbols SCIP
1 # Copyright (c) 2016 OpenStack Foundation
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
12 # implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc
17 from neutron.plugins.ml2 import managers
18 from neutron.plugins.ml2 import rpc as rpc
19 from neutron_lib.agent import topics
20
21
22 class Tunnel_Calls:
23 """Common tunnel calls for L2 agent."""
24 def __init__(self):
25 self._construct_rpc_stuff()
26
27 def _construct_rpc_stuff(self):
28 self.notifier = rpc.AgentNotifierApi(topics.AGENT)
29 self.type_manager = managers.TypeManager()
30 self.tunnel_rpc_obj = rpc.RpcCallbacks(self.notifier,
31 self.type_manager)
32
33 def trigger_tunnel_sync(self, context, tunnel_ip):
34 """Sends tunnel sync RPC message to the neutron
35
36 L2 agent.
37 """
38 tunnel_dict = {'tunnel_ip': tunnel_ip,
39 'tunnel_type': 'vxlan'}
40 self.tunnel_rpc_obj.tunnel_sync(context,
41 **tunnel_dict)
42
43 def trigger_l2pop_sync(self, context, other_fdb_entries):
44 """Sends L2pop ADD RPC message to the neutron L2 agent."""
45 l2pop_rpc.L2populationAgentNotifyAPI().add_fdb_entries(
46 context, other_fdb_entries)
47
48 def trigger_l2pop_delete(self, context, other_fdb_entries, host=None):
49 """Sends L2pop DELETE RPC message to the neutron L2 agent."""
50 l2pop_rpc.L2populationAgentNotifyAPI().remove_fdb_entries(
51 context, other_fdb_entries, host)