Skip to content

Commit 3aad340

Browse files
committed
Update add_user_account.py
1 parent cb15c8e commit 3aad340

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

examples/Redfish/add_user_account.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,29 +124,37 @@ def add_ilo_user_account_gen9(_redfishobj, new_loginname, new_username, new_pass
124124
#an account with specific privileges
125125
PRIVILEGE_DICT = {"iLOConfigPriv": True, "VirtualMediaPriv": True, "RemoteConsolePriv": True,\
126126
"UserConfigPriv": True, "VirtualPowerAndResetPriv": True, \
127-
"SystemRecoveryConfigPriv": True, "LoginPriv": True, \
127+
"SystemRecoveryConfigPriv": False, "LoginPriv": True, \
128128
"HostStorageConfigPriv": True, "HostNICConfigPriv": True, \
129129
"HostBIOSConfigPriv": True}
130130
# flag to force disable resource directory. Resource directory and associated operations are
131131
# intended for HPE servers.
132132
DISABLE_RESOURCE_DIR = False
133133

134-
ca_cert_data = {}
135-
ca_cert_data["cert_file"] = "c:\\test\\ppcacuser.crt"
136-
ca_cert_data["key_file"] = "c:\\test\\ppcacuserpriv.key"
137-
ca_cert_data["key_password"] = "password"
138-
LOGIN_ACCOUNT = None
139-
LOGIN_PASSWORD = None
134+
#For certificate login
135+
#ca_cert_data = {}
136+
#ca_cert_data["cert_file"] = "c:\\test\\ppcacuser.crt"
137+
#ca_cert_data["key_file"] = "c:\\test\\ppcacuserpriv.key"
138+
#ca_cert_data["key_password"] = "password"
139+
#LOGIN_ACCOUNT = None
140+
#LOGIN_PASSWORD = None
140141

141142
try:
142143
# Create a Redfish client object
143-
REDFISHOBJ = RedfishClient(base_url=SYSTEM_URL, username=LOGIN_ACCOUNT, password=LOGIN_PASSWORD, ca_cert_data=ca_cert_data)
144+
145+
REDFISHOBJ = RedfishClient(base_url=SYSTEM_URL, username=LOGIN_ACCOUNT, password=LOGIN_PASSWORD)
146+
REDFISHOBJ.login()
147+
148+
# For Certificate login
149+
#REDFISHOBJ = RedfishClient(base_url=SYSTEM_URL, username=LOGIN_ACCOUNT, password=LOGIN_PASSWORD, ca_cert_data=ca_cert_data)
144150
#REDFISHOBJ = RedfishClient(base_url=SYSTEM_URL, ca_cert_data=ca_cert_data)
145151
# Login with the Redfish client
146-
if ca_cert_data is None:
147-
REDFISHOBJ.login()
148-
else:
149-
REDFISHOBJ.login(auth='certificate')
152+
153+
154+
#if ca_cert_data is None:
155+
# REDFISHOBJ.login()
156+
#else:
157+
# REDFISHOBJ.login(auth='certificate')
150158
except ServerDownOrUnreachableError as excp:
151159
sys.stderr.write("ERROR: server not reachable or does not support RedFish.\n")
152160
sys.exit()
@@ -160,7 +168,7 @@ def add_ilo_user_account_gen9(_redfishobj, new_loginname, new_username, new_pass
160168
#add specified account
161169
(ilogen,_) = get_gen(REDFISHOBJ)
162170
print ("Generation is ", ilogen)
163-
if int(ilogen) == 5:
171+
if int(ilogen) >= 5:
164172
add_ilo_user_account(REDFISHOBJ,ACCOUNT_LOGIN_NAME,ACCOUNT_USER_NAME,ACCOUNT_PASSWORD,ROLE_ID,PRIVILEGE_DICT)
165173
else:
166174
add_ilo_user_account_gen9(REDFISHOBJ,ACCOUNT_LOGIN_NAME,ACCOUNT_USER_NAME,ACCOUNT_PASSWORD)

0 commit comments

Comments
 (0)