Closed spicerlabs closed 2 years ago
Hi @spicerlabs
Can you tell me which version of python you're running? I have version 3.9 installed and using version 4 of the script, no issues.
C:\Python39>GetSetPowerStateREDFISH_test.py -ip 192.168.0.130 -u root -p calvin -g
- INFO, Current server power state is: On
- Supported values for server power control are:
On
ForceOff
ForceRestart
GracefulRestart
GracefulShutdown
PushPowerButton
Nmi
PowerCycle
Thanks Tex
@spicerlabs could it be that your S:\GetSetPowerStateREDFISH.py
is an HTML file and not a Python file? Instead of downloading https://github.com/dell/iDRAC-Redfish-Scripting/blob/master/Redfish%20Python/GetSetPowerStateREDFISH.py
, get the raw version from https://raw.githubusercontent.com/dell/iDRAC-Redfish-Scripting/master/Redfish%20Python/GetSetPowerStateREDFISH.py
or clone the repo.
@texroemer I've installed python-3.10.4-amd64 and I'm getting so many warnings and errors. @ajya I think while importing the modules it's getting an error. I'm just a beginner at this kind of script.
Hi @spicerlabs
Are you using the raw link to to download the script from GitHub? If you don't use the raw link you'll run into multiple issues.
Example below of downloading raw link.
[root@localhost /]# python3
Python 3.6.8 (default, Mar 18 2021, 08:58:41)
[GCC 8.4.1 20200928 (Red Hat 8.4.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> get_script = requests.get("https://raw.githubusercontent.com/dell/iDRAC-Redfish-Scripting/master/Redfish%20Python/GetSetPowerStateREDFISH.py")
>>>
>>> with open("GetSetPowerStateREDFISH.py", "w") as x:
... x.writelines(get_script.text)
...
>>> exit()
[root@localhost /]# chmod +x GetSetPowerStateREDFISH.py
[root@localhost /]# python3 GetSetPowerStateREDFISH.py -h
usage: GetSetPowerStateREDFISH.py [-h] -ip IP -u U -p P
(--script-examples | -g | -r R)
Python script using Redfish API to either get current server power state and
possible power state values or execute server power state change
optional arguments:
-h, --help show this help message and exit
-ip IP iDRAC IP address
-u U iDRAC username
-p P iDRAC password
--script-examples Prints a set of examples for this script.
-g Get current power state of the server and possible values
for ComputerSystem.Reset.
-r R Pass in the computer system reset type you want to
perform. To get supported possible values, execute the
script with -g argument
[root@localhost /]#
S:>GetSetPowerStateREDFISH.py root password File "S:\GetSetPowerStateREDFISH.py", line 7 <!DOCTYPE html> ^ SyntaxError: invalid syntax