blob: 084ecac6d8745a5599ad7ce4e05259b37043c40e [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
47
48 # Delete BMC dump and Error logs.
49 Delete All BMC Dump
50 Redfish Purge Event Log
51
52 # Checking for file existence.
53 Valid File Path IMAGE_FILE_PATH
54
55
56Activate Existing Firmware
57 [Documentation] Set fimware image to lower priority.
58 [Arguments] ${image_version}
59
60 # Description of argument(s):
61 # image_version Version of image.
62
63 ${software_inventory_record}= Get Software Inventory State By Version
64 ... ${image_version}
65 ${num_keys}= Get Length ${software_inventory_record}
66
67 Rprint Vars software_inventory_record
68
69 # If no software inventory record was found, there is no existing
70 # firmware for the given version and therefore no action to be taken.
71 Return From Keyword If not ${num_keys}
72
73 # Check if the existing firmware is functional.
74 Pass Execution If ${software_inventory_record['functional']}
75 ... The existing ${image_version} firmware is already functional.
76
77 # If existing firmware is not functional, then set the priority to least.
78 Print Timen The existing ${image_version} firmware is not yet functional.
79 Set BMC Image Priority To Least ${image_version} ${software_inventory_record}
80
81 Pass Execution The existing ${image_version} firmware is now functional.
82
83
84Get Image Priority
85 [Documentation] Get Current Image Priority.
86 [Arguments] ${image_version}
87
88 # Description of argument(s):
89 # image_version The Fimware image version (e.g. ibm-v.x-xx).
90
91 ${software_info}= Read Properties
92 ... ${SOFTWARE_VERSION_URI}/enumerate quiet=1
93 # Get only the record associated with our image_version.
94
95 ${software_info}= Filter Struct
96 ... ${software_info} [('Version', '${image_version}')]
97 # Convert from dict to list.
98 ${software_info}= Get Dictionary Values ${software_info}
99
100 [Return] ${software_info[0]['Priority']}
101
102
103Set BMC Image Priority To Least
104 [Documentation] Set BMC image priority to least value.
105 [Arguments] ${image_version} ${software_inventory}
106
107 # Description of argument(s):
108 # image_version The Fimware image version (e.g. ibm-v.x-xx).
109 # software_inventory Software inventory details.
110
111 ${least_priority}= Get Least Value Priority Image ${VERSION_PURPOSE_BMC}
112 ${cur_priority}= Get Image Priority ${image_version}
113 Rprint Vars least_priority cur_priority
114
115 Return From Keyword If '${least_priority}' == ${cur_priority}
116 Set Host Software Property
117 ... ${SOFTWARE_VERSION_URI}${software_inventory['image_id']}
118 ... Priority ${least_priority}
119
120 # Reboot BMC And Login
121 Redfish OBMC Reboot (off)
122 Redfish.Login
123
124
125Redfish Update Firmware
126 [Documentation] Update the BMC firmware via redfish interface.
127
128 ${state}= Get Pre Reboot State
129 Rprint Vars state
130
131 Redfish Upload Image And Check Progress State Immediate
132 Reboot BMC And Verify BMC Image
133 ... Immediate start_boot_seconds=${state['epoch_seconds']}
134