xref: /openbmc/openbmc-test-automation/redfish/managers/test_bmc_config_ipv6.robot (revision 1d03ee954c3c53fadcac65e0c3ae1029ff6351b7)
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
337a7ae5c5SAbhijith NaikGet SLAAC And Static IPv6 Address And Verify Connectivity
347a7ae5c5SAbhijith Naik    [Documentation]  Fetch the SLAAC and Static IPv6 address
357a7ae5c5SAbhijith Naik    ...    and verify ping and SSH connection.
367a7ae5c5SAbhijith Naik    [Tags]  Get_SLAAC_And_Static_IPv6_Address_And_Verify_Connectivity
377a7ae5c5SAbhijith Naik    [Template]  Get IPv6 Address And Verify Connectivity
38e7b4db60SSweta Potthuri
397a7ae5c5SAbhijith Naik    # Address_type  channel_number
407a7ae5c5SAbhijith Naik    SLAAC           ${1}
417a7ae5c5SAbhijith Naik    Static          ${1}
427a7ae5c5SAbhijith Naik    SLAAC           ${2}
437a7ae5c5SAbhijith 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
82*1d03ee95SSweta PotthuriVerify BMC IPv4 And IPv6 Addresses Accessible Via SSH
83*1d03ee95SSweta Potthuri    [Documentation]  Verify BMC IPv4 and IPv6 addresses accessible via SSH.
84*1d03ee95SSweta Potthuri    [Tags]  Verify_BMC_IPv4_And_IPv6_Addresses_Accessible_Via_SSH
85*1d03ee95SSweta Potthuri
86*1d03ee95SSweta Potthuri    Open Connection And Log In  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  host=${OPENBMC_HOST}
87*1d03ee95SSweta Potthuri    Verify SSH Connection Via IPv6
88*1d03ee95SSweta Potthuri
89*1d03ee95SSweta Potthuri
90*1d03ee95SSweta PotthuriVerify IPv4 And IPv6 Access Concurrently Via Redfish
91*1d03ee95SSweta Potthuri    [Documentation]  Verify both interfaces access conurrently via redfish.
92*1d03ee95SSweta Potthuri    [Tags]  Verify_IPv4_And_IPv6_Access_Concurrently_Via_Redfish
93*1d03ee95SSweta Potthuri
94*1d03ee95SSweta Potthuri    ${dict}=  Execute Process Multi Keyword  ${2}
95*1d03ee95SSweta Potthuri    ...  Redfish.patch ${REDFISH_NW_ETH_IFACE}eth0 body={'DHCPv4':{'UseDNSServers':${True}}}
96*1d03ee95SSweta Potthuri    ...  RedfishIPv6.patch ${REDFISH_NW_ETH_IFACE}eth0 body={'DHCPv4':{'UseDNSServers':${True}}}
97*1d03ee95SSweta Potthuri    Dictionary Should Not Contain Value  ${dict}  False
98*1d03ee95SSweta Potthuri    ...  msg=One or more operations has failed.
99*1d03ee95SSweta Potthuri    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}eth0
100*1d03ee95SSweta Potthuri    ${resp1}=  Redfish1.Get  ${REDFISH_NW_ETH_IFACE}eth0
101*1d03ee95SSweta Potthuri    Should Be Equal  ${resp.dict["DHCPv4"]['UseDNSServers']}  ${True}
102*1d03ee95SSweta Potthuri    Should Be Equal  ${resp1.dict["DHCPv4"]['UseDNSServers']}  ${True}
103*1d03ee95SSweta Potthuri
104*1d03ee95SSweta Potthuri
105*1d03ee95SSweta PotthuriConfigure Static IPv6 From SLAAC Address
106*1d03ee95SSweta Potthuri    [Documentation]  Configure Static IPv6 From SLAAC Address.
107*1d03ee95SSweta Potthuri    [Tags]  Configure_Static_IPv6_From_SLAAC_Address
108*1d03ee95SSweta Potthuri
109*1d03ee95SSweta Potthuri    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
110*1d03ee95SSweta Potthuri    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
111*1d03ee95SSweta Potthuri    Connect BMC Using IPv6 Address  ${ipv6_slaac_addr}
112*1d03ee95SSweta Potthuri    RedfishIPv6.Login
113*1d03ee95SSweta Potthuri    Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}  Version=IPv6
114*1d03ee95SSweta Potthuri
115*1d03ee95SSweta Potthuri
116e7b4db60SSweta Potthuri*** Keywords ***
117e7b4db60SSweta Potthuri
118e7b4db60SSweta PotthuriSuite Setup Execution
119e7b4db60SSweta Potthuri    [Documentation]  Do suite setup execution.
120e7b4db60SSweta Potthuri
121e7b4db60SSweta Potthuri    Redfish.Login
122e7b4db60SSweta Potthuri    ${active_channel_config}=  Get Active Channel Config
123e7b4db60SSweta Potthuri    Set Suite Variable  ${active_channel_config}
124e7b4db60SSweta Potthuri    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
125e7b4db60SSweta Potthuri    Set Suite variable  ${ethernet_interface}
126e7b4db60SSweta Potthuri
127e7b4db60SSweta Potthuri
128e7b4db60SSweta PotthuriTest Teardown Execution
129e7b4db60SSweta Potthuri    [Documentation]  Test teardown execution.
130e7b4db60SSweta Potthuri
131e7b4db60SSweta Potthuri    FFDC On Test Case Fail
13215c7b3d2SSweta Potthuri    Redfish.Logout
13315c7b3d2SSweta Potthuri    RedfishIPv6.Logout
134e7b4db60SSweta Potthuri
135e7b4db60SSweta Potthuri
136e7b4db60SSweta PotthuriWait For IPv6 Host To Ping
137e7b4db60SSweta Potthuri    [Documentation]  Verify that the IPv6 host responds successfully to ping.
138e7b4db60SSweta Potthuri    [Arguments]  ${host}  ${timeout}=${OPENBMC_REBOOT_TIMEOUT}sec
139e7b4db60SSweta Potthuri    ...          ${interval}=5 sec  ${expected_rc}=${0}
140e7b4db60SSweta Potthuri    # Description of argument(s):
141e7b4db60SSweta Potthuri    # host         The IPv6 address of the host to ping.
142e7b4db60SSweta Potthuri    # timeout      Maximum time to wait for the host to respond to ping.
143e7b4db60SSweta Potthuri    # interval     Time to wait between ping attempts.
144e7b4db60SSweta Potthuri    # expected_rc  Expected return code of ping command.
145e7b4db60SSweta Potthuri    Wait Until Keyword Succeeds  ${timeout}  ${interval}  Ping Host Over IPv6  ${host}  ${expected_rc}
146e7b4db60SSweta Potthuri
147e7b4db60SSweta Potthuri
148e7b4db60SSweta PotthuriPing Host Over IPv6
149e7b4db60SSweta Potthuri    [Documentation]  Ping6 the given host.
150e7b4db60SSweta Potthuri    [Arguments]     ${host}  ${expected_rc}=${0}
151e7b4db60SSweta Potthuri    # Description of argument(s):
152e7b4db60SSweta Potthuri    # host           IPv6 address of the host to ping.
153e7b4db60SSweta Potthuri    # expected_rc    Expected return code of ping command.
154e7b4db60SSweta Potthuri    Should Not Be Empty    ${host}   msg=No host provided.
155e7b4db60SSweta Potthuri    ${rc}   ${output}=     Run and return RC and Output    ping6 -c 4 ${host}
156e7b4db60SSweta Potthuri    Log     RC: ${rc}\nOutput:\n${output}
157e7b4db60SSweta Potthuri    Should Be Equal     ${rc}   ${expected_rc}
158e7b4db60SSweta Potthuri
159e7b4db60SSweta Potthuri
160e7b4db60SSweta PotthuriCheck IPv6 Connectivity
161e7b4db60SSweta Potthuri    [Documentation]  Check ping6 status and verify.
162e7b4db60SSweta Potthuri    [Arguments]  ${OPENBMC_HOST_IPv6}
163e7b4db60SSweta Potthuri
164e7b4db60SSweta Potthuri    # Description of argument(s):
165e7b4db60SSweta Potthuri    # OPENBMC_HOST_IPv6   IPv6 address to check connectivity.
166e7b4db60SSweta Potthuri
167e7b4db60SSweta Potthuri    Open Connection And Log In  ${SERVER_USERNAME}  ${SERVER_PASSWORD}  host=${SERVER_IPv6}
168e7b4db60SSweta Potthuri    Wait For IPv6 Host To Ping  ${OPENBMC_HOST_IPv6}  30 secs
169e7b4db60SSweta Potthuri
170e7b4db60SSweta Potthuri
171e7b4db60SSweta PotthuriVerify SSH Connection Via IPv6
172e7b4db60SSweta Potthuri    [Documentation]  Verify connectivity to the IPv6 host via SSH.
173e7b4db60SSweta Potthuri    [Arguments]  ${OPENBMC_HOST_IPv6}
174e7b4db60SSweta Potthuri
175e7b4db60SSweta Potthuri    # Description of argument(s):
176e7b4db60SSweta Potthuri    # OPENBMC_HOST_IPv6   IPv6 address to check connectivity.
177e7b4db60SSweta Potthuri
178e7b4db60SSweta Potthuri    IF  '${SERVER_USERNAME}' == '${EMPTY}'
179e7b4db60SSweta Potthuri        SSHLibrary.Open Connection  ${OPENBMC_HOST_IPv6}
180e7b4db60SSweta Potthuri        SSHLibrary.Login  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}
181e7b4db60SSweta Potthuri    ELSE
182e7b4db60SSweta Potthuri        Open Connection And Log In  ${SERVER_USERNAME}  ${SERVER_PASSWORD}  host=${SERVER_IPv6}  alias=IPv6Conn
183e7b4db60SSweta Potthuri        SSHLibrary.Open Connection  ${OPENBMC_HOST_IPv6}
184e7b4db60SSweta Potthuri        SSHLibrary.Login  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  jumphost_index_or_alias=IPv6Conn
185e7b4db60SSweta Potthuri    END
186e7b4db60SSweta Potthuri
18715c7b3d2SSweta Potthuri
18815c7b3d2SSweta PotthuriSet SSH Protocol Using IPv6 Session And Verify
18915c7b3d2SSweta Potthuri    [Documentation]  Enable or disable SSH protocol via IPv6 and verify.
19015c7b3d2SSweta Potthuri    [Arguments]  ${enable_value}=${True}
19115c7b3d2SSweta Potthuri
19215c7b3d2SSweta Potthuri    # Description of argument(s}:
19315c7b3d2SSweta Potthuri    # enable_value  Enable or disable SSH, e.g. (true, false).
19415c7b3d2SSweta Potthuri
19515c7b3d2SSweta Potthuri    ${ssh_state}=  Create Dictionary  ProtocolEnabled=${enable_value}
19615c7b3d2SSweta Potthuri    ${data}=  Create Dictionary  SSH=${ssh_state}
19715c7b3d2SSweta Potthuri
19815c7b3d2SSweta Potthuri    RedfishIPv6.Login
19915c7b3d2SSweta Potthuri    RedfishIPv6.Patch  ${REDFISH_NW_PROTOCOL_URI}  body=&{data}
20015c7b3d2SSweta Potthuri    ...  valid_status_codes=[${HTTP_NO_CONTENT}]
20115c7b3d2SSweta Potthuri
20215c7b3d2SSweta Potthuri    # Wait for new values to take effect.
20315c7b3d2SSweta Potthuri    Sleep  30s
20415c7b3d2SSweta Potthuri
20515c7b3d2SSweta Potthuri    # Verify SSH Protocol State Via IPv6
20615c7b3d2SSweta Potthuri    ${resp}=  RedfishIPv6.Get  ${REDFISH_NW_PROTOCOL_URI}
20715c7b3d2SSweta Potthuri    Should Be Equal As Strings  ${resp.dict['SSH']['ProtocolEnabled']}  ${enable_value}
20815c7b3d2SSweta Potthuri    ...  msg=Protocol states are not matching.
20915c7b3d2SSweta Potthuri
21015c7b3d2SSweta Potthuri
21115c7b3d2SSweta PotthuriConnect BMC Using IPv6 Address
21215c7b3d2SSweta Potthuri    [Documentation]  Import bmc_redfish library with IPv6 configuration.
21315c7b3d2SSweta Potthuri    [Arguments]  ${OPENBMC_HOST_IPv6}
21415c7b3d2SSweta Potthuri
21515c7b3d2SSweta Potthuri    # Description of argument(s):
21615c7b3d2SSweta Potthuri    # OPENBMC_HOST_IPv6  IPv6 address of the BMC.
21715c7b3d2SSweta Potthuri
21815c7b3d2SSweta Potthuri    Import Library  ${CURDIR}/../../lib/bmc_redfish.py  https://[${OPENBMC_HOST_IPv6}]:${HTTPS_PORT}
21915c7b3d2SSweta Potthuri    ...             ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  AS  RedfishIPv6
2207a7ae5c5SAbhijith Naik
2217a7ae5c5SAbhijith Naik
2227a7ae5c5SAbhijith NaikGet IPv6 Address And Verify Connectivity
2237a7ae5c5SAbhijith Naik    [Documentation]  Get IPv6 address and verify connectivity.
2247a7ae5c5SAbhijith Naik    [Arguments]  ${ipv6_adress_type}  ${channel_number}
2257a7ae5c5SAbhijith Naik
2267a7ae5c5SAbhijith Naik    # Description of argument(s):
2277a7ae5c5SAbhijith Naik    # ipv6_adress_type   Type of IPv6 address(slaac/static).
2287a7ae5c5SAbhijith Naik    # channel_number     Ethernet channel number, 1(eth0) or 2(eth1).
2297a7ae5c5SAbhijith Naik
2307a7ae5c5SAbhijith Naik    @{ipv6_addressorigin_list}  ${ipv6_addr}=
2317a7ae5c5SAbhijith Naik    ...  Get Address Origin List And Address For Type  ${ipv6_adress_type}  ${channel_number}
2327a7ae5c5SAbhijith Naik    IF  '${SERVER_USERNAME}' != '${EMPTY}'
2337a7ae5c5SAbhijith Naik        Check IPv6 Connectivity  ${ipv6_addr}
2347a7ae5c5SAbhijith Naik    ELSE
2357a7ae5c5SAbhijith Naik        Wait For IPv6 Host To Ping  ${ipv6_addr}
2367a7ae5c5SAbhijith Naik    END
2377a7ae5c5SAbhijith Naik    Verify SSH Connection Via IPv6  ${ipv6_addr}
238