blob: da8caf16e0fccb475cc1f65e4f2cd5a141c91038 [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
18Resource ../../extended/code_update/update_bmc.robot
19Library ../../lib/gen_robot_valid.py
20Library ../../lib/var_funcs.py
21
22Suite Setup Suite Setup Execution
23Suite Teardown Redfish.Logout
24Test Setup Printn
25Test Teardown FFDC On Test Case Fail
26
27Force Tags BMC_Code_Update
28
29*** Test Cases ***
30
31Redfish BMC Code Update
32 [Documentation] Update the firmware image.
33 [Tags] Redfish_BMC_Code_Update
34
35 ${image_version}= Get Version Tar ${IMAGE_FILE_PATH}
36 Rprint Vars image_version
37
38 Run Keyword If not ${FORCE_UPDATE}
39 ... Activate Existing Firmware ${image_version}
40 Redfish Update Firmware
41
42*** Keywords ***
43
44Suite Setup Execution
45 [Documentation] Do the suite setup.
46
47 Redfish.Login
48
49 # Delete BMC dump and Error logs.
50 Delete All BMC Dump
51 Redfish Purge Event Log
52
53 # Checking for file existence.
54 Valid File Path IMAGE_FILE_PATH
55
56
57Activate Existing Firmware
58 [Documentation] Set fimware image to lower priority.
59 [Arguments] ${image_version}
60
61 # Description of argument(s):
62 # image_version Version of image.
63
64 ${software_inventory_record}= Get Software Inventory State By Version
65 ... ${image_version}
66 ${num_keys}= Get Length ${software_inventory_record}
67
68 Rprint Vars software_inventory_record
69
70 # If no software inventory record was found, there is no existing
71 # firmware for the given version and therefore no action to be taken.
72 Return From Keyword If not ${num_keys}
73
74 # Check if the existing firmware is functional.
75 Pass Execution If ${software_inventory_record['functional']}
76 ... The existing ${image_version} firmware is already functional.
77
78 # If existing firmware is not functional, then set the priority to least.
79 Print Timen The existing ${image_version} firmware is not yet functional.
80 Set BMC Image Priority To Least ${image_version} ${software_inventory_record}
81
82 Pass Execution The existing ${image_version} firmware is now functional.
83
84
85Get Image Priority
86 [Documentation] Get Current Image Priority.
87 [Arguments] ${image_version}
88
89 # Description of argument(s):
90 # image_version The Fimware image version (e.g. ibm-v.x-xx).
91
92 ${software_info}= Read Properties
93 ... ${SOFTWARE_VERSION_URI}/enumerate quiet=1
94 # Get only the record associated with our image_version.
95
96 ${software_info}= Filter Struct
97 ... ${software_info} [('Version', '${image_version}')]
98 # Convert from dict to list.
99 ${software_info}= Get Dictionary Values ${software_info}
100
101 [Return] ${software_info[0]['Priority']}
102
103
104Set BMC Image Priority To Least
105 [Documentation] Set BMC image priority to least value.
106 [Arguments] ${image_version} ${software_inventory}
107
108 # Description of argument(s):
109 # image_version The Fimware image version (e.g. ibm-v.x-xx).
110 # software_inventory Software inventory details.
111
112 ${least_priority}= Get Least Value Priority Image ${VERSION_PURPOSE_BMC}
113 ${cur_priority}= Get Image Priority ${image_version}
114 Rprint Vars least_priority cur_priority
115
116 Return From Keyword If '${least_priority}' == ${cur_priority}
117 Set Host Software Property
118 ... ${SOFTWARE_VERSION_URI}${software_inventory['image_id']}
119 ... Priority ${least_priority}
120
121 # Reboot BMC And Login
122 Redfish OBMC Reboot (off)
123 Redfish.Login
124
125
126Redfish Update Firmware
127 [Documentation] Update the BMC firmware via redfish interface.
128
129 ${state}= Get Pre Reboot State
130 Rprint Vars state
131
132 Redfish Upload Image And Check Progress State Immediate
133 Reboot BMC And Verify BMC Image
134 ... Immediate start_boot_seconds=${state['epoch_seconds']}
135