Merge "Fix get_ipv6_llas method in the interface driver"

This commit is contained in:
Zuul 2020-08-22 16:39:36 +00:00 committed by Gerrit Code Review
commit 856cae4cf8
2 changed files with 19 additions and 0 deletions

View File

@ -1361,6 +1361,9 @@ def get_devices_with_ip(namespace, name=None, **kwargs):
link_args = {} link_args = {}
if name: if name:
link_args['ifname'] = name link_args['ifname'] = name
scope = kwargs.pop('scope', None)
if scope:
kwargs['scope'] = IP_ADDRESS_SCOPE_NAME[scope]
devices = privileged.get_link_devices(namespace, **link_args) devices = privileged.get_link_devices(namespace, **link_args)
retval = [] retval = []
for parsed_ips in (_parse_link_device(namespace, device, **kwargs) for parsed_ips in (_parse_link_device(namespace, device, **kwargs)

View File

@ -69,6 +69,22 @@ class InterfaceDriverTestCaseMixin(object):
self.interface.set_mtu, self.interface.set_mtu,
device_name=device_name, namespace=namespace)) device_name=device_name, namespace=namespace))
def test_ipv6_lla_create_and_get(self):
lla_address = "fe80::f816:3eff:fe66:73bf/64"
global_address = "2001::1/64"
device_name = utils.get_rand_name()
namespace = self.useFixture(net_helpers.NamespaceFixture())
namespace.ip_wrapper.add_dummy(device_name)
self.interface.add_ipv6_addr(
device_name, lla_address, namespace.name, 'link')
self.interface.add_ipv6_addr(
device_name, global_address, namespace.name, 'global')
existing_addresses = [
a['cidr'] for a in self.interface.get_ipv6_llas(
device_name, namespace.name)]
self.assertIn(lla_address, existing_addresses)
self.assertNotIn(global_address, existing_addresses)
class OVSInterfaceDriverTestCase(linux_base.BaseOVSLinuxTestCase, class OVSInterfaceDriverTestCase(linux_base.BaseOVSLinuxTestCase,
InterfaceDriverTestCaseMixin): InterfaceDriverTestCaseMixin):