From 0c2d1eda44048deacbc8e4298cf45497b38a6e17 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 21:50:39 +0200 Subject: [PATCH] [PR #6819/17dce5a2 backport][stable-7] Adding 'Links' to the parameter list for data retrieved from get_disk_inventory (#7141) Adding 'Links' to the parameter list for data retrieved from get_disk_inventory (#6819) * Adding 'Links' parameter to be retrieved from get_disk_inventory * Adding changelog fragment * Updating as per PR suggestions * Updating to return volumes as a list of strings * Updating code to retrieve only volumes under the Links parameter * Updating changelog fragment * Update changelogs/fragments/6819-redfish-utils-add-links-parameter-for-get_disk_inventory.yml Agreed Co-authored-by: Felix Fontein --------- Co-authored-by: Kushal Co-authored-by: Felix Fontein (cherry picked from commit 17dce5a28851e85746a7ab9f85499c86a8b8b6f0) Co-authored-by: TSKushal <44438079+TSKushal@users.noreply.github.com> --- ...-utils-add-links-parameter-for-get_disk_inventory.yml | 2 ++ plugins/module_utils/redfish_utils.py | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/6819-redfish-utils-add-links-parameter-for-get_disk_inventory.yml diff --git a/changelogs/fragments/6819-redfish-utils-add-links-parameter-for-get_disk_inventory.yml b/changelogs/fragments/6819-redfish-utils-add-links-parameter-for-get_disk_inventory.yml new file mode 100644 index 0000000000..b0a5100482 --- /dev/null +++ b/changelogs/fragments/6819-redfish-utils-add-links-parameter-for-get_disk_inventory.yml @@ -0,0 +1,2 @@ +minor_changes: + - redfish_utils module utils - support ``Volumes`` in response for ``GetDiskInventory`` (https://github.com/ansible-collections/community.general/pull/6819). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index 16f0d58f0b..446d3daf7e 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -791,7 +791,7 @@ class RedfishUtils(object): properties = ['BlockSizeBytes', 'CapableSpeedGbs', 'CapacityBytes', 'EncryptionAbility', 'EncryptionStatus', 'FailurePredicted', 'HotspareType', 'Id', 'Identifiers', - 'Manufacturer', 'MediaType', 'Model', 'Name', + 'Links', 'Manufacturer', 'MediaType', 'Model', 'Name', 'PartNumber', 'PhysicalLocation', 'Protocol', 'Revision', 'RotationSpeedRPM', 'SerialNumber', 'Status'] @@ -861,7 +861,12 @@ class RedfishUtils(object): for property in properties: if property in data: if data[property] is not None: - drive_result[property] = data[property] + if property == "Links": + if "Volumes" in data["Links"].keys(): + volumes = [v["@odata.id"] for v in data["Links"]["Volumes"]] + drive_result["Volumes"] = volumes + else: + drive_result[property] = data[property] drive_results.append(drive_result) drives = {'Controller': controller_name, 'Drives': drive_results}