dell / dellemc-openmanage-ansible-modules

Dell OpenManage Ansible Modules
GNU General Public License v3.0
340 stars 165 forks source link

Try the legacy jobs URI if the primary jobs URI fails #618

Closed dlehrman closed 7 months ago

dlehrman commented 9 months ago

Description

iDRAC7 and iDRAC8 respond to iDRAC_JOB_URI, but not JOB_URI. This results in a failed condition when exporting SCP with job_wait=true. Falling back from JOB_URI to iDRAC_JOB_URI allows successful job_wait for iDRAC7-9. This PR will try the legacy jobs URI if the primary jobs URI fails.

GitHub Issues

List the GitHub issues impacted by this PR:

GitHub Issue #
Fixes #617

ISSUE TYPE

COMPONENT NAME

idrac_server_config_profile

OUTPUT

After applying the fix in this PR:

$ ansible-playbook idrac_system_info.yml -i inventory.ini --limit <REDACTED-IDRAC8-13G>,<REDACTED-IDRAC7-12G>,<REDACTED-IDRAC9-16G>

PLAY [Get Info] **********************************************************************************************************************

TASK [Export SCP File (job_wait=false)] **********************************************************************************************
ok: [<REDACTED-IDRAC9-16G>]
ok: [<REDACTED-IDRAC8-13G>]
ok: [<REDACTED-IDRAC7-12G>]

TASK [Export SCP File (job_wait=true)] ***********************************************************************************************
ok: [<REDACTED-IDRAC9-16G>]
ok: [<REDACTED-IDRAC8-13G>]
ok: [<REDACTED-IDRAC7-12G>]

PLAY RECAP ***************************************************************************************************************************
<REDACTED-IDRAC8-13G>                 : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
<REDACTED-IDRAC9-16G>          : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
<REDACTED-IDRAC7-12G>                    : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
ADDITIONAL INFORMATION

Output prior to the changes included in this PR:

$ ansible-playbook idrac_system_info.yml -i inventory.ini --limit <REDACTED-IDRAC8-13G>,<REDACTED-IDRAC7-12G>,<REDACTED-IDRAC9-16G>

PLAY [Get Info] **********************************************************************************************************************

TASK [Export SCP File (job_wait=false)] **********************************************************************************************
ok: [<REDACTED-IDRAC9-16G>]
ok: [<REDACTED-IDRAC7-12G>]
ok: [<REDACTED-IDRAC8-13G>]

TASK [Export SCP File (job_wait=true)] ***********************************************************************************************
ok: [<REDACTED-IDRAC9-16G>]
fatal: [<REDACTED-IDRAC7-12G>]: FAILED! => {"changed": false, "error_info": {"error": {"@Message.ExtendedInfo": [{"Message": "Unable to complete the operation because the resource Oem entered in not found.", "MessageArgs": ["Oem"], "MessageArgs@odata.count": 1, "MessageId": "IDRAC.1.6.SYS403", "RelatedProperties": [], "RelatedProperties@odata.count": 0, "Resolution": "Enter the correct resource and retry the operation. For information about valid resource, see the Redfish Users Guide available on the support site.", "Severity": "Critical"}, {"Message": "The resource at the URI Oem was not found.", "MessageArgs": ["Oem"], "MessageArgs@odata.count": 1, "MessageId": "Base.1.2.ResourceMissingAtURI", "RelatedProperties": [""], "RelatedProperties@odata.count": 1, "Resolution": "Place a valid resource at the URI or correct the URI and resubmit the request.", "Severity": "Critical"}], "code": "Base.1.2.GeneralError", "message": "A general error has occurred. See ExtendedInfo for more information"}}, "msg": "HTTP Error 404: Not Found"}
fatal: [<REDACTED-IDRAC8-13G>]: FAILED! => {"changed": false, "error_info": {"error": {"@Message.ExtendedInfo": [{"Message": "Unable to complete the operation because the resource Oem entered is not found.", "MessageArgs": ["Oem"], "MessageArgs@odata.count": 1, "MessageId": "IDRAC.1.6.SYS403", "RelatedProperties": [], "RelatedProperties@odata.count": 0, "Resolution": "Enter the correct resource and retry the operation. For information about valid resource, see the Redfish Users Guide available on the support site.", "Severity": "Critical"}, {"Message": "The resource at the URI Oem was not found.", "MessageArgs": ["Oem"], "MessageArgs@odata.count": 1, "MessageId": "Base.1.2.ResourceMissingAtURI", "RelatedProperties": [""], "RelatedProperties@odata.count": 1, "Resolution": "Place a valid resource at the URI or correct the URI and resubmit the request.", "Severity": "Critical"}], "code": "Base.1.2.GeneralError", "message": "A general error has occurred. See ExtendedInfo for more information"}}, "msg": "HTTP Error 404: Not Found"}

PLAY RECAP ***************************************************************************************************************************
<REDACTED-IDRAC8-13G>                 : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
<REDACTED-IDRAC9-16G>          : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
<REDACTED-IDRAC7-12G>                    : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Playbook used:

---

- name: "Get Info"
  hosts: idrac_supported
  gather_facts: false
  tasks:
    - name: "Export SCP File (job_wait=false)"
      dellemc.openmanage.idrac_server_config_profile:
        idrac_ip: "{{ ipv4_address }}"
        idrac_user: "{{ username }}"
        idrac_password: "{{ password }}"
        share_name: "{{ playbook_dir }}/files/tmp"
        command: "export"
        export_format: "JSON"
        export_use: "Default"
        job_wait: false
        scp_components: "ALL"
        scp_file: "{{ inventory_hostname }}_testing.json"
        validate_certs: false

    - name: "Export SCP File (job_wait=true)"
      dellemc.openmanage.idrac_server_config_profile:
        idrac_ip: "{{ ipv4_address }}"
        idrac_user: "{{ username }}"
        idrac_password: "{{ password }}"
        share_name: "{{ playbook_dir }}/files/tmp"
        command: "export"
        export_format: "JSON"
        export_use: "Default"
        job_wait: true
        scp_components: "ALL"
        scp_file: "{{ inventory_hostname }}_testing.json"
        validate_certs: false

Checklist:

ansible-collections-svc commented 9 months ago

Can one of the admins verify this patch?

codecov-commenter commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 93.26%. Comparing base (14bef55) to head (13dd0aa).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## collections #618 +/- ## ============================================ Coverage 93.26% 93.26% ============================================ Files 195 195 Lines 32303 32300 -3 Branches 4973 4972 -1 ============================================ - Hits 30126 30125 -1 + Misses 1332 1331 -1 + Partials 845 844 -1 ``` | [Flag](https://app.codecov.io/gh/dell/dellemc-openmanage-ansible-modules/pull/618/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell) | Coverage Δ | | |---|---|---| | [units](https://app.codecov.io/gh/dell/dellemc-openmanage-ansible-modules/pull/618/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell) | `93.26% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sachin-apa commented 9 months ago

@dlehrman Can you please update the UT for the above code. All 5 lines added is not covered by the UT. https://github.com/dell/dellemc-openmanage-ansible-modules/pull/618#issuecomment-1951038424

dlehrman commented 8 months ago

@dlehrman Can you please update the UT for the above code. All 5 lines added is not covered by the UT. #618 (comment)

@sachin-apa I was having difficulty figuring out how to trip the exception in the unit test, but discovered a better approach to fix #617 that I believe will be covered by existing unit tests and have updated the PR to include that change.

sachin-apa commented 8 months ago

@dlehrman Looks like the changes is done only for export operation, I think its good to make the changes for import and preview as well to keep it consistent.

dlehrman commented 8 months ago

@dlehrman Looks like the changes is done only for export operation, I think its good to make the changes for import and preview as well to keep it consistent.

@sachin-apa #617 and the changes in this PR are only applicable to the export operation. Import and preview operations already use the wait_for_job_tracking_redfish function.