~ubuntu-branches/ubuntu/vivid/neutron/vivid

« back to all changes in this revision

Viewing changes to neutron/tests/functional/agent/test_l3_agent.py

  • Committer: Package Import Robot
  • Author(s): Corey Bryant, Corey Bryant, James Page
  • Date: 2015-02-16 09:59:01 UTC
  • mfrom: (1.1.20)
  • Revision ID: package-import@ubuntu.com-20150216095901-irf6gdwh5tzmfi73
Tags: 1:2015.1~b2-0ubuntu1
[ Corey Bryant ]
* New upstream release.
  - d/control: Align with upstream dependencies.
  - d/p/disable-udev-tests.patch: Rebased.
  - d/p/pep-0476.patch: Dropped. Fixed upstream.

[ James Page ]
* d/neutron-common.install: Drop fwaas_driver.ini and vpnaas.filters, will
  provided by driver specific packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
import copy
17
17
import functools
18
18
 
19
 
import fixtures
20
19
import mock
 
20
import netaddr
21
21
from oslo.config import cfg
22
22
import webob
23
23
import webob.dec
24
24
import webob.exc
25
25
 
26
26
from neutron.agent.common import config as agent_config
27
 
from neutron.agent.l3 import agent as l3_agent
 
27
from neutron.agent.l3 import agent as neutron_l3_agent
 
28
from neutron.agent import l3_agent as l3_agent_main
28
29
from neutron.agent.linux import dhcp
29
30
from neutron.agent.linux import external_process
30
31
from neutron.agent.linux import ip_lib
31
32
from neutron.agent.metadata import agent as metadata_agent
32
33
from neutron.common import config as common_config
33
34
from neutron.common import constants as l3_constants
 
35
from neutron.common import utils as common_utils
34
36
from neutron.openstack.common import log as logging
35
37
from neutron.openstack.common import uuidutils
36
38
from neutron.services import advanced_service as adv_svc
60
62
        config.register_cli_opts(logging.logging_cli_opts)
61
63
        config.register_opts(logging.generic_log_opts)
62
64
        config.register_opts(logging.log_opts)
 
65
        agent_config.register_process_monitor_opts(config)
63
66
        return config
64
67
 
65
68
    def _configure_agent(self, host):
66
69
        conf = self._get_config_opts()
67
 
        l3_agent._register_opts(conf)
 
70
        l3_agent_main.register_opts(conf)
68
71
        cfg.CONF.set_override('debug', False)
69
72
        agent_config.setup_logging()
70
73
        conf.set_override(
78
81
        conf.set_override('ovs_integration_bridge', br_int.br_name)
79
82
        conf.set_override('external_network_bridge', br_ex.br_name)
80
83
 
81
 
        temp_dir = self.useFixture(fixtures.TempDir()).path
82
 
        conf.set_override('state_path', temp_dir)
 
84
        temp_dir = self.get_new_temp_dir()
 
85
        get_temp_file_path = functools.partial(self.get_temp_file_path,
 
86
                                               root=temp_dir)
 
87
        conf.set_override('state_path', temp_dir.path)
83
88
        conf.set_override('metadata_proxy_socket',
84
 
                          '%s/metadata_proxy' % temp_dir)
 
89
                          get_temp_file_path('metadata_proxy'))
85
90
        conf.set_override('ha_confs_path',
86
 
                          '%s/ha_confs' % temp_dir)
 
91
                          get_temp_file_path('ha_confs'))
87
92
        conf.set_override('external_pids',
88
 
                          '%s/external/pids' % temp_dir)
 
93
                          get_temp_file_path('external/pids'))
89
94
        conf.set_override('host', host)
90
95
        agent = l3_test_agent.TestL3NATAgent(host, conf)
91
 
        mock.patch.object(agent, '_arping').start()
 
96
        mock.patch.object(ip_lib, 'send_gratuitous_arp').start()
92
97
 
93
98
        return agent
94
99
 
95
100
    def generate_router_info(self, enable_ha):
96
101
        return test_l3_agent.prepare_router_data(enable_snat=True,
97
102
                                                 enable_floating_ip=True,
98
 
                                                 enable_ha=enable_ha)
 
103
                                                 enable_ha=enable_ha,
 
104
                                                 extra_routes=True)
99
105
 
100
106
    def manage_router(self, agent, router):
101
107
        self.addCleanup(self._delete_router, agent, router['id'])
116
122
               'fixed_ip_address': fixed_address}
117
123
        router.router[l3_constants.FLOATINGIP_KEY].append(fip)
118
124
 
119
 
    def _namespace_exists(self, router):
120
 
        ip = ip_lib.IPWrapper(self.root_helper, router.ns_name)
121
 
        return ip.netns.exists(router.ns_name)
 
125
    def _namespace_exists(self, namespace):
 
126
        ip = ip_lib.IPWrapper(self.root_helper, namespace)
 
127
        return ip.netns.exists(namespace)
122
128
 
123
129
    def _metadata_proxy_exists(self, conf, router):
124
130
        pm = external_process.ProcessManager(
139
145
    def get_expected_keepalive_configuration(self, router):
140
146
        ha_confs_path = self.agent.conf.ha_confs_path
141
147
        router_id = router.router_id
142
 
        ha_device_name = self.agent.get_ha_device_name(router.ha_port['id'])
 
148
        ha_device_name = router.get_ha_device_name(router.ha_port['id'])
143
149
        ha_device_cidr = router.ha_port['ip_cidr']
144
150
        external_port = self.agent._get_ex_gw_port(router)
 
151
        ex_port_ipv6 = router._get_ipv6_lladdr(
 
152
            external_port['mac_address'])
145
153
        external_device_name = self.agent.get_external_device_name(
146
154
            external_port['id'])
147
155
        external_device_cidr = external_port['ip_cidr']
148
156
        internal_port = router.router[l3_constants.INTERFACE_KEY][0]
 
157
        int_port_ipv6 = router._get_ipv6_lladdr(
 
158
            internal_port['mac_address'])
149
159
        internal_device_name = self.agent.get_internal_device_name(
150
160
            internal_port['id'])
151
161
        internal_device_cidr = internal_port['ip_cidr']
152
 
        floating_ip_cidr = (
153
 
            self.agent.get_floating_ips(router)[0]
154
 
            ['floating_ip_address'] + l3_agent.FLOATING_IP_CIDR_SUFFIX)
 
162
        floating_ip_cidr = common_utils.ip_to_cidr(
 
163
            self.agent.get_floating_ips(router)[0]['floating_ip_address'])
155
164
        default_gateway_ip = external_port['subnet'].get('gateway_ip')
156
165
 
157
166
        return """vrrp_sync_group VG_1 {
173
182
        %(ha_device_name)s
174
183
    }
175
184
    virtual_ipaddress {
 
185
        169.254.0.1/24 dev %(ha_device_name)s
 
186
    }
 
187
    virtual_ipaddress_excluded {
176
188
        %(floating_ip_cidr)s dev %(external_device_name)s
177
 
    }
178
 
    virtual_ipaddress_excluded {
179
189
        %(external_device_cidr)s dev %(external_device_name)s
180
190
        %(internal_device_cidr)s dev %(internal_device_name)s
 
191
        %(ex_port_ipv6)s dev %(external_device_name)s scope link
 
192
        %(int_port_ipv6)s dev %(internal_device_name)s scope link
181
193
    }
182
194
    virtual_routes {
183
195
        0.0.0.0/0 via %(default_gateway_ip)s dev %(external_device_name)s
 
196
        8.8.8.0/24 via 19.4.4.4
184
197
    }
185
198
}""" % {
186
199
            'ha_confs_path': ha_confs_path,
192
205
            'internal_device_name': internal_device_name,
193
206
            'internal_device_cidr': internal_device_cidr,
194
207
            'floating_ip_cidr': floating_ip_cidr,
195
 
            'default_gateway_ip': default_gateway_ip
 
208
            'default_gateway_ip': default_gateway_ip,
 
209
            'int_port_ipv6': int_port_ipv6,
 
210
            'ex_port_ipv6': ex_port_ipv6
196
211
        }
197
212
 
 
213
    def _get_rule(self, iptables_manager, table, chain, predicate):
 
214
        rules = iptables_manager.get_chain(table, chain)
 
215
        result = next(rule for rule in rules if predicate(rule))
 
216
        return result
 
217
 
 
218
    def _assert_router_does_not_exist(self, router):
 
219
        # If the namespace assertion succeeds
 
220
        # then the devices and iptable rules have also been deleted,
 
221
        # so there's no need to check that explicitly.
 
222
        self.assertFalse(self._namespace_exists(router.ns_name))
 
223
        self.assertFalse(self._metadata_proxy_exists(self.agent.conf, router))
 
224
 
 
225
    def _assert_snat_chains(self, router):
 
226
        self.assertFalse(router.iptables_manager.is_chain_empty(
 
227
            'nat', 'snat'))
 
228
        self.assertFalse(router.iptables_manager.is_chain_empty(
 
229
            'nat', 'POSTROUTING'))
 
230
 
 
231
    def _assert_floating_ip_chains(self, router):
 
232
        self.assertFalse(router.iptables_manager.is_chain_empty(
 
233
            'nat', 'float-snat'))
 
234
 
 
235
    def _assert_metadata_chains(self, router):
 
236
        metadata_port_filter = lambda rule: (
 
237
            str(self.agent.conf.metadata_port) in rule.rule)
 
238
        self.assertTrue(self._get_rule(router.iptables_manager,
 
239
                                       'nat',
 
240
                                       'PREROUTING',
 
241
                                       metadata_port_filter))
 
242
        self.assertTrue(self._get_rule(router.iptables_manager,
 
243
                                       'filter',
 
244
                                       'INPUT',
 
245
                                       metadata_port_filter))
 
246
 
 
247
    def _assert_internal_devices(self, router):
 
248
        internal_devices = router.router[l3_constants.INTERFACE_KEY]
 
249
        self.assertTrue(len(internal_devices))
 
250
        for device in internal_devices:
 
251
            self.assertTrue(self.device_exists_with_ip_mac(
 
252
                device, self.agent.get_internal_device_name, router.ns_name))
 
253
 
 
254
    def _assert_extra_routes(self, router):
 
255
        routes = ip_lib.get_routing_table(self.root_helper, router.ns_name)
 
256
        routes = [{'nexthop': route['nexthop'],
 
257
                   'destination': route['destination']} for route in routes]
 
258
 
 
259
        for extra_route in router.router['routes']:
 
260
            self.assertIn(extra_route, routes)
 
261
 
198
262
 
199
263
class L3AgentTestCase(L3AgentTestFramework):
200
264
    def test_observer_notifications_legacy_router(self):
257
321
        self.assertIn(new_fip, new_config)
258
322
        self.assertNotIn(old_gw, new_config)
259
323
        self.assertIn(new_gw, new_config)
260
 
        self.assertNotIn(old_external_device_ip, new_config)
261
 
        self.assertIn(new_external_device_ip, new_config)
 
324
        external_port = self.agent._get_ex_gw_port(router)
 
325
        external_device_name = self.agent.get_external_device_name(
 
326
            external_port['id'])
 
327
        self.assertNotIn('%s/24 dev %s' %
 
328
                         (old_external_device_ip, external_device_name),
 
329
                         new_config)
 
330
        self.assertIn('%s/24 dev %s' %
 
331
                      (new_external_device_ip, external_device_name),
 
332
                      new_config)
262
333
 
263
334
    def _router_lifecycle(self, enable_ha):
264
335
        router_info = self.generate_router_info(enable_ha)
265
336
        router = self.manage_router(self.agent, router_info)
266
337
 
267
338
        if enable_ha:
 
339
            port = self.agent._get_ex_gw_port(router)
 
340
            interface_name = self.agent.get_external_device_name(port['id'])
 
341
            self._assert_no_ip_addresses_on_interface(router, interface_name)
268
342
            helpers.wait_until_true(lambda: router.ha_state == 'master')
269
343
 
270
344
            # Keepalived notifies of a state transition when it starts,
279
353
                router.ns_name)
280
354
            helpers.wait_until_true(device_exists)
281
355
 
282
 
        self.assertTrue(self._namespace_exists(router))
 
356
        self.assertTrue(self._namespace_exists(router.ns_name))
283
357
        self.assertTrue(self._metadata_proxy_exists(self.agent.conf, router))
284
358
        self._assert_internal_devices(router)
285
359
        self._assert_external_device(router)
287
361
        self._assert_floating_ips(router)
288
362
        self._assert_snat_chains(router)
289
363
        self._assert_floating_ip_chains(router)
 
364
        self._assert_metadata_chains(router)
 
365
        self._assert_extra_routes(router)
290
366
 
291
367
        if enable_ha:
292
368
            self._assert_ha_device(router)
298
374
        if enable_ha:
299
375
            self.assertFalse(router.keepalived_manager.process.active)
300
376
 
301
 
    def _assert_internal_devices(self, router):
302
 
        internal_devices = router.router[l3_constants.INTERFACE_KEY]
303
 
        self.assertTrue(len(internal_devices))
304
 
        for device in internal_devices:
305
 
            self.assertTrue(self.device_exists_with_ip_mac(
306
 
                device, self.agent.get_internal_device_name, router.ns_name))
307
 
 
308
377
    def _assert_external_device(self, router):
309
378
        external_port = self.agent._get_ex_gw_port(router)
310
379
        self.assertTrue(self.device_exists_with_ip_mac(
334
403
                external_port['mac_address'],
335
404
                router.ns_name, self.root_helper))
336
405
 
337
 
    def _assert_snat_chains(self, router):
338
 
        self.assertFalse(router.iptables_manager.is_chain_empty(
339
 
            'nat', 'snat'))
340
 
        self.assertFalse(router.iptables_manager.is_chain_empty(
341
 
            'nat', 'POSTROUTING'))
342
 
 
343
 
    def _assert_floating_ip_chains(self, router):
344
 
        self.assertFalse(router.iptables_manager.is_chain_empty(
345
 
            'nat', 'float-snat'))
346
 
 
347
 
    def _assert_router_does_not_exist(self, router):
348
 
        # If the namespace assertion succeeds
349
 
        # then the devices and iptable rules have also been deleted,
350
 
        # so there's no need to check that explicitly.
351
 
        self.assertFalse(self._namespace_exists(router))
352
 
        self.assertFalse(self._metadata_proxy_exists(self.agent.conf, router))
353
 
 
354
406
    def _assert_ha_device(self, router):
355
407
        self.assertTrue(self.device_exists_with_ip_mac(
356
408
            router.router[l3_constants.HA_INTERFACE_KEY],
357
 
            self.agent.get_ha_device_name, router.ns_name))
 
409
            router.get_ha_device_name, router.ns_name))
 
410
 
 
411
    def _assert_no_ip_addresses_on_interface(self, router, interface):
 
412
        device = ip_lib.IPDevice(interface, self.root_helper, router.ns_name)
 
413
        self.assertEqual([], device.addr.list())
358
414
 
359
415
 
360
416
class L3HATestFramework(L3AgentTestFramework):
377
433
 
378
434
        router_info_2 = copy.deepcopy(router_info)
379
435
        router_info_2[l3_constants.HA_INTERFACE_KEY] = (
380
 
            test_l3_agent.get_ha_interface(ip='169.254.0.3',
 
436
            test_l3_agent.get_ha_interface(ip='169.254.192.2',
381
437
                                           mac='22:22:22:22:22:22'))
382
438
 
383
439
        router2 = self.manage_router(self.failover_agent, router_info_2)
385
441
        helpers.wait_until_true(lambda: router1.ha_state == 'master')
386
442
        helpers.wait_until_true(lambda: router2.ha_state == 'backup')
387
443
 
388
 
        device_name = self.agent.get_ha_device_name(
 
444
        device_name = router1.get_ha_device_name(
389
445
            router1.router[l3_constants.HA_INTERFACE_KEY]['id'])
390
446
        ha_device = ip_lib.IPDevice(device_name, self.root_helper,
391
447
                                    router1.ns_name)
454
510
        # Check status code
455
511
        firstline = raw_headers.splitlines()[0]
456
512
        self.assertIn(str(webob.exc.HTTPOk.code), firstline.split())
 
513
 
 
514
 
 
515
class TestDvrRouter(L3AgentTestFramework):
 
516
    def test_dvr_router_lifecycle_without_ha_without_snat_with_fips(self):
 
517
        self._dvr_router_lifecycle(enable_ha=False, enable_snat=False)
 
518
 
 
519
    def test_dvr_router_lifecycle_without_ha_with_snat_with_fips(self):
 
520
        self._dvr_router_lifecycle(enable_ha=False, enable_snat=True)
 
521
 
 
522
    def _dvr_router_lifecycle(self, enable_ha=False, enable_snat=False):
 
523
        '''Test dvr router lifecycle
 
524
 
 
525
        :param enable_ha: sets the ha value for the router.
 
526
        :param enable_snat:  the value of enable_snat is used
 
527
        to  set the  agent_mode.
 
528
        '''
 
529
 
 
530
        # The value of agent_mode can be dvr, dvr_snat, or legacy.
 
531
        # Since by definition this is a dvr (distributed = true)
 
532
        # only dvr and dvr_snat are applicable
 
533
        self.agent.conf.agent_mode = 'dvr_snat' if enable_snat else 'dvr'
 
534
 
 
535
        # We get the router info particular to a dvr router
 
536
        router_info = self.generate_dvr_router_info(
 
537
            enable_ha, enable_snat)
 
538
 
 
539
        # We need to mock the get_agent_gateway_port return value
 
540
        # because the whole L3PluginApi is mocked and we need the port
 
541
        # gateway_port information before the l3_agent will create it.
 
542
        # The port returned needs to have the same information as
 
543
        # router_info['gw_port']
 
544
        mocked_gw_port = (
 
545
            neutron_l3_agent.L3PluginApi.return_value.get_agent_gateway_port)
 
546
        mocked_gw_port.return_value = router_info['gw_port']
 
547
 
 
548
        # We also need to mock the get_external_network_id method to
 
549
        # get the correct fip namespace.
 
550
        mocked_ext_net_id = (
 
551
            neutron_l3_agent.L3PluginApi.return_value.get_external_network_id)
 
552
        mocked_ext_net_id.return_value = (
 
553
            router_info['_floatingips'][0]['floating_network_id'])
 
554
 
 
555
        # With all that set we can now ask the l3_agent to
 
556
        # manage the router (create it, create namespaces,
 
557
        # attach interfaces, etc...)
 
558
        router = self.manage_router(self.agent, router_info)
 
559
 
 
560
        self.assertTrue(self._namespace_exists(router.ns_name))
 
561
        self.assertTrue(self._metadata_proxy_exists(self.agent.conf, router))
 
562
        self._assert_internal_devices(router)
 
563
        self._assert_dvr_external_device(router)
 
564
        self._assert_dvr_gateway(router)
 
565
        self._assert_dvr_floating_ips(router)
 
566
        self._assert_snat_chains(router)
 
567
        self._assert_floating_ip_chains(router)
 
568
        self._assert_metadata_chains(router)
 
569
        self._assert_extra_routes(router)
 
570
 
 
571
        self._delete_router(self.agent, router.router_id)
 
572
        self._assert_router_does_not_exist(router)
 
573
 
 
574
    def generate_dvr_router_info(self, enable_ha=False, enable_snat=False):
 
575
        router = test_l3_agent.prepare_router_data(
 
576
            enable_snat=enable_snat,
 
577
            enable_floating_ip=True,
 
578
            enable_ha=enable_ha)
 
579
        internal_ports = router.get(l3_constants.INTERFACE_KEY, [])
 
580
        router['distributed'] = True
 
581
        router['gw_port_host'] = self.agent.conf.host
 
582
        router['gw_port']['binding:host_id'] = self.agent.conf.host
 
583
        floating_ip = router['_floatingips'][0]
 
584
        floating_ip['floating_network_id'] = router['gw_port']['network_id']
 
585
        floating_ip['host'] = self.agent.conf.host
 
586
        floating_ip['port_id'] = internal_ports[0]['id']
 
587
        floating_ip['status'] = 'ACTIVE'
 
588
 
 
589
        if not enable_snat:
 
590
            return router
 
591
 
 
592
        self._add_snat_port_info_to_router(router, internal_ports)
 
593
        return router
 
594
 
 
595
    def _add_snat_port_info_to_router(self, router, internal_ports):
 
596
        # Add snat port information to the router
 
597
        snat_port_list = router.get(l3_constants.SNAT_ROUTER_INTF_KEY, [])
 
598
        if not snat_port_list and internal_ports:
 
599
            # Get values from internal port
 
600
            port = internal_ports[0]
 
601
            fixed_ip = port['fixed_ips'][0]
 
602
            snat_subnet = port['subnet']
 
603
            port_ip = fixed_ip['ip_address']
 
604
            # Pick an ip address which is not the same as port_ip
 
605
            snat_ip = str(netaddr.IPAddress(port_ip) + 5)
 
606
            # Add the info to router as the first snat port
 
607
            # in the list of snat ports
 
608
            router[l3_constants.SNAT_ROUTER_INTF_KEY] = [
 
609
                {'subnet':
 
610
                    {'cidr': snat_subnet['cidr'],
 
611
                        'gateway_ip': snat_subnet['gateway_ip'],
 
612
                        'id': fixed_ip['subnet_id']},
 
613
                    'network_id': port['network_id'],
 
614
                    'device_owner': 'network:router_centralized_snat',
 
615
                    'mac_address': 'fa:16:3e:80:8d:89',
 
616
                    'fixed_ips': [{'subnet_id': fixed_ip['subnet_id'],
 
617
                                    'ip_address': snat_ip}],
 
618
                    'id': _uuid(),
 
619
                    'device_id': _uuid()}
 
620
            ]
 
621
 
 
622
    def _assert_dvr_external_device(self, router):
 
623
        external_port = self.agent._get_ex_gw_port(router)
 
624
        snat_ns_name = self.agent.get_snat_ns_name(router.router_id)
 
625
 
 
626
        # if the agent is in dvr_snat mode, then we have to check
 
627
        # that the correct ports and ip addresses exist in the
 
628
        # snat_ns_name namespace
 
629
        if self.agent.conf.agent_mode == 'dvr_snat':
 
630
            self.assertTrue(self.device_exists_with_ip_mac(
 
631
                external_port, self.agent.get_external_device_name,
 
632
                snat_ns_name))
 
633
        # if the agent is in dvr mode then the snat_ns_name namespace
 
634
        # should not be present at all:
 
635
        elif self.agent.conf.agent_mode == 'dvr':
 
636
            self.assertFalse(
 
637
                self._namespace_exists(snat_ns_name),
 
638
                "namespace %s was found but agent is in dvr mode not dvr_snat"
 
639
                % (str(snat_ns_name))
 
640
            )
 
641
        # if the agent is anything else the test is misconfigured
 
642
        # we force a test failure with message
 
643
        else:
 
644
            self.assertTrue(False, " agent not configured for dvr or dvr_snat")
 
645
 
 
646
    def _assert_dvr_gateway(self, router):
 
647
        gateway_expected_in_snat_namespace = (
 
648
            self.agent.conf.agent_mode == 'dvr_snat'
 
649
        )
 
650
        if gateway_expected_in_snat_namespace:
 
651
            self._assert_dvr_snat_gateway(router)
 
652
 
 
653
        snat_namespace_should_not_exist = (
 
654
            self.agent.conf.agent_mode == 'dvr'
 
655
        )
 
656
        if snat_namespace_should_not_exist:
 
657
            self._assert_snat_namespace_does_not_exist(router)
 
658
 
 
659
    def _assert_dvr_snat_gateway(self, router):
 
660
        namespace = self.agent.get_snat_ns_name(router.router_id)
 
661
        external_port = self.agent._get_ex_gw_port(router)
 
662
        external_device_name = self.agent.get_external_device_name(
 
663
            external_port['id'])
 
664
        external_device = ip_lib.IPDevice(external_device_name,
 
665
                                          self.root_helper,
 
666
                                          namespace)
 
667
        existing_gateway = (
 
668
            external_device.route.get_gateway().get('gateway'))
 
669
        expected_gateway = external_port['subnet']['gateway_ip']
 
670
        self.assertEqual(expected_gateway, existing_gateway)
 
671
 
 
672
    def _assert_snat_namespace_does_not_exist(self, router):
 
673
        namespace = self.agent.get_snat_ns_name(router.router_id)
 
674
        self.assertFalse(self._namespace_exists(namespace))
 
675
 
 
676
    def _assert_dvr_floating_ips(self, router):
 
677
        # in the fip namespace:
 
678
        # Check that the fg-<port-id> (floatingip_agent_gateway)
 
679
        # is created with the ip address of the external gateway port
 
680
        floating_ips = router.router[l3_constants.FLOATINGIP_KEY]
 
681
        self.assertTrue(floating_ips)
 
682
 
 
683
        external_port = self.agent._get_ex_gw_port(router)
 
684
        fip_ns = self.agent.get_fip_ns(floating_ips[0]['floating_network_id'])
 
685
        fip_ns_name = fip_ns.get_name()
 
686
        fg_port_created_succesfully = ip_lib.device_exists_with_ip_mac(
 
687
            fip_ns.get_ext_device_name(external_port['id']),
 
688
            external_port['ip_cidr'],
 
689
            external_port['mac_address'],
 
690
            fip_ns_name, self.root_helper)
 
691
        self.assertTrue(fg_port_created_succesfully)
 
692
        # Check fpr-router device has been created
 
693
        device_name = fip_ns.get_int_device_name(router.router_id)
 
694
        fpr_router_device_created_succesfully = ip_lib.device_exists(
 
695
            device_name, self.root_helper, fip_ns_name)
 
696
        self.assertTrue(fpr_router_device_created_succesfully)
 
697
 
 
698
        # In the router namespace
 
699
        # Check rfp-<router-id> is created correctly
 
700
        for fip in floating_ips:
 
701
            device_name = fip_ns.get_rtr_ext_device_name(router.router_id)
 
702
            self.assertTrue(ip_lib.device_exists(
 
703
                device_name, self.root_helper, router.ns_name))