dell/redfish-ansible-module

Job history of iDRAC using Redfish-Ansible module

Closed this issue · 5 comments

Hi,
I am in need of a Redfish API that can validate if a particular job is run most recently in iDRAC 9.

For example:
Remote diagnostic.
Scheduled tart time:
Scheduled end time.

Can we use the redfish URL ?
URL
/redfish/v1/Managers//Jobs/<Job-Id
But we cannot use the job-id because that will vary unlike job name "Remote Diagnostics".
As part of the script we need to collect the such job and its id

Would appreciate your support.

Regards
Ashok Behera

@ashokbeh, I am guessing following is the workflow that you are looking to automate using ansible:

  • Find out whether there are any Remote Diagnostics jobs are running.
  • If yes, then monitor the existing job till completion or failure
  • If not, then create a new remote diagnostics job and monitor the job till completion or failure.
    An ansible-role idrac_diagnostics would be the best for realizing the above workflow. In the meanwhile, following is a sample playbook:
  tasks:
  - name: Get the job queue
    ansible.builtin.uri:
      url: "https://{{ inventory_hostname }}/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/Jobs?$expand=*"
      user: "root"
      password: "Dell_123"
      validate_certs: False
      force_basic_auth: yes
      method: GET
      headers:
        Accept: "application/json"
        OData-Version: "4.0"
      status_code: 200
    register: job_queue_response

  - name: check if a diagnostics job is still running
    ansible.builtin.set_fact:
      diag_jobs: "{{ job_queue_response.json.Members | selectattr('Name', 'eq', 'Remote Diagnostics') }}"
    when:
      - job_queue_response.json["Members@odata.count"] > 0

  - ansible.builtin.debug:
      var: diag_jobs

  - block:
      - name: get the diag job ID if still running
        ansible.builtin.set_fact:
          diag_job_id: "{{ item.Id }}"
          diag_job_running: True
        when:
          - item.JobState == "Running"
        loop: "{{ diag_jobs }}"
    when:
      - diag_jobs is defined and diag_jobs|length > 0

  - ansible.builtin.debug:
      msg: "{{ diag_job_id }} {{ diag_job_running }}"
    when:
      - diag_job_id is defined and diag_job_running is defined

  - block:
      - name: run diagnostics
        ansible.builtin.uri:
          url: "https://{{ inventory_hostname }}/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLCService/Actions/DellLCService.RunePSADiagnostics"
          user: "root"
          password: "Dell_123"
          validate_certs: False
          force_basic_auth: yes
          method: POST
          headers:
            Accept: "application/json"
            Content-Type: "application/json"
            OData-Version: "4.0"
          body:
            RebootJobType: "GracefulRebootWithoutForcedShutdown"
            RunMode: "Express"
          body_format: json
          status_code: [200, 202]
        register: diag_response

      - name: get the job ID
        ansible.builtin.set_fact:
          diag_job_id: "{{ diag_response.location.split('/')[-1] }}"

    when:
      - (diag_job_running is not defined) or (not diag_job_running)

  - name: track job till completion
    dellemc.openmanage.idrac_lifecycle_controller_job_status_info:
      idrac_ip: "{{ inventory_hostname }}"
      idrac_user: "{{ user }}"
      idrac_password: "{{ password }}"
      job_id: "{{ diag_job_id }}"
    register: result
    until: result.job_info.JobStatus == "Completed" or result.job_info.JobStatus == "Failed"
    failed_when: result.job_info.JobStatus == "Failed"
    retries: 6
    delay: 300
    when:
      - diag_job_id

Hi Anupamaloke,

Thank you for sharing the sample Ansible playbook.
I will test and confirm.

Also, to know the most recent "Remote Diagnostic" before we run the next diagnostic test on iDRAC, can we use
URL /redfish/v1/Dell/Managers//DellLCService/Actions/ ?

  • _DellLCService.ExportePSADiagnosticsResul
  • Supported Action — ExportePSADiagnosticsResult
  • Description
  • This method exports the result file of the last completed diagnostics to a remote share (CIFS/NFS). The result file includes time
  • stamps to show when the diagnostics was run.
  • URL
  • /redfish/v1/Dell/Managers//DellLCService/Actions/_
  • DellLCService.ExportePSADiagnosticsResul

The export output contains all the components end time stamp.Thinking if it will be right to consider the end time of test of the last component.

Example: Ended: 09/21/2021 16:31:05, Elapsed time: 00:00:00

** System Management - Functional Test **

Started: 09/21/2021 16:31:05

IPMI Sep 21 2021 13:15:03 Warning. POST Pkg Repair: Memory sensor, redundancy degraded A4 was asserted.

3 records since last scan (Pass=2, Warning=1, Fail=0 Critical=0, Other=0)

Ended: 09/21/2021 16:31:05, Elapsed time: 00:00:00

Test Results : Warning

Msg : Event log - The log contains failing records **

Regards
Ashok Behera

@ashokbeh, you can use the /redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLCService/Actions/DellLCService.ExportePSADiagnosticsResult URI to export the diagnostics logs.

Closing this issue as there has been no update since long.

Thank you for you support Anup.