blob: 6c330921bc5ff3208266a5e13f61baa1db663494 [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
11${BMC_UPD_METHOD} /org/openbmc/control/flash/bmc/action/update
12${BMC_UPD_ATTR} /org/openbmc/control/flash/bmc
13
14*** Keywords ***
15
16Preserve BMC Network Setting
17 [Documentation] Preserve Network setting
18 ${policy} = Set Variable ${1}
19 ${value} = create dictionary data=${policy}
20 Write Attribute ${BMC_UPD_ATTR} preserve_network_settings data=${value}
21 ${data}= Read Properties ${BMC_UPD_ATTR}
22 should be equal as strings ${data['preserve_network_settings']} ${1}
23 ... msg=0 indicates network is not preserved
24
25
26Activate BMC flash image
27 [Documentation] Activate and verify the update status
28 ... The status could be either one of these
29 ... 'Deferred for mounted filesystem. reboot BMC to apply.'
30 ... 'Image ready to apply.'
31 @{img_path} = Create List /tmp/flashimg
32 ${data} = create dictionary data=@{img_path}
33 ${resp}= openbmc post request ${BMC_UPD_METHOD} data=${data}
34 should be equal as strings ${resp.status_code} ${HTTP_OK}
George Keishing5e870cd2016-08-24 10:05:47 -050035
36 ${data}= Read Properties ${BMC_UPD_ATTR}
George Keishing0229cd32016-08-30 08:32:32 -050037 should be equal as strings ${data["filename"]} /tmp/flashimg
George Keishing5e870cd2016-08-24 10:05:47 -050038 should contain ${data['status']} to apply
39
40
41SCP Tar Image File to BMC
42 [arguments] ${filepath}
43 Open Connection for SCP
44 scp.Put File ${filepath} /tmp/flashimg
45
46
47Check If warmReset is Initiated
48 # Ping would be still alive, so try SSH to connect if fails
49 # the ports are down indicating reboot in progress
50 ${alive}= Run Keyword and Return Status
51 ... Open Connection And Log In
52 Return From Keyword If '${alive}' == '${False}' ${False}
53 [return] ${True}
54
55
56Check If File Exist
57 [Arguments] ${filepath}
58 Log \n PATH: ${filepath}
59 OperatingSystem.File Should Exist ${filepath}
60 ... msg=${filepath} doesn't exist [ ERROR ]
61
62 Set Global Variable ${FILE_PATH} ${filepath}
63
64
65System Readiness Test
66 ${l_status} = Run Keyword Verify Ping and REST Authentication
67 Run Keyword If '${l_status}' == '${False}'
68 ... Fail msg=System not in ideal state to use [ERROR]
69
70
71Wait for BMC to respond
72 # Average code update takes from 15 -20 minutes
73 # For worse case 30 minutes, check every 1 min
74 Wait For Host To Ping ${OPENBMC_HOST} 30 min 1 min
75
76
77Validate 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
94 Open Connection And Log In
95
96 ${rc}= SSHLibrary.Execute Command
97 ... /sbin/reboot return_stdout=False return_rc=True
98 Should Be Equal As Integers ${rc} 0