xref: /openbmc/openbmc-test-automation/redfish/managers/test_bmc_config_ipv6.robot (revision 7a7ae5c53e5283d8b6d688f7320f47bf3d8ab265)
1e7b4db60SSweta Potthuri*** Settings ***
2e7b4db60SSweta PotthuriDocumentation  Network interface IPv6 configuration connected to DHCP server
3e7b4db60SSweta Potthuri               ...   and verification tests.
4e7b4db60SSweta Potthuri
5e7b4db60SSweta PotthuriResource       ../../lib/bmc_redfish_resource.robot
6e7b4db60SSweta PotthuriResource       ../../lib/openbmc_ffdc.robot
7e7b4db60SSweta PotthuriResource       ../../lib/bmc_ipv6_utils.robot
8e7b4db60SSweta PotthuriResource       ../../lib/bmc_network_utils.robot
915c7b3d2SSweta PotthuriResource       ../../lib/protocol_setting_utils.robot
1015c7b3d2SSweta Potthuri
11e7b4db60SSweta PotthuriLibrary        Collections
12e7b4db60SSweta PotthuriLibrary        Process
13e7b4db60SSweta PotthuriLibrary        OperatingSystem
14e7b4db60SSweta PotthuriSuite Setup     Suite Setup Execution
1515c7b3d2SSweta PotthuriTest Teardown   Test Teardown Execution
16e7b4db60SSweta Potthuri
17e7b4db60SSweta PotthuriTest Tags     BMC_IPv6_Config
18e7b4db60SSweta Potthuri
19e7b4db60SSweta Potthuri*** Variables ***
20e7b4db60SSweta Potthuri# Remote DHCP test bed server. Leave variables EMPTY if server is configured local
21e7b4db60SSweta Potthuri# to the test where it is running else if remote pass the server credentials
22e7b4db60SSweta Potthuri# -v SERVER_IPv6:xx.xx.xx.xx
23e7b4db60SSweta Potthuri# -v SERVER_USERNAME:root
24e7b4db60SSweta Potthuri# -v SERVER_PASSWORD:*********
25e7b4db60SSweta Potthuri
26e7b4db60SSweta Potthuri${SERVER_USERNAME}      ${EMPTY}
27e7b4db60SSweta Potthuri${SERVER_PASSWORD}      ${EMPTY}
28e7b4db60SSweta Potthuri${SERVER_IPv6}          ${EMPTY}
29e7b4db60SSweta Potthuri
30e7b4db60SSweta Potthuri
31e7b4db60SSweta Potthuri*** Test Cases ***
32e7b4db60SSweta Potthuri
33*7a7ae5c5SAbhijith NaikGet SLAAC And Static IPv6 Address And Verify Connectivity
34*7a7ae5c5SAbhijith Naik    [Documentation]  Fetch the SLAAC and Static IPv6 address
35*7a7ae5c5SAbhijith Naik    ...    and verify ping and SSH connection.
36*7a7ae5c5SAbhijith Naik    [Tags]  Get_SLAAC_And_Static_IPv6_Address_And_Verify_Connectivity
37*7a7ae5c5SAbhijith Naik    [Template]  Get IPv6 Address And Verify Connectivity
38e7b4db60SSweta Potthuri
39*7a7ae5c5SAbhijith Naik    # Address_type  channel_number
40*7a7ae5c5SAbhijith Naik    SLAAC           ${1}
41*7a7ae5c5SAbhijith Naik    Static          ${1}
42*7a7ae5c5SAbhijith Naik    SLAAC           ${2}
43*7a7ae5c5SAbhijith Naik    Static          ${2}
44e7b4db60SSweta Potthuri
45e7b4db60SSweta Potthuri
4615c7b3d2SSweta PotthuriEnable SSH Protocol Via IPv6 And Verify
4715c7b3d2SSweta Potthuri    [Documentation]  Enable SSH protocol via eth1 and verify.
4815c7b3d2SSweta Potthuri    [Tags]  Enable_SSH_Protocol_Via_IPv6_And_Verify
4915c7b3d2SSweta Potthuri
5015c7b3d2SSweta Potthuri    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
5115c7b3d2SSweta Potthuri    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
5215c7b3d2SSweta Potthuri    Connect BMC Using IPv6 Address  ${ipv6_slaac_addr}
5315c7b3d2SSweta Potthuri    Set SSH Protocol Using IPv6 Session And Verify  ${True}
5415c7b3d2SSweta Potthuri    Verify SSH Login And Commands Work
5515c7b3d2SSweta Potthuri    Verify SSH Connection Via IPv6  ${ipv6_slaac_addr}
5615c7b3d2SSweta Potthuri
5715c7b3d2SSweta Potthuri
5815c7b3d2SSweta PotthuriDisable SSH Protocol Via IPv6 And Verify
5915c7b3d2SSweta Potthuri    [Documentation]  Disable SSH protocol via IPv6 and verify.
6015c7b3d2SSweta Potthuri    [Tags]  Disable_SSH_Protocol_Via_IPv6_And_Verify
6115c7b3d2SSweta Potthuri    [Teardown]  Set SSH Protocol Using IPv6 Session And Verify  ${True}
6215c7b3d2SSweta Potthuri
6315c7b3d2SSweta Potthuri    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
6415c7b3d2SSweta Potthuri    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
6515c7b3d2SSweta Potthuri    Connect BMC Using IPv6 Address  ${ipv6_slaac_addr}
6615c7b3d2SSweta Potthuri
6715c7b3d2SSweta Potthuri    Set SSH Protocol Using IPv6 Session And Verify  ${False}
6815c7b3d2SSweta Potthuri
6915c7b3d2SSweta Potthuri    # Verify SSH Login And Commands Work.
7015c7b3d2SSweta Potthuri    ${status}=  Run Keyword And Return Status
7115c7b3d2SSweta Potthuri    ...    Verify SSH Connection Via IPv6  ${ipv6_slaac_addr}
7215c7b3d2SSweta Potthuri    Should Be Equal As Strings  ${status}  False
7315c7b3d2SSweta Potthuri    ...  msg=SSH Login and commands are working after disabling SSH via IPv6.
7415c7b3d2SSweta Potthuri
7515c7b3d2SSweta Potthuri    # Verify SSH Connection Via IPv6.
7615c7b3d2SSweta Potthuri    ${status}=  Run Keyword And Return Status
7715c7b3d2SSweta Potthuri    ...  Verify SSH Login And Commands Work
7815c7b3d2SSweta Potthuri    Should Be Equal As Strings  ${status}  False
7915c7b3d2SSweta Potthuri    ...  msg=SSH Login and commands are working after disabling SSH.
8015c7b3d2SSweta Potthuri
8115c7b3d2SSweta Potthuri
82e7b4db60SSweta Potthuri*** Keywords ***
83e7b4db60SSweta Potthuri
84e7b4db60SSweta PotthuriSuite Setup Execution
85e7b4db60SSweta Potthuri    [Documentation]  Do suite setup execution.
86e7b4db60SSweta Potthuri
87e7b4db60SSweta Potthuri    Redfish.Login
88e7b4db60SSweta Potthuri    ${active_channel_config}=  Get Active Channel Config
89e7b4db60SSweta Potthuri    Set Suite Variable  ${active_channel_config}
90e7b4db60SSweta Potthuri    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
91e7b4db60SSweta Potthuri    Set Suite variable  ${ethernet_interface}
92e7b4db60SSweta Potthuri
93e7b4db60SSweta Potthuri
94e7b4db60SSweta PotthuriTest Teardown Execution
95e7b4db60SSweta Potthuri    [Documentation]  Test teardown execution.
96e7b4db60SSweta Potthuri
97e7b4db60SSweta Potthuri    FFDC On Test Case Fail
9815c7b3d2SSweta Potthuri    Redfish.Logout
9915c7b3d2SSweta Potthuri    RedfishIPv6.Logout
100e7b4db60SSweta Potthuri
101e7b4db60SSweta Potthuri
102e7b4db60SSweta PotthuriWait For IPv6 Host To Ping
103e7b4db60SSweta Potthuri    [Documentation]  Verify that the IPv6 host responds successfully to ping.
104e7b4db60SSweta Potthuri    [Arguments]  ${host}  ${timeout}=${OPENBMC_REBOOT_TIMEOUT}sec
105e7b4db60SSweta Potthuri    ...          ${interval}=5 sec  ${expected_rc}=${0}
106e7b4db60SSweta Potthuri    # Description of argument(s):
107e7b4db60SSweta Potthuri    # host         The IPv6 address of the host to ping.
108e7b4db60SSweta Potthuri    # timeout      Maximum time to wait for the host to respond to ping.
109e7b4db60SSweta Potthuri    # interval     Time to wait between ping attempts.
110e7b4db60SSweta Potthuri    # expected_rc  Expected return code of ping command.
111e7b4db60SSweta Potthuri    Wait Until Keyword Succeeds  ${timeout}  ${interval}  Ping Host Over IPv6  ${host}  ${expected_rc}
112e7b4db60SSweta Potthuri
113e7b4db60SSweta Potthuri
114e7b4db60SSweta PotthuriPing Host Over IPv6
115e7b4db60SSweta Potthuri    [Documentation]  Ping6 the given host.
116e7b4db60SSweta Potthuri    [Arguments]     ${host}  ${expected_rc}=${0}
117e7b4db60SSweta Potthuri    # Description of argument(s):
118e7b4db60SSweta Potthuri    # host           IPv6 address of the host to ping.
119e7b4db60SSweta Potthuri    # expected_rc    Expected return code of ping command.
120e7b4db60SSweta Potthuri    Should Not Be Empty    ${host}   msg=No host provided.
121e7b4db60SSweta Potthuri    ${rc}   ${output}=     Run and return RC and Output    ping6 -c 4 ${host}
122e7b4db60SSweta Potthuri    Log     RC: ${rc}\nOutput:\n${output}
123e7b4db60SSweta Potthuri    Should Be Equal     ${rc}   ${expected_rc}
124e7b4db60SSweta Potthuri
125e7b4db60SSweta Potthuri
126e7b4db60SSweta PotthuriCheck IPv6 Connectivity
127e7b4db60SSweta Potthuri    [Documentation]  Check ping6 status and verify.
128e7b4db60SSweta Potthuri    [Arguments]  ${OPENBMC_HOST_IPv6}
129e7b4db60SSweta Potthuri
130e7b4db60SSweta Potthuri    # Description of argument(s):
131e7b4db60SSweta Potthuri    # OPENBMC_HOST_IPv6   IPv6 address to check connectivity.
132e7b4db60SSweta Potthuri
133e7b4db60SSweta Potthuri    Open Connection And Log In  ${SERVER_USERNAME}  ${SERVER_PASSWORD}  host=${SERVER_IPv6}
134e7b4db60SSweta Potthuri    Wait For IPv6 Host To Ping  ${OPENBMC_HOST_IPv6}  30 secs
135e7b4db60SSweta Potthuri
136e7b4db60SSweta Potthuri
137e7b4db60SSweta PotthuriVerify SSH Connection Via IPv6
138e7b4db60SSweta Potthuri    [Documentation]  Verify connectivity to the IPv6 host via SSH.
139e7b4db60SSweta Potthuri    [Arguments]  ${OPENBMC_HOST_IPv6}
140e7b4db60SSweta Potthuri
141e7b4db60SSweta Potthuri    # Description of argument(s):
142e7b4db60SSweta Potthuri    # OPENBMC_HOST_IPv6   IPv6 address to check connectivity.
143e7b4db60SSweta Potthuri
144e7b4db60SSweta Potthuri    IF  '${SERVER_USERNAME}' == '${EMPTY}'
145e7b4db60SSweta Potthuri        SSHLibrary.Open Connection  ${OPENBMC_HOST_IPv6}
146e7b4db60SSweta Potthuri        SSHLibrary.Login  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}
147e7b4db60SSweta Potthuri    ELSE
148e7b4db60SSweta Potthuri        Open Connection And Log In  ${SERVER_USERNAME}  ${SERVER_PASSWORD}  host=${SERVER_IPv6}  alias=IPv6Conn
149e7b4db60SSweta Potthuri        SSHLibrary.Open Connection  ${OPENBMC_HOST_IPv6}
150e7b4db60SSweta Potthuri        SSHLibrary.Login  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  jumphost_index_or_alias=IPv6Conn
151e7b4db60SSweta Potthuri    END
152e7b4db60SSweta Potthuri
15315c7b3d2SSweta Potthuri
15415c7b3d2SSweta PotthuriSet SSH Protocol Using IPv6 Session And Verify
15515c7b3d2SSweta Potthuri    [Documentation]  Enable or disable SSH protocol via IPv6 and verify.
15615c7b3d2SSweta Potthuri    [Arguments]  ${enable_value}=${True}
15715c7b3d2SSweta Potthuri
15815c7b3d2SSweta Potthuri    # Description of argument(s}:
15915c7b3d2SSweta Potthuri    # enable_value  Enable or disable SSH, e.g. (true, false).
16015c7b3d2SSweta Potthuri
16115c7b3d2SSweta Potthuri    ${ssh_state}=  Create Dictionary  ProtocolEnabled=${enable_value}
16215c7b3d2SSweta Potthuri    ${data}=  Create Dictionary  SSH=${ssh_state}
16315c7b3d2SSweta Potthuri
16415c7b3d2SSweta Potthuri    RedfishIPv6.Login
16515c7b3d2SSweta Potthuri    RedfishIPv6.Patch  ${REDFISH_NW_PROTOCOL_URI}  body=&{data}
16615c7b3d2SSweta Potthuri    ...  valid_status_codes=[${HTTP_NO_CONTENT}]
16715c7b3d2SSweta Potthuri
16815c7b3d2SSweta Potthuri    # Wait for new values to take effect.
16915c7b3d2SSweta Potthuri    Sleep  30s
17015c7b3d2SSweta Potthuri
17115c7b3d2SSweta Potthuri    # Verify SSH Protocol State Via IPv6
17215c7b3d2SSweta Potthuri    ${resp}=  RedfishIPv6.Get  ${REDFISH_NW_PROTOCOL_URI}
17315c7b3d2SSweta Potthuri    Should Be Equal As Strings  ${resp.dict['SSH']['ProtocolEnabled']}  ${enable_value}
17415c7b3d2SSweta Potthuri    ...  msg=Protocol states are not matching.
17515c7b3d2SSweta Potthuri
17615c7b3d2SSweta Potthuri
17715c7b3d2SSweta PotthuriConnect BMC Using IPv6 Address
17815c7b3d2SSweta Potthuri    [Documentation]  Import bmc_redfish library with IPv6 configuration.
17915c7b3d2SSweta Potthuri    [Arguments]  ${OPENBMC_HOST_IPv6}
18015c7b3d2SSweta Potthuri
18115c7b3d2SSweta Potthuri    # Description of argument(s):
18215c7b3d2SSweta Potthuri    # OPENBMC_HOST_IPv6  IPv6 address of the BMC.
18315c7b3d2SSweta Potthuri
18415c7b3d2SSweta Potthuri    Import Library  ${CURDIR}/../../lib/bmc_redfish.py  https://[${OPENBMC_HOST_IPv6}]:${HTTPS_PORT}
18515c7b3d2SSweta Potthuri    ...             ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  AS  RedfishIPv6
186*7a7ae5c5SAbhijith Naik
187*7a7ae5c5SAbhijith Naik
188*7a7ae5c5SAbhijith NaikGet IPv6 Address And Verify Connectivity
189*7a7ae5c5SAbhijith Naik    [Documentation]  Get IPv6 address and verify connectivity.
190*7a7ae5c5SAbhijith Naik    [Arguments]  ${ipv6_adress_type}  ${channel_number}
191*7a7ae5c5SAbhijith Naik
192*7a7ae5c5SAbhijith Naik    # Description of argument(s):
193*7a7ae5c5SAbhijith Naik    # ipv6_adress_type   Type of IPv6 address(slaac/static).
194*7a7ae5c5SAbhijith Naik    # channel_number     Ethernet channel number, 1(eth0) or 2(eth1).
195*7a7ae5c5SAbhijith Naik
196*7a7ae5c5SAbhijith Naik    @{ipv6_addressorigin_list}  ${ipv6_addr}=
197*7a7ae5c5SAbhijith Naik    ...  Get Address Origin List And Address For Type  ${ipv6_adress_type}  ${channel_number}
198*7a7ae5c5SAbhijith Naik    IF  '${SERVER_USERNAME}' != '${EMPTY}'
199*7a7ae5c5SAbhijith Naik        Check IPv6 Connectivity  ${ipv6_addr}
200*7a7ae5c5SAbhijith Naik    ELSE
201*7a7ae5c5SAbhijith Naik        Wait For IPv6 Host To Ping  ${ipv6_addr}
202*7a7ae5c5SAbhijith Naik    END
203*7a7ae5c5SAbhijith Naik    Verify SSH Connection Via IPv6  ${ipv6_addr}
204