blob: 7cb179af5e76bf038cbca69a20b15c8bfcc5063a [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 ***
11
12Wait For Host To Ping
13 [Arguments] ${host}
14 Wait Until Keyword Succeeds ${OPENBMC_REBOOT_TIMEOUT}min 5 sec Ping Host ${host}
15
16Ping Host
17 [Arguments] ${host}
18 ${RC} ${output} = Run and return RC and Output ping -c 4 ${host}
19 Log RC: ${RC}\nOutput:\n${output}
20 Should be equal ${RC} ${0}
21
22Get Boot Progress
23 ${state} = Read Attribute /org/openbmc/sensors/host/BootProgress value
24 [return] ${state}
25
26Is Power On
27 ${state} = Get Boot Progress
28 Should be equal ${state} FW Progress, Starting OS
29
30Is Power Off
31 ${state} = Get Boot Progress
32 Should be equal ${state} Off
33
34Power On Host
35 @{arglist}= Create List
36 ${args}= Create Dictionary data=@{arglist}
37 ${resp}= Call Method /org/openbmc/control/chassis0/ powerOn data=${args}
38 should be equal as strings ${resp.status_code} ${HTTP_OK}
39 Wait Until Keyword Succeeds 3 min 10 sec Is Power On
40
41Power Off Host
42 @{arglist}= Create List
43 ${args}= Create Dictionary data=@{arglist}
44 ${resp}= Call Method /org/openbmc/control/chassis0/ powerOff data=${args}
45 should be equal as strings ${resp.status_code} ${HTTP_OK}
46 Wait Until Keyword Succeeds 1 min 10 sec Is Power Off
47
48Trigger Warm Reset
49 log to console "Triggering warm reset"
50 ${data} = create dictionary data=@{EMPTY}
51 ${resp} = openbmc post request /org/openbmc/control/bmc0/action/warmReset data=${data}
52 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
53 Sleep ${SYSTEM_SHUTDOWN_TIME}min
54 Wait For Host To Ping ${OPENBMC_HOST}
Michael Walsh49ab0f42016-07-20 11:44:33 -050055
56Check OS
57 [Documentation] Checks that the host OS is up by running an SSH command.
58
59 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
60 ... ${os_password}=${OS_PASSWORD}
61 [Teardown] Close Connection
62
63 # os_host The DNS name/IP of the OS host associated with our BMC.
64 # os_username The username to be used to sign on to the OS host.
65 # os_password The password to be used to sign on to the OS host.
66
67 Open connection ${os_host}
68 Login ${os_username} ${os_password}
69
70 ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True
71 ... return_rc=True
72
73 # If the return code returned by "Execute Command" is non-zero, this keyword
74 # will fail.
75 Should Be Equal ${rc} ${0}
76 # We will likewise fail if there is any stderr data.
77 Should Be Empty ${stderr}
78
79Wait for OS
80 [Documentation] Waits for the host OS to come up via calls to "Check OS".
81 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
82 ... ${os_password}=${OS_PASSWORD} ${timeout}=${OS_WAIT_TIMEOUT}
83
84 # os_host The DNS name or IP of the OS host associated with our
85 # BMC.
86 # os_username The username to be used to sign on to the OS host.
87 # os_password The password to be used to sign on to the OS host.
88 # timeout The timeout in seconds indicating how long you're
89 # willing to wait for the OS to respond.
90
91 # The interval to be used between calls to "Check OS".
92 ${interval}= Set Variable 5
93
94 Wait Until Keyword Succeeds ${timeout} sec ${interval} Check OS
95 ... ${os_host} ${os_username} ${os_password}