Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redfish: Filter empty account slots from ListUsers #6772

Merged

Conversation

mraineri
Copy link
Contributor

SUMMARY

Fixes the output for the ListUsers command in redfish.info to suppress empty account slots for services that do not support POST/DELETE to add/remove users.

Fixex #6771

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

redfish_info.py, redfish_utils.py

ADDITIONAL INFORMATION

Sample playbook; requires a Redfish service that shows empty account slots (like an iDRAC on a Dell PowerEdge server)

---
- hosts: all
  gather_facts: false
  vars:
    username: <REDACTED>
    password: <REDACTED>
    baseuri: <REDACTED>
    default_uri_timeout: 5
    default_uri_retries: 5
  tasks:
  - name: Get users
    community.general.redfish_info:
      category: Accounts
      command: ListUsers
      baseuri: "{{ baseuri }}"
      username: "{{ username }}"
      password: "{{ password }}"
    retries: "{{ default_uri_retries }}"
    register: redfish_results
  - debug:
      var: redfish_results

Before:

ok: [localhost] => {
    "redfish_results": {
        "ansible_facts": {
            "discovered_interpreter_python": "/usr/bin/python3"
        },
        "changed": false,
        "failed": false,
        "redfish_facts": {
            "user": {
                "entries": [
                    {
                        "Enabled": false,
                        "Id": "1",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "None",
                        "UserName": ""
                    },
                    {
                        "Enabled": true,
                        "Id": "2",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "Administrator",
                        "UserName": "root"
                    },
                    {
                        "Enabled": false,
                        "Id": "3",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "4",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "5",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "6",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "7",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "8",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "9",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "10",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "11",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "12",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": true,
                        "Id": "13",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "14",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "15",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "16",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    }
                ],
                "ret": true
            }
        }
    }
}

After:

ok: [localhost] => {
    "redfish_results": {
        "ansible_facts": {
            "discovered_interpreter_python": "/usr/bin/python3"
        },
        "changed": false,
        "failed": false,
        "redfish_facts": {
            "user": {
                "entries": [
                    {
                        "Enabled": true,
                        "Id": "2",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "Administrator",
                        "UserName": "root"
                    }
                ],
                "ret": true
            }
        }
    }
}

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module_utils module_utils plugins plugin (any type) labels Jun 23, 2023
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-6 backport-7 Automatically create a backport for the stable-7 branch labels Jun 24, 2023
Co-authored-by: Felix Fontein <felix@fontein.de>
@felixfontein felixfontein merged commit 93f5a48 into ansible-collections:main Jun 26, 2023
148 checks passed
@patchback
Copy link

patchback bot commented Jun 26, 2023

Backport to stable-6: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-6/93f5a48b8c155ae91cacd44e80a11b7260dfda24/pr-6772

Backported as #6793

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Jun 26, 2023
patchback bot pushed a commit that referenced this pull request Jun 26, 2023
* Redfish: Filter empty account slots from ListUsers

Signed-off-by: Mike Raineri <michael.raineri@dell.com>

* Update 6771-redfish-filter-empty-account-slots.yml

* Update changelogs/fragments/6771-redfish-filter-empty-account-slots.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Signed-off-by: Mike Raineri <michael.raineri@dell.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 93f5a48)
@patchback
Copy link

patchback bot commented Jun 26, 2023

Backport to stable-7: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-7/93f5a48b8c155ae91cacd44e80a11b7260dfda24/pr-6772

Backported as #6794

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein
Copy link
Collaborator

@mraineri thanks for your contribution!

patchback bot pushed a commit that referenced this pull request Jun 26, 2023
* Redfish: Filter empty account slots from ListUsers

Signed-off-by: Mike Raineri <michael.raineri@dell.com>

* Update 6771-redfish-filter-empty-account-slots.yml

* Update changelogs/fragments/6771-redfish-filter-empty-account-slots.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Signed-off-by: Mike Raineri <michael.raineri@dell.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 93f5a48)
felixfontein pushed a commit that referenced this pull request Jun 27, 2023
…slots from ListUsers (#6793)

Redfish: Filter empty account slots from ListUsers (#6772)

* Redfish: Filter empty account slots from ListUsers

Signed-off-by: Mike Raineri <michael.raineri@dell.com>

* Update 6771-redfish-filter-empty-account-slots.yml

* Update changelogs/fragments/6771-redfish-filter-empty-account-slots.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Signed-off-by: Mike Raineri <michael.raineri@dell.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 93f5a48)

Co-authored-by: Mike Raineri <mraineri@gmail.com>
felixfontein pushed a commit that referenced this pull request Jun 27, 2023
…slots from ListUsers (#6794)

Redfish: Filter empty account slots from ListUsers (#6772)

* Redfish: Filter empty account slots from ListUsers

Signed-off-by: Mike Raineri <michael.raineri@dell.com>

* Update 6771-redfish-filter-empty-account-slots.yml

* Update changelogs/fragments/6771-redfish-filter-empty-account-slots.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Signed-off-by: Mike Raineri <michael.raineri@dell.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 93f5a48)

Co-authored-by: Mike Raineri <mraineri@gmail.com>
@mraineri mraineri deleted the Redfish-Empty-Account-Slots-Fix branch May 17, 2024 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-7 Automatically create a backport for the stable-7 branch bug This issue/PR relates to a bug module_utils module_utils plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants