Skip to content

Commit ef1905f

Browse files
authored
Merge pull request #175 from stackhpc/upstream/2023.1-2024-09-02
Synchronise 2023.1 with upstream
2 parents 6554f1d + 33f1d27 commit ef1905f

File tree

4 files changed

+34
-10
lines changed

4 files changed

+34
-10
lines changed

neutron/common/ipv6_utils.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"""
1717
IPv6-related utilities and helper functions.
1818
"""
19+
import ipaddress
20+
1921
import netaddr
2022
from neutron_lib import constants as const
2123
from oslo_log import log
@@ -56,3 +58,19 @@ def valid_ipv6_url(host, port):
5658
else:
5759
uri = '%s:%s' % (host, port)
5860
return uri
61+
62+
63+
# TODO(egarciar): Remove and use oslo.utils version of this function whenever
64+
# it is available for Neutron.
65+
# https://review.opendev.org/c/openstack/oslo.utils/+/925469
66+
def get_noscope_ipv6(address):
67+
try:
68+
_ipv6 = ipaddress.IPv6Address(address)
69+
if _ipv6.scope_id:
70+
address = address.removesuffix('%' + _ipv6.scope_id)
71+
return address
72+
except (ipaddress.AddressValueError, AttributeError):
73+
if netutils.is_valid_ipv6(address):
74+
parts = address.rsplit("%", 1)
75+
return parts[0]
76+
raise

neutron/common/ovn/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
from neutron._i18n import _
4343
from neutron.common import _constants as n_const
44+
from neutron.common import ipv6_utils
4445
from neutron.common.ovn import constants
4546
from neutron.common.ovn import exceptions as ovn_exc
4647
from neutron.common import utils as common_utils
@@ -605,6 +606,8 @@ def get_system_dns_resolvers(resolver_file=DNS_RESOLVER_FILE):
605606
valid_ip = (netutils.is_valid_ipv4(line, strict=True) or
606607
netutils.is_valid_ipv6(line))
607608
if valid_ip:
609+
if netutils.is_valid_ipv6(line):
610+
line = ipv6_utils.get_noscope_ipv6(line)
608611
resolvers.append(line)
609612

610613
return resolvers

neutron/tests/unit/common/test_ipv6_utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,16 @@ def test_valid_hostname_url(self):
9898
port = 443
9999
self.assertEqual("controller:443",
100100
ipv6_utils.valid_ipv6_url(host, port))
101+
102+
103+
class TestNoscopeIpv6(base.BaseTestCase):
104+
def test_get_noscope_ipv6(self):
105+
self.assertEqual('2001:db8::f0:42:8329',
106+
ipv6_utils.get_noscope_ipv6('2001:db8::f0:42:8329%1'))
107+
self.assertEqual('ff02::5678',
108+
ipv6_utils.get_noscope_ipv6('ff02::5678%eth0'))
109+
self.assertEqual('fe80::1',
110+
ipv6_utils.get_noscope_ipv6('fe80::1%eth0'))
111+
self.assertEqual('::1', ipv6_utils.get_noscope_ipv6('::1%eth0'))
112+
self.assertEqual('::1', ipv6_utils.get_noscope_ipv6('::1'))
113+
self.assertRaises(ValueError, ipv6_utils.get_noscope_ipv6, '::132:::')

zuul.d/job-templates.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
- openstack-tox-py310: # from openstack-python3-jobs template
3131
timeout: 3600
3232
irrelevant-files: *irrelevant-files
33-
# NOTE(ralonsoh): to be updated when "openstack-tox-py311" is defined
34-
# and added to "openstack-python3-jobs" template.
35-
- tox-py311:
36-
voting: false
37-
timeout: 3600
38-
irrelevant-files: *irrelevant-files
3933
- openstack-tox-cover: # from openstack-cover-jobs template
4034
timeout: 4800
4135
irrelevant-files: *irrelevant-files
@@ -89,10 +83,6 @@
8983
name: neutron-periodic-jobs
9084
periodic:
9185
jobs:
92-
# NOTE(ralonsoh): to be removed when "openstack-tox-py311" is defined
93-
# and added to "openstack-python3-jobs" template.
94-
- tox-py311:
95-
timeout: 3600
9686
- neutron-functional
9787
- neutron-functional-with-uwsgi-fips
9888
- neutron-fullstack

0 commit comments

Comments
 (0)