redfish code update keyword
Resolves openbmc/openbmc-test-automation#1612
Change-Id: I9b6cea5e0b6b2424ed347ea0e6e44275baeac7c0
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/code_update_utils.robot b/lib/code_update_utils.robot
index d6c0be6..1207618 100644
--- a/lib/code_update_utils.robot
+++ b/lib/code_update_utils.robot
@@ -5,6 +5,7 @@
Library OperatingSystem
Library String
Library utilities.py
+Library gen_robot_valid.py
Variables ../data/variables.py
Resource boot_utils.robot
Resource rest_client.robot
@@ -158,6 +159,50 @@
... Set Host Software Property @{images}[0] Priority ${priority}
+Redfish Upload Image
+ [Documentation] Upload an image to the BMC via redfish.
+ [Arguments] ${uri} ${image_file_path}
+
+ # Description of argument(s):
+ # uri URI for uploading image via redfish.
+ # image_file_path The path to the image tarball.
+
+ ${image_data}= OperatingSystem.Get Binary File ${image_file_path}
+
+ Wait Until Keyword Succeeds 3 times 60 sec
+ ... Upload Image To BMC ${uri} data=${image_data}
+
+
+Redfish Verify BMC Version
+ [Documentation] Verify that the version on the BMC is the same as the
+ ... version in the given image via Redfish.
+ [Arguments] ${image_file_path}
+
+ # Description of argument(s):
+ # image_file_path Path to the image tarball.
+
+ # Extract the version from the image tarball on our local system.
+ ${tar_version}= Get Version Tar ${image_file_path}
+ ${bmc_version}= Redfish Get BMC Version
+
+ Rvalid Value bmc_version valid_values=['${tar_version}']
+
+
+Redfish Verify Host Version
+ [Documentation] Verify that the version of the PNOR image that is on the
+ ... BMC is the same as the one in the given image via Redfish.
+ [Arguments] ${image_file_path}
+
+ # Description of argument(s):
+ # image_file_path Path to the image tarball.
+
+ # Extract the version from the image tarball on our local system.
+ ${tar_version}= Get Version Tar ${image_file_path}
+ ${host_version}= Redfish Get Host Version
+
+ Rvalid Value host_version valid_values=['${tar_version}']
+
+
Upload And Activate Image
[Documentation] Upload an image to the BMC and activate it with REST.
[Arguments] ${image_file_path} ${wait}=${1} ${skip_if_active}=false
diff --git a/lib/common_utils.robot b/lib/common_utils.robot
index bbac89f..e3eae8a 100755
--- a/lib/common_utils.robot
+++ b/lib/common_utils.robot
@@ -851,6 +851,19 @@
[Return] ${bmc_version} ${pnor_version}
+Redfish Get BMC Version
+ [Documentation] Get BMC version via Redfish.
+
+ ${output}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc FirmwareVersion
+ [Return] ${output}
+
+Redfish Get Host Version
+ [Documentation] Get host version via Redfish.
+
+ ${output}= Redfish.Get Attribute ${REDFISH_BASE_URI}Systems/system BiosVersion
+ [Return] ${output}
+
+
Copy Address Translation Utils To HOST OS
[Documentation] Copy address translation utils to host OS.
diff --git a/redfish/update_service/redfish_bmc_code_update.robot b/redfish/update_service/redfish_bmc_code_update.robot
new file mode 100644
index 0000000..5925af6
--- /dev/null
+++ b/redfish/update_service/redfish_bmc_code_update.robot
@@ -0,0 +1,58 @@
+*** Settings ***
+Documentation Update the BMC code on a target BMC via Redifsh.
+
+Resource ../../lib/resource.robot
+Resource ../../lib/bmc_redfish_resource.robot
+Resource ../../lib/openbmc_ffdc.robot
+Resource ../../lib/common_utils.robot
+Resource ../../lib/code_update_utils.robot
+Library ../../lib/gen_robot_valid.py
+
+Suite Setup Suite Setup Execution
+Suite Teardown Redfish.Logout
+Test Setup Printn
+Test Teardown FFDC On Test Case Fail
+
+Force Tags BMC_Code_Update
+
+*** Variables ***
+${immediate} Immediate
+${onreset} OnReset
+
+*** Test Cases ***
+
+Redfish BMC Code Update
+ [Documentation] Do a BMC code update by uploading image on BMC via redfish.
+ [Tags] Redfish_BMC_Code_Update
+
+ Set ApplyTime policy=${onreset}
+
+ ${base_redfish_uri}= Set Variable ${REDFISH_BASE_URI}UpdateService
+
+ Redfish Upload Image ${base_redfish_uri} ${IMAGE_FILE_PATH}
+
+ ${image_id}= Get Latest Image ID
+ Rprint Vars image_id
+
+ Check Image Update Progress State match_state='Disabled', 'Updating' image_id=${image_id}
+
+ # Wait a few seconds to check if the update progress started.
+ Sleep 5s
+ Check Image Update Progress State match_state='Updating' image_id=${image_id}
+
+ Wait Until Keyword Succeeds 5 min 20 sec
+ ... Check Image Update Progress State match_state='Enabled' image_id=${image_id}
+
+ Redfish OBMC Reboot (off)
+ Redfish.Login
+ Redfish Verify BMC Version ${IMAGE_FILE_PATH}
+
+
+*** Keywords ***
+
+Suite Setup Execution
+ [Documentation] Do the suite setup.
+
+ Redfish.Login
+ # Checking for file existence.
+ OperatingSystem.File Should Exist ${IMAGE_FILE_PATH}