.. image:: /images/hpe_logo2.png
   :width: 150pt

|

.. toctree::
   :maxdepth: 1

First create an instance of Rest or Redfish Object using the **RestObject** or
**RedfishObject** class respectively. The class constructor takes iLO hostname/
ip address formatted as a string ("https://xx.xx.xx.xx"), iLO login username
and password as arguments. The class also initializes a login session, gets
systems resources and message registries.

Rest Object creation:

.. code-block:: python

 REST_OBJ = RestObject(iLO_https_host, login_account, login_password)

Redfish Object creation:

.. code-block:: python

 REDFISH_OBJ = RedfishObject(iLO_https_host, login_account, login_password)

Example 45: Get license key
===========================

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

.. code-block:: python

 def ex45_get_license_key(restobj):

Find and get the system resource for HpSmartStorageArrayController.

.. code-block:: python

 instances = restobj.search_for_type("HpiLOLicense.")

Create a dictionary to hold license results. Create a list of license
properties.

.. code-block:: python

 license_result = dict()
 licenseproperties = ["License", "LicenseKey", "LicenseType"]

Send HTTP GET request to the system URI(s).

.. code-block:: python

 for instance in instances:
     response = restobj.rest_get(instance["href"])

For each license property, check the license property from the response body.
Then print the value.

.. code-block:: python

 for licenseproperty in licenseproperties:
     sys.stdout.write("\t" + licenseproperty + ": " + \
                       str(response.dict[licenseproperty]) + "\n")
