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