xref: /openbmc/openbmc-test-automation/redfish/managers/test_bmc_config_ipv6.robot (revision 1d03ee954c3c53fadcac65e0c3ae1029ff6351b7)
1*** Settings ***
2Documentation  Network interface IPv6 configuration connected to DHCP server
3               ...   and verification tests.
4
5Resource       ../../lib/bmc_redfish_resource.robot
6Resource       ../../lib/openbmc_ffdc.robot
7Resource       ../../lib/bmc_ipv6_utils.robot
8Resource       ../../lib/bmc_network_utils.robot
9Resource       ../../lib/protocol_setting_utils.robot
10
11Library        Collections
12Library        Process
13Library        OperatingSystem
14Suite Setup     Suite Setup Execution
15Test Teardown   Test Teardown Execution
16
17Test Tags     BMC_IPv6_Config
18
19*** Variables ***
20# Remote DHCP test bed server. Leave variables EMPTY if server is configured local
21# to the test where it is running else if remote pass the server credentials
22# -v SERVER_IPv6:xx.xx.xx.xx
23# -v SERVER_USERNAME:root
24# -v SERVER_PASSWORD:*********
25
26${SERVER_USERNAME}      ${EMPTY}
27${SERVER_PASSWORD}      ${EMPTY}
28${SERVER_IPv6}          ${EMPTY}
29
30
31*** Test Cases ***
32
33Get SLAAC And Static IPv6 Address And Verify Connectivity
34    [Documentation]  Fetch the SLAAC and Static IPv6 address
35    ...    and verify ping and SSH connection.
36    [Tags]  Get_SLAAC_And_Static_IPv6_Address_And_Verify_Connectivity
37    [Template]  Get IPv6 Address And Verify Connectivity
38
39    # Address_type  channel_number
40    SLAAC           ${1}
41    Static          ${1}
42    SLAAC           ${2}
43    Static          ${2}
44
45
46Enable SSH Protocol Via IPv6 And Verify
47    [Documentation]  Enable SSH protocol via eth1 and verify.
48    [Tags]  Enable_SSH_Protocol_Via_IPv6_And_Verify
49
50    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
51    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
52    Connect BMC Using IPv6 Address  ${ipv6_slaac_addr}
53    Set SSH Protocol Using IPv6 Session And Verify  ${True}
54    Verify SSH Login And Commands Work
55    Verify SSH Connection Via IPv6  ${ipv6_slaac_addr}
56
57
58Disable SSH Protocol Via IPv6 And Verify
59    [Documentation]  Disable SSH protocol via IPv6 and verify.
60    [Tags]  Disable_SSH_Protocol_Via_IPv6_And_Verify
61    [Teardown]  Set SSH Protocol Using IPv6 Session And Verify  ${True}
62
63    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
64    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
65    Connect BMC Using IPv6 Address  ${ipv6_slaac_addr}
66
67    Set SSH Protocol Using IPv6 Session And Verify  ${False}
68
69    # Verify SSH Login And Commands Work.
70    ${status}=  Run Keyword And Return Status
71    ...    Verify SSH Connection Via IPv6  ${ipv6_slaac_addr}
72    Should Be Equal As Strings  ${status}  False
73    ...  msg=SSH Login and commands are working after disabling SSH via IPv6.
74
75    # Verify SSH Connection Via IPv6.
76    ${status}=  Run Keyword And Return Status
77    ...  Verify SSH Login And Commands Work
78    Should Be Equal As Strings  ${status}  False
79    ...  msg=SSH Login and commands are working after disabling SSH.
80
81
82Verify BMC IPv4 And IPv6 Addresses Accessible Via SSH
83    [Documentation]  Verify BMC IPv4 and IPv6 addresses accessible via SSH.
84    [Tags]  Verify_BMC_IPv4_And_IPv6_Addresses_Accessible_Via_SSH
85
86    Open Connection And Log In  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  host=${OPENBMC_HOST}
87    Verify SSH Connection Via IPv6
88
89
90Verify IPv4 And IPv6 Access Concurrently Via Redfish
91    [Documentation]  Verify both interfaces access conurrently via redfish.
92    [Tags]  Verify_IPv4_And_IPv6_Access_Concurrently_Via_Redfish
93
94    ${dict}=  Execute Process Multi Keyword  ${2}
95    ...  Redfish.patch ${REDFISH_NW_ETH_IFACE}eth0 body={'DHCPv4':{'UseDNSServers':${True}}}
96    ...  RedfishIPv6.patch ${REDFISH_NW_ETH_IFACE}eth0 body={'DHCPv4':{'UseDNSServers':${True}}}
97    Dictionary Should Not Contain Value  ${dict}  False
98    ...  msg=One or more operations has failed.
99    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}eth0
100    ${resp1}=  Redfish1.Get  ${REDFISH_NW_ETH_IFACE}eth0
101    Should Be Equal  ${resp.dict["DHCPv4"]['UseDNSServers']}  ${True}
102    Should Be Equal  ${resp1.dict["DHCPv4"]['UseDNSServers']}  ${True}
103
104
105Configure Static IPv6 From SLAAC Address
106    [Documentation]  Configure Static IPv6 From SLAAC Address.
107    [Tags]  Configure_Static_IPv6_From_SLAAC_Address
108
109    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
110    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
111    Connect BMC Using IPv6 Address  ${ipv6_slaac_addr}
112    RedfishIPv6.Login
113    Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}  Version=IPv6
114
115
116*** Keywords ***
117
118Suite Setup Execution
119    [Documentation]  Do suite setup execution.
120
121    Redfish.Login
122    ${active_channel_config}=  Get Active Channel Config
123    Set Suite Variable  ${active_channel_config}
124    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
125    Set Suite variable  ${ethernet_interface}
126
127
128Test Teardown Execution
129    [Documentation]  Test teardown execution.
130
131    FFDC On Test Case Fail
132    Redfish.Logout
133    RedfishIPv6.Logout
134
135
136Wait For IPv6 Host To Ping
137    [Documentation]  Verify that the IPv6 host responds successfully to ping.
138    [Arguments]  ${host}  ${timeout}=${OPENBMC_REBOOT_TIMEOUT}sec
139    ...          ${interval}=5 sec  ${expected_rc}=${0}
140    # Description of argument(s):
141    # host         The IPv6 address of the host to ping.
142    # timeout      Maximum time to wait for the host to respond to ping.
143    # interval     Time to wait between ping attempts.
144    # expected_rc  Expected return code of ping command.
145    Wait Until Keyword Succeeds  ${timeout}  ${interval}  Ping Host Over IPv6  ${host}  ${expected_rc}
146
147
148Ping Host Over IPv6
149    [Documentation]  Ping6 the given host.
150    [Arguments]     ${host}  ${expected_rc}=${0}
151    # Description of argument(s):
152    # host           IPv6 address of the host to ping.
153    # expected_rc    Expected return code of ping command.
154    Should Not Be Empty    ${host}   msg=No host provided.
155    ${rc}   ${output}=     Run and return RC and Output    ping6 -c 4 ${host}
156    Log     RC: ${rc}\nOutput:\n${output}
157    Should Be Equal     ${rc}   ${expected_rc}
158
159
160Check IPv6 Connectivity
161    [Documentation]  Check ping6 status and verify.
162    [Arguments]  ${OPENBMC_HOST_IPv6}
163
164    # Description of argument(s):
165    # OPENBMC_HOST_IPv6   IPv6 address to check connectivity.
166
167    Open Connection And Log In  ${SERVER_USERNAME}  ${SERVER_PASSWORD}  host=${SERVER_IPv6}
168    Wait For IPv6 Host To Ping  ${OPENBMC_HOST_IPv6}  30 secs
169
170
171Verify SSH Connection Via IPv6
172    [Documentation]  Verify connectivity to the IPv6 host via SSH.
173    [Arguments]  ${OPENBMC_HOST_IPv6}
174
175    # Description of argument(s):
176    # OPENBMC_HOST_IPv6   IPv6 address to check connectivity.
177
178    IF  '${SERVER_USERNAME}' == '${EMPTY}'
179        SSHLibrary.Open Connection  ${OPENBMC_HOST_IPv6}
180        SSHLibrary.Login  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}
181    ELSE
182        Open Connection And Log In  ${SERVER_USERNAME}  ${SERVER_PASSWORD}  host=${SERVER_IPv6}  alias=IPv6Conn
183        SSHLibrary.Open Connection  ${OPENBMC_HOST_IPv6}
184        SSHLibrary.Login  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  jumphost_index_or_alias=IPv6Conn
185    END
186
187
188Set SSH Protocol Using IPv6 Session And Verify
189    [Documentation]  Enable or disable SSH protocol via IPv6 and verify.
190    [Arguments]  ${enable_value}=${True}
191
192    # Description of argument(s}:
193    # enable_value  Enable or disable SSH, e.g. (true, false).
194
195    ${ssh_state}=  Create Dictionary  ProtocolEnabled=${enable_value}
196    ${data}=  Create Dictionary  SSH=${ssh_state}
197
198    RedfishIPv6.Login
199    RedfishIPv6.Patch  ${REDFISH_NW_PROTOCOL_URI}  body=&{data}
200    ...  valid_status_codes=[${HTTP_NO_CONTENT}]
201
202    # Wait for new values to take effect.
203    Sleep  30s
204
205    # Verify SSH Protocol State Via IPv6
206    ${resp}=  RedfishIPv6.Get  ${REDFISH_NW_PROTOCOL_URI}
207    Should Be Equal As Strings  ${resp.dict['SSH']['ProtocolEnabled']}  ${enable_value}
208    ...  msg=Protocol states are not matching.
209
210
211Connect BMC Using IPv6 Address
212    [Documentation]  Import bmc_redfish library with IPv6 configuration.
213    [Arguments]  ${OPENBMC_HOST_IPv6}
214
215    # Description of argument(s):
216    # OPENBMC_HOST_IPv6  IPv6 address of the BMC.
217
218    Import Library  ${CURDIR}/../../lib/bmc_redfish.py  https://[${OPENBMC_HOST_IPv6}]:${HTTPS_PORT}
219    ...             ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  AS  RedfishIPv6
220
221
222Get IPv6 Address And Verify Connectivity
223    [Documentation]  Get IPv6 address and verify connectivity.
224    [Arguments]  ${ipv6_adress_type}  ${channel_number}
225
226    # Description of argument(s):
227    # ipv6_adress_type   Type of IPv6 address(slaac/static).
228    # channel_number     Ethernet channel number, 1(eth0) or 2(eth1).
229
230    @{ipv6_addressorigin_list}  ${ipv6_addr}=
231    ...  Get Address Origin List And Address For Type  ${ipv6_adress_type}  ${channel_number}
232    IF  '${SERVER_USERNAME}' != '${EMPTY}'
233        Check IPv6 Connectivity  ${ipv6_addr}
234    ELSE
235        Wait For IPv6 Host To Ping  ${ipv6_addr}
236    END
237    Verify SSH Connection Via IPv6  ${ipv6_addr}
238