Skip to content

Get resource directory

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

First 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. The class also initializes a login session, gets systems resources and message registries.

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 1: Get resource directory

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

def ex1_get_resource_directory(restobj):

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

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

For a successful response status, resource directory is retrieved from the response body.

if response.status == 200:
       sys.stdout.write("\tFound resource directory at /rest/v1/resource" \
                                                           "directory" + "\n")
       SYSTEMS_RESOURCES["resources"] = response.dict["Instances"]

else:
       sys.stderr.write("\tResource directory missing at /rest/v1/resource" \
                                                           "directory" + "\n")
Clone this wiki locally