blob: ff0580f884292301043da6b19e5db9463b0ff16e [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
8
9*** Keywords ***
10
11Get Software Functional State
12 [Documentation] Return functional or active state of the software (i.e. True/False).
13 [Arguments] ${image_id}
14
15 # Description of argument(s):
16 # image_id The image ID (e.g. "acc9e073").
17
18 ${image_info}= Redfish.Get Properties /redfish/v1/UpdateService/FirmwareInventory/${image_id}
19
20 ${sw_functional}= Run Keyword If '${image_info["Description"]}' == 'BMC update'
21 ... Redfish.Get Attribute /redfish/v1/Managers/bmc FirmwareVersion
22 ... ELSE
23 ... Redfish.Get Attribute /redfish/v1/Systems/system BiosVersion
24
25 ${functional}= Run Keyword And Return Status
26 ... Should Be Equal ${sw_functional} ${image_info["Version"]}
27
28 [Return] ${functional}
29
30
31Get Software Inventory State
32 [Documentation] Return dictionary of the image type, version and functional state
33 ... of the software objects active on the system.
34
35 # User defined state for software objects.
36 # Note: "Functional" term refers to firmware which system is currently booted with.
37 # sw_inv_dict:
38 # [ace821ef]:
39 # [image_type]: Host update
George Keishing31029492019-07-30 13:14:13 -050040 # [image_id]: ace821ef
George Keishing72abe822019-07-29 08:03:40 -050041 # [functional]: True
42 # [version]: witherspoon-xx.xx.xx.xx
43 # [b9101858]:
44 # [image_type]: BMC update
George Keishing31029492019-07-30 13:14:13 -050045 # [image_id]: b9101858
George Keishing72abe822019-07-29 08:03:40 -050046 # [functional]: True
47 # [version]: 2.8.0-dev-150-g04508dc9f
48 # [c45eafa5]:
49 # [image_type]: BMC update
George Keishing31029492019-07-30 13:14:13 -050050 # [image_id]: c45eafa5
George Keishing72abe822019-07-29 08:03:40 -050051 # [functional]: False
52 # [version]: 2.8.0-dev-149-g1a8df5077
53
54 ${sw_member_list}= Redfish_Utils.Get Member List /redfish/v1/UpdateService/FirmwareInventory
55 &{sw_inv_dict}= Create Dictionary
56
57 # sw_member_list:
58 # [0]: /redfish/v1/UpdateService/FirmwareInventory/98744d76
59 # [1]: /redfish/v1/UpdateService/FirmwareInventory/9a8028ec
60 # [2]: /redfish/v1/UpdateService/FirmwareInventory/acc9e073
61
62 FOR ${uri_path} IN @{sw_member_list}
63 &{tmp_dict}= Create Dictionary
64 ${image_info}= Redfish.Get Properties ${uri_path}
65 Set To Dictionary ${tmp_dict} image_type ${image_info["Description"]}
George Keishing31029492019-07-30 13:14:13 -050066 Set To Dictionary ${tmp_dict} image_id ${uri_path.split("/")[-1]}
George Keishing72abe822019-07-29 08:03:40 -050067 ${functional}= Get Software Functional State ${uri_path.split("/")[-1]}
68 Set To Dictionary ${tmp_dict} functional ${functional}
George Keishing72abe822019-07-29 08:03:40 -050069 Set To Dictionary ${tmp_dict} version ${image_info["Version"]}
George Keishing31029492019-07-30 13:14:13 -050070 Set To Dictionary ${sw_inv_dict} ${uri_path.split("/")[-1]} ${tmp_dict}
George Keishing72abe822019-07-29 08:03:40 -050071 END
72
73 [Return] &{sw_inv_dict}
George Keishing31029492019-07-30 13:14:13 -050074
75
76Get Software Inventory State By Version
77 [Documentation] Return the software inventory record that matches the given software version.
78 [Arguments] ${software_version}
79
80 # If no matchine record can be found, return ${EMPTY}.
81
82 # Example of returned data:
83 # software_inventory_record:
84 # [image_type]: BMC update
85 # [image_id]: 1e662ba8
86 # [functional]: True
87 # [version]: 2.8.0-dev-150-g04508dc9f
88
89 # Description of argument(s):
90 # software_version A BMC or Host version (e.g "2.8.0-dev-150-g04508dc9f").
91
92 ${software_inventory}= Get Software Inventory State
93 # Filter out entries that don't match the criterion..
94 ${software_inventory}= Filter Struct ${software_inventory} [('version', '${software_version}')]
95 # Convert from dictionary to list.
96 ${software_inventory}= Get Dictionary Values ${software_inventory}
97 ${num_records}= Get Length ${software_inventory}
98
99 Return From Keyword If ${num_records} == ${0} ${EMPTY}
100
101 # Return the first list entry.
102 [Return] ${software_inventory}[0]
Sushil Singh87dcee12019-08-07 13:13:13 -0500103
104
105Redfish Upload Image And Check Progress State
106 [Documentation] Code update with ApplyTime.
107 [Arguments] ${apply_time}
108
109 # Description of argument(s):
110 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
111
112 Set ApplyTime policy=${apply_Time}
113 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${IMAGE_FILE_PATH}
114
115 ${image_id}= Get Latest Image ID
116 Rprint Vars image_id
117
118 Check Image Update Progress State
119 ... match_state='Disabled', 'Updating' image_id=${image_id}
120
121 # Wait a few seconds to check if the update progress started.
122 Sleep 5s
123 Check Image Update Progress State
124 ... match_state='Updating' image_id=${image_id}
125
126 Wait Until Keyword Succeeds 8 min 20 sec
127 ... Check Image Update Progress State
128 ... match_state='Enabled' image_id=${image_id}
129
130
131Reboot BMC And Verify BMC Image
132 [Documentation] Reboot or wait for BMC standby post reboot and
133 ... verify installed image is functional.
134 [Arguments] ${apply_time} ${start_boot_seconds}
135
136 # Description of argument(s):
137 # policy ApplyTime allowed values
138 # (e.g. "OnReset", "Immediate").
139 # start_boot_seconds See 'Wait For Reboot' for details.
140
141 Run Keyword if 'OnReset' == '${apply_time}'
142 ... Run Keyword
143 ... Redfish OBMC Reboot (off)
144 ... ELSE
145 ... Run Keyword
146 ... Wait For Reboot start_boot_seconds=${start_boot_seconds}
147 Redfish.Login
148 Redfish Verify BMC Version ${IMAGE_FILE_PATH}
149