dell / iDRAC-Redfish-Scripting

Python and PowerShell scripting for Dell EMC PowerEdge iDRAC REST API with DMTF Redfish
GNU General Public License v2.0
600 stars 278 forks source link

ConvertToRAIDREDFISH.py Key error #199

Closed Kassouma closed 2 years ago

Kassouma commented 2 years ago

Hi team, Thanks for the tool it saves time to operate.

When using Redfish Python/ConvertToRAIDREDFISH.py you will have a keyerror with "PercentComplete"

Example (_venv) $ python ConvertToRAIDREDFISH.py -ip 192.168.235.11 -u root -p calvin -n Disk.Bay.2:Enclosure.Internal.0-1:RAID.Integrated.1-1


-PASS: POST command passed to convert disk "Disk.Bay.2:Enclosure.Internal.0-1:RAID.Integrated.1-1" to RAID, status code 200 returned
- Job ID JID_419384593171 successfully created for storage method "ConvertToRAID"
Traceback (most recent call last):
  File "iDRAC-Redfish-Scripting/Redfish Python/ConvertToRAIDREDFISH.py", line 177, in <module>
    loop_job_status()
  File "iDRAC-Redfish-Scripting/Redfish Python/ConvertToRAIDREDFISH.py", line 163, in loop_job_status
    print("- WARNING, JobStatus not completed, current status: \"%s\", percent complete: \"%s\"" % (data[u'Message'],data[u'PercentComplete']))
KeyError: 'PercentComplete'

adding a try on the variable makes it non invasive and solves the issue Change

 else:
            print("- WARNING, JobStatus not completed, current status: \"%s\", percent complete: \"%s\"" % (data[u'Message'],data[u'PercentComplete']))
            time.sleep(3)

to

            try: 
                print("- WARNING, JobStatus not completed, current status: \"%s\", percent complete: \"%s\"" % (data[u'Message'],data[u'PercentComplete']))
                time.sleep(3)
            except:
                continue
texroemer commented 2 years ago

@Kassouma

Thanks for bringing this to my attention, i updated both scripts for convert to raid, convert to non raid with an exception for checking job status.

Thanks Tex