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: wait until scp is applied (re-created PR) #504

Merged

Conversation

satoshi-tokyo
Copy link
Contributor

Description

Use idrac_redfish_job_tracking in module_utils/utils.py to track job progress so that ansible playbook completes after iDRAC SCP import job is actually completed when "job_wait: True".

GitHub Issues

List the GitHub issues impacted by this PR:

GitHub Issue #
#486

ISSUE TYPE

  • Bugfix Pull Request
COMPONENT NAME

idrac_server_config_profile.py

OUTPUT
# ansible-playbook import_Config_SCP.yml -i inventory -e scp_config="firmware_scp.json" -vvv
ansible-playbook [core 2.14.1]
~~~~~

PLAYBOOK: import_Config_SCP.yml *******************************************************************
1 plays in import_Config_SCP.yml

PLAY [Server Configuration Profile] ***************************************************************

TASK [Import SCP from a network share and wait for this job to get completed] *********************
~~~~~

changed: [idracca] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "ca_path": null,
            "command": "import",
            "end_host_power_state": "On",
            "export_format": "XML",
            "export_use": "Default",
            "idrac_ip": "{iDRAC_IP_ADDRESS}",
            "idrac_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "idrac_port": 443,
            "idrac_user": "root",
            "ignore_certificate_warning": "ignore",
            "import_buffer": null,
            "include_in_export": "default",
            "job_wait": true,
            "proxy_password": null,
            "proxy_port": "80",
            "proxy_server": null,
            "proxy_support": false,
            "proxy_type": "http",
            "proxy_username": null,
            "scp_components": [
                "ALL"
            ],
            "scp_file": "firmware_scp.json",
            "share_name": "{NFS_ADDRESS}",
            "share_password": null,
            "share_user": null,
            "shutdown_type": "Graceful",
            "timeout": 30,
            "validate_certs": false
        }
    },
    "msg": "Successfully imported the Server Configuration Profile.",
    "scp_status": {
        "ActualRunningStartTime": "2023-04-12T16:33:20",
        "ActualRunningStopTime": "2023-04-12T16:42:49",
        "CompletionTime": "2023-04-12T16:42:49",
        "Id": "JID_812848002970",
        "JobState": "Completed",
        "JobType": "ImportConfiguration",
        "Message": "Successfully imported and applied Server Configuration Profile.",
        "MessageArgs": [],
        "MessageId": "SYS053",
        "PercentComplete": 100,
        "TargetSettingsURI": null,
        "file": "{NFS_ADDRESS}/firmware_scp.json",
        "retval": true
    }
}

PLAY RECAP ****************************************************************************************
idracca                    : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

ADDITIONAL INFORMATION

Tested on PowerEdge R650, iDRAC firmware version: 6.10.30.00
Please note that this was based on a fork from v7.4.0.
I checked diff on the below files which are related to my change, between v7.4.0 and my branch, and confirmed that there is no other possible changes.

plugins/module_utils/utils.py
plugins/module_utils/idrac_redfish.py 
plugins/modules/idrac_server_config_profile.py

Checklist:

  • I have performed a self-review of my own code to ensure there are no formatting, vetting, linting, or security issues
  • I have verified that new and existing unit tests pass locally with my changes
  • I have not allowed coverage numbers to degenerate
  • I have maintained at least 90% code coverage
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have maintained backward compatibility

@rajshekarp87
Copy link
Contributor

SCP import is failing with HTTP and HTTPS share when job_wait=true. Checked on iDRAC8 and iDRAC9
iDRAC8 firmware: 2.83.83.83
iDRAC9 firmware: 6.10.80.00

Task output:

fatal: [idrac]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"ca_path": null,
"command": "import",
"end_host_power_state": "On",
"export_format": "XML",
"export_use": "Default",
"idrac_ip": "{{idrac_ip}}",
"idrac_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"idrac_port": 443,
"idrac_user": "root",
"ignore_certificate_warning": "ignore",
"import_buffer": null,
"include_in_export": "default",
"job_wait": true,
"proxy_password": null,
"proxy_port": "80",
"proxy_server": null,
"proxy_support": false,
"proxy_type": "http",
"proxy_username": null,
"scp_components": [
"ALL"
],
"scp_file": "omam_test_scp.json",
"share_name": "{{http/https_share}}",
"share_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"share_user": "{{share_username}}",
"shutdown_type": "Graceful",
"timeout": 30,
"validate_certs": false
}
},
"msg": "Unable to parse json"
}

PLAY RECAP ********************************************************************************************************************************
idrac : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

@satoshi-tokyo
Copy link
Contributor Author

Hi @rajshekarp87
On top of collection 7.6.1 newly installed, I made modification as PR shows. Then I ran import scp playbook, and on our PowerEdge R650 (iDRAC firmware version: 6.10.30.00) it completed as below:

PLAY [Server Configuration Profile] ****************************************************************************************************************************************************************************

TASK [Import SCP from a network share and wait for this job to get completed] **********************************************************************************************************************************
task path: /root/{workdir}/{Playbook}.yml:19
changed: [{hostname}] => {"changed": true, "msg": "Successfully imported the Server Configuration Profile.", "scp_status": {"ActualRunningStartTime": "2023-06-12T18:23:27", "ActualRunningStopTime": "2023-06-12T18:32:49", "CompletionTime": "2023-06-12T18:32:49", "Id": "JID_865618070686", "JobState": "Completed", "JobType": "ImportConfiguration", "Message": "Successfully imported and applied Server Configuration Profile.", "MessageArgs": [], "MessageId": "SYS053", "PercentComplete": 100, "TargetSettingsURI": null, "file": "{NFS_SERVER_IP}:{NFS_SHARE_PATH}/{SCP_NAME}.json", "retval": true}}

PLAY RECAP *****************************************************************************************************************************************************************************************************
{hostname}                    : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Would you kindly check if the scp file is a valid one since the message says "Unable to parse json"?

@rajshekarp87
Copy link
Contributor

Hi @satoshi-tokyo,
SCP file is valid. I hope you are trying with NFS share. But the issue is observed with HTTP and HTTPS share. Can you kindly check

@satoshi-tokyo
Copy link
Contributor Author

satoshi-tokyo commented Jun 13, 2023

@rajshekarp87 Thanks for checking. We use only NFS but added handling of http.

TASK [Import SCP from a network share and wait for this job to get completed] **********************************************************************************************************************************
~~~~

changed: [idraccb] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "ca_path": null,
            "command": "import",
            "end_host_power_state": "On",
            "export_format": "XML",
            "export_use": "Default",
            "idrac_ip": "{IP ADDRESS}",
            "idrac_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "idrac_port": 443,
            "idrac_user": "root",
            "ignore_certificate_warning": "ignore",
            "import_buffer": null,
            "include_in_export": "default",
            "job_wait": true,
            "proxy_password": null,
            "proxy_port": "80",
            "proxy_server": null,
            "proxy_support": false,
            "proxy_type": "http",
            "proxy_username": null,
            "scp_components": [
                "ALL"
            ],
            "scp_file": "{SCP FILE NAME}.json",
            "share_name": "http://{SHARE PATH}",
            "share_password": null,
            "share_user": null,
            "shutdown_type": "Graceful",
            "timeout": 30,
            "validate_certs": false
        }
    },
    "msg": "Successfully imported the Server Configuration Profile.",
    "scp_status": {
        "ActualRunningStartTime": "2023-06-13T19:57:50",
        "ActualRunningStopTime": "2023-06-13T20:07:12",
        "CompletionTime": "2023-06-13T20:07:12",
        "Id": "JID_866538704758",
        "JobState": "Completed",
        "JobType": "ImportConfiguration",
        "Message": "Successfully imported and applied Server Configuration Profile.",
        "MessageArgs": [],
        "MessageId": "SYS053",
        "PercentComplete": 100,
        "TargetSettingsURI": null,
        "file": "http://{SHARE PATH}/{SCP FILE NAME}.json",
        "retval": true
    }
}

PLAY RECAP *****************************************************************************************************************************************************************************************************
idraccb                    : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

@sachin-apa sachin-apa added the validation/completed Validation is completed label Jun 21, 2023
@sachin-apa sachin-apa added this to the v8.0.0 milestone Jun 21, 2023
@satoshi-tokyo satoshi-tokyo force-pushed the fix/wait-until-scp-is-applied branch from 2a83a8b to 7d33082 Compare June 23, 2023 11:37
fix: add idrac_redfish_job_tracking for http share
@satoshi-tokyo satoshi-tokyo force-pushed the fix/wait-until-scp-is-applied branch from 7d33082 to 2e50239 Compare June 23, 2023 11:47
@sachin-apa
Copy link
Collaborator

The UT's are failing because of some changes in devl. Will be merging this and we will take care of this to checkout stable branches in the next PR releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validation/completed Validation is completed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants