1*** Settings ***
2
3Documentation    Module to test IPMI chassis functionality.
4Resource         ../lib/ipmi_client.robot
5Resource         ../lib/openbmc_ffdc.robot
6Resource         ../lib/boot_utils.robot
7Library          ../lib/ipmi_utils.py
8
9Test Teardown    FFDC On Test Case Fail
10
11*** Test Cases ***
12
13IPMI Chassis Status On
14    [Documentation]  This test case verfies system power on status
15    ...               using IPMI Get Chassis status command.
16    [Tags]  IPMI_Chassis_Status_On
17
18    Redfish Power On  stack_mode=skip  quiet=1
19    ${resp}=  Run IPMI Standard Command  chassis status
20    ${power_status}=  Get Lines Containing String  ${resp}  System Power
21    Should Contain  ${power_status}  on
22
23IPMI Chassis Status Off
24    [Documentation]  This test case verfies system power off status
25    ...               using IPMI Get Chassis status command.
26    [Tags]  IPMI_Chassis_Status_Off
27
28    Redfish Power Off  stack_mode=skip  quiet=1
29    ${resp}=  Run IPMI Standard Command  chassis status
30    ${power_status}=  Get Lines Containing String  ${resp}  System Power
31    Should Contain  ${power_status}  off
32
33Verify Host PowerOff Via IPMI
34    [Documentation]   Verify host power off operation using external IPMI command.
35    [Tags]  Verify_Host_PowerOff_Via_IPMI
36
37    IPMI Power Off
38    ${ipmi_state}=  Get Host State Via External IPMI
39    Valid Value  ipmi_state  ['off']
40
41Verify Host PowerOn Via IPMI
42    [Documentation]   Verify host power on operation using external IPMI command.
43    [Tags]  Verify_Host_PowerOn_Via_IPMI
44
45    IPMI Power On
46    ${ipmi_state}=  Get Host State Via External IPMI
47    Valid Value  ipmi_state  ['on']
48
49
50Verify Soft Shutdown
51    [Documentation]  Verify host OS shutdown softly via IPMI command.
52    [Tags]  Verify_Soft_Stutdown
53
54    Redfish Power On  stack_mode=skip
55    Run IPMI Standard Command  chassis power soft
56    Wait Until Keyword Succeeds  3 min  10 sec  Is Host Off Via IPMI
57
58
59Verify Chassis Power Policy
60    [Documentation]  Verify setting chassis power policy via IPMI command.
61    [Tags]  Verify_Chassis_Power_Policy
62    [Setup]  Test Setup Execution
63    [Teardown]  Run Keywords  FFDC On Test Case Fail  AND
64    ...  Run IPMI Standard Command  chassis policy ${initial_power_policy}
65    [Template]  Set Chassis Power Policy Via IPMI And Verify
66
67    # power_policy
68    always-off
69    always-on
70    previous
71
72
73*** Keywords ***
74
75Set Chassis Power Policy Via IPMI And Verify
76    [Documentation]  Set chasiss power policy via IPMI and verify.
77    [Arguments]  ${power_policy}
78
79    # Description of argument(s):
80    # power_policy    Chassis power policy to be set(e.g. "always-off", "always-on").
81
82    Run IPMI Standard Command  chassis policy ${power_policy}
83    ${resp}=  Get Chassis Status
84    Valid Value  resp['power_restore_policy']  ['${power_policy}']
85
86
87Test Setup Execution
88    [Documentation]  Do test setup tasks.
89
90    ${chassis_status}=  Get Chassis Status
91    Set Test Variable  ${initial_power_policy}  ${chassis_status['power_restore_policy']}
92
93