blob: 190e4fc33b632f3abaaad7618dbdf0c6e1044f7d [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
2Resource ../lib/resource.txt
3Resource ../lib/rest_client.robot
4
5Library OperatingSystem
6
7*** Variables ***
8${SYSTEM_SHUTDOWN_TIME} ${5}
9
10*** Keywords ***
Chris Austenb29d2e82016-06-07 12:25:35 -050011Wait For Host To Ping
root442f0ef2016-08-04 20:23:05 +000012 [Arguments] ${host} ${timeout}=${OPENBMC_REBOOT_TIMEOUT}min
13 ... ${interval}=5 sec
14
15 # host The DNS name or IP of the host to ping.
16 # timeout The amount of time after which attempts to ping cease.
17 # interval The amount of time in between attempts to ping.
18
19 Wait Until Keyword Succeeds ${timeout} ${interval} Ping Host ${host}
Chris Austenb29d2e82016-06-07 12:25:35 -050020
21Ping Host
22 [Arguments] ${host}
George Keishing8a84f952016-08-25 04:54:53 -050023 Should Not Be Empty ${host} msg=No host provided
Chris Austenb29d2e82016-06-07 12:25:35 -050024 ${RC} ${output} = Run and return RC and Output ping -c 4 ${host}
25 Log RC: ${RC}\nOutput:\n${output}
26 Should be equal ${RC} ${0}
27
28Get Boot Progress
29 ${state} = Read Attribute /org/openbmc/sensors/host/BootProgress value
30 [return] ${state}
31
32Is Power On
root442f0ef2016-08-04 20:23:05 +000033 ${state}= Get Power State
34 Should be equal ${state} ${1}
Chris Austenb29d2e82016-06-07 12:25:35 -050035
36Is Power Off
root442f0ef2016-08-04 20:23:05 +000037 ${state}= Get Power State
38 Should be equal ${state} ${0}
Chris Austenb29d2e82016-06-07 12:25:35 -050039
root442f0ef2016-08-04 20:23:05 +000040Initiate Power On
41 [Documentation] Initiates the power on and waits until the Is Power On
42 ... keyword returns that the power state has switched to on.
Chris Austenb29d2e82016-06-07 12:25:35 -050043 @{arglist}= Create List
44 ${args}= Create Dictionary data=@{arglist}
45 ${resp}= Call Method /org/openbmc/control/chassis0/ powerOn data=${args}
46 should be equal as strings ${resp.status_code} ${HTTP_OK}
47 Wait Until Keyword Succeeds 3 min 10 sec Is Power On
48
root442f0ef2016-08-04 20:23:05 +000049Initiate Power Off
50 [Documentation] Initiates the power off and waits until the Is Power Off
51 ... keyword returns that the power state has switched to off.
Chris Austenb29d2e82016-06-07 12:25:35 -050052 @{arglist}= Create List
53 ${args}= Create Dictionary data=@{arglist}
54 ${resp}= Call Method /org/openbmc/control/chassis0/ powerOff data=${args}
55 should be equal as strings ${resp.status_code} ${HTTP_OK}
56 Wait Until Keyword Succeeds 1 min 10 sec Is Power Off
57
58Trigger Warm Reset
59 log to console "Triggering warm reset"
60 ${data} = create dictionary data=@{EMPTY}
61 ${resp} = openbmc post request /org/openbmc/control/bmc0/action/warmReset data=${data}
62 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
63 Sleep ${SYSTEM_SHUTDOWN_TIME}min
64 Wait For Host To Ping ${OPENBMC_HOST}
Michael Walsh49ab0f42016-07-20 11:44:33 -050065
66Check OS
root442f0ef2016-08-04 20:23:05 +000067 [Documentation] Attempts to ping the host OS and then checks that the host
68 ... OS is up by running an SSH command.
Michael Walsh49ab0f42016-07-20 11:44:33 -050069
70 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
71 ... ${os_password}=${OS_PASSWORD}
72 [Teardown] Close Connection
73
74 # os_host The DNS name/IP of the OS host associated with our BMC.
75 # os_username The username to be used to sign on to the OS host.
76 # os_password The password to be used to sign on to the OS host.
77
root442f0ef2016-08-04 20:23:05 +000078 # Attempt to ping the OS. Store the return code to check later.
79 ${ping_rc}= Run Keyword and Return Status Ping Host ${os_host}
80
Michael Walsh49ab0f42016-07-20 11:44:33 -050081 Open connection ${os_host}
82 Login ${os_username} ${os_password}
83
84 ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True
85 ... return_rc=True
86
87 # If the return code returned by "Execute Command" is non-zero, this keyword
88 # will fail.
89 Should Be Equal ${rc} ${0}
90 # We will likewise fail if there is any stderr data.
91 Should Be Empty ${stderr}
92
root442f0ef2016-08-04 20:23:05 +000093 # We will likewise fail if the OS did not ping, as we could SSH but not ping
94 Should Be Equal As Strings ${ping_rc} ${TRUE}
95
Michael Walsh49ab0f42016-07-20 11:44:33 -050096Wait for OS
97 [Documentation] Waits for the host OS to come up via calls to "Check OS".
98 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
99 ... ${os_password}=${OS_PASSWORD} ${timeout}=${OS_WAIT_TIMEOUT}
100
101 # os_host The DNS name or IP of the OS host associated with our
102 # BMC.
103 # os_username The username to be used to sign on to the OS host.
104 # os_password The password to be used to sign on to the OS host.
105 # timeout The timeout in seconds indicating how long you're
106 # willing to wait for the OS to respond.
107
108 # The interval to be used between calls to "Check OS".
109 ${interval}= Set Variable 5
110
111 Wait Until Keyword Succeeds ${timeout} sec ${interval} Check OS
112 ... ${os_host} ${os_username} ${os_password}
root442f0ef2016-08-04 20:23:05 +0000113
114Get BMC State
115 [Documentation] Returns the state of the BMC as a string. (i.e: BMC_READY)
116 @{arglist}= Create List
117 ${args}= Create Dictionary data=@{arglist}
118 ${resp}= Call Method /org/openbmc/managers/System/ getSystemState
119 ... data=${args}
120 Should be equal as strings ${resp.status_code} ${HTTP_OK}
121 ${content}= to json ${resp.content}
122 [return] ${content["data"]}
123
124Get Power State
125 [Documentation] Returns the power state as an integer. Either 0 or 1.
126 @{arglist}= Create List
127 ${args}= Create Dictionary data=@{arglist}
128 ${resp}= Call Method /org/openbmc/control/chassis0/ getPowerState
129 ... data=${args}
130 Should be equal as strings ${resp.status_code} ${HTTP_OK}
131 ${content}= to json ${resp.content}
132 [return] ${content["data"]}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500133
134Clear BMC Record Log
135 [Documentation] Clears all the event logs on the BMC. This would be
136 ... equivalent to ipmitool sel clear.
137 @{arglist}= Create List
138 ${args}= Create Dictionary data=@{arglist}
139 ${resp}= Call Method /org/openbmc/records/events/ clear data=${args}
140 should be equal as strings ${resp.status_code} ${HTTP_OK}
141
142Copy PNOR to BMC
143 Import Library SCPLibrary WITH NAME scp
144 Open Connection for SCP
145 Log Copying ${PNOR_IMAGE_PATH} to /tmp
146 scp.Put File ${PNOR_IMAGE_PATH} /tmp
147
148Flash PNOR
149 [Documentation] Calls flash bios update method to flash PNOR image
150 [arguments] ${pnor_image}
151 @{arglist}= Create List ${pnor_image}
152 ${args}= Create Dictionary data=@{arglist}
153 ${resp}= Call Method /org/openbmc/control/flash/bios/ update data=${args}
154 should be equal as strings ${resp.status_code} ${HTTP_OK}
155 Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing
156
157Get Flash BIOS Status
158 [Documentation] Returns the status of the flash BIOS API as a string. For
159 ... example 'Flashing', 'Flash Done', etc
160 ${data}= Read Properties /org/openbmc/control/flash/bios
161 [return] ${data['status']}
162
163Is PNOR Flashing
164 [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR
165 ... flashing has started.
166 ${status}= Get Flash BIOS Status
167 should be equal as strings ${status} Flashing
168
169Is PNOR Flash Done
170 [Documentation] Get BIOS 'Flash Done' status. This indicates that the
171 ... PNOR flashing has completed.
172 ${status}= Get Flash BIOS Status
173 should be equal as strings ${status} Flash Done
174
175Is System State Host Booted
176 [Documentation] Checks whether system state is HOST_BOOTED.
177 ${state}= Get BMC State
178 should be equal as strings ${state} HOST_BOOTED