dell / iDRAC-Redfish-Scripting

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

ChangeIdracUserPasswordREDFISH.py unsupported operand type(s) for %: 'NoneType' and 'int' #94

Closed Rouzax closed 4 years ago

Rouzax commented 4 years ago

Running https://github.com/dell/iDRAC-Redfish-Scripting/blob/master/Redfish%20Python/ChangeIdracUserPasswordREDFISH.py will give

ChangeIdracUserPasswordREDFISH.py 10.0.40.12 root calvin 2 test

- FAIL, status code %s returned, password was not changed
Traceback (most recent call last):
  File "C:\TEMP\Python\ChangeIdracUserPasswordREDFISH.py", line 66, in <module>
    set_idrac_user_password()
  File "C:\TEMP\Python\ChangeIdracUserPasswordREDFISH.py", line 51, in set_idrac_user_password
    print("\n- FAIL, status code %s returned, password was not changed") % statusCode
TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'

Running Python 3.8.2 Server in question is R930 with iDRAC 2.70.70.70

texroemer commented 4 years ago

Hi @Rouzax

Typo in print statement when i made the update from Python 2 to Python 3. Script has been corrected and uploaded to GitHub. I also updated the script to use argparse, be consistent with other Python scripts. I also added support to get iDRAC user account information.

Example of executing new script:

C:\Python38-32>python3 ChangeIdracUserPasswordREDFISH.py -h usage: ChangeIdracUserPasswordREDFISH.py [-h] -ip IP -u U -p P [-g G] [-id ID] [-np NP]

Python script using Redfish API with OEM extension to change iDRAC username password. Once the password is changed, the script will also execute a GET command to verify the password change was successful.

positional arguments: script_examples ChangeIdracUserPasswordREDFISH.py -ip 192.168.0.120 -u root -p calvin -g y, this example will get user account information for all iDRAC users. ChangeIdracUserPasswordREDFISH.py -ip 192.168.0.120 -u user -p calvin -id 3 -np pAssw0rd, this example shows changing iDRAC user ID 3 password.

optional arguments: -h, --help show this help message and exit -ip IP iDRAC IP address -u U iDRAC username -p P iDRAC password -g G Get iDRAC user account information, pass in "y". This will return detailed information for each iDRAC user account. -id ID Pass in the iDRAC user account ID you want to change the password for. If needed, use argument -g to get the iDRAC user account ID. -np NP Pass in the new password you want to set for the iDRAC user ID.

C:\Python38-32>python3 ChangeIdracUserPasswordREDFISH.py -ip 192.168.0.120 -u user3 -p calvin -id 3 -np p@ssw0rd