blob: c067b4bd940e7a34fdff272685b2b7f59fc66346 [file] [log] [blame]
Sushil Singh87dcee12019-08-07 13:13:13 -05001*** Settings ***
2Documentation Update the BMC code on a target BMC via Redifsh.
3
4# Test Parameters:
5# IMAGE_FILE_PATH The path to the BMC image file.
6#
7# Firmware update states:
8# Enabled Image is installed and either functional or active.
9# Disabled Image installation failed or ready for activation.
10# Updating Image installation currently in progress.
11
12Resource ../../lib/resource.robot
13Resource ../../lib/bmc_redfish_resource.robot
14Resource ../../lib/openbmc_ffdc.robot
15Resource ../../lib/common_utils.robot
16Resource ../../lib/code_update_utils.robot
17Resource ../../lib/redfish_code_update_utils.robot
Sushil Singh87dcee12019-08-07 13:13:13 -050018Library ../../lib/gen_robot_valid.py
19Library ../../lib/var_funcs.py
20
Sushil Singhb2162d82019-09-27 07:22:04 -050021Suite Setup Suite Setup Execution
22Suite Teardown Redfish.Logout
23Test Setup Printn
24Test Teardown FFDC On Test Case Fail
Sushil Singh87dcee12019-08-07 13:13:13 -050025
Sushil Singhb2162d82019-09-27 07:22:04 -050026Force Tags BMC_Code_Update
Sushil Singh87dcee12019-08-07 13:13:13 -050027
28*** Test Cases ***
29
30Redfish BMC Code Update
31 [Documentation] Update the firmware image.
32 [Tags] Redfish_BMC_Code_Update
33
34 ${image_version}= Get Version Tar ${IMAGE_FILE_PATH}
35 Rprint Vars image_version
36
37 Run Keyword If not ${FORCE_UPDATE}
38 ... Activate Existing Firmware ${image_version}
39 Redfish Update Firmware
40
41*** Keywords ***
42
43Suite Setup Execution
44 [Documentation] Do the suite setup.
45
46 Redfish.Login
Sushil Singh87dcee12019-08-07 13:13:13 -050047 # Delete BMC dump and Error logs.
48 Delete All BMC Dump
49 Redfish Purge Event Log
Sushil Singh87dcee12019-08-07 13:13:13 -050050 # Checking for file existence.
51 Valid File Path IMAGE_FILE_PATH
52
53
54Activate Existing Firmware
55 [Documentation] Set fimware image to lower priority.
56 [Arguments] ${image_version}
57
58 # Description of argument(s):
59 # image_version Version of image.
60
61 ${software_inventory_record}= Get Software Inventory State By Version
62 ... ${image_version}
63 ${num_keys}= Get Length ${software_inventory_record}
64
65 Rprint Vars software_inventory_record
66
67 # If no software inventory record was found, there is no existing
68 # firmware for the given version and therefore no action to be taken.
69 Return From Keyword If not ${num_keys}
70
71 # Check if the existing firmware is functional.
72 Pass Execution If ${software_inventory_record['functional']}
73 ... The existing ${image_version} firmware is already functional.
74
75 # If existing firmware is not functional, then set the priority to least.
76 Print Timen The existing ${image_version} firmware is not yet functional.
77 Set BMC Image Priority To Least ${image_version} ${software_inventory_record}
78
79 Pass Execution The existing ${image_version} firmware is now functional.
80
81
82Get Image Priority
83 [Documentation] Get Current Image Priority.
84 [Arguments] ${image_version}
85
86 # Description of argument(s):
87 # image_version The Fimware image version (e.g. ibm-v.x-xx).
88
89 ${software_info}= Read Properties
90 ... ${SOFTWARE_VERSION_URI}/enumerate quiet=1
91 # Get only the record associated with our image_version.
92
93 ${software_info}= Filter Struct
94 ... ${software_info} [('Version', '${image_version}')]
95 # Convert from dict to list.
96 ${software_info}= Get Dictionary Values ${software_info}
97
98 [Return] ${software_info[0]['Priority']}
99
100
101Set BMC Image Priority To Least
102 [Documentation] Set BMC image priority to least value.
103 [Arguments] ${image_version} ${software_inventory}
104
105 # Description of argument(s):
106 # image_version The Fimware image version (e.g. ibm-v.x-xx).
107 # software_inventory Software inventory details.
108
109 ${least_priority}= Get Least Value Priority Image ${VERSION_PURPOSE_BMC}
110 ${cur_priority}= Get Image Priority ${image_version}
111 Rprint Vars least_priority cur_priority
112
113 Return From Keyword If '${least_priority}' == ${cur_priority}
114 Set Host Software Property
115 ... ${SOFTWARE_VERSION_URI}${software_inventory['image_id']}
116 ... Priority ${least_priority}
117
118 # Reboot BMC And Login
119 Redfish OBMC Reboot (off)
120 Redfish.Login
121
122
123Redfish Update Firmware
124 [Documentation] Update the BMC firmware via redfish interface.
125
126 ${state}= Get Pre Reboot State
127 Rprint Vars state
128
Sushil Singh090eedc2019-11-05 02:04:59 -0600129 Run Keyword And Ignore Error Set ApplyTime policy=OnReset
Sushil Singh6f86f172019-10-30 11:36:25 -0500130 Redfish Upload Image And Check Progress State
Sushil Singh87dcee12019-08-07 13:13:13 -0500131 Reboot BMC And Verify BMC Image
Sushil Singh090eedc2019-11-05 02:04:59 -0600132 ... OnReset start_boot_seconds=${state['epoch_seconds']}
Sushil Singh87dcee12019-08-07 13:13:13 -0500133