blob: ba5fb6018fa4b214c89a2bc9874451da7f43dd68 [file] [log] [blame]
George Keishing72abe822019-07-29 08:03:40 -05001*** Settings ***
2Documentation Redfish BMC and PNOR software utilities keywords.
3
4Library code_update_utils.py
5Library gen_robot_valid.py
Sushil Singh87dcee12019-08-07 13:13:13 -05006Library tftp_update_utils.py
George Keishing72abe822019-07-29 08:03:40 -05007Resource bmc_redfish_utils.robot
Sushil Singh32e2b582019-08-16 04:58:24 -05008Resource boot_utils.robot
George Keishing72abe822019-07-29 08:03:40 -05009
10*** Keywords ***
11
12Get Software Functional State
13 [Documentation] Return functional or active state of the software (i.e. True/False).
14 [Arguments] ${image_id}
15
16 # Description of argument(s):
17 # image_id The image ID (e.g. "acc9e073").
18
19 ${image_info}= Redfish.Get Properties /redfish/v1/UpdateService/FirmwareInventory/${image_id}
20
Sushil Singh8469a482020-07-30 04:19:10 -050021 ${sw_functional}= Run Keyword If
22 ... '${image_info["Description"]}' == 'BMC image' or '${image_info["Description"]}' == 'BMC update'
George Keishing72abe822019-07-29 08:03:40 -050023 ... Redfish.Get Attribute /redfish/v1/Managers/bmc FirmwareVersion
24 ... ELSE
25 ... Redfish.Get Attribute /redfish/v1/Systems/system BiosVersion
26
27 ${functional}= Run Keyword And Return Status
28 ... Should Be Equal ${sw_functional} ${image_info["Version"]}
29
30 [Return] ${functional}
31
32
33Get Software Inventory State
34 [Documentation] Return dictionary of the image type, version and functional state
35 ... of the software objects active on the system.
36
37 # User defined state for software objects.
38 # Note: "Functional" term refers to firmware which system is currently booted with.
39 # sw_inv_dict:
40 # [ace821ef]:
41 # [image_type]: Host update
George Keishing31029492019-07-30 13:14:13 -050042 # [image_id]: ace821ef
George Keishing72abe822019-07-29 08:03:40 -050043 # [functional]: True
44 # [version]: witherspoon-xx.xx.xx.xx
45 # [b9101858]:
46 # [image_type]: BMC update
George Keishing31029492019-07-30 13:14:13 -050047 # [image_id]: b9101858
George Keishing72abe822019-07-29 08:03:40 -050048 # [functional]: True
49 # [version]: 2.8.0-dev-150-g04508dc9f
50 # [c45eafa5]:
51 # [image_type]: BMC update
George Keishing31029492019-07-30 13:14:13 -050052 # [image_id]: c45eafa5
George Keishing72abe822019-07-29 08:03:40 -050053 # [functional]: False
54 # [version]: 2.8.0-dev-149-g1a8df5077
55
56 ${sw_member_list}= Redfish_Utils.Get Member List /redfish/v1/UpdateService/FirmwareInventory
57 &{sw_inv_dict}= Create Dictionary
58
59 # sw_member_list:
60 # [0]: /redfish/v1/UpdateService/FirmwareInventory/98744d76
61 # [1]: /redfish/v1/UpdateService/FirmwareInventory/9a8028ec
62 # [2]: /redfish/v1/UpdateService/FirmwareInventory/acc9e073
63
64 FOR ${uri_path} IN @{sw_member_list}
65 &{tmp_dict}= Create Dictionary
66 ${image_info}= Redfish.Get Properties ${uri_path}
67 Set To Dictionary ${tmp_dict} image_type ${image_info["Description"]}
George Keishing31029492019-07-30 13:14:13 -050068 Set To Dictionary ${tmp_dict} image_id ${uri_path.split("/")[-1]}
George Keishing72abe822019-07-29 08:03:40 -050069 ${functional}= Get Software Functional State ${uri_path.split("/")[-1]}
70 Set To Dictionary ${tmp_dict} functional ${functional}
George Keishing72abe822019-07-29 08:03:40 -050071 Set To Dictionary ${tmp_dict} version ${image_info["Version"]}
George Keishing31029492019-07-30 13:14:13 -050072 Set To Dictionary ${sw_inv_dict} ${uri_path.split("/")[-1]} ${tmp_dict}
George Keishing72abe822019-07-29 08:03:40 -050073 END
74
75 [Return] &{sw_inv_dict}
George Keishing31029492019-07-30 13:14:13 -050076
77
78Get Software Inventory State By Version
79 [Documentation] Return the software inventory record that matches the given software version.
80 [Arguments] ${software_version}
81
82 # If no matchine record can be found, return ${EMPTY}.
83
84 # Example of returned data:
85 # software_inventory_record:
86 # [image_type]: BMC update
87 # [image_id]: 1e662ba8
88 # [functional]: True
89 # [version]: 2.8.0-dev-150-g04508dc9f
90
91 # Description of argument(s):
92 # software_version A BMC or Host version (e.g "2.8.0-dev-150-g04508dc9f").
93
94 ${software_inventory}= Get Software Inventory State
95 # Filter out entries that don't match the criterion..
96 ${software_inventory}= Filter Struct ${software_inventory} [('version', '${software_version}')]
97 # Convert from dictionary to list.
98 ${software_inventory}= Get Dictionary Values ${software_inventory}
99 ${num_records}= Get Length ${software_inventory}
100
101 Return From Keyword If ${num_records} == ${0} ${EMPTY}
102
103 # Return the first list entry.
104 [Return] ${software_inventory}[0]
Sushil Singh87dcee12019-08-07 13:13:13 -0500105
106
107Redfish Upload Image And Check Progress State
108 [Documentation] Code update with ApplyTime.
Sushil Singh87dcee12019-08-07 13:13:13 -0500109
Sushil Singh87dcee12019-08-07 13:13:13 -0500110 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${IMAGE_FILE_PATH}
111
112 ${image_id}= Get Latest Image ID
113 Rprint Vars image_id
114
George Keishingeb0b0842020-03-03 23:09:49 -0600115 ${manifest} ${stderr} ${rc}= BMC Execute Command cat /tmp/images/${image_id}/MANIFEST
116 Rprint Vars manifest
117
Sushil Singh8469a482020-07-30 04:19:10 -0500118 Wait Until Keyword Succeeds 1 min 05 sec
119 ... Check Image Update Progress State match_state='Disabled', 'Updating' image_id=${image_id}
120
Sushil Singh87dcee12019-08-07 13:13:13 -0500121 # Wait a few seconds to check if the update progress started.
122 Sleep 5s
Sushil Singh8469a482020-07-30 04:19:10 -0500123
Sushil Singh87dcee12019-08-07 13:13:13 -0500124 Check Image Update Progress State
125 ... match_state='Updating' image_id=${image_id}
126
127 Wait Until Keyword Succeeds 8 min 20 sec
128 ... Check Image Update Progress State
129 ... match_state='Enabled' image_id=${image_id}
130
131
Sushil Singh32e2b582019-08-16 04:58:24 -0500132Get Host Power State
133 [Documentation] Get host power state.
134 [Arguments] ${quiet}=0
135
136 # Description of arguments:
137 # quiet Indicates whether results should be printed.
138
139 ${state}= Redfish.Get Attribute
140 ... ${REDFISH_BASE_URI}Systems/system PowerState
141 Rqprint Vars state
142
143 [Return] ${state}
144
145
146Check Host Power State
147 [Documentation] Check that the machine's host state matches
148 ... the caller's required host state.
149 [Arguments] ${match_state}
150
151 # Description of argument(s):
152 # match_state The expected state. This may be one or more
153 # comma-separated values (e.g. "On", "Off").
154 # If the actual state matches any of the
155 # states named in this argument,
156 # this keyword passes.
157
158 ${state}= Get Host Power State
159 Rvalid Value state valid_values=[${match_state}]
160
Sushil Singhf17a7f62020-02-03 01:09:30 -0600161
162Get System Firmware Details
163 [Documentation] Return dictionary of system firmware details.
164
165 # {
166 # FirmwareVersion: 2.8.0-dev-1067-gdc66ce1c5,
167 # BiosVersion: witherspoon-XXX-XX.X-X
168 # }
169
170 ${firmware_version}= Redfish Get BMC Version
171 ${bios_version}= Redfish Get Host Version
172
173 &{sys_firmware_dict}= Create Dictionary
174 Set To Dictionary
175 ... ${sys_firmware_dict} FirmwareVersion ${firmware_version} BiosVersion ${bios_version}
176 Rprint Vars sys_firmware_dict
177
178 [Return] &{sys_firmware_dict}
179