inspect_utils, handle bracketed IPv6 redfish addr
If redfish_address is in brackets, unwrap it and check that it is a valid IPv6 address. If that is the case use the unwrapped address to avoid "Name or service not known". Also add a unit test for normal_ipv6_as_url. Closes-Bug: #2036455 Change-Id: I8df20e85e40d8321bd5f88c09fae33b6015bcf51
This commit is contained in:
parent
88fd22de79
commit
21e3e71ea3
@ -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:
|
||||
|
@ -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):
|
||||
|
||||
|
6
releasenotes/notes/bug-2036455-edd0e97335579684.yaml
Normal file
6
releasenotes/notes/bug-2036455-edd0e97335579684.yaml
Normal 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>`_.
|
Loading…
Reference in New Issue
Block a user