Use oslo netutils for get_noscope_ipv6 function
We needed to declare get_noscope_ipv6() on ipv6_netutils in Neutron while this function was made avaliable in oslo.utils. This is not needed anymore. Related-Bug: #2073894 Change-Id: I76a1c9f75906e8c0bd0ad368c55f01d58811b42d
This commit is contained in:
@@ -16,8 +16,6 @@
|
||||
"""
|
||||
IPv6-related utilities and helper functions.
|
||||
"""
|
||||
import ipaddress
|
||||
|
||||
import netaddr
|
||||
from neutron_lib import constants as const
|
||||
from oslo_log import log
|
||||
@@ -58,19 +56,3 @@ def valid_ipv6_url(host, port):
|
||||
else:
|
||||
uri = '%s:%s' % (host, port)
|
||||
return uri
|
||||
|
||||
|
||||
# TODO(egarciar): Remove and use oslo.utils version of this function whenever
|
||||
# it is available for Neutron.
|
||||
# https://review.opendev.org/c/openstack/oslo.utils/+/925469
|
||||
def get_noscope_ipv6(address):
|
||||
try:
|
||||
_ipv6 = ipaddress.IPv6Address(address)
|
||||
if _ipv6.scope_id:
|
||||
address = address.removesuffix('%' + _ipv6.scope_id)
|
||||
return address
|
||||
except (ipaddress.AddressValueError, AttributeError):
|
||||
if netutils.is_valid_ipv6(address):
|
||||
parts = address.rsplit("%", 1)
|
||||
return parts[0]
|
||||
raise
|
||||
|
||||
@@ -44,7 +44,6 @@ import tenacity
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.common import _constants as n_const
|
||||
from neutron.common import ipv6_utils
|
||||
from neutron.common.ovn import constants
|
||||
from neutron.common.ovn import exceptions as ovn_exc
|
||||
from neutron.common import utils as common_utils
|
||||
@@ -677,7 +676,7 @@ def get_system_dns_resolvers(resolver_file=DNS_RESOLVER_FILE):
|
||||
netutils.is_valid_ipv6(line))
|
||||
if valid_ip:
|
||||
if netutils.is_valid_ipv6(line):
|
||||
line = ipv6_utils.get_noscope_ipv6(line)
|
||||
line = netutils.get_noscope_ipv6(line)
|
||||
resolvers.append(line)
|
||||
|
||||
return resolvers
|
||||
|
||||
@@ -98,16 +98,3 @@ class TestValidIpv6URL(base.BaseTestCase):
|
||||
port = 443
|
||||
self.assertEqual("controller:443",
|
||||
ipv6_utils.valid_ipv6_url(host, port))
|
||||
|
||||
|
||||
class TestNoscopeIpv6(base.BaseTestCase):
|
||||
def test_get_noscope_ipv6(self):
|
||||
self.assertEqual('2001:db8::f0:42:8329',
|
||||
ipv6_utils.get_noscope_ipv6('2001:db8::f0:42:8329%1'))
|
||||
self.assertEqual('ff02::5678',
|
||||
ipv6_utils.get_noscope_ipv6('ff02::5678%eth0'))
|
||||
self.assertEqual('fe80::1',
|
||||
ipv6_utils.get_noscope_ipv6('fe80::1%eth0'))
|
||||
self.assertEqual('::1', ipv6_utils.get_noscope_ipv6('::1%eth0'))
|
||||
self.assertEqual('::1', ipv6_utils.get_noscope_ipv6('::1'))
|
||||
self.assertRaises(ValueError, ipv6_utils.get_noscope_ipv6, '::132:::')
|
||||
|
||||
@@ -39,7 +39,7 @@ oslo.rootwrap>=5.15.0 # Apache-2.0
|
||||
oslo.serialization>=5.5.0 # Apache-2.0
|
||||
oslo.service>=3.5.0 # Apache-2.0
|
||||
oslo.upgradecheck>=1.3.0 # Apache-2.0
|
||||
oslo.utils>=7.0.0 # Apache-2.0
|
||||
oslo.utils>=7.3.0 # Apache-2.0
|
||||
oslo.versionedobjects>=1.35.1 # Apache-2.0
|
||||
osprofiler>=2.3.0 # Apache-2.0
|
||||
os-ken>=2.2.0 # Apache-2.0
|
||||
|
||||
Reference in New Issue
Block a user