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

Add GetChassisPower command to Chassis category of redfish_facts #54314

Open
wants to merge 8 commits into
base: devel
from

Conversation

Projects
None yet
5 participants
@xmadsen
Copy link
Contributor

commented Mar 25, 2019

SUMMARY

This feature request adds a GetChassisPower command for the Chassis category of redfish_facts. The get_chassis_power() function added to redfish_utils implements the retrieval of various wattage-related data for each chassis in the system.

Fixes #54230

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

redfish_facts
redfish_utils

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

  tasks:

    - name: Get Chassis Power
      redfish_facts:
        category: Chassis
        command: GetChassisPower
        baseuri: "{{ baseuri }}"
        username: "{{ user }}"
        password: "{{ password }}"
ansible-playbook 2.8.0.dev0
  config file = None
  configured module search path = [u'/Users/xandermadsen/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/xandermadsen/ansible/lib/ansible
  executable location = /Users/xandermadsen/ansible/bin/ansible-playbook
  python version = 2.7.15 (default, Feb 12 2019, 11:00:12) [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)]
No config file found; using defaults
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'


PLAYBOOK: test_redfish_facts.yml ***************************************************************************************************
1 plays in /Users/xandermadsen/test_redfish_facts.yml

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

TASK [Get Chassis Power] ***********************************************************************************************************
task path: /Users/xandermadsen/test_redfish_facts.yml:11
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: xandermadsen
<127.0.0.1> EXEC /bin/sh -c 'echo ~xandermadsen && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/xandermadsen/.ansible/tmp/ansible-tmp-1553478912.99-149907692690693 `" && echo ansible-tmp-1553478912.99-149907692690693="` echo /Users/xandermadsen/.ansible/tmp/ansible-tmp-1553478912.99-149907692690693 `" ) && sleep 0'
Using module file /Users/xandermadsen/ansible/lib/ansible/modules/remote_management/redfish/redfish_facts.py
<127.0.0.1> PUT /Users/xandermadsen/.ansible/tmp/ansible-local-645745cjm_F/tmpchwgFC TO /Users/xandermadsen/.ansible/tmp/ansible-tmp-1553478912.99-149907692690693/AnsiballZ_redfish_facts.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /Users/xandermadsen/.ansible/tmp/ansible-tmp-1553478912.99-149907692690693/ /Users/xandermadsen/.ansible/tmp/ansible-tmp-1553478912.99-149907692690693/AnsiballZ_redfish_facts.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/local/opt/python@2/bin/python2.7 /Users/xandermadsen/.ansible/tmp/ansible-tmp-1553478912.99-149907692690693/AnsiballZ_redfish_facts.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /Users/xandermadsen/.ansible/tmp/ansible-tmp-1553478912.99-149907692690693/ > /dev/null 2>&1 && sleep 0'
ok: [localhost] => {
    "ansible_facts": {
        "redfish_facts": {
            "power": {
                "chassis_power": [
                    {
                        "MemberId": "0", 
                        "Name": "Server Power Control", 
                        "PowerAllocatedWatts": 1920, 
                        "PowerAvailableWatts": 0, 
                        "PowerCapacityWatts": 1920, 
                        "PowerConsumedWatts": 234, 
                        "PowerMetrics": {
                            "AverageConsumedWatts": 193.25, 
                            "IntervalInMin": 60, 
                            "MaxConsumedWatts": 242, 
                            "MinConsumedWatts": 184
                        }, 
                        "PowerRequestedWatts": 701, 
                        "Status": {
                            "HealthRollup": "OK", 
                            "State": "Enabled"
                        }
                    }
                ], 
                "ret": true
            }
        }
    }, 
    "changed": false, 
    "invocation": {
        "module_args": {
            "baseuri": "10.240.50.78", 
            "category": [
                "Chassis"
            ], 
            "command": [
                "GetChassisPower"
            ], 
            "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    rescued=0    ignored=0   

@ansibot

This comment has been minimized.

@xmadsen

This comment has been minimized.

Copy link
Contributor Author

commented Mar 25, 2019

@samerhaj

This comment has been minimized.

Copy link

commented Mar 27, 2019

some feedback:

  • RelatedItem[] is a key property to add to the output, as it maps the power reading to the correct component(s) or subsystem, if there are multiple power readings in a chassis

  • MemberId is not needed since this is Redfish collection/array specific element, not useful otherwise

Otherwise, looks good

@billdodd
Copy link
Contributor

left a comment

See inline comment below for one additional comment beyond what @samerhaj mentioned.

lib/ansible/module_utils/redfish_utils.py Outdated
return {'ret': False, 'msg': 'Key Power not found.'}

result['chassis_power'] = chassis_power_results
return result

This comment has been minimized.

Copy link
@billdodd

billdodd Mar 28, 2019

Contributor

This is only returning the chassis power from the first chassis. Also, check the format of the result payload being returned and be sure it matches the structure in psu_inventory and fan_inventory (including the "entries" array ).

This comment has been minimized.

Copy link
@xmadsen

xmadsen Mar 28, 2019

Author Contributor

This should be resolved now.

This comment has been minimized.

Copy link
@billdodd

billdodd Apr 3, 2019

Contributor

Looks like this is not resolved yet. The return statement is within the for loop, so it breaks out after one loop. And the results and not within an "entries" array (see get_psu_inventory() for comparison).

@ansibot ansibot removed the needs_triage label Mar 28, 2019

@billdodd
Copy link
Contributor

left a comment

@xmadsen Sorry for not catching this on the first review, but I found another small issue after some additional testing. See inline comment for an additional suggestion.

Show resolved Hide resolved lib/ansible/module_utils/redfish_utils.py Outdated
@jose-delarosa

This comment has been minimized.

Copy link
Contributor

commented Apr 1, 2019

@xmadsen Please rebase

@xmadsen xmadsen force-pushed the xmadsen:feat/add-getchassispower branch Apr 3, 2019

@billdodd

This comment has been minimized.

Copy link
Contributor

commented Apr 3, 2019

@xmadsen - See this comment I added: #54314 (comment)

@xmadsen xmadsen force-pushed the xmadsen:feat/add-getchassispower branch to 8f4496e Apr 4, 2019

Update lib/ansible/module_utils/redfish_utils.py
Co-Authored-By: xmadsen <xander.madsen@gmail.com>
@xmadsen

This comment has been minimized.

Copy link
Contributor Author

commented Apr 8, 2019

@billdodd updated with your suggested change

@billdodd
Copy link
Contributor

left a comment

@xmadsen - thanks for that update. Looks good.

shipit

@xmadsen

This comment has been minimized.

Copy link
Contributor Author

commented Apr 10, 2019

@jose-delarosa @samerhaj this should be ready to go

@jose-delarosa

This comment has been minimized.

Copy link
Contributor

commented Apr 17, 2019

The key Power is not available in the Dell implementation, but the error is captured correctly.

shipit

@ansibot ansibot added shipit and removed community_review labels Apr 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.