blob: adb76916da09e2a43d83f7541d1a376dcfeabaf4 [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 Keishingdc5aa58e92016-09-27 01:35:11 -050011${BMC_UPD_METHOD} /org/openbmc/control/flash/bmc/action/update
12${BMC_PREP_METHOD} /org/openbmc/control/flash/bmc/action/PrepareForUpdate
13${BMC_UPD_ATTR} /org/openbmc/control/flash/bmc
George Keishing5e870cd2016-08-24 10:05:47 -050014
15*** Keywords ***
16
17Preserve BMC Network Setting
18 [Documentation] Preserve Network setting
19 ${policy} = Set Variable ${1}
20 ${value} = create dictionary data=${policy}
21 Write Attribute ${BMC_UPD_ATTR} preserve_network_settings data=${value}
22 ${data}= Read Properties ${BMC_UPD_ATTR}
23 should be equal as strings ${data['preserve_network_settings']} ${1}
24 ... msg=0 indicates network is not preserved
25
26
27Activate BMC flash image
28 [Documentation] Activate and verify the update status
29 ... The status could be either one of these
30 ... 'Deferred for mounted filesystem. reboot BMC to apply.'
31 ... 'Image ready to apply.'
32 @{img_path} = Create List /tmp/flashimg
33 ${data} = create dictionary data=@{img_path}
34 ${resp}= openbmc post request ${BMC_UPD_METHOD} data=${data}
35 should be equal as strings ${resp.status_code} ${HTTP_OK}
George Keishing5e870cd2016-08-24 10:05:47 -050036
37 ${data}= Read Properties ${BMC_UPD_ATTR}
George Keishing0229cd32016-08-30 08:32:32 -050038 should be equal as strings ${data["filename"]} /tmp/flashimg
George Keishing5e870cd2016-08-24 10:05:47 -050039 should contain ${data['status']} to apply
40
41
George Keishingdc5aa58e92016-09-27 01:35:11 -050042Prepare For Update
43 [Documentation] Switch to update mode in progress. This method calls
44 ... the Abort method to remove the pending update if there
45 ... is any before code activation.
46 ${data} = create dictionary data=@{EMPTY}
47 ${resp}= openbmc post request ${BMC_PREP_METHOD} data=${data}
48 should be equal as strings ${resp.status_code} ${HTTP_OK}
49
50 ${data}= Read Properties ${BMC_UPD_ATTR}
51 should contain ${data['status']} Switch to update mode in progress
52
53
George Keishing5e870cd2016-08-24 10:05:47 -050054SCP Tar Image File to BMC
55 [arguments] ${filepath}
56 Open Connection for SCP
57 scp.Put File ${filepath} /tmp/flashimg
58
59
George Keishing5e870cd2016-08-24 10:05:47 -050060Check If File Exist
61 [Arguments] ${filepath}
62 Log \n PATH: ${filepath}
63 OperatingSystem.File Should Exist ${filepath}
64 ... msg=${filepath} doesn't exist [ ERROR ]
65
66 Set Global Variable ${FILE_PATH} ${filepath}
67
68
69System Readiness Test
George Keishingc4d3dc02016-09-19 03:45:55 -050070 ${l_status} = Run Keyword and Return Status
71 ... Verify Ping and REST Authentication
George Keishing5e870cd2016-08-24 10:05:47 -050072 Run Keyword If '${l_status}' == '${False}'
73 ... Fail msg=System not in ideal state to use [ERROR]
74
75
George Keishing5e870cd2016-08-24 10:05:47 -050076Validate BMC Version
77 [Arguments] ${args}=post
78 # Check BMC installed version
79 Open Connection And Log In
80 ${version} ${stderr}= Execute Command cat /etc/version
81 ... return_stderr=True
82 Should Be Empty ${stderr}
83 # The File name contains the version installed
84 Run Keyword If '${args}' == 'before'
85 ... Should not Contain ${FILE_PATH} ${version}
86 ... msg=Same version already installed
87 ... ELSE
88 ... Should Contain ${FILE_PATH} ${version}
89 ... msg=Code update Failed
90
91
92Trigger Warm Reset via Reboot
George Keishingb3700812016-08-31 03:03:30 -050093 [Documentation] The reboot commands execute successfully but
94 ... returns negative value 1
George Keishing5e870cd2016-08-24 10:05:47 -050095 Open Connection And Log In
96
97 ${rc}= SSHLibrary.Execute Command
98 ... /sbin/reboot return_stdout=False return_rc=True
George Keishingb3700812016-08-31 03:03:30 -050099 Should Be Equal As Integers ${rc} ${-1}