Skip to content
Jack Garcia edited this page May 25, 2017 · 1 revision

If not created already, create an instance of Rest or Redfish Object using the RestObject or RedfishObject class respectively. The class constructor takes iLO hostname/ ip address, iLO login username and password as arguments.

Rest Object creation:

REST_OBJ = RestObject(iLO_host, login_account, login_password)

Redfish Object creation:

REDFISH_OBJ = RedfishObject(iLO_host, login_account, login_password)

Example 2: Get base registry

The method ex2_get_base_registry takes an instance of rest object ( or redfish object if using Redfish API) as argument.

def ex2_get_base_registry(restobj):

A Restful GET request is performed next by calling the Rest object's get method with the registries uri ('/rest/v1/registries') as parameter. For Redfish RESTful request the URI is ('/redfish/v1/registries')

response = restobj.rest_get("/rest/v1/Registries")

From the response body for each "Location" in "Items" with "Base" or "iLO" Id , a GET request in performed with the URI retrieved from ["Location"]["Uri"]["extref"].

for entry in response.dict["Items"]:
       if entry["Id"] not in ["Base", "iLO"]:
           continue
       for location in entry["Location"]:
           reg_resp = restobj.rest_get(location["Uri"]["extref"])

For successful response status, messages are added to MESSAGE_REGISTRIES.

if reg_resp.status == 200:
    sys.stdout.write("\tFound " + entry["Id"] + " at " + \
                                location["Uri"]["extref"] + "\n")
    MESSAGE_REGISTRIES[entry["Id"]] = reg_resp.dict["Messages"]
else:
    sys.stdout.write("\t" + entry["Id"] + " not found at "\
                                + location["Uri"]["extref"] + "\n")
Clone this wiki locally