From 93f5a48b8c155ae91cacd44e80a11b7260dfda24 Mon Sep 17 00:00:00 2001 From: Mike Raineri Date: Mon, 26 Jun 2023 17:29:51 -0400 Subject: [PATCH] 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 --- .../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 ffcb739bd6..c16287091e 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -1163,6 +1163,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