xref: /openbmc/openbmc-test-automation/redfish/managers/test_bmc_protocol_settings.robot (revision ab2553ebd9621e621dbcd3561f3c75e46d39b8ea)
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
12abbce3daSPrashanth Katti
1370620175SPrashanth Katti*** Variables ***
1470620175SPrashanth Katti
156f1d9d86Smeghagn${cmd_prefix}  ipmitool -I lanplus -C 17 -p 623 -U ${IPMI_USERNAME} -P ${IPMI_PASSWORD}
1670620175SPrashanth Katti
1770620175SPrashanth Katti
18abbce3daSPrashanth Katti*** Test Cases ***
19abbce3daSPrashanth Katti
202e413457SPrashanth KattiVerify SSH Is Enabled By Default
212e413457SPrashanth Katti    [Documentation]  Verify SSH is enabled by default.
222e413457SPrashanth Katti    [Tags]  Verify_SSH_Is_Enabled_By_Default
232e413457SPrashanth Katti
242e413457SPrashanth Katti    # Check if SSH is enabled by default.
252e413457SPrashanth Katti    Verify SSH Protocol State  ${True}
262e413457SPrashanth Katti
272e413457SPrashanth Katti
28abbce3daSPrashanth KattiEnable SSH Protocol And Verify
29abbce3daSPrashanth Katti    [Documentation]  Enable SSH protocol and verify.
30abbce3daSPrashanth Katti    [Tags]  Enable_SSH_Protocol_And_Verify
31abbce3daSPrashanth Katti
32abbce3daSPrashanth Katti    Enable SSH Protocol  ${True}
33abbce3daSPrashanth Katti
34abbce3daSPrashanth Katti    # Check if SSH is really enabled via Redfish.
35abbce3daSPrashanth Katti    Verify SSH Protocol State  ${True}
36abbce3daSPrashanth Katti
37abbce3daSPrashanth Katti    # Check if SSH login and commands on SSH session work.
38abbce3daSPrashanth Katti    Verify SSH Login And Commands Work
39abbce3daSPrashanth Katti
40abbce3daSPrashanth Katti
41abbce3daSPrashanth KattiDisable SSH Protocol And Verify
42abbce3daSPrashanth Katti    [Documentation]  Disable SSH protocol and verify.
4353a5c89cSGeorge Keishing    [Tags]  Disable_SSH_Protocol_And_Verify
44abbce3daSPrashanth Katti    [Teardown]  Enable SSH Protocol  ${True}
45abbce3daSPrashanth Katti
46abbce3daSPrashanth Katti    # Disable SSH interface.
47abbce3daSPrashanth Katti    Enable SSH Protocol  ${False}
48abbce3daSPrashanth Katti
49abbce3daSPrashanth Katti    # Check if SSH is really disabled via Redfish.
50abbce3daSPrashanth Katti    Verify SSH Protocol State  ${False}
51abbce3daSPrashanth Katti
52abbce3daSPrashanth Katti    # Check if SSH login and commands fail.
53abbce3daSPrashanth Katti    ${status}=  Run Keyword And Return Status
54abbce3daSPrashanth Katti    ...  Verify SSH Login And Commands Work
55abbce3daSPrashanth Katti
56abbce3daSPrashanth Katti    Should Be Equal As Strings  ${status}  False
57abbce3daSPrashanth Katti    ...  msg=SSH Login and commands are working after disabling SSH.
58abbce3daSPrashanth Katti
59abbce3daSPrashanth Katti
60abbce3daSPrashanth KattiEnable SSH Protocol And Check Persistency On BMC Reboot
61abbce3daSPrashanth Katti    [Documentation]  Enable SSH protocol and verify persistency.
6253a5c89cSGeorge Keishing    [Tags]  Enable_SSH_Protocol_And_Check_Persistency_On_BMC_Reboot
63abbce3daSPrashanth Katti
64abbce3daSPrashanth Katti    Enable SSH Protocol  ${True}
65abbce3daSPrashanth Katti
66abbce3daSPrashanth Katti    # Reboot BMC and verify persistency.
67a4c4040cSMegha GN    Redfish OBMC Reboot (off)  stack_mode=skip
68abbce3daSPrashanth Katti
69abbce3daSPrashanth Katti    # Check if SSH is really enabled via Redfish.
70abbce3daSPrashanth Katti    Verify SSH Protocol State  ${True}
71abbce3daSPrashanth Katti
72abbce3daSPrashanth Katti    # Check if SSH login and commands on SSH session work.
73abbce3daSPrashanth Katti    Verify SSH Login And Commands Work
74abbce3daSPrashanth Katti
75abbce3daSPrashanth Katti
76abbce3daSPrashanth KattiDisable SSH Protocol And Check Persistency On BMC Reboot
77abbce3daSPrashanth Katti    [Documentation]  Disable SSH protocol and verify persistency.
7853a5c89cSGeorge Keishing    [Tags]  Disable_SSH_Protocol_And_Check_Persistency_On_BMC_Reboot
79abbce3daSPrashanth Katti    [Teardown]  Enable SSH Protocol  ${True}
80abbce3daSPrashanth Katti
81abbce3daSPrashanth Katti    # Disable SSH interface.
82abbce3daSPrashanth Katti    Enable SSH Protocol  ${False}
83abbce3daSPrashanth Katti
84abbce3daSPrashanth Katti    # Reboot BMC and verify persistency.
85a4c4040cSMegha GN    Redfish OBMC Reboot (off)  stack_mode=skip
86abbce3daSPrashanth Katti
87abbce3daSPrashanth Katti    # Check if SSH is really disabled via Redfish.
88abbce3daSPrashanth Katti    Verify SSH Protocol State  ${False}
89abbce3daSPrashanth Katti
90abbce3daSPrashanth Katti    # Check if SSH login and commands fail.
91abbce3daSPrashanth Katti    ${status}=  Run Keyword And Return Status
92abbce3daSPrashanth Katti    ...  Verify SSH Login And Commands Work
93abbce3daSPrashanth Katti
94abbce3daSPrashanth Katti    Should Be Equal As Strings  ${status}  False
95abbce3daSPrashanth Katti    ...  msg=SSH Login and commands are working after disabling SSH.
96abbce3daSPrashanth Katti
97abbce3daSPrashanth Katti
982e413457SPrashanth KattiVerify Disabling SSH Port Does Not Disable Serial Console Port
992e413457SPrashanth Katti    [Documentation]  Verify disabling SSH does not disable serial console port.
1002e413457SPrashanth Katti    [Tags]  Verify_Disabling_SSH_Port_Does_Not_Disable_Serial_Console_Port
1012e413457SPrashanth Katti    [Teardown]  Enable SSH Protocol  ${True}
1022e413457SPrashanth Katti
1032e413457SPrashanth Katti    # Disable SSH interface.
1042e413457SPrashanth Katti    Enable SSH Protocol  ${False}
1052e413457SPrashanth Katti
1062e413457SPrashanth Katti    # Check able to establish connection with serial port console.
1072e413457SPrashanth Katti    Open Connection And Log In  host=${OPENBMC_HOST}  port=2200
1082e413457SPrashanth Katti    Close All Connections
1092e413457SPrashanth Katti
1102e413457SPrashanth Katti
1112e413457SPrashanth KattiVerify Existing SSH Session Gets Closed On Disabling SSH
1122e413457SPrashanth Katti    [Documentation]  Verify existing SSH session gets closed on disabling ssh.
1132e413457SPrashanth Katti    [Tags]  Verify_Existing_SSH_Session_Gets_Closed_On_Disabling_SSH
1142e413457SPrashanth Katti    [Teardown]  Enable SSH Protocol  ${True}
1152e413457SPrashanth Katti
1162e413457SPrashanth Katti    # Open SSH connection.
1172e413457SPrashanth Katti    Open Connection And Login
1182e413457SPrashanth Katti
1192e413457SPrashanth Katti    # Disable SSH interface.
1202e413457SPrashanth Katti    Enable SSH Protocol  ${False}
1212e413457SPrashanth Katti
1222e413457SPrashanth Katti    # Check if SSH is really disabled via Redfish.
1232e413457SPrashanth Katti    Verify SSH Protocol State  ${False}
1242e413457SPrashanth Katti
1252e413457SPrashanth Katti    # Try to execute CLI command on SSH connection.
1262e413457SPrashanth Katti    # It should fail as disable SSH will close pre existing sessions.
1272e413457SPrashanth Katti    ${status}=  Run Keyword And Return Status
1282e413457SPrashanth Katti    ...  BMC Execute Command  /sbin/ip addr
1292e413457SPrashanth Katti
1302e413457SPrashanth Katti    Should Be Equal As Strings  ${status}  False
1312e413457SPrashanth Katti    ...  msg=Disabling SSH has not closed existing SSH sessions.
1322e413457SPrashanth Katti
1332e413457SPrashanth Katti
13470620175SPrashanth KattiEnable IPMI Protocol And Verify
13570620175SPrashanth Katti    [Documentation]  Enable IPMI protocol and verify.
13670620175SPrashanth Katti    [Tags]  Enable_IPMI_Protocol_And_Verify
13770620175SPrashanth Katti
13870620175SPrashanth Katti    Enable IPMI Protocol  ${True}
13970620175SPrashanth Katti
14070620175SPrashanth Katti    # Check if IPMI is really enabled via Redfish.
14170620175SPrashanth Katti    Verify IPMI Protocol State  ${True}
14270620175SPrashanth Katti
14370620175SPrashanth Katti    # Check if IPMI commands starts working.
14470620175SPrashanth Katti    Verify IPMI Works  lan print
14570620175SPrashanth Katti
14670620175SPrashanth Katti
14770620175SPrashanth KattiDisable IPMI Protocol And Verify
14870620175SPrashanth Katti    [Documentation]  Disable IPMI protocol and verify.
14970620175SPrashanth Katti    [Tags]  Disable_IPMI_Protocol_And_Verify
15070620175SPrashanth Katti
15170620175SPrashanth Katti    # Disable IPMI interface.
15270620175SPrashanth Katti    Enable IPMI Protocol  ${False}
15370620175SPrashanth Katti
15470620175SPrashanth Katti    # Check if IPMI is really disabled via Redfish.
15570620175SPrashanth Katti    Verify IPMI Protocol State  ${False}
15670620175SPrashanth Katti
15770620175SPrashanth Katti    # Check if IPMI commands fail.
15870620175SPrashanth Katti    ${status}=  Run Keyword And Return Status
15970620175SPrashanth Katti    ...  Verify IPMI Works  lan print
16070620175SPrashanth Katti
16170620175SPrashanth Katti    Should Be Equal As Strings  ${status}  False
16270620175SPrashanth Katti    ...  msg=IPMI commands are working after disabling IPMI.
16370620175SPrashanth Katti
16470620175SPrashanth Katti
165ef433de8SmeghagnEnable IPMI Protocol And Check Persistency On BMC Reboot
16633be359bSGeorge Keishing    [Documentation]  Set the IPMI protocol attribute to True, reset BMC, and verify
16733be359bSGeorge Keishing    ...              that the setting persists.
168ef433de8Smeghagn    [Tags]  Enable_IPMI_Protocol_And_Check_Persistency_On_BMC_Reboot
169ef433de8Smeghagn
170ef433de8Smeghagn    Enable IPMI Protocol  ${True}
171ef433de8Smeghagn
172ef433de8Smeghagn    Redfish OBMC Reboot (off)  stack_mode=skip
173ef433de8Smeghagn
174ef433de8Smeghagn    # Check if the IPMI enabled is set.
175ef433de8Smeghagn    Verify IPMI Protocol State  ${True}
176ef433de8Smeghagn
177ef433de8Smeghagn    # Confirm that IPMI commands to access BMC work.
178ef433de8Smeghagn    Verify IPMI Works  lan print
179ef433de8Smeghagn
180ef433de8Smeghagn
181ef433de8SmeghagnDisable IPMI Protocol And Check Persistency On BMC Reboot
18233be359bSGeorge Keishing    [Documentation]  Set the IPMI protocol attribute to False, reset BMC, and verify
18333be359bSGeorge Keishing    ...              that the setting persists.
184ef433de8Smeghagn    [Tags]  Disable_IPMI_Protocol_And_Check_Persistency_On_BMC_Reboot
185ef433de8Smeghagn
186ef433de8Smeghagn    # Disable IPMI interface.
187ef433de8Smeghagn    Enable IPMI Protocol  ${False}
188ef433de8Smeghagn
189ef433de8Smeghagn    Redfish OBMC Reboot (off)  stack_mode=skip
190ef433de8Smeghagn
191ef433de8Smeghagn    # Check if the IPMI disabled is set.
192ef433de8Smeghagn    Verify IPMI Protocol State  ${False}
193ef433de8Smeghagn
194ef433de8Smeghagn    # Confirm that IPMI connection request fails.
195ef433de8Smeghagn    ${status}=  Run Keyword And Return Status
196ef433de8Smeghagn    ...  Verify IPMI Works  lan print
197ef433de8Smeghagn
198ef433de8Smeghagn    Should Be Equal As Strings  ${status}  False
199ef433de8Smeghagn    ...  msg=IPMI commands are working after disabling IPMI.
200ef433de8Smeghagn
201ef433de8Smeghagn
202e21e1a39SMegha GNConfigure SSH And IPMI Settings And Verify
203e21e1a39SMegha GN    [Documentation]  Set the SSH and IPMI protocol attribute to True/False, and verify.
204e21e1a39SMegha GN    [Tags]  Configure_SSH_And_IPMI_Settings_And_Verify
205e21e1a39SMegha GN    [Template]  Set SSH And IPMI Protocol
206*ab2553ebSMegha G N    [Teardown]  Run Keywords  FFDC On Test Case Fail
207*ab2553ebSMegha G N    ...  AND  Enable SSH Protocol  ${True}
2086f1d9d86Smeghagn
209e21e1a39SMegha GN    # ssh_state  ipmi_state
210e21e1a39SMegha GN    ${True}      ${False}
211e21e1a39SMegha GN    ${True}      ${True}
212e21e1a39SMegha GN    ${False}     ${True}
213e21e1a39SMegha GN    ${False}     ${False}
2146f1d9d86Smeghagn
2156f1d9d86Smeghagn
216*ab2553ebSMegha G NConfigure SSH And IPMI Settings And Verify Persistency On BMC Reboot
217*ab2553ebSMegha G N    [Documentation]  Set the SSH and IPMI protocol attribute to True/False, and verify
218*ab2553ebSMegha G N    ...  it's persistency after BMC reboot.
219*ab2553ebSMegha G N    [Tags]  Configure_SSH_And_IPMI_Settings_And_Verify_Persistency_On_BMC_Reboot
220*ab2553ebSMegha G N    [Template]  Set SSH And IPMI Protocol
221*ab2553ebSMegha G N    [Teardown]  Run Keywords  FFDC On Test Case Fail
222*ab2553ebSMegha G N    ...  AND  Enable SSH Protocol  ${True}
2237735cbbaSMegha G N
224*ab2553ebSMegha G N    # ssh_state  ipmi_state  persistency_check
225*ab2553ebSMegha G N    ${True}      ${False}    ${True}
226*ab2553ebSMegha G N    ${True}      ${True}     ${True}
227*ab2553ebSMegha G N    ${False}     ${True}     ${True}
228*ab2553ebSMegha G N    ${False}     ${False}    ${True}
2297735cbbaSMegha G N
2307735cbbaSMegha G N
231abbce3daSPrashanth Katti*** Keywords ***
232abbce3daSPrashanth Katti
233274b7241SBrian MaSuite Setup Execution
234274b7241SBrian Ma    [Documentation]  Do suite setup tasks.
235274b7241SBrian Ma
236274b7241SBrian Ma    Redfish.Login
237274b7241SBrian Ma
238274b7241SBrian Ma    ${state}=  Run Keyword And Return Status  Verify IPMI Protocol State
239274b7241SBrian Ma    Set Suite Variable  ${initial_ipmi_state}  ${state}
240e21e1a39SMegha GN    Sleep  ${NETWORK_TIMEOUT}s
241274b7241SBrian Ma
2424ddcb4d4SBrian MaIs BMC LastResetTime Changed
2437735cbbaSMegha G N    [Documentation]  return fail if BMC last reset time is not changed.
2444ddcb4d4SBrian Ma    [Arguments]  ${reset_time}
2454ddcb4d4SBrian Ma
2464ddcb4d4SBrian Ma    ${last_reset_time}=  Redfish.Get Attribute  /redfish/v1/Managers/bmc  LastResetTime
2474ddcb4d4SBrian Ma    Should Not Be Equal  ${last_reset_time}  ${reset_time}
2484ddcb4d4SBrian Ma
2494ddcb4d4SBrian Ma
2504ddcb4d4SBrian MaRedfish BMC Reboot
2517735cbbaSMegha G N    [Documentation]  Use Redfish API reboot BMC and wait for BMC ready.
2524ddcb4d4SBrian Ma
2534ddcb4d4SBrian Ma    #  Get BMC last reset time for compare
2544ddcb4d4SBrian Ma    ${last_reset_time}=  Redfish.Get Attribute  /redfish/v1/Managers/bmc  LastResetTime
2554ddcb4d4SBrian Ma
2564ddcb4d4SBrian Ma    # Reboot BMC by Redfish API
2574ddcb4d4SBrian Ma    Redfish BMC Reset Operation
2584ddcb4d4SBrian Ma
2594ddcb4d4SBrian Ma    # Wait for BMC real reboot and Redfish API ready
2604ddcb4d4SBrian Ma    Wait Until Keyword Succeeds  3 min  10 sec  Is BMC LastResetTime Changed  ${last_reset_time}
2614ddcb4d4SBrian Ma
2626f1d9d86Smeghagn
2636f1d9d86SmeghagnSet SSH And IPMI Protocol
2646f1d9d86Smeghagn    [Documentation]  Set SSH and IPMI protocol state.
2657735cbbaSMegha G N    [Arguments]  ${ssh_state}  ${ipmi_state}  ${persistency_check}=${False}
2666f1d9d86Smeghagn
2676f1d9d86Smeghagn    # Description of argument(s):
268e21e1a39SMegha GN    # ssh_state     State of SSH to be set (e.g. True, False).
269e21e1a39SMegha GN    # ipmi_state    State of IPMI to be set (e.g. True, False).
2706f1d9d86Smeghagn
2716f1d9d86Smeghagn    ${ssh_protocol_state}=  Create Dictionary  ProtocolEnabled=${ssh_state}
2726f1d9d86Smeghagn    ${ipmi_protocol_state}=  Create Dictionary  ProtocolEnabled=${ipmi_state}
2736f1d9d86Smeghagn    ${data}=  Create Dictionary  SSH=${ssh_protocol_state}  IPMI=${ipmi_protocol_state}
2746f1d9d86Smeghagn
2756f1d9d86Smeghagn    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body=&{data}
2766f1d9d86Smeghagn    ...  valid_status_codes=[${HTTP_NO_CONTENT}]
2776f1d9d86Smeghagn
2786f1d9d86Smeghagn    # Wait for timeout for new values to take effect.
2796f1d9d86Smeghagn    Sleep  ${NETWORK_TIMEOUT}s
280e21e1a39SMegha GN
281*ab2553ebSMegha G N    Run Keyword if  ${persistency_check} == ${True}
282*ab2553ebSMegha G N    ...  Redfish OBMC Reboot (off)  stack_mode=skip
283e21e1a39SMegha GN    Verify Protocol State  ${ssh_state}  ${ipmi_state}
284e21e1a39SMegha GN
285e21e1a39SMegha GN
286e21e1a39SMegha GNVerify Protocol State
287e21e1a39SMegha GN    [Documentation]  Verify SSH and IPMI protocol state.
288e21e1a39SMegha GN    [Arguments]  ${ssh_state}  ${ipmi_state}
289e21e1a39SMegha GN
290e21e1a39SMegha GN    # Description of argument(s):
291e21e1a39SMegha GN    # ssh_state     State of SSH to be verified (e.g. True, False).
292e21e1a39SMegha GN    # ipmi_state    State of IPMI to be verified (e.g. True, False).
293e21e1a39SMegha GN
294e21e1a39SMegha GN    # Verify SSH state value.
295e21e1a39SMegha GN    ${status}=  Run Keyword And Return Status
296e21e1a39SMegha GN    ...  Verify SSH Login And Commands Work
297e21e1a39SMegha GN    Should Be Equal As Strings  ${status}  ${ssh_state}
298e21e1a39SMegha GN    ...  msg=SSH states are not matching.
299e21e1a39SMegha GN
300e21e1a39SMegha GN    # Verify IPMI state value.
301e21e1a39SMegha GN    ${status}=  Run Keyword And Return Status
302e21e1a39SMegha GN    ...  Verify IPMI Works  lan print
303e21e1a39SMegha GN
304e21e1a39SMegha GN    Should Be Equal As Strings  ${status}  ${ipmi_state}
305e21e1a39SMegha GN    ...  msg=IPMI states are not matching.
306