xref: /openbmc/openbmc-test-automation/redfish/managers/test_bmc_protocol_settings.robot (revision 6fb70d98f2f1cb9273ba912deaa2cebe3c23ea86)
1abbce3daSPrashanth Katti*** Settings ***
2abbce3daSPrashanth KattiDocumentation  Test BMC manager protocol enable/disable functionality.
3abbce3daSPrashanth Katti
4abbce3daSPrashanth KattiResource   ../../lib/bmc_redfish_resource.robot
5abbce3daSPrashanth KattiResource   ../../lib/openbmc_ffdc.robot
6f59a73e8SPrashanth KattiResource   ../../lib/protocol_setting_utils.robot
7abbce3daSPrashanth Katti
8274b7241SBrian MaSuite Setup     Suite Setup Execution
9274b7241SBrian MaSuite Teardown  Run Keywords  Enable IPMI Protocol  ${initial_ipmi_state}  AND  Redfish.Logout
10abbce3daSPrashanth KattiTest Teardown   FFDC On Test Case Fail
11abbce3daSPrashanth Katti
12*6fb70d98SMatt FischerTest Tags      BMC_Protocol_Settings
13abbce3daSPrashanth Katti
1470620175SPrashanth Katti*** Variables ***
1570620175SPrashanth Katti
166f1d9d86Smeghagn${cmd_prefix}            ipmitool -I lanplus -C 17 -p 623 -U ${IPMI_USERNAME} -P ${IPMI_PASSWORD}
17e2b32b69SMegha G N${SETTING_WAIT_TIMEOUT}  30s
1870620175SPrashanth Katti
1970620175SPrashanth Katti
20abbce3daSPrashanth Katti*** Test Cases ***
21abbce3daSPrashanth Katti
222e413457SPrashanth KattiVerify SSH Is Enabled By Default
232e413457SPrashanth Katti    [Documentation]  Verify SSH is enabled by default.
242e413457SPrashanth Katti    [Tags]  Verify_SSH_Is_Enabled_By_Default
252e413457SPrashanth Katti
262e413457SPrashanth Katti    # Check if SSH is enabled by default.
272e413457SPrashanth Katti    Verify SSH Protocol State  ${True}
282e413457SPrashanth Katti
292e413457SPrashanth Katti
30abbce3daSPrashanth KattiEnable SSH Protocol And Verify
31abbce3daSPrashanth Katti    [Documentation]  Enable SSH protocol and verify.
32abbce3daSPrashanth Katti    [Tags]  Enable_SSH_Protocol_And_Verify
33abbce3daSPrashanth Katti
34abbce3daSPrashanth Katti    Enable SSH Protocol  ${True}
35abbce3daSPrashanth Katti
36abbce3daSPrashanth Katti    # Check if SSH is really enabled via Redfish.
37abbce3daSPrashanth Katti    Verify SSH Protocol State  ${True}
38abbce3daSPrashanth Katti
39abbce3daSPrashanth Katti    # Check if SSH login and commands on SSH session work.
40abbce3daSPrashanth Katti    Verify SSH Login And Commands Work
41abbce3daSPrashanth Katti
42abbce3daSPrashanth Katti
43abbce3daSPrashanth KattiDisable SSH Protocol And Verify
44abbce3daSPrashanth Katti    [Documentation]  Disable SSH protocol and verify.
4553a5c89cSGeorge Keishing    [Tags]  Disable_SSH_Protocol_And_Verify
46abbce3daSPrashanth Katti    [Teardown]  Enable SSH Protocol  ${True}
47abbce3daSPrashanth Katti
48abbce3daSPrashanth Katti    # Disable SSH interface.
49abbce3daSPrashanth Katti    Enable SSH Protocol  ${False}
50abbce3daSPrashanth Katti
51abbce3daSPrashanth Katti    # Check if SSH is really disabled via Redfish.
52abbce3daSPrashanth Katti    Verify SSH Protocol State  ${False}
53abbce3daSPrashanth Katti
54abbce3daSPrashanth Katti    # Check if SSH login and commands fail.
55abbce3daSPrashanth Katti    ${status}=  Run Keyword And Return Status
56abbce3daSPrashanth Katti    ...  Verify SSH Login And Commands Work
57abbce3daSPrashanth Katti
58abbce3daSPrashanth Katti    Should Be Equal As Strings  ${status}  False
59abbce3daSPrashanth Katti    ...  msg=SSH Login and commands are working after disabling SSH.
60abbce3daSPrashanth Katti
61abbce3daSPrashanth Katti
62abbce3daSPrashanth KattiEnable SSH Protocol And Check Persistency On BMC Reboot
63abbce3daSPrashanth Katti    [Documentation]  Enable SSH protocol and verify persistency.
6453a5c89cSGeorge Keishing    [Tags]  Enable_SSH_Protocol_And_Check_Persistency_On_BMC_Reboot
65abbce3daSPrashanth Katti
66abbce3daSPrashanth Katti    Enable SSH Protocol  ${True}
67abbce3daSPrashanth Katti
68abbce3daSPrashanth Katti    # Reboot BMC and verify persistency.
69a4c4040cSMegha GN    Redfish OBMC Reboot (off)  stack_mode=skip
70abbce3daSPrashanth Katti
71abbce3daSPrashanth Katti    # Check if SSH is really enabled via Redfish.
72abbce3daSPrashanth Katti    Verify SSH Protocol State  ${True}
73abbce3daSPrashanth Katti
74abbce3daSPrashanth Katti    # Check if SSH login and commands on SSH session work.
75abbce3daSPrashanth Katti    Verify SSH Login And Commands Work
76abbce3daSPrashanth Katti
77abbce3daSPrashanth Katti
78abbce3daSPrashanth KattiDisable SSH Protocol And Check Persistency On BMC Reboot
79abbce3daSPrashanth Katti    [Documentation]  Disable SSH protocol and verify persistency.
8053a5c89cSGeorge Keishing    [Tags]  Disable_SSH_Protocol_And_Check_Persistency_On_BMC_Reboot
81abbce3daSPrashanth Katti    [Teardown]  Enable SSH Protocol  ${True}
82abbce3daSPrashanth Katti
83abbce3daSPrashanth Katti    # Disable SSH interface.
84abbce3daSPrashanth Katti    Enable SSH Protocol  ${False}
85abbce3daSPrashanth Katti
86abbce3daSPrashanth Katti    # Reboot BMC and verify persistency.
87a4c4040cSMegha GN    Redfish OBMC Reboot (off)  stack_mode=skip
88abbce3daSPrashanth Katti
89abbce3daSPrashanth Katti    # Check if SSH is really disabled via Redfish.
90abbce3daSPrashanth Katti    Verify SSH Protocol State  ${False}
91abbce3daSPrashanth Katti
92abbce3daSPrashanth Katti    # Check if SSH login and commands fail.
93abbce3daSPrashanth Katti    ${status}=  Run Keyword And Return Status
94abbce3daSPrashanth Katti    ...  Verify SSH Login And Commands Work
95abbce3daSPrashanth Katti
96abbce3daSPrashanth Katti    Should Be Equal As Strings  ${status}  False
97abbce3daSPrashanth Katti    ...  msg=SSH Login and commands are working after disabling SSH.
98abbce3daSPrashanth Katti
99abbce3daSPrashanth Katti
1002e413457SPrashanth KattiVerify Disabling SSH Port Does Not Disable Serial Console Port
1012e413457SPrashanth Katti    [Documentation]  Verify disabling SSH does not disable serial console port.
1022e413457SPrashanth Katti    [Tags]  Verify_Disabling_SSH_Port_Does_Not_Disable_Serial_Console_Port
1032e413457SPrashanth Katti    [Teardown]  Enable SSH Protocol  ${True}
1042e413457SPrashanth Katti
1052e413457SPrashanth Katti    # Disable SSH interface.
1062e413457SPrashanth Katti    Enable SSH Protocol  ${False}
1072e413457SPrashanth Katti
1082e413457SPrashanth Katti    # Check able to establish connection with serial port console.
1092e413457SPrashanth Katti    Open Connection And Log In  host=${OPENBMC_HOST}  port=2200
1102e413457SPrashanth Katti    Close All Connections
1112e413457SPrashanth Katti
1122e413457SPrashanth Katti
1132e413457SPrashanth KattiVerify Existing SSH Session Gets Closed On Disabling SSH
1142e413457SPrashanth Katti    [Documentation]  Verify existing SSH session gets closed on disabling ssh.
1152e413457SPrashanth Katti    [Tags]  Verify_Existing_SSH_Session_Gets_Closed_On_Disabling_SSH
1162e413457SPrashanth Katti    [Teardown]  Enable SSH Protocol  ${True}
1172e413457SPrashanth Katti
1182e413457SPrashanth Katti    # Open SSH connection.
1192e413457SPrashanth Katti    Open Connection And Login
1202e413457SPrashanth Katti
1212e413457SPrashanth Katti    # Disable SSH interface.
1222e413457SPrashanth Katti    Enable SSH Protocol  ${False}
1232e413457SPrashanth Katti
1242e413457SPrashanth Katti    # Check if SSH is really disabled via Redfish.
1252e413457SPrashanth Katti    Verify SSH Protocol State  ${False}
1262e413457SPrashanth Katti
1272e413457SPrashanth Katti    # Try to execute CLI command on SSH connection.
1282e413457SPrashanth Katti    # It should fail as disable SSH will close pre existing sessions.
1292e413457SPrashanth Katti    ${status}=  Run Keyword And Return Status
1302e413457SPrashanth Katti    ...  BMC Execute Command  /sbin/ip addr
1312e413457SPrashanth Katti
1322e413457SPrashanth Katti    Should Be Equal As Strings  ${status}  False
1332e413457SPrashanth Katti    ...  msg=Disabling SSH has not closed existing SSH sessions.
1342e413457SPrashanth Katti
1352e413457SPrashanth Katti
13670620175SPrashanth KattiEnable IPMI Protocol And Verify
13770620175SPrashanth Katti    [Documentation]  Enable IPMI protocol and verify.
13870620175SPrashanth Katti    [Tags]  Enable_IPMI_Protocol_And_Verify
13970620175SPrashanth Katti
14070620175SPrashanth Katti    Enable IPMI Protocol  ${True}
14170620175SPrashanth Katti
14270620175SPrashanth Katti    # Check if IPMI is really enabled via Redfish.
14370620175SPrashanth Katti    Verify IPMI Protocol State  ${True}
14470620175SPrashanth Katti
14570620175SPrashanth Katti    # Check if IPMI commands starts working.
14670620175SPrashanth Katti    Verify IPMI Works  lan print
14770620175SPrashanth Katti
14870620175SPrashanth Katti
14970620175SPrashanth KattiDisable IPMI Protocol And Verify
15070620175SPrashanth Katti    [Documentation]  Disable IPMI protocol and verify.
15170620175SPrashanth Katti    [Tags]  Disable_IPMI_Protocol_And_Verify
15270620175SPrashanth Katti
15370620175SPrashanth Katti    # Disable IPMI interface.
15470620175SPrashanth Katti    Enable IPMI Protocol  ${False}
15570620175SPrashanth Katti
15670620175SPrashanth Katti    # Check if IPMI is really disabled via Redfish.
15770620175SPrashanth Katti    Verify IPMI Protocol State  ${False}
15870620175SPrashanth Katti
15970620175SPrashanth Katti    # Check if IPMI commands fail.
16070620175SPrashanth Katti    ${status}=  Run Keyword And Return Status
16170620175SPrashanth Katti    ...  Verify IPMI Works  lan print
16270620175SPrashanth Katti
16370620175SPrashanth Katti    Should Be Equal As Strings  ${status}  False
16470620175SPrashanth Katti    ...  msg=IPMI commands are working after disabling IPMI.
16570620175SPrashanth Katti
16670620175SPrashanth Katti
167ef433de8SmeghagnEnable IPMI Protocol And Check Persistency On BMC Reboot
16833be359bSGeorge Keishing    [Documentation]  Set the IPMI protocol attribute to True, reset BMC, and verify
16933be359bSGeorge Keishing    ...              that the setting persists.
170ef433de8Smeghagn    [Tags]  Enable_IPMI_Protocol_And_Check_Persistency_On_BMC_Reboot
171ef433de8Smeghagn
172ef433de8Smeghagn    Enable IPMI Protocol  ${True}
173ef433de8Smeghagn
174ef433de8Smeghagn    Redfish OBMC Reboot (off)  stack_mode=skip
175ef433de8Smeghagn
176ef433de8Smeghagn    # Check if the IPMI enabled is set.
177ef433de8Smeghagn    Verify IPMI Protocol State  ${True}
178ef433de8Smeghagn
179ef433de8Smeghagn    # Confirm that IPMI commands to access BMC work.
180ef433de8Smeghagn    Verify IPMI Works  lan print
181ef433de8Smeghagn
182ef433de8Smeghagn
183ef433de8SmeghagnDisable IPMI Protocol And Check Persistency On BMC Reboot
18433be359bSGeorge Keishing    [Documentation]  Set the IPMI protocol attribute to False, reset BMC, and verify
18533be359bSGeorge Keishing    ...              that the setting persists.
186ef433de8Smeghagn    [Tags]  Disable_IPMI_Protocol_And_Check_Persistency_On_BMC_Reboot
187ef433de8Smeghagn
188ef433de8Smeghagn    # Disable IPMI interface.
189ef433de8Smeghagn    Enable IPMI Protocol  ${False}
190ef433de8Smeghagn
191ef433de8Smeghagn    Redfish OBMC Reboot (off)  stack_mode=skip
192ef433de8Smeghagn
193ef433de8Smeghagn    # Check if the IPMI disabled is set.
194ef433de8Smeghagn    Verify IPMI Protocol State  ${False}
195ef433de8Smeghagn
196ef433de8Smeghagn    # Confirm that IPMI connection request fails.
197ef433de8Smeghagn    ${status}=  Run Keyword And Return Status
198ef433de8Smeghagn    ...  Verify IPMI Works  lan print
199ef433de8Smeghagn
200ef433de8Smeghagn    Should Be Equal As Strings  ${status}  False
201ef433de8Smeghagn    ...  msg=IPMI commands are working after disabling IPMI.
202ef433de8Smeghagn
203ef433de8Smeghagn
204e21e1a39SMegha GNConfigure SSH And IPMI Settings And Verify
205e21e1a39SMegha GN    [Documentation]  Set the SSH and IPMI protocol attribute to True/False, and verify.
206e21e1a39SMegha GN    [Tags]  Configure_SSH_And_IPMI_Settings_And_Verify
207e21e1a39SMegha GN    [Template]  Set SSH And IPMI Protocol
208ab2553ebSMegha G N    [Teardown]  Run Keywords  FFDC On Test Case Fail
209ab2553ebSMegha G N    ...  AND  Enable SSH Protocol  ${True}
2106f1d9d86Smeghagn
211e21e1a39SMegha GN    # ssh_state  ipmi_state
212e21e1a39SMegha GN    ${True}      ${False}
213e21e1a39SMegha GN    ${True}      ${True}
214e21e1a39SMegha GN    ${False}     ${True}
215e21e1a39SMegha GN    ${False}     ${False}
2166f1d9d86Smeghagn
2176f1d9d86Smeghagn
218ab2553ebSMegha G NConfigure SSH And IPMI Settings And Verify Persistency On BMC Reboot
219ab2553ebSMegha G N    [Documentation]  Set the SSH and IPMI protocol attribute to True/False, and verify
220ab2553ebSMegha G N    ...  it's persistency after BMC reboot.
221ab2553ebSMegha G N    [Tags]  Configure_SSH_And_IPMI_Settings_And_Verify_Persistency_On_BMC_Reboot
222ab2553ebSMegha G N    [Template]  Set SSH And IPMI Protocol
223ab2553ebSMegha G N    [Teardown]  Run Keywords  FFDC On Test Case Fail
224ab2553ebSMegha G N    ...  AND  Enable SSH Protocol  ${True}
2257735cbbaSMegha G N
226ab2553ebSMegha G N    # ssh_state  ipmi_state  persistency_check
227ab2553ebSMegha G N    ${True}      ${False}    ${True}
228ab2553ebSMegha G N    ${True}      ${True}     ${True}
229ab2553ebSMegha G N    ${False}     ${True}     ${True}
230ab2553ebSMegha G N    ${False}     ${False}    ${True}
2317735cbbaSMegha G N
2327735cbbaSMegha G N
233abbce3daSPrashanth Katti*** Keywords ***
234abbce3daSPrashanth Katti
235274b7241SBrian MaSuite Setup Execution
236274b7241SBrian Ma    [Documentation]  Do suite setup tasks.
237274b7241SBrian Ma
238274b7241SBrian Ma    Redfish.Login
239274b7241SBrian Ma
240274b7241SBrian Ma    ${state}=  Run Keyword And Return Status  Verify IPMI Protocol State
241274b7241SBrian Ma    Set Suite Variable  ${initial_ipmi_state}  ${state}
242e21e1a39SMegha GN    Sleep  ${NETWORK_TIMEOUT}s
243274b7241SBrian Ma
2446f1d9d86Smeghagn
2456f1d9d86SmeghagnSet SSH And IPMI Protocol
2466f1d9d86Smeghagn    [Documentation]  Set SSH and IPMI protocol state.
2477735cbbaSMegha G N    [Arguments]  ${ssh_state}  ${ipmi_state}  ${persistency_check}=${False}
2486f1d9d86Smeghagn
2496f1d9d86Smeghagn    # Description of argument(s):
250e21e1a39SMegha GN    # ssh_state     State of SSH to be set (e.g. True, False).
251e21e1a39SMegha GN    # ipmi_state    State of IPMI to be set (e.g. True, False).
2526f1d9d86Smeghagn
2536f1d9d86Smeghagn    ${ssh_protocol_state}=  Create Dictionary  ProtocolEnabled=${ssh_state}
2546f1d9d86Smeghagn    ${ipmi_protocol_state}=  Create Dictionary  ProtocolEnabled=${ipmi_state}
2556f1d9d86Smeghagn    ${data}=  Create Dictionary  SSH=${ssh_protocol_state}  IPMI=${ipmi_protocol_state}
2566f1d9d86Smeghagn
2576f1d9d86Smeghagn    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body=&{data}
2586f1d9d86Smeghagn    ...  valid_status_codes=[${HTTP_NO_CONTENT}]
2596f1d9d86Smeghagn
2606f1d9d86Smeghagn    # Wait for timeout for new values to take effect.
261e2b32b69SMegha G N    Sleep  ${SETTING_WAIT_TIMEOUT}
262e21e1a39SMegha GN
263ab2553ebSMegha G N    Run Keyword if  ${persistency_check} == ${True}
264ab2553ebSMegha G N    ...  Redfish OBMC Reboot (off)  stack_mode=skip
265e21e1a39SMegha GN    Verify Protocol State  ${ssh_state}  ${ipmi_state}
266e21e1a39SMegha GN
267e21e1a39SMegha GN
268e21e1a39SMegha GNVerify Protocol State
269e21e1a39SMegha GN    [Documentation]  Verify SSH and IPMI protocol state.
270e21e1a39SMegha GN    [Arguments]  ${ssh_state}  ${ipmi_state}
271e21e1a39SMegha GN
272e21e1a39SMegha GN    # Description of argument(s):
273e21e1a39SMegha GN    # ssh_state     State of SSH to be verified (e.g. True, False).
274e21e1a39SMegha GN    # ipmi_state    State of IPMI to be verified (e.g. True, False).
275e21e1a39SMegha GN
276e21e1a39SMegha GN    # Verify SSH state value.
277e21e1a39SMegha GN    ${status}=  Run Keyword And Return Status
278e21e1a39SMegha GN    ...  Verify SSH Login And Commands Work
279e21e1a39SMegha GN    Should Be Equal As Strings  ${status}  ${ssh_state}
280e21e1a39SMegha GN    ...  msg=SSH states are not matching.
281e21e1a39SMegha GN
282e21e1a39SMegha GN    # Verify IPMI state value.
283e21e1a39SMegha GN    ${status}=  Run Keyword And Return Status
284e21e1a39SMegha GN    ...  Verify IPMI Works  lan print
285e21e1a39SMegha GN
286e21e1a39SMegha GN    Should Be Equal As Strings  ${status}  ${ipmi_state}
287e21e1a39SMegha GN    ...  msg=IPMI states are not matching.
288