Redfish code update changes
Changes:
- Added task state in json file
data/task_state.json
- Added Keyword Create List Of Task,
Create Initiated Task State Dict,
Match Target URI,
Check Task With Match TargetUri,
Verify Task Progress State
- Added Keyword Get Task State From File
Tested:
Ran succesfully redfish/
update_service/test_redfish_bmc_code_update.robot
Change-Id: Iba2131925cb60614f456cbf5ec91b1b02bddc06b
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
diff --git a/lib/redfish_code_update_utils.robot b/lib/redfish_code_update_utils.robot
index 17ffbe0..5210c9b 100644
--- a/lib/redfish_code_update_utils.robot
+++ b/lib/redfish_code_update_utils.robot
@@ -284,3 +284,101 @@
Redfish.Patch /redfish/v1/Managers/bmc
... body={'Links': {'ActiveSoftwareImage': {'@odata.id': '${firmware_inv_path}'}}}
+
+Create List Of Task
+ [Documentation] Return list of task id(s) from provided list of dictionary.
+ [Arguments] ${task_dict_list}
+
+ # Description of argument(s):
+ # task_dict_list Task id dictionary list.
+
+ # '@odata.id': '/redfish/v1/TaskService/Tasks/0'
+
+ ${task_list}= Create List
+
+ FOR ${task_dict} IN @{task_dict_list}
+ Append To List ${task_list} ${task_dict['@odata.id']}
+ END
+
+ [Return] ${task_list}
+
+
+Create Initiated Task State Dict
+ [Documentation] Create active task inventory dictionary as certain URI create task
+ ... to serve the user request.
+ [Arguments] ${task_obj}
+
+ # Description of argument(s):
+ # task_obj Task dictionary.
+
+ # task_inv
+ # TargetUri /redfish/v1/UpdateService
+ # TaskIdURI /redfish/v1/TaskService/Tasks/0
+ # TaskState Starting
+ # TaskStatus OK
+
+ ${task_inv}= Create Dictionary
+ Set To Dictionary ${task_inv} TargetUri ${task_obj['Payload']['TargetUri']}
+ Set To Dictionary ${task_inv} TaskIdURI ${task_obj['@odata.id']}
+ Set To Dictionary ${task_inv} TaskState ${task_obj['TaskState']}
+ Set To Dictionary ${task_inv} TaskStatus ${task_obj['TaskStatus']}
+
+ [Return] ${task_inv}
+
+
+Match Target URI
+ [Documentation] Match target uri from task list.
+ [Arguments] ${task_list} ${target_uri}
+
+ # Description of argument(s):
+ # task_list Task id list.
+ # target_uri Task created for target URI.
+
+ # target_uri /redfish/v1/UpdateService
+
+ FOR ${task_id} IN @{task_list}
+ ${task_payload}= Redfish.Get Properties ${task_id}
+ Run Keyword And Return If '${task_payload['Payload']['TargetUri']}' == '${target_uri}' Create Initiated Task State Dict ${task_payload}
+ END
+
+
+Check Task With Match TargetUri
+ [Documentation] Create task state dictionary.
+ [Arguments] ${target_uri}=/redfish/v1/TaskService/Tasks
+
+ # Description of argument(s):
+ # target_uri Target URI for which task is initiated.
+
+ ${task_dict_list}= Redfish.Get Attribute /redfish/v1/TaskService/Tasks Members
+
+ ${task_list}= Create List Of Task ${task_dict_list}
+
+ ${task_inv}= Match Target URI ${task_list} ${target_uri}
+
+ [Return] ${task_inv}
+
+
+Verify Task Progress State
+ [Documentation] Verify task progress matches the user expected task state.
+ [Arguments] ${task_inv} ${task_state}
+
+ # Description of argument(s):
+ # task_inv Initiated task inventory dict information.
+ # task_state Expected task state, user reference from data/task_state.json.
+
+ # task_inv
+ # TaskIdURI /redfish/v1/TaskService/Tasks/0
+ # TaskState Starting
+ # TaskStatus OK
+
+ ${task_payload}= Redfish.Get Properties ${task_inv['TaskIdURI']}
+
+ ${temp_task_inv}= Create Dictionary
+ Set To Dictionary ${temp_task_inv} TaskState ${task_payload['TaskState']}
+ Set To Dictionary ${temp_task_inv} TaskStatus ${task_payload['TaskStatus']}
+
+ Rprint Vars temp_task_inv
+
+ Should Be Equal As Strings ${task_state['TaskState']} ${task_payload['TaskState']}
+ Should Be Equal As Strings ${task_state['TaskStatus']} ${task_payload['TaskStatus']}
+