xref: /openbmc/openbmc-test-automation/lib/state_manager.robot (revision aca557110becf3f4d45391b6f70d0f52f1046f4e)
1*** Settings ***
2Resource          ../lib/utils.robot
3Variables         ../data/variables.py
4
5*** Variables ***
6
7${QUIET}  ${0}
8
9*** Keywords ***
10
11Initiate Host Boot
12    [Documentation]  Initiate host power on.
13    ${args}=  Create Dictionary   data=${HOST_POWERON_TRANS}
14    Write Attribute
15    ...  ${HOST_STATE_URI}  RequestedHostTransition   data=${args}
16
17    Wait Until Keyword Succeeds
18    ...  10 min  10 sec  Is Host Running
19
20
21Initiate Host PowerOff
22    [Documentation]  Initiate host power off.
23    ${args}=  Create Dictionary   data=${HOST_POWEROFF_TRANS}
24    Write Attribute
25    ...  ${HOST_STATE_URI}  RequestedHostTransition   data=${args}
26
27    Wait Until Keyword Succeeds
28    ...  3 min  10 sec  Is Host Off
29
30
31Is Host Running
32    [Documentation]  Check if Chassis and Host state is ON.
33    ${power_state}=  Get Chassis Power State
34    Should Be Equal  On  ${power_state}
35    ${host_state}=  Get Host State
36    Should Be Equal  Running  ${host_state}
37
38
39Is Host Off
40    [Documentation]  Check if Chassis and Host state is OFF.
41    ${power_state}=  Get Chassis Power State
42    Should Be Equal  Off  ${power_state}
43    ${host_state}=  Get Host State
44    Should Be Equal  Off  ${host_state}
45
46
47Get Host State
48    [Documentation]  Return the state of the host as a string.
49    [Arguments]  ${quiet}=${QUIET}
50    # quiet - Suppress REST output logging to console.
51    ${state}=
52    ...  Read Attribute  ${HOST_STATE_URI}  CurrentHostState
53    ...  quiet=${quiet}
54    [Return]  ${state.rsplit('.', 1)[1]}
55
56
57Get Chassis Power State
58    [Documentation]  Return the power state of the Chassis
59    ...              as a string.
60    [Arguments]  ${quiet}=${QUIET}
61    # quiet - Suppress REST output logging to console.
62    ${state}=
63    ...  Read Attribute  ${CHASSIS_STATE_URI}  CurrentPowerState
64    ...  quiet=${quiet}
65    [Return]  ${state.rsplit('.', 1)[1]}
66