Browse Source

Use custom RouterInfo for L3 agent

Override RouterInfo.initialize
  Disable namespace creation
Override RouterInfo.process
Override RouterInfo.delete
  Disable namespace deletion
Use reference implementation of _router_added
and _router_deleted methods

Change-Id: I8f179b63cb78b0e14e3634628fb317874e1ead9a
Harkirat Singh 4 years ago
parent
commit
4f78be5dce

+ 4
- 0
networking_brocade/vyatta/common/exceptions.py View File

@@ -78,3 +78,7 @@ class ResourceNotFound(exceptions.NotFound):
78 78
 
79 79
 class TableCellNotFound(exceptions.NotFound):
80 80
     message = _('There is no cell in vRouter status table.')
81
+
82
+
83
+class DvrOrHaRouterNotSupported(exceptions.NeutronException):
84
+    message = _('DVR or HA routers are not supported.')

+ 30
- 18
networking_brocade/vyatta/common/l3_agent.py View File

@@ -29,6 +29,24 @@ _KEY_VYATTA_EXTRA_DATA = '_vyatta'
29 29
 _KEY_MANAGEMENT_IP_ADDRESS = 'management_ip_address'
30 30
 
31 31
 
32
+class RouterInfo(router_info.RouterInfo):
33
+
34
+    def add_floating_ip(self, fip, interface_name, device):
35
+        pass
36
+
37
+    def initialize(self, process_monitor):
38
+        pass
39
+
40
+    def process(self, agent):
41
+        pass
42
+
43
+    def delete(self, agent):
44
+        self.router['gw_port'] = None
45
+        self.router[l3_constants.INTERFACE_KEY] = []
46
+        self.router[l3_constants.FLOATINGIP_KEY] = []
47
+        self.process(agent)
48
+
49
+
32 50
 class L3AgentMiddleware(l3_agent.L3NATAgentWithStateReport):
33 51
     def __init__(self, host, conf=None):
34 52
         super(L3AgentMiddleware, self).__init__(host, conf)
@@ -61,24 +79,18 @@ class L3AgentMiddleware(l3_agent.L3NATAgentWithStateReport):
61 79
                              'management ip address').format(router_id))
62 80
         return self._vyatta_clients_pool.get_by_address(router_id, address)
63 81
 
64
-    def _router_added(self, router_id, router):
65
-        ri = router_info.RouterInfo(
66
-            router_id, router, self.conf, self.driver)
67
-        self.router_info[router_id] = ri
68
-        self.process_router_add(ri)
69
-
70
-    def _router_removed(self, router_id):
71
-        ri = self.router_info[router_id]
72
-        if ri:
73
-            ri.router['gw_port'] = None
74
-            ri.router[l3_constants.INTERFACE_KEY] = []
75
-            ri.router[l3_constants.FLOATINGIP_KEY] = []
76
-            self.process_router(ri)
77
-
78
-        del self.router_info[router_id]
79
-
80
-    def process_router(self, ri):
81
-        pass
82
+    def _create_router(self, router_id, router):
83
+        if router.get('distributed') or router.get('ha'):
84
+            raise v_exc.DvrOrHaRouterNotSupported(router_id=router_id)
85
+
86
+        kwargs = {
87
+            'router_id': router_id,
88
+            'router': router,
89
+            'use_ipv6': self.use_ipv6,
90
+            'agent_conf': self.conf,
91
+            'interface_driver': self.driver,
92
+        }
93
+        return RouterInfo(**kwargs)
82 94
 
83 95
     def _get_router_info_list_for_tenant(self, router_ids, tenant_id):
84 96
         """Returns the list of router info objects on which to apply the fw."""

Loading…
Cancel
Save