Skip to content

Commit

Permalink
Merge pull request #175 from stackhpc/upstream/2023.1-2024-09-02
Browse files Browse the repository at this point in the history
Synchronise 2023.1 with upstream
  • Loading branch information
priteau authored Sep 5, 2024
2 parents 6554f1d + 33f1d27 commit ef1905f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
18 changes: 18 additions & 0 deletions neutron/common/ipv6_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"""
IPv6-related utilities and helper functions.
"""
import ipaddress

import netaddr
from neutron_lib import constants as const
from oslo_log import log
Expand Down Expand Up @@ -56,3 +58,19 @@ 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
3 changes: 3 additions & 0 deletions neutron/common/ovn/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

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
Expand Down Expand Up @@ -605,6 +606,8 @@ def get_system_dns_resolvers(resolver_file=DNS_RESOLVER_FILE):
valid_ip = (netutils.is_valid_ipv4(line, strict=True) or
netutils.is_valid_ipv6(line))
if valid_ip:
if netutils.is_valid_ipv6(line):
line = ipv6_utils.get_noscope_ipv6(line)
resolvers.append(line)

return resolvers
Expand Down
13 changes: 13 additions & 0 deletions neutron/tests/unit/common/test_ipv6_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,16 @@ def test_valid_hostname_url(self):
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:::')
10 changes: 0 additions & 10 deletions zuul.d/job-templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@
- openstack-tox-py310: # from openstack-python3-jobs template
timeout: 3600
irrelevant-files: *irrelevant-files
# NOTE(ralonsoh): to be updated when "openstack-tox-py311" is defined
# and added to "openstack-python3-jobs" template.
- tox-py311:
voting: false
timeout: 3600
irrelevant-files: *irrelevant-files
- openstack-tox-cover: # from openstack-cover-jobs template
timeout: 4800
irrelevant-files: *irrelevant-files
Expand Down Expand Up @@ -89,10 +83,6 @@
name: neutron-periodic-jobs
periodic:
jobs:
# NOTE(ralonsoh): to be removed when "openstack-tox-py311" is defined
# and added to "openstack-python3-jobs" template.
- tox-py311:
timeout: 3600
- neutron-functional
- neutron-functional-with-uwsgi-fips
- neutron-fullstack
Expand Down

0 comments on commit ef1905f

Please sign in to comment.