Browse Source

Add multiple IPv6 prefixes support

enable unit test for vrouter
skips unit tests due to support status
updates gateway configuration on gw ip change
removes unused parameter from driver clear_gateway
adds helper functions to router API client

Change-Id: I5df3b24beb03e0d5af7dda4ad61b687482308508
Harkirat Singh 3 years ago
parent
commit
f601c00510

+ 2
- 1
networking_brocade/test_discover/test_discover.py View File

@@ -30,7 +30,8 @@ def load_tests(loader, tests, pattern):
30 30
     test_dirs = {'./networking_brocade/tests',
31 31
                  './networking_brocade/vdx/tests/unit/ml2/drivers/brocade',
32 32
                  MLX_TEST_BASE_PATH + '/unit/ml2/drivers/brocade',
33
-                 MLX_TEST_BASE_PATH + '/unit/services/l3_router/brocade'
33
+                 MLX_TEST_BASE_PATH + '/unit/services/l3_router/brocade',
34
+                 './networking_brocade/vyatta/tests'
34 35
                  }
35 36
     for test_dir in test_dirs:
36 37
         if not pattern:

+ 1
- 1
networking_brocade/vyatta/tests/test_vrouter_driver.py View File

@@ -152,7 +152,7 @@ class TestVRouterDriver(n_base.BaseTestCase):
152 152
         ctx = context.Context('', 'tenant_id1')
153 153
         router_id = _uuid()
154 154
 
155
-        self.driver.clear_gateway(ctx, router_id, None)
155
+        self.driver.clear_gateway(ctx, router_id)
156 156
 
157 157
         self._router_api.update_router.assert_called_once_with(
158 158
             external_gateway_info=None)

+ 6
- 0
networking_brocade/vyatta/tests/test_vrouter_neutron_plugin.py View File

@@ -372,3 +372,9 @@ class VRouterTestCase(test_db_plugin.NeutronDbPluginV2TestCase,
372 372
 
373 373
     def test_router_add_gateway_no_subnet(self):
374 374
         self.skipTest("Skip because it is not supported.")
375
+
376
+    def test_router_specify_id_backend(self):
377
+        self.skipTest("Router id is autogenerated")
378
+
379
+    def test_router_update_gateway_upon_subnet_create_max_ips_ipv6(self):
380
+        self.skipTest("Router external gateway supports only one IP address")

+ 47
- 14
networking_brocade/vyatta/vrouter/client.py View File

@@ -29,6 +29,7 @@ from networking_brocade.vyatta.common import exceptions as v_exc
29 29
 from networking_brocade.vyatta.common import globals as vyatta_globals
30 30
 from networking_brocade.vyatta.common import parsers
31 31
 from networking_brocade.vyatta.common import utils as vyatta_utils
32
+from networking_brocade.vyatta.common import vrouter_config
32 33
 
33 34
 
34 35
 LOG = logging.getLogger(__name__)
@@ -152,12 +153,13 @@ class VRouterRestAPIClient(object):
152 153
                                   if_ip_address,
153 154
                                   self._ROUTER_INTERFACE_DESCR)
154 155
 
155
-        router_if_subnet = self._get_subnet_from_ip_address(if_ip_address)
156
+        ip_network = netaddr.IPNetwork(if_ip_address)
157
+        router_if_subnet = str(ip_network.cidr)
156 158
 
157 159
         # If external gateway was configured before then
158 160
         # we need to add SNAT rules
159 161
         rule_num = None
160
-        if self._external_gw_info is not None:
162
+        if ip_network.version == 4 and self._external_gw_info is not None:
161 163
             rule_num = self._add_snat_rule_for_router_if_cmd(
162 164
                 cmd_list, router_if_subnet, self._external_gw_info)
163 165
 
@@ -198,6 +200,27 @@ class VRouterRestAPIClient(object):
198 200
         # Remove the router interface info from cache
199 201
         self._router_if_subnet_dict.pop(router_if_subnet, None)
200 202
 
203
+    def update_interface(self, interface_info):
204
+        if_name = self.get_ethernet_if_id(interface_info.mac_address)
205
+        router_config = self.get_config()
206
+        if_config = router_config.find_interface(if_name)
207
+
208
+        old_addrs = set(netaddr.IPNetwork(ip)
209
+                        for ip in if_config.getlist('address'))
210
+        new_addrs = set(interface_info.ip_addresses)
211
+
212
+        cmd_list = []
213
+
214
+        for ip in old_addrs - new_addrs:
215
+            self._delete_ethernet_ip_cmd(cmd_list, if_name, str(ip))
216
+            # TODO(asaprykin): Configure SNAT
217
+
218
+        for ip in new_addrs - old_addrs:
219
+            self._set_ethernet_ip(cmd_list, if_name, str(ip))
220
+            # TODO(asaprykin): Configure SNAT
221
+
222
+        self.exec_cmd_batch(cmd_list)
223
+
201 224
     def assign_floating_ip(self, floating_ip, fixed_ip):
202 225
         """Creates SNAT and DNAT rules for given floating ip and fixed ip."""
203 226
 
@@ -401,9 +424,11 @@ class VRouterRestAPIClient(object):
401 424
         # Add NAT rules for the existing router interfaces
402 425
         nat_rules = {}
403 426
         for router_if_subnet in self._router_if_subnet_dict.keys():
404
-            rule_num = self._add_snat_rule_for_router_if_cmd(cmd_list,
405
-                                                             router_if_subnet,
406
-                                                             gw_info)
427
+            if netaddr.IPNetwork(router_if_subnet).version != 4:
428
+                continue
429
+
430
+            rule_num = self._add_snat_rule_for_router_if_cmd(
431
+                cmd_list, router_if_subnet, gw_info)
407 432
             nat_rules[router_if_subnet] = rule_num
408 433
 
409 434
         return nat_rules
@@ -681,16 +706,12 @@ class VRouterRestAPIClient(object):
681 706
 
682 707
         LOG.debug('Vyatta vRouter:get_ethernet_if_id. Given MAC {0}'
683 708
                   .format(repr(mac_address)))
684
-        mac_address = mac_address.strip().lower()
685
-        ifaces = self._get_interfaces()
686
-        for iface in ifaces:
687
-            if iface['mac_address'] == mac_address:
688
-                return iface['name']
709
+        iface = self._find_interface(mac_address)
710
+        return iface['name']
689 711
 
690
-        raise v_exc.VRouterOperationError(
691
-            ip_address=self.address,
692
-            reason='Ethernet interface with Mac-address {0} does not exist'
693
-            .format(mac_address))
712
+    def get_config(self):
713
+        raw_config = self._show_cmd('configuration/all')
714
+        return vrouter_config.RouterConfig.from_string(raw_config)
694 715
 
695 716
     def _get_interface_cmd(self):
696 717
         if self._vrouter_model == self._VROUTER_VR_MODEL:
@@ -1015,6 +1036,18 @@ class VRouterRestAPIClient(object):
1015 1036
         output = self._show_cmd('interfaces/detail')
1016 1037
         return parsers.parse_interfaces(output)
1017 1038
 
1039
+    def _find_interface(self, mac_address):
1040
+        mac_address = mac_address.strip().lower()
1041
+        ifaces = self._get_interfaces()
1042
+        for iface in ifaces:
1043
+            if iface['mac_address'] == mac_address:
1044
+                return iface
1045
+
1046
+        raise v_exc.VRouterOperationError(
1047
+            ip_address=self.address,
1048
+            reason='Ethernet interface with Mac-address {0} does not exist'
1049
+            .format(mac_address))
1050
+
1018 1051
 
1019 1052
 class ClientsPool(object):
1020 1053
     _client_factory = VRouterRestAPIClient

+ 7
- 1
networking_brocade/vyatta/vrouter/driver.py View File

@@ -21,6 +21,7 @@ from oslo_log import log as logging
21 21
 from oslo_utils import excutils
22 22
 from sqlalchemy.orm import exc as orm_exception
23 23
 
24
+from neutron.common import log
24 25
 from neutron.db import models_v2
25 26
 from neutron.i18n import _LE, _LI
26 27
 from novaclient import exceptions as nova_exc
@@ -93,6 +94,11 @@ class VyattaVRouterDriver(object):
93 94
         for interface_info in interface_infos:
94 95
             vrouter_api.add_interface_to_router(interface_info)
95 96
 
97
+    @log.log
98
+    def update_interface(self, context, router_id, interface_info):
99
+        vrouter_api = self._get_router_api(context, router_id)
100
+        vrouter_api.update_interface(interface_info)
101
+
96 102
     def deconfigure_interface(self, context, router_id, interface_infos):
97 103
         LOG.debug("Vyatta vRouter Driver::Deconfigure interface")
98 104
         vrouter_api = self._get_router_api(context, router_id)
@@ -108,7 +114,7 @@ class VyattaVRouterDriver(object):
108 114
         vrouter_api = self._get_router_api(context, router_id)
109 115
         vrouter_api.update_router(external_gateway_info=interface_infos[0])
110 116
 
111
-    def clear_gateway(self, context, router_id, interface_infos):
117
+    def clear_gateway(self, context, router_id):
112 118
         LOG.debug("Vyatta vRouter Driver::Clear gateway")
113 119
         vrouter_api = self._get_router_api(context, router_id)
114 120
         vrouter_api.update_router(external_gateway_info=None)

+ 154
- 153
networking_brocade/vyatta/vrouter/neutron_plugin.py View File

@@ -191,114 +191,60 @@ class VyattaVRouterMixin(common_db_mixin.CommonDbMixin,
191 191
     def add_router_interface(self, context, router_id, interface_info):
192 192
         LOG.debug("Vyatta vRouter Plugin::Add Router Interface. "
193 193
                   "router: %s; interface: %s", router_id, interface_info)
194
+        add_by_port, add_by_sub = self._validate_interface_info(interface_info)
194 195
         router = self._get_router(context, router_id)
195 196
 
196
-        self._validate_interface_info(interface_info)
197
+        new_port = True
197 198
 
198
-        port_tenant_id = None
199
+        if add_by_port:
200
+            port, subnets = self._add_interface_by_port(
201
+                    context, router, interface_info['port_id'], '')
202
+        elif add_by_sub:
203
+            port, subnets, new_port = self._add_interface_by_subnet(
204
+                    context, router, interface_info['subnet_id'], '')
199 205
 
200
-        if 'port_id' in interface_info:
201
-            # make sure port update is committed
202
-            with context.session.begin(subtransactions=True):
203
-                if 'subnet_id' in interface_info:
204
-                    msg = _("Cannot specify both subnet-id and port-id")
205
-                    raise q_exc.BadRequest(resource='router', msg=msg)
206
-
207
-                port = self._core_plugin._get_port(context.elevated(),
208
-                                                   interface_info['port_id'])
209
-                if port['device_id']:
210
-                    raise q_exc.PortInUse(net_id=port['network_id'],
211
-                                          port_id=port['id'],
212
-                                          device_id=port['device_id'])
213
-                fixed_ips = [ip for ip in port['fixed_ips']]
214
-                if len(fixed_ips) != 1:
215
-                    msg = _('Router port must have exactly one fixed IP')
216
-                    raise q_exc.BadRequest(resource='router', msg=msg)
217
-                subnet_id = fixed_ips[0]['subnet_id']
218
-                subnet = self._core_plugin._get_subnet(context.elevated(),
219
-                                                       subnet_id)
220
-                self._check_for_dup_router_subnet(context, router,
221
-                                                  port['network_id'],
222
-                                                  subnet['id'],
223
-                                                  subnet['cidr'])
206
+        if new_port:
224 207
             port_tenant_id = port['tenant_id']
225 208
             self._core_plugin._delete_port_security_group_bindings(
226 209
                 context.elevated(), port['id'])
227 210
             port = self._core_plugin.update_port(
228 211
                 context.elevated(), port['id'], {'port': {
229 212
                     'tenant_id': config.VROUTER.tenant_id,
230
-                    psec.PORTSECURITY: False,
231
-                }})
232
-            port_created = False
233
-        elif 'subnet_id' in interface_info:
234
-            subnet_id = interface_info['subnet_id']
235
-            subnet = self._core_plugin._get_subnet(context.elevated(),
236
-                                                   subnet_id)
237
-
238
-            # Ensure the subnet has a gateway
239
-            if not subnet['gateway_ip']:
240
-                msg = _('Subnet for router interface must have a gateway IP')
241
-                raise q_exc.BadRequest(resource='router', msg=msg)
242
-            if (subnet['ip_version'] == 6 and subnet['ipv6_ra_mode'] is None
243
-                    and subnet['ipv6_address_mode'] is not None):
244
-                msg = (_('IPv6 subnet %s configured to receive RAs from an '
245
-                       'external router cannot be added to Neutron Router.') %
246
-                       subnet['id'])
247
-                raise q_exc.BadRequest(resource='router', msg=msg)
248
-            self._check_for_dup_router_subnet(context, router,
249
-                                              subnet['network_id'],
250
-                                              subnet_id,
251
-                                              subnet['cidr'])
252
-
253
-            fixed_ip = {'ip_address': subnet['gateway_ip'],
254
-                        'subnet_id': subnet['id']}
255
-
256
-            port_tenant_id = subnet['tenant_id']
257
-            port = self._core_plugin.create_port(context.elevated(), {
258
-                'port': {
259
-                    'tenant_id': config.VROUTER.tenant_id,
260
-                    'network_id': subnet['network_id'],
261
-                    'fixed_ips': [fixed_ip],
262
-                    'mac_address': attributes.ATTR_NOT_SPECIFIED,
263
-                    'admin_state_up': True,
264 213
                     'device_id': '',
265
-                    'device_owner': '',
266
-                    'name': '',
267 214
                     psec.PORTSECURITY: False,
268
-                }
269
-            })
270
-            port_created = True
215
+                }})
271 216
 
272
-        try:
273
-            self._attach_port(context, router_id, port)
274
-        except Exception:
275
-            with excutils.save_and_reraise_exception():
276
-                if port_created:
277
-                    try:
278
-                        self._core_plugin.delete_port(context.elevated(),
279
-                                                      port['id'])
280
-                    except Exception:
281
-                        LOG.exception(_LE(
282
-                            'Failed to delete previously created '
283
-                            'port for Vyatta vRouter.'))
284
-
285
-        port = self._core_plugin.update_port(
286
-            context.elevated(), port['id'], {'port': {
287
-                'tenant_id': port_tenant_id,
288
-            }})
217
+            try:
218
+                self._attach_port(context, router_id, port)
219
+            except Exception:
220
+                with excutils.save_and_reraise_exception():
221
+                    if add_by_sub:
222
+                        try:
223
+                            self._core_plugin.delete_port(context.elevated(),
224
+                                                          port['id'])
225
+                        except Exception:
226
+                            LOG.exception(_LE(
227
+                                'Failed to delete previously created '
228
+                                'port for Vyatta vRouter.'))
289 229
 
290
-        with context.session.begin(subtransactions=True):
291
-            router_port = l3_db.RouterPort(
292
-                port_id=port['id'],
293
-                router_id=router.id,
294
-                port_type=port['device_owner']
295
-            )
296
-            context.session.add(router_port)
230
+            port = self._core_plugin.update_port(
231
+                context.elevated(), port['id'], {'port': {
232
+                    'tenant_id': port_tenant_id,
233
+                }})
234
+
235
+            with context.session.begin(subtransactions=True):
236
+                router_port = l3_db.RouterPort(
237
+                    port_id=port['id'],
238
+                    router_id=router.id,
239
+                    port_type=port['device_owner']
240
+                )
241
+                context.session.add(router_port)
242
+        else:
243
+            self._update_port(context, router_id, port)
297 244
 
298
-        subnet_id = port['fixed_ips'][0]['subnet_id']
299 245
         router_interface_info = self._make_router_interface_info(
300
-            router_id, port['tenant_id'], port['id'],
301
-            subnet_id, [subnet_id])
246
+            router_id, port['tenant_id'], port['id'], subnets[-1]['id'],
247
+            [subnet['id'] for subnet in subnets])
302 248
         self.notify_router_interface_action(
303 249
             context, router_interface_info, 'add')
304 250
         return router_interface_info
@@ -307,70 +253,98 @@ class VyattaVRouterMixin(common_db_mixin.CommonDbMixin,
307 253
         LOG.debug("Vyatta vRouter Plugin::Remove Router Interface. "
308 254
                   "router: %s; interface_info: %s", router_id, interface_info)
309 255
 
310
-        if not interface_info:
311
-            msg = _("Either subnet_id or port_id must be specified")
312
-            raise q_exc.BadRequest(resource='router', msg=msg)
313
-
314
-        if 'port_id' in interface_info:
315
-            port_id = interface_info['port_id']
316
-            port_db = self._core_plugin._get_port(context.elevated(), port_id)
317
-            if not (port_db['device_owner'] ==
318
-                    l3_constants.DEVICE_OWNER_ROUTER_INTF and
319
-                    port_db['device_id'] == router_id):
320
-                raise l3.RouterInterfaceNotFound(router_id=router_id,
321
-                                                 port_id=port_id)
322
-            if 'subnet_id' in interface_info:
323
-                port_subnet_id = port_db['fixed_ips'][0]['subnet_id']
324
-                if port_subnet_id != interface_info['subnet_id']:
325
-                    raise q_exc.SubnetMismatchForPort(
326
-                        port_id=port_id,
327
-                        subnet_id=interface_info['subnet_id'])
328
-            subnet_id = port_db['fixed_ips'][0]['subnet_id']
329
-            subnet = self._core_plugin._get_subnet(context.elevated(),
330
-                                                   subnet_id)
331
-            self._confirm_router_interface_not_in_use(
332
-                context, router_id, subnet_id)
333
-            port = port_db
334
-        elif 'subnet_id' in interface_info:
335
-            subnet_id = interface_info['subnet_id']
336
-            self._confirm_router_interface_not_in_use(context, router_id,
337
-                                                      subnet_id)
338
-            subnet = self._core_plugin._get_subnet(context.elevated(),
339
-                                                   subnet_id)
340
-            found = False
341
-            try:
342
-                rport_qry = context.session.query(models_v2.Port)
343
-                ports = rport_qry.filter_by(
344
-                    device_id=router_id,
345
-                    device_owner=l3_constants.DEVICE_OWNER_ROUTER_INTF,
346
-                    network_id=subnet['network_id'])
347
-
348
-                for p in ports:
349
-                    if p['fixed_ips'][0]['subnet_id'] == subnet_id:
350
-                        port = p
351
-                        found = True
352
-                        break
353
-            except exc.NoResultFound:
354
-                pass
355
-
356
-            if not found:
357
-                raise l3.RouterInterfaceNotFoundForSubnet(router_id=router_id,
358
-                                                          subnet_id=subnet_id)
359
-
360
-        port = self._core_plugin.update_port(
361
-            context.elevated(), port['id'], {'port': {
362
-                'tenant_id': config.VROUTER.tenant_id,
363
-            }})
256
+        remove_by_port, remove_by_subnet = (
257
+            self._validate_interface_info(interface_info, for_removal=True)
258
+        )
259
+        port_id = interface_info.get('port_id')
260
+        subnet_id = interface_info.get('subnet_id')
261
+        router = self._get_router(context, router_id)
262
+        device_owner = self._get_device_owner(context, router)
263
+
264
+        if remove_by_port:
265
+            port, subnets, delete_port = self._remove_interface_by_port(
266
+                    context, router_id, port_id, subnet_id, device_owner)
267
+        # remove_by_subnet is not used here, because the validation logic of
268
+        # _validate_interface_info ensures that at least one of remote_by_*
269
+        # is True.
270
+        else:
271
+            port, subnets, delete_port = self._remove_interface_by_subnet(
272
+                    context, router_id, subnet_id, device_owner)
364 273
 
365
-        self._delete_router_port(context, router_id, port)
274
+        port_tenant_id = port['tenant_id']
275
+        if delete_port:
276
+            port = self._core_plugin.update_port(
277
+                context.elevated(), port['id'], {'port': {
278
+                    'tenant_id': config.VROUTER.tenant_id,
279
+                }})
280
+            self._delete_router_port(context, router_id, port)
281
+        else:
282
+            self._update_port(context, router_id, port)
366 283
 
367 284
         router_interface_info = self._make_router_interface_info(
368
-            router_id, subnet['tenant_id'], port['id'],
369
-            subnet['id'], [subnet['id']])
285
+            router_id, port_tenant_id, port['id'], subnets[0]['id'],
286
+            [subnet['id'] for subnet in subnets])
370 287
         self.notify_router_interface_action(
371 288
             context, router_interface_info, 'remove')
372 289
         return router_interface_info
373 290
 
291
+    def _remove_interface_by_port(self, context, router_id,
292
+                                  port_id, subnet_id, owner):
293
+        qry = context.session.query(l3_db.RouterPort)
294
+        qry = qry.filter_by(
295
+            port_id=port_id,
296
+            router_id=router_id,
297
+            port_type=owner
298
+        )
299
+        try:
300
+            port_db = qry.one().port
301
+        except exc.NoResultFound:
302
+            raise l3.RouterInterfaceNotFound(router_id=router_id,
303
+                                             port_id=port_id)
304
+        port_subnet_ids = [fixed_ip['subnet_id']
305
+                           for fixed_ip in port_db['fixed_ips']]
306
+        if subnet_id and subnet_id not in port_subnet_ids:
307
+            raise q_exc.SubnetMismatchForPort(
308
+                port_id=port_id, subnet_id=subnet_id)
309
+        subnets = [self._core_plugin._get_subnet(context, port_subnet_id)
310
+                   for port_subnet_id in port_subnet_ids]
311
+        for port_subnet_id in port_subnet_ids:
312
+            self._confirm_router_interface_not_in_use(
313
+                    context, router_id, port_subnet_id)
314
+        return port_db, subnets, True
315
+
316
+    def _remove_interface_by_subnet(self, context,
317
+                                    router_id, subnet_id, owner):
318
+        self._confirm_router_interface_not_in_use(
319
+            context, router_id, subnet_id)
320
+        subnet = self._core_plugin._get_subnet(context, subnet_id)
321
+
322
+        try:
323
+            rport_qry = context.session.query(models_v2.Port).join(
324
+                l3_db.RouterPort)
325
+            ports = rport_qry.filter(
326
+                l3_db.RouterPort.router_id == router_id,
327
+                l3_db.RouterPort.port_type == owner,
328
+                models_v2.Port.network_id == subnet['network_id']
329
+            )
330
+
331
+            for p in ports:
332
+                port_subnets = [fip['subnet_id'] for fip in p['fixed_ips']]
333
+                if subnet_id in port_subnets and len(port_subnets) > 1:
334
+                    # multiple prefix port - delete prefix from port
335
+                    fixed_ips = [fip for fip in p['fixed_ips'] if
336
+                            fip['subnet_id'] != subnet_id]
337
+                    p = self._core_plugin.update_port(context, p['id'],
338
+                            {'port':
339
+                                {'fixed_ips': fixed_ips}})
340
+                    return p, [subnet], False
341
+                elif subnet_id in port_subnets:
342
+                    return p, [subnet], True
343
+        except exc.NoResultFound:
344
+            pass
345
+        raise l3.RouterInterfaceNotFoundForSubnet(router_id=router_id,
346
+                                                  subnet_id=subnet_id)
347
+
374 348
     def _get_interface_infos(self, context, port):
375 349
         LOG.debug("Vyatta vRouter Plugin::Get interface infos")
376 350
 
@@ -391,6 +365,21 @@ class VyattaVRouterMixin(common_db_mixin.CommonDbMixin,
391 365
                 pass
392 366
         return interface_infos
393 367
 
368
+    def _get_interface_infos_new(self, context, port):
369
+        mac_address = port['mac_address']
370
+        ip_list = []
371
+
372
+        for fixed_ip in port['fixed_ips']:
373
+            subnet = self._core_plugin._get_subnet(
374
+                context.elevated(), fixed_ip['subnet_id'])
375
+            network = netaddr.IPNetwork(subnet.cidr)
376
+            ip = netaddr.IPNetwork('{0}/{1}'.format(
377
+                fixed_ip['ip_address'], network.prefixlen))
378
+            ip_list.append(ip)
379
+
380
+        return vyatta_utils.InterfaceInfo(
381
+            ip_addresses=ip_list, mac_address=mac_address)
382
+
394 383
     def _delete_router_port(self, context, router_id, port, external_gw=False):
395 384
         # Get instance, deconfigure interface and detach port from it. To do
396 385
         # this need to change port owner back to that instance.
@@ -438,6 +427,10 @@ class VyattaVRouterMixin(common_db_mixin.CommonDbMixin,
438 427
                                       {'port': {'device_owner': device_owner,
439 428
                                                 'device_id': router_id}})
440 429
 
430
+    def _update_port(self, context, router_id, port):
431
+        interface_info = self._get_interface_infos_new(context, port)
432
+        self.driver.update_interface(context, router_id, interface_info)
433
+
441 434
     def _update_router_gw_info(self, context, router_id, info, router=None):
442 435
         LOG.debug("Vyatta vRouter Plugin::Update router gateway info")
443 436
 
@@ -457,6 +450,17 @@ class VyattaVRouterMixin(common_db_mixin.CommonDbMixin,
457 450
             self._create_gw_port(context, router_id, router, network_id,
458 451
                                  ext_ips)
459 452
 
453
+    def _update_current_gw_port(self, context, router_id, router, ext_ips):
454
+        super(VyattaVRouterMixin, self)._update_current_gw_port(
455
+            context, router_id, router, ext_ips)
456
+
457
+        port = router.gw_port
458
+
459
+        self.driver.clear_gateway(context, router_id)
460
+        self.driver.configure_gateway(
461
+            context, router_id,
462
+            self._get_interface_infos(context.elevated(), port))
463
+
460 464
     def _delete_current_gw_port(self, context, router_id, router, new_network):
461 465
         """Delete gw port if attached to an old network or IPs changed."""
462 466
         port_requires_deletion = (
@@ -470,10 +474,7 @@ class VyattaVRouterMixin(common_db_mixin.CommonDbMixin,
470 474
                 router_id=router_id, net_id=router.gw_port['network_id'])
471 475
 
472 476
         gw_port = router.gw_port
473
-        self.driver.clear_gateway(
474
-            context, router_id,
475
-            self._get_interface_infos(context.elevated(),
476
-                                      gw_port))
477
+        self.driver.clear_gateway(context, router_id)
477 478
         with context.session.begin(subtransactions=True):
478 479
             router.gw_port = None
479 480
             context.session.add(router)

Loading…
Cancel
Save