Closed hassan-ayo closed 4 years ago
Do you have the "get_resource_directory.py" file in the same directory as the "add_user_account.py" script you are running?
If not, you could move it there, or you could remove/comment out the lines
25#from get_resource_directory import get_resource_directory
29#resource_instances = get_resource_directory(_redfishobj)
And change:
111DISABLE_RESOURCE_DIR = False
to DISABLE_RESOURCE_DIR = True
Thank you it works for get_resource-directory .
I dont know what is wrong with RedfishClient , I get the error bellow
from redfish import Redfishclient ImportError : cannot import name RedfishClient
Thank you
from redfish import Redfishclient ImportError : cannot import name RedfishClient
Could you try reinstalling the library? Either build from source, or pip install python-ilorest-library
yes I unistall it and install it many time using pip , but still stuck with redfishClient import error
Cannot find reference "RedfishClient" in "--init--.py"
@hassan-ayo Which version of the library are you using? 3.0 was the first version we started using the RedfishClient class.
yep it's python-ilorest-library-3.0.0
Do you also have the DMTF python-redfish-library installed? Because of Python's packaging mechanism installing both of them will result in overwritten files, which can cause these type of errors.
right , the python-redfish-library was installed , I remove it and the script works properly .
on some iLO it doesn't create the account , it gives me the message [ { "MessageArgs": [ "RoleId" ], "MessageId": "Base.0.10.PropertyUnknown" } ]
On the most iLO it works fine but some iLO no ( I am using only iLO4 and 5)
Maybe the is more properties on iLO5 and less on iLO4
iLO 4 does not support adding an account by RoleId
you must use the privilege dictionary. We may need to update the example to ensure this also works on iLO 4 Redfish.
Thank you so much for your help
I am trying the modify the script to work also for iLO4 , is there any suggestion to disable the Role_ID after that I will keep only 5 privilege dictionary to much with iLO4
body = {"RoleId": role_id}
The above statement will not apply to you.
Additionally, you may need to reduce your privilege dictionary to include only the following keys:
['LoginPriv', 'RemoteConsolePriv', 'UserConfigPriv', 'VirtualMediaPriv', 'VirtualPowerAndResetPriv', 'iLOConfigPriv']
'HostNICConfigPriv', 'HostBIOSConfigPriv', 'HostStorageConfigPriv' and 'SystemRecoveryConfigPriv'
are likely not supported in your iLO version.
(You can verify the privileges by performing a get on any of the accounts in /redfish/v1/AccountService/Accounts/, 'i.e: _redfishobj.get('/redfish/v1/AccountService/Accounts/1/') or by referencing the manager accounts schema (/redfish/v1/SchemaStore/en/HpiLOAccount.json/)
Thank you for your feed back
The privilege dictionary is reduced to match with iLO4 , but my question is how to disable the "body" parameter, it's everywhere in the function :
The body is just a variable to hold the values needed for the post command. Here is a stripped down version of the script that will add a new user account on a Gen9 server. Hopefully that will help you understand what we are doing in our example.
Let me know if that helps you.
Thank you for sharing the doc , I will test it and get back to you Regards
Hey there, thanks a lot for all the helpful info. I was able to get it working for iLO 5 for adding a user. I have a generic code based on the example shared that can be easily converted to iLO 4 if you want:
import sys
import requests
server_ipmiAddress = "x.x.x.x"
server_user = "xxxxxx"
server_pass = "xxxxxxx"
body = {'Oem': {'Hpe': {'Privileges': {"LoginPriv": True, "RemoteConsolePriv": True,
"UserConfigPriv": True, "VirtualMediaPriv": True, "VirtualPowerAndResetPriv": True,
"iLOConfigPriv": True, "HostNICConfigPriv": True, "HostBIOSConfigPriv": True, "HostStorageConfigPriv": True, "SystemRecoveryConfigPriv": True},
'LoginName': 'testuser'}},'UserName': 'newuser', 'Password': 'newpasswrod'}
ilo_headers={'Content-type':'application/json', 'Accept':'application/json'}
request_status = requests.post("https://" + server_ipmiAddress + "/redfish/v1/AccountService/Accounts/", headers=ilo_headers, verify=False, auth=(server_user, server_pass), json=body)
sys.stdout.write("%s\n" % request_status)
Hope that helps :)
You are welcome. Your suggestions are noted and will be incorporated into the next release Please let us know if you have any further questions,
I forgot to mention one thing, iLO 4 uses the value 'Hp' instead of 'Hpe' in body, else it will give the MessageId": "Base.0.10.PropertyUnknown response. So you need to change that also for iLO 4.
Fixed. Add User Account is fixed for Gen9 as well. Same script should work for both gen9 and gen10 https://github.com/HewlettPackard/python-ilorest-library/blob/master/examples/Redfish/add_user_account.py
yes I unistall it and install it many time using pip , but still stuck with redfishClient import error
Cannot find reference "RedfishClient" in "--init--.py"
Command to install HPE library is "pip install python-ilorest-library".
(Note : First do this "pip uninstall redfish", this is NOT HPE library)
Hello, I am currently working on an important project for my finals and I am stuck... I am still having a similar or even identical issue even though this seems to be fixed. I have been given an iLO4 and been tasked with creating users on this interface with ansible
All I am getting after running the playbook is:
failed: [ansible-1 -> localhost] (item={'new_username': 'admin', 'new_password': 'password', 'roleid': 'Administrator'}) => {"ansible_loop_var": "item", "changed": false, "item": {"new_password": "password", "new_username": "admin", "roleid": "Administrator"}, "msg": "HTTP Error 400 on POST request to 'https://{baseuri}/redfish/v1/AccountService/Accounts', extended message: '[{'MessageArgs': ['RoleId'], 'MessageId': 'Base.0.10.PropertyUnknown'}]'"}
I'd be very very thankful for any help
Hello ,
When I run the script " add_user_account.py" I get the error bellow :
From get_resource_directory import get_resource_directory ImportError : No module named get_resource_directory
Please help to fix it