HewlettPackard / python-ilorest-library

Python library for interacting with devices which support a Redfish Service
Apache License 2.0
189 stars 92 forks source link

Setting iLO licence example seems to be wrong #100

Closed VladoPortos closed 3 years ago

VladoPortos commented 3 years ago

Hi, In your example to set ilo license you look for uri containing #HpeiLOLicense. and trying to do POST operation on it.

        #Use Resource directory to find the relevant URI
        for instance in resource_instances:
            if '#HpeiLOLicense.' in instance['@odata.type']:
                ilo_lic_uri = instance['@odata.id']

And later on:

resp = _redfishobj.post(ilo_lic_uri, {'LicenseKey' : ilo_key})

However this uri does not support POST operations:

{'@odata.id': '/redfish/v1/Managers/1/LicenseService/1/', '@odata.type': '#HpeiLOLicense.v2_3_0.HpeiLOLicense', 'ETag': 'W/"69DF09CB"', 'HttpMethods': ['GET', 'HEAD', 'DELETE']}

So it will fail with not allowed operation.

VladoPortos commented 3 years ago

Bit more digging and I managed to get it working. Instead calling : /redfish/v1/Managers/1/LicenseService/1/ You need to call: /redfish/v1/Managers/1/LicenseService/

This is how I got to it ( if there is another way let me know )

    for instance in resource_instances:
        if '#Manager.' in instance['@odata.type']:
            manager_uri = instance['@odata.id']
            mager_data = _redfishobj.get(manager_uri)
            ilo_lic_uri = mager_data.obj['Oem']['Hpe']['Links']['LicenseService']['@odata.id']

And than when I do post it works.

rajeevkallur commented 3 years ago

Thanks. Script Updated.