blob: c931ab63f110bc6e14ad723be7b65b838d79ba00 [file] [log] [blame]
Leah McNuttf9689502016-11-03 15:38:08 +00001*** Settings ***
2Documentation Contains all keywords and supporting keywords to do various reboots.
3
4Resource ../resource.txt
5Resource ../utils.robot
6Resource ../connection_client.robot
7Library DateTime
8
9*** Keywords ***
10BMC Reboot
11 [Documentation] Gets the uptime of the BMC, then reboots the BMC. If an OS_HOST
12 ... is given, will also attempt to get the uptime of the OS Host and verify that
13 ... the host stayed active during the reboot.
14
15 &{bmc_connection_args}= Create Dictionary alias=bmc_connection
16 ${OS_exists}= Set Variable If '${OS_HOST}' != '${EMPTY}' ${True}
17 ... '${OS_HOST}' == '${EMPTY}' ${False}
18
19 &{os_connection_args}= Run Keyword If ${OS_exists} == ${True}
20 ... Create Dictionary host=${OS_HOST} alias=os_connection
21
22 Open Connection and Log In &{bmc_connection_args}
23
24 ${bmc_start_uptime}= Get Uptime In Seconds
25
26 ${conn_rc}= Run Keyword and Return Status Run Keyword If ${OS_exists} == ${True}
27 ... Open Connection and Log In ${OS_USERNAME} ${OS_PASSWORD} &{os_connection_args}
28
29 ${OS_exists}= Set Variable If ${conn_rc} == False ${False}
30
31 ${ping_rc}= Run Keyword and Return Status Ping Host ${OS_HOST}
32 ${OS_exists}= Set Variable If ${ping_rc} == ${False} ${False}
33
34 ${os_start_uptime}= Run Keyword If ${OS_exists} == ${True} Get Uptime In Seconds
35
36 Validate or Open Connection bmc_connection
37
38 Reboot BMC
39 Check If BMC Is Up
40
41 Close All Connections
42
43 Open Connection and Log In &{bmc_connection_args}
44
45 ${bmc_end_uptime}= Get Uptime In Seconds
46 Should Be True ${bmc_end_uptime} < ${bmc_start_uptime}
47
48 Run Keyword If ${OS_exists} == ${True}
49 ... Open Connection and Log In ${OS_USERNAME} ${OS_PASSWORD} &{os_connection_args}
50
51 ${os_end_uptime}= Run Keyword If ${OS_exists} == ${True} Get Uptime In Seconds
52
53 Run Keyword If ${OS_exists} == ${True}
54 ... Should Be True ${os_end_uptime} > ${os_start_uptime}
55
56 Close All Connections
57
58Get Uptime In Seconds
59 ${uptime_string} ${stderr} ${rc}= Execute Command cat /proc/uptime
60 ... return_stderr=True return_rc=True
61
62 Should Be Empty ${stderr}
63 Should Be Equal ${rc} ${0}
64
65 ${uptime} ${idle_time}= Split String ${uptime_string} ${SPACE}
66
67 [return] ${uptime}
68
69Reboot BMC
70 Start Command /sbin/reboot