xref: /openbmc/openbmc-test-automation/redfish/managers/test_bmc_config_ipv6.robot (revision 15c7b3d2651a853b3748c87c774ce80aeb4e3c0e)
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
9*15c7b3d2SSweta PotthuriResource       ../../lib/protocol_setting_utils.robot
10*15c7b3d2SSweta Potthuri
11e7b4db60SSweta PotthuriLibrary        Collections
12e7b4db60SSweta PotthuriLibrary        Process
13e7b4db60SSweta PotthuriLibrary        OperatingSystem
14e7b4db60SSweta PotthuriSuite Setup     Suite Setup Execution
15*15c7b3d2SSweta 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
33e7b4db60SSweta PotthuriGet SLAAC Address And Verify Connectivity
34e7b4db60SSweta Potthuri    [Documentation]  Fetch the SLAAC address and verify ping and SSH connection.
35e7b4db60SSweta Potthuri    [Tags]  Get_SLAAC_Address_And_Verify_Connectivity
36e7b4db60SSweta Potthuri
37e7b4db60SSweta Potthuri    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
38*15c7b3d2SSweta Potthuri    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
39e7b4db60SSweta Potthuri    IF  '${SERVER_USERNAME}' != '${EMPTY}'
40e7b4db60SSweta Potthuri        Check IPv6 Connectivity  ${ipv6_slaac_addr}
41e7b4db60SSweta Potthuri    ELSE
42e7b4db60SSweta Potthuri        Wait For IPv6 Host To Ping  ${ipv6_slaac_addr}
43e7b4db60SSweta Potthuri    END
44e7b4db60SSweta Potthuri    Verify SSH Connection Via IPv6  ${ipv6_slaac_addr}
45e7b4db60SSweta Potthuri
46e7b4db60SSweta Potthuri
47*15c7b3d2SSweta PotthuriEnable SSH Protocol Via IPv6 And Verify
48*15c7b3d2SSweta Potthuri    [Documentation]  Enable SSH protocol via eth1 and verify.
49*15c7b3d2SSweta Potthuri    [Tags]  Enable_SSH_Protocol_Via_IPv6_And_Verify
50*15c7b3d2SSweta Potthuri
51*15c7b3d2SSweta Potthuri    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
52*15c7b3d2SSweta Potthuri    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
53*15c7b3d2SSweta Potthuri    Connect BMC Using IPv6 Address  ${ipv6_slaac_addr}
54*15c7b3d2SSweta Potthuri    Set SSH Protocol Using IPv6 Session And Verify  ${True}
55*15c7b3d2SSweta Potthuri    Verify SSH Login And Commands Work
56*15c7b3d2SSweta Potthuri    Verify SSH Connection Via IPv6  ${ipv6_slaac_addr}
57*15c7b3d2SSweta Potthuri
58*15c7b3d2SSweta Potthuri
59*15c7b3d2SSweta PotthuriDisable SSH Protocol Via IPv6 And Verify
60*15c7b3d2SSweta Potthuri    [Documentation]  Disable SSH protocol via IPv6 and verify.
61*15c7b3d2SSweta Potthuri    [Tags]  Disable_SSH_Protocol_Via_IPv6_And_Verify
62*15c7b3d2SSweta Potthuri    [Teardown]  Set SSH Protocol Using IPv6 Session And Verify  ${True}
63*15c7b3d2SSweta Potthuri
64*15c7b3d2SSweta Potthuri    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
65*15c7b3d2SSweta Potthuri    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
66*15c7b3d2SSweta Potthuri    Connect BMC Using IPv6 Address  ${ipv6_slaac_addr}
67*15c7b3d2SSweta Potthuri
68*15c7b3d2SSweta Potthuri    Set SSH Protocol Using IPv6 Session And Verify  ${False}
69*15c7b3d2SSweta Potthuri
70*15c7b3d2SSweta Potthuri    # Verify SSH Login And Commands Work.
71*15c7b3d2SSweta Potthuri    ${status}=  Run Keyword And Return Status
72*15c7b3d2SSweta Potthuri    ...    Verify SSH Connection Via IPv6  ${ipv6_slaac_addr}
73*15c7b3d2SSweta Potthuri    Should Be Equal As Strings  ${status}  False
74*15c7b3d2SSweta Potthuri    ...  msg=SSH Login and commands are working after disabling SSH via IPv6.
75*15c7b3d2SSweta Potthuri
76*15c7b3d2SSweta Potthuri    # Verify SSH Connection Via IPv6.
77*15c7b3d2SSweta Potthuri    ${status}=  Run Keyword And Return Status
78*15c7b3d2SSweta Potthuri    ...  Verify SSH Login And Commands Work
79*15c7b3d2SSweta Potthuri    Should Be Equal As Strings  ${status}  False
80*15c7b3d2SSweta Potthuri    ...  msg=SSH Login and commands are working after disabling SSH.
81*15c7b3d2SSweta Potthuri
82*15c7b3d2SSweta Potthuri
83e7b4db60SSweta Potthuri*** Keywords ***
84e7b4db60SSweta Potthuri
85e7b4db60SSweta PotthuriSuite Setup Execution
86e7b4db60SSweta Potthuri    [Documentation]  Do suite setup execution.
87e7b4db60SSweta Potthuri
88e7b4db60SSweta Potthuri    Redfish.Login
89e7b4db60SSweta Potthuri    ${active_channel_config}=  Get Active Channel Config
90e7b4db60SSweta Potthuri    Set Suite Variable  ${active_channel_config}
91e7b4db60SSweta Potthuri    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
92e7b4db60SSweta Potthuri    Set Suite variable  ${ethernet_interface}
93e7b4db60SSweta Potthuri
94e7b4db60SSweta Potthuri
95e7b4db60SSweta PotthuriTest Teardown Execution
96e7b4db60SSweta Potthuri    [Documentation]  Test teardown execution.
97e7b4db60SSweta Potthuri
98e7b4db60SSweta Potthuri    FFDC On Test Case Fail
99*15c7b3d2SSweta Potthuri    Redfish.Logout
100*15c7b3d2SSweta Potthuri    RedfishIPv6.Logout
101e7b4db60SSweta Potthuri
102e7b4db60SSweta Potthuri
103e7b4db60SSweta PotthuriWait For IPv6 Host To Ping
104e7b4db60SSweta Potthuri    [Documentation]  Verify that the IPv6 host responds successfully to ping.
105e7b4db60SSweta Potthuri    [Arguments]  ${host}  ${timeout}=${OPENBMC_REBOOT_TIMEOUT}sec
106e7b4db60SSweta Potthuri    ...          ${interval}=5 sec  ${expected_rc}=${0}
107e7b4db60SSweta Potthuri    # Description of argument(s):
108e7b4db60SSweta Potthuri    # host         The IPv6 address of the host to ping.
109e7b4db60SSweta Potthuri    # timeout      Maximum time to wait for the host to respond to ping.
110e7b4db60SSweta Potthuri    # interval     Time to wait between ping attempts.
111e7b4db60SSweta Potthuri    # expected_rc  Expected return code of ping command.
112e7b4db60SSweta Potthuri    Wait Until Keyword Succeeds  ${timeout}  ${interval}  Ping Host Over IPv6  ${host}  ${expected_rc}
113e7b4db60SSweta Potthuri
114e7b4db60SSweta Potthuri
115e7b4db60SSweta PotthuriPing Host Over IPv6
116e7b4db60SSweta Potthuri    [Documentation]  Ping6 the given host.
117e7b4db60SSweta Potthuri    [Arguments]     ${host}  ${expected_rc}=${0}
118e7b4db60SSweta Potthuri    # Description of argument(s):
119e7b4db60SSweta Potthuri    # host           IPv6 address of the host to ping.
120e7b4db60SSweta Potthuri    # expected_rc    Expected return code of ping command.
121e7b4db60SSweta Potthuri    Should Not Be Empty    ${host}   msg=No host provided.
122e7b4db60SSweta Potthuri    ${rc}   ${output}=     Run and return RC and Output    ping6 -c 4 ${host}
123e7b4db60SSweta Potthuri    Log     RC: ${rc}\nOutput:\n${output}
124e7b4db60SSweta Potthuri    Should Be Equal     ${rc}   ${expected_rc}
125e7b4db60SSweta Potthuri
126e7b4db60SSweta Potthuri
127e7b4db60SSweta PotthuriCheck IPv6 Connectivity
128e7b4db60SSweta Potthuri    [Documentation]  Check ping6 status and verify.
129e7b4db60SSweta Potthuri    [Arguments]  ${OPENBMC_HOST_IPv6}
130e7b4db60SSweta Potthuri
131e7b4db60SSweta Potthuri    # Description of argument(s):
132e7b4db60SSweta Potthuri    # OPENBMC_HOST_IPv6   IPv6 address to check connectivity.
133e7b4db60SSweta Potthuri
134e7b4db60SSweta Potthuri    Open Connection And Log In  ${SERVER_USERNAME}  ${SERVER_PASSWORD}  host=${SERVER_IPv6}
135e7b4db60SSweta Potthuri    Wait For IPv6 Host To Ping  ${OPENBMC_HOST_IPv6}  30 secs
136e7b4db60SSweta Potthuri
137e7b4db60SSweta Potthuri
138e7b4db60SSweta PotthuriVerify SSH Connection Via IPv6
139e7b4db60SSweta Potthuri    [Documentation]  Verify connectivity to the IPv6 host via SSH.
140e7b4db60SSweta Potthuri    [Arguments]  ${OPENBMC_HOST_IPv6}
141e7b4db60SSweta Potthuri
142e7b4db60SSweta Potthuri    # Description of argument(s):
143e7b4db60SSweta Potthuri    # OPENBMC_HOST_IPv6   IPv6 address to check connectivity.
144e7b4db60SSweta Potthuri
145e7b4db60SSweta Potthuri    IF  '${SERVER_USERNAME}' == '${EMPTY}'
146e7b4db60SSweta Potthuri        SSHLibrary.Open Connection  ${OPENBMC_HOST_IPv6}
147e7b4db60SSweta Potthuri        SSHLibrary.Login  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}
148e7b4db60SSweta Potthuri    ELSE
149e7b4db60SSweta Potthuri        Open Connection And Log In  ${SERVER_USERNAME}  ${SERVER_PASSWORD}  host=${SERVER_IPv6}  alias=IPv6Conn
150e7b4db60SSweta Potthuri        SSHLibrary.Open Connection  ${OPENBMC_HOST_IPv6}
151e7b4db60SSweta Potthuri        SSHLibrary.Login  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  jumphost_index_or_alias=IPv6Conn
152e7b4db60SSweta Potthuri    END
153e7b4db60SSweta Potthuri
154*15c7b3d2SSweta Potthuri
155*15c7b3d2SSweta PotthuriSet SSH Protocol Using IPv6 Session And Verify
156*15c7b3d2SSweta Potthuri    [Documentation]  Enable or disable SSH protocol via IPv6 and verify.
157*15c7b3d2SSweta Potthuri    [Arguments]  ${enable_value}=${True}
158*15c7b3d2SSweta Potthuri
159*15c7b3d2SSweta Potthuri    # Description of argument(s}:
160*15c7b3d2SSweta Potthuri    # enable_value  Enable or disable SSH, e.g. (true, false).
161*15c7b3d2SSweta Potthuri
162*15c7b3d2SSweta Potthuri    ${ssh_state}=  Create Dictionary  ProtocolEnabled=${enable_value}
163*15c7b3d2SSweta Potthuri    ${data}=  Create Dictionary  SSH=${ssh_state}
164*15c7b3d2SSweta Potthuri
165*15c7b3d2SSweta Potthuri    RedfishIPv6.Login
166*15c7b3d2SSweta Potthuri    RedfishIPv6.Patch  ${REDFISH_NW_PROTOCOL_URI}  body=&{data}
167*15c7b3d2SSweta Potthuri    ...  valid_status_codes=[${HTTP_NO_CONTENT}]
168*15c7b3d2SSweta Potthuri
169*15c7b3d2SSweta Potthuri    # Wait for new values to take effect.
170*15c7b3d2SSweta Potthuri    Sleep  30s
171*15c7b3d2SSweta Potthuri
172*15c7b3d2SSweta Potthuri    # Verify SSH Protocol State Via IPv6
173*15c7b3d2SSweta Potthuri    ${resp}=  RedfishIPv6.Get  ${REDFISH_NW_PROTOCOL_URI}
174*15c7b3d2SSweta Potthuri    Should Be Equal As Strings  ${resp.dict['SSH']['ProtocolEnabled']}  ${enable_value}
175*15c7b3d2SSweta Potthuri    ...  msg=Protocol states are not matching.
176*15c7b3d2SSweta Potthuri
177*15c7b3d2SSweta Potthuri
178*15c7b3d2SSweta PotthuriConnect BMC Using IPv6 Address
179*15c7b3d2SSweta Potthuri    [Documentation]  Import bmc_redfish library with IPv6 configuration.
180*15c7b3d2SSweta Potthuri    [Arguments]  ${OPENBMC_HOST_IPv6}
181*15c7b3d2SSweta Potthuri
182*15c7b3d2SSweta Potthuri    # Description of argument(s):
183*15c7b3d2SSweta Potthuri    # OPENBMC_HOST_IPv6  IPv6 address of the BMC.
184*15c7b3d2SSweta Potthuri
185*15c7b3d2SSweta Potthuri    Import Library  ${CURDIR}/../../lib/bmc_redfish.py  https://[${OPENBMC_HOST_IPv6}]:${HTTPS_PORT}
186*15c7b3d2SSweta Potthuri    ...             ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  AS  RedfishIPv6
187