From 3aad34088ebc95b9bb67b04807f4a73429fbf08b Mon Sep 17 00:00:00 2001 From: Rajeevalochana Kallur Date: Fri, 28 Jul 2023 18:22:13 +0530 Subject: [PATCH] Update add_user_account.py --- examples/Redfish/add_user_account.py | 34 +++++++++++++++++----------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/examples/Redfish/add_user_account.py b/examples/Redfish/add_user_account.py index 3b4c605..f8b69cd 100644 --- a/examples/Redfish/add_user_account.py +++ b/examples/Redfish/add_user_account.py @@ -124,29 +124,37 @@ def add_ilo_user_account_gen9(_redfishobj, new_loginname, new_username, new_pass #an account with specific privileges PRIVILEGE_DICT = {"iLOConfigPriv": True, "VirtualMediaPriv": True, "RemoteConsolePriv": True,\ "UserConfigPriv": True, "VirtualPowerAndResetPriv": True, \ - "SystemRecoveryConfigPriv": True, "LoginPriv": True, \ + "SystemRecoveryConfigPriv": False, "LoginPriv": True, \ "HostStorageConfigPriv": True, "HostNICConfigPriv": True, \ "HostBIOSConfigPriv": True} # flag to force disable resource directory. Resource directory and associated operations are # intended for HPE servers. DISABLE_RESOURCE_DIR = False - ca_cert_data = {} - ca_cert_data["cert_file"] = "c:\\test\\ppcacuser.crt" - ca_cert_data["key_file"] = "c:\\test\\ppcacuserpriv.key" - ca_cert_data["key_password"] = "password" - LOGIN_ACCOUNT = None - LOGIN_PASSWORD = None + #For certificate login + #ca_cert_data = {} + #ca_cert_data["cert_file"] = "c:\\test\\ppcacuser.crt" + #ca_cert_data["key_file"] = "c:\\test\\ppcacuserpriv.key" + #ca_cert_data["key_password"] = "password" + #LOGIN_ACCOUNT = None + #LOGIN_PASSWORD = None try: # Create a Redfish client object - REDFISHOBJ = RedfishClient(base_url=SYSTEM_URL, username=LOGIN_ACCOUNT, password=LOGIN_PASSWORD, ca_cert_data=ca_cert_data) + + REDFISHOBJ = RedfishClient(base_url=SYSTEM_URL, username=LOGIN_ACCOUNT, password=LOGIN_PASSWORD) + REDFISHOBJ.login() + + # For Certificate login + #REDFISHOBJ = RedfishClient(base_url=SYSTEM_URL, username=LOGIN_ACCOUNT, password=LOGIN_PASSWORD, ca_cert_data=ca_cert_data) #REDFISHOBJ = RedfishClient(base_url=SYSTEM_URL, ca_cert_data=ca_cert_data) # Login with the Redfish client - if ca_cert_data is None: - REDFISHOBJ.login() - else: - REDFISHOBJ.login(auth='certificate') + + + #if ca_cert_data is None: + # REDFISHOBJ.login() + #else: + # REDFISHOBJ.login(auth='certificate') except ServerDownOrUnreachableError as excp: sys.stderr.write("ERROR: server not reachable or does not support RedFish.\n") sys.exit() @@ -160,7 +168,7 @@ def add_ilo_user_account_gen9(_redfishobj, new_loginname, new_username, new_pass #add specified account (ilogen,_) = get_gen(REDFISHOBJ) print ("Generation is ", ilogen) - if int(ilogen) == 5: + if int(ilogen) >= 5: add_ilo_user_account(REDFISHOBJ,ACCOUNT_LOGIN_NAME,ACCOUNT_USER_NAME,ACCOUNT_PASSWORD,ROLE_ID,PRIVILEGE_DICT) else: add_ilo_user_account_gen9(REDFISHOBJ,ACCOUNT_LOGIN_NAME,ACCOUNT_USER_NAME,ACCOUNT_PASSWORD)