-3

I am trying to write python script for logging into one of my server and do some check . For that I want pass my url ,username and password to script . something like script.py 1.1.1.2 admin admin . i want to use IP ,USERNAME and PASSWORD in my script .I can use it as print IP ?? With below approach am getting credential error

>   File "/usr/lib/python2.6/site-packages/redfish/rest/v1.py", line
> 1064, in login
>     raise InvalidCredentialsError(delay) redfish.rest.v1.InvalidCredentialsError: 10

Here is my script

import sys
from _restobject import RestObject
IP = sys.argv[1]
USERNAME = sys.argv[2]
PASSWORD = sys.argv[3]


def ex3_change_bios_setting(restobj, bios_property, property_value, \
                                                              ):

    sys.stdout.write("\nEXAMPLE 3: Change a BIOS setting\n")
    instances = restobj.search_for_type("HpBios.")

    for instance in instances:
        body = {bios_property: property_value}
        response = restobj.rest_patch(instance["href"], body, \
                                            )
        restobj.error_handler(response)

if __name__ == "__main__":

    iLO_https_url = "https://"+ IP +""
    iLO_account = PASSWORD 
    iLO_password = USERNAME

    #Create a REST object
    REST_OBJ = RestObject(iLO_https_url, iLO_account, iLO_password)
    ex3_change_bios_setting(REST_OBJ, "InternalSDCardSlot", "Disabled")
SARATH CHANDRAN
  • 307
  • 1
  • 6
  • 16
  • Possible duplicate of [How can strings be concatenated?](https://stackoverflow.com/questions/2711579/how-can-strings-be-concatenated) – JeffUK Mar 14 '19 at 11:22

1 Answers1

1

You can concatenate the string with hardcode value by + operator in python. Try this code . It works fine.

IP = sys.argv[1]
USERNAME = sys.argv[2]
PASSWORD = sys.argv[3]

iLO_https_url = "https://"+ IP +""
iLO_account = PASSWORD
iLO_password = USERNAME
Usman
  • 1,983
  • 15
  • 28