diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index 0d5557ecb..c8627e605 100644 --- a/ironic_python_agent/hardware.py +++ b/ironic_python_agent/hardware.py @@ -274,11 +274,15 @@ def _get_multipath_parent_device(device): # size=56G features='1 retain_attached_hw_handler' hwhandler='0' wp=rw # `-+- policy='service-time 0' prio=1 status=active # `- 0:0:0:0 sda 8:0 active ready running + # Other format: + # mpathat (wwid/alias) device_name vendor,product try: lines = out.splitlines() - mpath_device = lines[0].split(' ')[1] - # give back something like dm-0 so we can log it. - return mpath_device + mpath_device_out = lines[0].split(' ') + for mpath_device in mpath_device_out: + if mpath_device.startswith("dm"): + # give back something like dm-0 so we can log it. + return mpath_device except IndexError: # We didn't get any command output, so Nope. pass diff --git a/ironic_python_agent/tests/unit/samples/hardware_samples.py b/ironic_python_agent/tests/unit/samples/hardware_samples.py index 5e588eb8e..93a63ac56 100644 --- a/ironic_python_agent/tests/unit/samples/hardware_samples.py +++ b/ironic_python_agent/tests/unit/samples/hardware_samples.py @@ -1764,7 +1764,7 @@ MULTIPATH_VALID_PATH = '%s is a valid multipath device path' MULTIPATH_INVALID_PATH = '%s is not a valid multipath device path' MULTIPATH_LINKS_DM = ( - 'SUPER_FRIENDLY_NAME %s ATA,INTEL SSDSC2CT06\n' + 'SUPER_FRIENDLY_ NAME (12345) %s ATA, INTEL SSDSC2CT06\n' 'size=56G features=\'1 retain_attached_hw_handler\' hwhandler=\'0\' wp=rw\n' # noqa ' `-+- policy=\'service-time 0\' prio=1 status=active\n' ' `- 0:0:0:0 device s 8:0 active ready running\n' diff --git a/releasenotes/notes/fix-multipath-parent-device-e85afad63159250c.yaml b/releasenotes/notes/fix-multipath-parent-device-e85afad63159250c.yaml new file mode 100644 index 000000000..31312edbe --- /dev/null +++ b/releasenotes/notes/fix-multipath-parent-device-e85afad63159250c.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fix the logic to detect the right parent device for a given multipath + device.