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

Fix redfish_facts Storage command GetStorageControllerInventory - SimpleStorage not found #52928

Conversation

xmadsen
Copy link
Contributor

@xmadsen xmadsen commented Feb 25, 2019

SUMMARY

This pull request allows the redfish_facts Systems command GetStorageControllerInventory to work as intended, replacing its references to the deprecated SimpleStorage resource, and instead searching through the Storage resource to find storage controller details.

The code now loops through each Storage resource's Members list, and loops through each Member's StorageControllers list, returning each StorageController and its properties as list elements of entries in the module output.

If the Storage resource is not found, a ret: False is returned along with a message stating as much.

Fixes half of #51286 , the other half is fixed by #52939

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

redfish_utils
redfish_facts

ADDITIONAL INFORMATION
- name: Test Redfish modules
  hosts: localhost
  gather_facts: false
  vars:
    baseuri: 10.243.5.31
    user: USERID
    password: PASSW0RD

  tasks:
    - name: Get Storage Controller inventory
      redfish_facts:
        category: Systems
        command: GetStorageControllerInventory
        baseuri: "{{ baseuri }}"
        username: "{{ user }}"
        password: "{{ password }}"

Before:

ansible-playbook 2.8.0.dev0
  config file = None  configured module search path = [u'/home/xander/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /mnt/c/Users/amadsen/Coding/redfish/ansible/lib/ansible  executable location = bin/ansible-playbook  python version = 2.7.12 (default, Nov 12 2018, 14:36:49) [GCC 5.4.0 20160609]
No config file found; using defaults
setting up inventory pluginshost_list declined parsing /etc/ansible/hosts as it did not pass it's verify_file() methodSkipping due to inventory source not existing or not being readable by the current user
script declined parsing /etc/ansible/hosts as it did not pass it's verify_file() methodauto declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
yaml declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
ini declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
toml declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

Loading callback plugin default of type stdout, v2.0 from /mnt/c/Users/amadsen/Coding/redfish/ansible/lib/ansible/plugins/callback/default.pyc

PLAYBOOK: test_redfish_facts.yml ********************************************************************************************************************Positional arguments: ../test_redfish_facts.yml
become_user: root
become_method: sudo
inventory: (u'/etc/ansible/hosts',)
tags: (u'all',)
forks: 5
verbosity: 4
connection: smart
timeout: 10
1 plays in ../test_redfish_facts.yml

PLAY [Test Redfish modules] *************************************************************************************************************************META: ran handlers

TASK [redfish_facts] ********************************************************************************************************************************task path: /mnt/c/Users/amadsen/Coding/redfish/test_redfish_facts.yml:10
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: xander
<127.0.0.1> EXEC /bin/sh -c 'echo ~xander && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/xander/.ansible/tmp/ansible-tmp-1548344056.08-90755211161256 `" && echo ansible-tmp-1548344056.08-90755211161256="` echo /home/xander/.ansible/tmp/ansible-tmp-1548344056.08-90755211161256 `" ) && sleep 0'
Using module file /mnt/c/Users/amadsen/Coding/redfish/ansible/lib/ansible/modules/remote_management/redfish/redfish_facts.py
<127.0.0.1> PUT /home/xander/.ansible/tmp/ansible-local-725hvzXdP/tmpVOEPBn TO /home/xander/.ansible/tmp/ansible-tmp-1548344056.08-90755211161256/AnsiballZ_redfish_facts.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/xander/.ansible/tmp/ansible-tmp-1548344056.08-90755211161256/ /home/xander/.ansible/tmp/ansible-tmp-1548344056.08-90755211161256/AnsiballZ_redfish_facts.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/xander/.ansible/tmp/ansible-tmp-1548344056.08-90755211161256/AnsiballZ_redfish_facts.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/xander/.ansible/tmp/ansible-tmp-1548344056.08-90755211161256/ > /dev/null 2>&1 && sleep 0'
ok: [localhost] => (item=GetStorageControllerInventory) => {
    "ansible_facts": {
        "redfish_facts": {
            "storage_controller": {
                "msg": "SimpleStorage resource not found",
                "ret": false
            }
        }
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "baseuri": "10.240.50.78",
            "category": [
                "Systems"
            ],
            "command": [
                "GetStorageControllerInventory"
            ],
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "username": "USERID"
        }
    },
    "item": "GetStorageControllerInventory"
}
META: ran handlers
META: ran handlers

PLAY RECAP ******************************************************************************************************************************************localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0

After:

ansible-playbook 2.8.0.dev0
  config file = None
  configured module search path = [u'/home/xander/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /mnt/c/Users/amadsen/Coding/lenovo-redfish-automated-testing/ansible/lib/ansible
  executable location = /mnt/c/Users/amadsen/Coding/lenovo-redfish-automated-testing/ansible/bin/ansible-playbook
  python version = 2.7.12 (default, Nov 12 2018, 14:36:49) [GCC 5.4.0 20160609]
No config file found; using defaults
setting up inventory plugins
host_list declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
script declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
yaml declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
ini declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
toml declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

Loading callback plugin default of type stdout, v2.0 from /mnt/c/Users/amadsen/Coding/lenovo-redfish-automated-testing/ansible/lib/ansible/plugins/callback/default.pyc

PLAYBOOK: test_redfish_facts.1.yml **************************************************************************************************************************************************************************************************Positional arguments: ../test_redfish_facts.1.yml
become_method: sudo
inventory: (u'/etc/ansible/hosts',)
forks: 5
tags: (u'all',)
verbosity: 4
connection: smart
timeout: 10
1 plays in ../test_redfish_facts.1.yml

PLAY [Test Redfish modules] *********************************************************************************************************************************************************************************************************META: ran handlers

TASK [Get Storage Controller inventory] *********************************************************************************************************************************************************************************************task path: /mnt/c/Users/amadsen/Coding/lenovo-redfish-automated-testing/test_redfish_facts.1.yml:10
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: xander
<127.0.0.1> EXEC /bin/sh -c 'echo ~xander && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/xander/.ansible/tmp/ansible-tmp-1551109455.82-239082994177190 `" && echo ansible-tmp-1551109455.82-239082994177190="` echo /home/xander/.ansible/tmp/ansible-tmp-1551109455.82-239082994177190 `" ) && sleep 0'
Using module file /mnt/c/Users/amadsen/Coding/lenovo-redfish-automated-testing/ansible/lib/ansible/modules/remote_management/redfish/redfish_facts.py
<127.0.0.1> PUT /home/xander/.ansible/tmp/ansible-local-9175oUCSb/tmpnOpTnm TO /home/xander/.ansible/tmp/ansible-tmp-1551109455.82-239082994177190/AnsiballZ_redfish_facts.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/xander/.ansible/tmp/ansible-tmp-1551109455.82-239082994177190/ /home/xander/.ansible/tmp/ansible-tmp-1551109455.82-239082994177190/AnsiballZ_redfish_facts.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/xander/.ansible/tmp/ansible-tmp-1551109455.82-239082994177190/AnsiballZ_redfish_facts.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/xander/.ansible/tmp/ansible-tmp-1551109455.82-239082994177190/ > /dev/null 2>&1 && sleep 0'
ok: [localhost] => {
    "ansible_facts": {
        "redfish_facts": {
            "storage_controller": {
                "entries": [
                    {
                        "CacheSummary": {
                            "Status": {
                                "State": "Disabled"
                            }, 
                            "TotalCacheSizeMiB": 0
                        }, 
                        "FirmwareVersion": "3.125.11.0", 
                        "Identifiers": [
                            {
                                "DurableName": "97CFBEFAC1C5418586AE130E6CBC5131", 
                                "DurableNameFormat": "UUID"
                            }
                        ], 
                        "Location": {
                            "Info": "Slot 7", 
                            "InfoFormat": "Slot X"
                        }, 
                        "Model": "SAS3408", 
                        "Name": "ThinkSystem 430-8i SAS/SATA 12Gb HBA", 
                        "PartNumber": "SR17A04509", 
                        "SerialNumber": "L2ST76KS481"
                    }, 
                    {
                        "CacheSummary": {
                            "Status": {
                                "State": "Disabled"
                            }, 
                            "TotalCacheSizeMiB": 0
                        }, 
                        "FirmwareVersion": "2.3.10.1085", 
                        "Identifiers": [
                            {
                                "DurableName": "241F1DFA677611E78AE9F4DA8AA0D0DB", 
                                "DurableNameFormat": "UUID"
                            }
                        ], 
                        "Location": {
                            "Info": "Slot 8", 
                            "InfoFormat": "Slot X"
                        }, 
                        "Model": "88SE9230", 
                        "Name": "ThinkSystem M.2 with Mirroring Enablement Kit", 
                        "PartNumber": "SR17A04514", 
                        "SerialNumber": "W1ZS77B00SB"
                    }
                ], 
                "ret": true
            }
        }
    }, 
    "changed": false, 
    "invocation": {
        "module_args": {
            "baseuri": "10.243.5.31", 
            "category": [
                "Systems"
            ], 
            "command": [
                "GetStorageControllerInventory"
            ], 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "username": "USERID"
        }
    }
}
META: ran handlers
META: ran handlers

PLAY RECAP **************************************************************************************************************************************************************************************************************************localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0

@ansibot
Copy link
Contributor

ansibot commented Feb 25, 2019

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. remote_management Working Group: https://docs.ansible.com/ansible/latest/community/communication.html support:community This issue/PR relates to code supported by the Ansible community. labels Feb 25, 2019
Copy link
Contributor

@billdodd billdodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GetStorageControllerInventory changes look good.

But I also see the PSU changes from one of your other PRs. A git flow issue?

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Feb 26, 2019
@xmadsen xmadsen force-pushed the fix_getstoragecontrollerinventory_simplestorage_not_found branch from 866bc6e to 9f10420 Compare February 26, 2019 20:25
@xmadsen
Copy link
Contributor Author

xmadsen commented Feb 26, 2019

@billdodd yep, fixed here :)

@ansibot ansibot removed the module This issue/PR relates to a module. label Feb 26, 2019
Copy link
Contributor

@billdodd billdodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looked good to me and I tested against the DMTF localstorage mockup.

shipit

@jose-delarosa
Copy link
Contributor

Thank you for your patch @xmadsen. Looks good.

shipit

@ansibot ansibot added shipit This PR is ready to be merged by Core and removed community_review In order to be merged, this PR must follow the community review workflow. labels Feb 26, 2019
@jose-delarosa
Copy link
Contributor

Asked Core Team yesterday in IRC to merge but no luck, will try again today.

@gundalow gundalow merged commit 96549bf into ansible:devel Mar 1, 2019
@gundalow
Copy link
Contributor

gundalow commented Mar 1, 2019

@xmadsen Thank you for the bug fix
@jose-delarosa @billdodd Thank you for the reviews

Merged into devel for release in Ansible 2.8

@xmadsen xmadsen deleted the fix_getstoragecontrollerinventory_simplestorage_not_found branch March 1, 2019 18:59
@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. remote_management Working Group: https://docs.ansible.com/ansible/latest/community/communication.html shipit This PR is ready to be merged by Core support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants