Merge "inspect_utils, handle bracketed IPv6 redfish addr"

This commit is contained in:
Zuul 2023-09-19 17:41:21 +00:00 committed by Gerrit Code Review
commit bc1c89d993
3 changed files with 21 additions and 0 deletions

View File

@ -342,6 +342,9 @@ def _get_bmc_addresses(node):
if '//' in address:
address = urllib.parse.urlparse(address).hostname
# Strip brackets in case used on IPv6 address.
address = address.strip('[').strip(']')
try:
addrinfo = socket.getaddrinfo(address, None, proto=socket.SOL_TCP)
except socket.gaierror as exc:

View File

@ -442,6 +442,12 @@ class GetBMCAddressesTestCase(db_base.DbTestCase):
driver_info={'redfish_address': 'https://192.0.2.1/redfish'})
self.assertEqual({'192.0.2.1'}, utils._get_bmc_addresses(node))
def test_normal_ipv6_as_url(self):
node = obj_utils.create_test_node(
self.context,
driver_info={'redfish_address': 'https://[2001:db8::42]/redfish'})
self.assertEqual({'2001:db8::42'}, utils._get_bmc_addresses(node))
@mock.patch.object(socket, 'getaddrinfo', autospec=True)
def test_resolved_host(self, mock_getaddrinfo):
mock_getaddrinfo.return_value = [
@ -474,6 +480,12 @@ class GetBMCAddressesTestCase(db_base.DbTestCase):
mock_getaddrinfo.assert_called_once_with(
'example.com', None, proto=socket.SOL_TCP)
def test_redfish_bmc_address_ipv6_brackets_no_scheme(self):
node = obj_utils.create_test_node(
self.context,
driver_info={'redfish_address': '[2001:db8::42]'})
self.assertEqual({'2001:db8::42'}, utils._get_bmc_addresses(node))
class LookupCacheTestCase(db_base.DbTestCase):

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes an issue where inspection would fail if an IPv6 address wrapped in
brackets is used for the redfish BMC address. See bug:
`2036455 <https://bugs.launchpad.net/ironic/+bug/2036455>`_.