99File : accounts.py
1010
1111Brief : This file contains the definitions and functionalities for managing
12- accounts on a Redfish Service
12+ accounts on a Redfish service
1313"""
1414
1515from .messages import verify_response
16+ from .tasks import poll_task_monitor
17+ from . import config
1618
1719
1820class RedfishAccountCollectionNotFoundError (Exception ):
1921 """
20- Raised when the Account Service or Account Collection cannot be found
22+ Raised when the account service or account collection cannot be found
2123 """
2224
2325 pass
2426
2527
2628class RedfishAccountNotFoundError (Exception ):
2729 """
28- Raised when the Account Service or Account Collection cannot be found
30+ Raised when the account service or account collection cannot be found
2931 """
3032
3133 pass
@@ -52,7 +54,7 @@ def get_users(context):
5254
5355 user_list = []
5456
55- # Go through each Account in the Account Collection
57+ # Go through each account in the account collection
5658 account_col = context .get (get_account_collection (context ), None )
5759 for account_member in account_col .dict ["Members" ]:
5860 account = context .get (account_member ["@odata.id" ], None )
@@ -128,6 +130,8 @@ def add_user(context, user_name, password, role):
128130 user_name
129131 )
130132 )
133+ if config .__auto_task_handling__ :
134+ response = poll_task_monitor (context , response , silent = True )
131135 verify_response (response )
132136 return response
133137
@@ -154,6 +158,8 @@ def delete_user(context, user_name):
154158 # Some also do not allow for both Enabled and UserName to be modified simultaneously
155159 modify_user (context , user_name , new_enabled = False )
156160 return modify_user (context , user_name , new_name = "" )
161+ if config .__auto_task_handling__ :
162+ response = poll_task_monitor (context , response , silent = True )
157163 verify_response (response )
158164 return response
159165
@@ -203,6 +209,8 @@ def modify_user(
203209
204210 # Update the user
205211 response = context .patch (user_uri , body = new_info , headers = {"If-Match" : user_info .getheader ("ETag" )})
212+ if config .__auto_task_handling__ :
213+ response = poll_task_monitor (context , response , silent = True )
206214 verify_response (response )
207215 return response
208216
@@ -218,17 +226,17 @@ def get_account_collection(context):
218226 The URI for the account collection
219227 """
220228
221- # Get the Service Root to find the Account Service
229+ # Get the service root to find the account service
222230 service_root = context .get ("/redfish/v1" )
223231 if "AccountService" not in service_root .dict :
224- # No Account Service
225- raise RedfishAccountCollectionNotFoundError ("Service does not contain an Account Service " )
232+ # No account service
233+ raise RedfishAccountCollectionNotFoundError ("Service does not contain an account service " )
226234
227- # Get the Account Service to find the Account Collection
235+ # Get the account service to find the account collection
228236 account_service = context .get (service_root .dict ["AccountService" ]["@odata.id" ])
229237 if "Accounts" not in account_service .dict :
230238 # No Account Collection
231- raise RedfishAccountCollectionNotFoundError ("Service does not contain an Account Collection " )
239+ raise RedfishAccountCollectionNotFoundError ("Service does not contain an account collection " )
232240
233241 return account_service .dict ["Accounts" ]["@odata.id" ]
234242
0 commit comments