Example #1
0
    def test_device_exists_with_ip_mac(self):
        attr = self.generate_device_details()
        device = self.manage_device(attr)
        self.assertTrue(
            ip_lib.device_exists_with_ip_mac(
                *attr, root_helper=self.root_helper))

        wrong_ip_cidr = '10.0.0.1/8'
        wrong_mac_address = 'aa:aa:aa:aa:aa:aa'

        attr = self.generate_device_details(name='wrong_name')
        self.assertFalse(
            ip_lib.device_exists_with_ip_mac(
                *attr, root_helper=self.root_helper))

        attr = self.generate_device_details(ip_cidr=wrong_ip_cidr)
        self.assertFalse(
            ip_lib.device_exists_with_ip_mac(
                *attr, root_helper=self.root_helper))

        attr = self.generate_device_details(mac_address=wrong_mac_address)
        self.assertFalse(
            ip_lib.device_exists_with_ip_mac(
                *attr, root_helper=self.root_helper))

        attr = self.generate_device_details(namespace='wrong_namespace')
        self.assertFalse(
            ip_lib.device_exists_with_ip_mac(
                *attr, root_helper=self.root_helper))

        device.link.delete()
Example #2
0
 def device_exists_with_ip_mac(self, expected_device, name_getter,
                               namespace):
     return ip_lib.device_exists_with_ip_mac(
         name_getter(expected_device['id']),
         expected_device['ip_cidr'],
         expected_device['mac_address'],
         namespace, self.root_helper)
Example #3
0
    def _assert_dvr_floating_ips(self, router):
        # in the fip namespace:
        # Check that the fg-<port-id> (floatingip_agent_gateway)
        # is created with the ip address of the external gateway port
        floating_ips = router.router[l3_constants.FLOATINGIP_KEY]
        self.assertTrue(floating_ips)

        external_port = self.agent._get_ex_gw_port(router)
        fip_ns = self.agent.get_fip_ns(floating_ips[0]['floating_network_id'])
        fip_ns_name = fip_ns.get_name()
        fg_port_created_succesfully = ip_lib.device_exists_with_ip_mac(
            fip_ns.get_ext_device_name(external_port['id']),
            external_port['ip_cidr'],
            external_port['mac_address'],
            fip_ns_name, self.root_helper)
        self.assertTrue(fg_port_created_succesfully)
        # Check fpr-router device has been created
        device_name = fip_ns.get_int_device_name(router.router_id)
        fpr_router_device_created_succesfully = ip_lib.device_exists(
            device_name, self.root_helper, fip_ns_name)
        self.assertTrue(fpr_router_device_created_succesfully)

        # In the router namespace
        # Check rfp-<router-id> is created correctly
        for fip in floating_ips:
            device_name = fip_ns.get_rtr_ext_device_name(router.router_id)
            self.assertTrue(ip_lib.device_exists(
                device_name, self.root_helper, router.ns_name))
Example #4
0
 def floating_ips_configured(self, router):
     floating_ips = router.router[l3_constants.FLOATINGIP_KEY]
     external_port = router.get_ex_gw_port()
     return len(floating_ips) and all(ip_lib.device_exists_with_ip_mac(
         self.agent.get_external_device_name(external_port['id']),
         '%s/32' % fip['floating_ip_address'],
         external_port['mac_address'],
         namespace=router.ns_name) for fip in floating_ips)
Example #5
0
 def _assert_floating_ips(self, router):
     floating_ips = router.router[l3_constants.FLOATINGIP_KEY]
     self.assertTrue(len(floating_ips))
     external_port = self.agent._get_ex_gw_port(router)
     for fip in floating_ips:
         self.assertTrue(ip_lib.device_exists_with_ip_mac(
             self.agent.get_external_device_name(external_port['id']),
             '%s/32' % fip['floating_ip_address'],
             external_port['mac_address'],
             router.ns_name, self.root_helper))