blob: 6d12349cc9f5082c9aad82a439138aeeac81f0ce [file] [log] [blame]
George Keishing5e870cd2016-08-24 10:05:47 -05001*** Settings ***
2Documentation Code update utility
3
4Resource ../../lib/rest_client.robot
5Resource ../../lib/connection_client.robot
6Resource ../../lib/utils.robot
7Library OperatingSystem
8
9*** Variables ***
10
George Keishing0fd3b242016-11-24 09:01:41 -060011${BMC_UPD_METHOD} ${OPENBMC_BASE_URI}control/flash/bmc/action/update
12${BMC_PREP_METHOD} ${OPENBMC_BASE_URI}control/flash/bmc/action/PrepareForUpdate
13${BMC_UPD_ATTR} ${OPENBMC_BASE_URI}control/flash/bmc
14${HOST_SETTING} ${OPENBMC_BASE_URI}settings/host0
George Keishing5e870cd2016-08-24 10:05:47 -050015
16*** Keywords ***
17
18Preserve BMC Network Setting
19 [Documentation] Preserve Network setting
Gunnar Mills597ffa02016-12-06 11:26:53 -060020 ${policy}= Set Variable ${1}
21 ${value}= create dictionary data=${policy}
George Keishing5e870cd2016-08-24 10:05:47 -050022 Write Attribute ${BMC_UPD_ATTR} preserve_network_settings data=${value}
23 ${data}= Read Properties ${BMC_UPD_ATTR}
24 should be equal as strings ${data['preserve_network_settings']} ${1}
25 ... msg=0 indicates network is not preserved
26
27
28Activate BMC flash image
29 [Documentation] Activate and verify the update status
30 ... The status could be either one of these
31 ... 'Deferred for mounted filesystem. reboot BMC to apply.'
32 ... 'Image ready to apply.'
Gunnar Mills597ffa02016-12-06 11:26:53 -060033 @{img_path}= Create List /tmp/flashimg
34 ${data}= create dictionary data=@{img_path}
George Keishing5e870cd2016-08-24 10:05:47 -050035 ${resp}= openbmc post request ${BMC_UPD_METHOD} data=${data}
36 should be equal as strings ${resp.status_code} ${HTTP_OK}
George Keishing5e870cd2016-08-24 10:05:47 -050037
38 ${data}= Read Properties ${BMC_UPD_ATTR}
George Keishing0229cd32016-08-30 08:32:32 -050039 should be equal as strings ${data["filename"]} /tmp/flashimg
George Keishing5e870cd2016-08-24 10:05:47 -050040 should contain ${data['status']} to apply
41
42
George Keishingdc5aa58e92016-09-27 01:35:11 -050043Prepare For Update
44 [Documentation] Switch to update mode in progress. This method calls
45 ... the Abort method to remove the pending update if there
46 ... is any before code activation.
Gunnar Mills597ffa02016-12-06 11:26:53 -060047 ${data}= create dictionary data=@{EMPTY}
George Keishingdc5aa58e92016-09-27 01:35:11 -050048 ${resp}= openbmc post request ${BMC_PREP_METHOD} data=${data}
49 should be equal as strings ${resp.status_code} ${HTTP_OK}
50
51 ${data}= Read Properties ${BMC_UPD_ATTR}
52 should contain ${data['status']} Switch to update mode in progress
53
54
George Keishing5e870cd2016-08-24 10:05:47 -050055SCP Tar Image File to BMC
56 [arguments] ${filepath}
57 Open Connection for SCP
58 scp.Put File ${filepath} /tmp/flashimg
59
60
George Keishing5e870cd2016-08-24 10:05:47 -050061Check If File Exist
62 [Arguments] ${filepath}
63 Log \n PATH: ${filepath}
64 OperatingSystem.File Should Exist ${filepath}
65 ... msg=${filepath} doesn't exist [ ERROR ]
66
67 Set Global Variable ${FILE_PATH} ${filepath}
68
69
70System Readiness Test
Gunnar Mills597ffa02016-12-06 11:26:53 -060071 ${l_status}= Run Keyword and Return Status
George Keishingc4d3dc02016-09-19 03:45:55 -050072 ... Verify Ping and REST Authentication
George Keishing5e870cd2016-08-24 10:05:47 -050073 Run Keyword If '${l_status}' == '${False}'
74 ... Fail msg=System not in ideal state to use [ERROR]
75
76
George Keishing5e870cd2016-08-24 10:05:47 -050077Validate BMC Version
78 [Arguments] ${args}=post
79 # Check BMC installed version
80 Open Connection And Log In
81 ${version} ${stderr}= Execute Command cat /etc/version
82 ... return_stderr=True
83 Should Be Empty ${stderr}
84 # The File name contains the version installed
85 Run Keyword If '${args}' == 'before'
86 ... Should not Contain ${FILE_PATH} ${version}
87 ... msg=Same version already installed
88 ... ELSE
89 ... Should Contain ${FILE_PATH} ${version}
90 ... msg=Code update Failed
91
92
93Trigger Warm Reset via Reboot
George Keishing6c0f7152016-10-20 08:27:16 -050094 [Documentation] Execute reboot command on the remote BMC and
95 ... returns immediately. This keyword "Start Command"
96 ... returns nothing and does not wait for the command
97 ... execution to be finished.
George Keishing5e870cd2016-08-24 10:05:47 -050098 Open Connection And Log In
99
George Keishing6c0f7152016-10-20 08:27:16 -0500100 Start Command /sbin/reboot
George Keishing8db0e1b2016-10-20 13:46:54 -0500101
102Set Policy Setting
103 [Documentation] Set the given test policy
104 [arguments] ${policy}
105
Gunnar Mills597ffa02016-12-06 11:26:53 -0600106 ${valueDict}= create dictionary data=${policy}
George Keishing8db0e1b2016-10-20 13:46:54 -0500107 Write Attribute ${HOST_SETTING} power_policy data=${valueDict}
108 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
109 Should Be Equal ${currentPolicy} ${policy}