From fd3bc75fb37721425d31c306890cce8380050d5f Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 27 Jun 2023 07:07:58 +0200 Subject: [PATCH] [PR #6772/93f5a48b backport][stable-7] Redfish: Filter empty account slots from ListUsers (#6794) Redfish: Filter empty account slots from ListUsers (#6772) * Redfish: Filter empty account slots from ListUsers Signed-off-by: Mike Raineri * Update 6771-redfish-filter-empty-account-slots.yml * Update changelogs/fragments/6771-redfish-filter-empty-account-slots.yml Co-authored-by: Felix Fontein --------- Signed-off-by: Mike Raineri Co-authored-by: Felix Fontein (cherry picked from commit 93f5a48b8c155ae91cacd44e80a11b7260dfda24) Co-authored-by: Mike Raineri --- .../fragments/6771-redfish-filter-empty-account-slots.yml | 2 ++ plugins/module_utils/redfish_utils.py | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 changelogs/fragments/6771-redfish-filter-empty-account-slots.yml diff --git a/changelogs/fragments/6771-redfish-filter-empty-account-slots.yml b/changelogs/fragments/6771-redfish-filter-empty-account-slots.yml new file mode 100644 index 0000000000..82e74af583 --- /dev/null +++ b/changelogs/fragments/6771-redfish-filter-empty-account-slots.yml @@ -0,0 +1,2 @@ +bugfixes: + - redfish_info - fix ``ListUsers`` to not show empty account slots (https://github.com/ansible-collections/community.general/issues/6771, https://github.com/ansible-collections/community.general/pull/6772). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index 027ce56308..6f010bbc9b 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -1144,6 +1144,12 @@ class RedfishUtils(object): if property in data: user[property] = data[property] + # Filter out empty account slots + # An empty account slot can be detected if the username is an empty + # string and if the account is disabled + if user.get('UserName', '') == '' and not user.get('Enabled', False): + continue + users_results.append(user) result["entries"] = users_results return result