redfish: extended: dump: fix "Verify Download BMC Dump" test failed

Symptom:
"Verify Download BMC Dump" test item in test_bmc_dump.robot got failed.

Root cause:
From test report that error message is
JSONDecodeError: Expecting value: line 1 column 1 (char 0).
Due to this test item using REST method "Create User Initiated Dump"
to create bmc dump and got failed. Thus, "Get The Dump Id" return unexpected value.

Solution:
Using Redfish method to create BMC Dump according current bmcweb design.

Tested:
Run robot "Verify Download BMC Dump" of test_bmc_dump.robot

Signed-off-by: Tim Lee <timlee660101@gmail.com>
Change-Id: I14b25408277809d5de6148fed91a36b85ede479e
diff --git a/lib/dump_utils.robot b/lib/dump_utils.robot
index 5516f3f..9070e0f 100644
--- a/lib/dump_utils.robot
+++ b/lib/dump_utils.robot
@@ -242,13 +242,12 @@
     Should Be Equal As Integers  ${rc}  ${0}
     ...  msg=BMC execute command return code is not zero.
 
-Create User Initiated BMC Dump Using Redfish
-    [Documentation]  Trigger user initiated BMC dump via Redfish and return task id.
+Create User Initiated BMC Dump Via Redfish
+    [Documentation]  Generate user initiated BMC dump via Redfish and return the dump id number (e.g., "5").
 
     ${payload}=  Create Dictionary  DiagnosticDataType=Manager
-    ${resp}=  Redfish.Post
-    ...  /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData
-    ...  body=${payload}  valid_status_codes=[${HTTP_ACCEPTED}, ${HTTP_OK}]
+    ${resp}=  Redfish.Post  /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData
+    ...  body=${payload}  valid_status_codes=[${HTTP_ACCEPTED}]
 
     # Example of response from above Redfish POST request.
     # "@odata.id": "/redfish/v1/TaskService/Tasks/0",
@@ -257,8 +256,27 @@
     # "TaskState": "Running",
     # "TaskStatus": "OK"
 
+    Wait Until Keyword Succeeds  5 min  15 sec  Check Task Completion  ${resp.dict['Id']}
     ${task_id}=  Set Variable  ${resp.dict['Id']}
-    [Return]  ${task_id}
+
+    ${task_dict}=  Redfish.Get Properties  /redfish/v1/TaskService/Tasks/${task_id}
+
+    # Example of HttpHeaders field of task details.
+    # "Payload": {
+    #   "HttpHeaders": [
+    #     "Host: <BMC_IP>",
+    #      "Accept-Encoding: identity",
+    #      "Connection: Keep-Alive",
+    #      "Accept: */*",
+    #      "Content-Length: 33",
+    #      "Location: /redfish/v1/Managers/bmc/LogServices/Dump/Entries/2"]
+    #    ],
+    #    "HttpOperation": "POST",
+    #    "JsonBody": "{\"DiagnosticDataType\":\"Manager\"}",
+    #     "TargetUri": "/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData"
+    # }
+
+    [Return]  ${task_dict["Payload"]["HttpHeaders"][-1].split("/")[-1]}
 
 Auto Generate BMC Dump
     [Documentation]  Auto generate BMC dump.
@@ -340,10 +358,8 @@
     # Description of argument(s):
     # task_id        Task ID.
 
-    ${status}=  Get Task Status  ${task_id}
-    Run Keyword Unless  '${status}' == 'Cancelled' or '${status}' == 'Completed'
-    ...  Fail  Task is still running.
-    [Return]  ${status}
+    ${task_dict}=  Redfish.Get Properties  /redfish/v1/TaskService/Tasks/${task_id}
+    Should Be Equal As Strings  ${task_dict['TaskState']}  Completed
 
 Get Dump ID And Status
     [Documentation]  Return dump ID and status.
diff --git a/redfish/extended/test_bmc_dump.robot b/redfish/extended/test_bmc_dump.robot
index 5f7b8fa..b97b851 100644
--- a/redfish/extended/test_bmc_dump.robot
+++ b/redfish/extended/test_bmc_dump.robot
@@ -67,7 +67,7 @@
     [Documentation]  Verify that a BMC dump can be downloaded to the local machine.
     [Tags]  Verify_Download_BMC_Dump
 
-    ${dump_id}=  Create User Initiated Dump
+    ${dump_id}=  Create User Initiated BMC Dump Via Redfish
     ${dump_dict}=  Get Dump Dict
     ${bmc_dump_name}=  Fetch From Right  ${dump_dict['${dump_id}']}  /
     ${bmc_dump_checksum}  ${stderr}  ${rc}=  BMC Execute Command
diff --git a/redfish/extended/test_websocket.robot b/redfish/extended/test_websocket.robot
index 6ab49f2..afb86e6 100755
--- a/redfish/extended/test_websocket.robot
+++ b/redfish/extended/test_websocket.robot
@@ -78,7 +78,7 @@
 
     Redfish Delete All BMC Dumps
     Start Websocket Monitor  dump
-    ${dump_id}=  Create User Initiated BMC Dump Using Redfish
+    ${dump_id}=  Create User Initiated BMC Dump Via Redfish
     Check Existence Of BMC Dump File  ${dump_id}
 
     # Check that the monitor received notification of the dump.
diff --git a/redfish/managers/test_bmc_dumps.robot b/redfish/managers/test_bmc_dumps.robot
index b2112d9..6ee639c 100644
--- a/redfish/managers/test_bmc_dumps.robot
+++ b/redfish/managers/test_bmc_dumps.robot
@@ -179,43 +179,6 @@
 
 *** Keywords ***
 
-Create User Initiated BMC Dump Via Redfish
-    [Documentation]  Generate user initiated BMC dump via Redfish and return the dump id number (e.g., "5").
-
-    ${payload}=  Create Dictionary  DiagnosticDataType=Manager
-    ${resp}=  Redfish.Post  /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData
-    ...  body=${payload}  valid_status_codes=[${HTTP_ACCEPTED}]
-
-    # Example of response from above Redfish POST request.
-    # "@odata.id": "/redfish/v1/TaskService/Tasks/0",
-    # "@odata.type": "#Task.v1_4_3.Task",
-    # "Id": "0",
-    # "TaskState": "Running",
-    # "TaskStatus": "OK"
-
-    Wait Until Keyword Succeeds  5 min  15 sec  Is Task Completed  ${resp.dict['Id']}
-    ${task_id}=  Set Variable  ${resp.dict['Id']}
-
-    ${task_dict}=  Redfish.Get Properties  /redfish/v1/TaskService/Tasks/${task_id}
-
-    # Example of HttpHeaders field of task details.
-    # "Payload": {
-    #   "HttpHeaders": [
-    #     "Host: <BMC_IP>",
-    #      "Accept-Encoding: identity",
-    #      "Connection: Keep-Alive",
-    #      "Accept: */*",
-    #      "Content-Length: 33",
-    #      "Location: /redfish/v1/Managers/bmc/LogServices/Dump/Entries/2"]
-    #    ],
-    #    "HttpOperation": "POST",
-    #    "JsonBody": "{\"DiagnosticDataType\":\"Manager\"}",
-    #     "TargetUri": "/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData"
-    # }
-
-    [Return]  ${task_dict["Payload"]["HttpHeaders"][-1].split("/")[-1]}
-
-
 Get BMC Dump Entries
     [Documentation]  Return BMC dump ids list.
 
@@ -245,17 +208,6 @@
     [return]  ${usage_output}
 
 
-Is Task Completed
-    [Documentation]  Verify if the given task is completed.
-    [Arguments]   ${task_id}
-
-    # Description of argument(s):
-    # task_id        Id of task which needs to be checked.
-
-    ${task_dict}=  Redfish.Get Properties  /redfish/v1/TaskService/Tasks/${task_id}
-    Should Be Equal As Strings  ${task_dict['TaskState']}  Completed
-
-
 Test Teardown Execution
     [Documentation]  Do test teardown operation.