blob: 8ab1f9262ff1823672a9de81619c3ef74246553f [file] [log] [blame]
Prashanth Katti8abbb4d2021-01-29 02:17:45 -06001*** Settings ***
2Documentation Network interface IPv6 configuration and verification
3 ... tests.
4
5Resource ../../lib/bmc_redfish_resource.robot
6Resource ../../lib/openbmc_ffdc.robot
7Resource ../../lib/bmc_ipv6_utils.robot
8Library ../../lib/bmc_network_utils.py
9Library Collections
10
11Test Setup Test Setup Execution
12Test Teardown Test Teardown Execution
Prashanth Katti3270fd02021-06-11 08:02:22 -050013Suite Setup Suite Setup Execution
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060014
15
16*** Variables ***
17${test_ipv6_addr} 2001:db8:3333:4444:5555:6666:7777:8888
Prashanth Kattic1d2daa2022-07-26 03:53:06 -050018${test_ipv6_invalid_addr} 2001:db8:3333:4444:5555:6666:7777:JJKK
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060019
George Keishinge16f1582022-12-15 07:32:21 -060020# Valid prefix length is a integer ranges from 1 to 128.
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060021${test_prefix_lenght} 64
22
23
24*** Test Cases ***
25
26Get IPv6 Address And Verify
27 [Documentation] Get IPv6 Address And Verify.
28 [Tags] Get_IPv6_Address_And_Verify
29
30 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
31 Verify IPv6 On BMC ${ipv6_network_configuration['Address']}
32 END
33
34
Prashanth Katti2c73abc2021-03-17 07:42:25 -050035Get PrefixLength And Verify
36 [Documentation] Get IPv6 prefix length and verify.
37 [Tags] Get_PrefixLength_And_Verify
38
39 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
40 Verify IPv6 On BMC ${ipv6_network_configuration['PrefixLength']}
41 END
42
43
44Get IPv6 Default Gateway And Verify
George Keishing96143832021-03-23 07:55:08 -050045 [Documentation] Get IPv6 default gateway and verify.
George Keishingade6ab42022-07-19 11:41:03 -050046 [Tags] Get_IPv6_Default_Gateway_And_Verify
Prashanth Katti2c73abc2021-03-17 07:42:25 -050047
48 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
49 ${ipv6_gateway}= Get From Dictionary ${resp.dict} IPv6DefaultGateway
50 Verify IPv6 Default Gateway On BMC ${ipv6_gateway}
51
52
Prashanth Kattic1d2daa2022-07-26 03:53:06 -050053Verify All Configured IPv6 And PrefixLength On BMC
54 [Documentation] Verify IPv6 address and its prefix length on BMC.
55 [Tags] Verify_All_Configured_IPv6_And_PrefixLength_On_BMC
56
57 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
George Keishingf02ca2b2023-04-05 22:11:03 +053058 Verify IPv6 And PrefixLength ${ipv6_network_configuration['Address']}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -050059 ... ${ipv6_network_configuration['PrefixLength']}
60 END
61
62
63Configure IPv6 Address And Verify
64 [Documentation] Configure IPv6 address and verify.
65 [Tags] Configure_IPv6_Address_And_Verify
66 [Template] Configure IPv6 Address On BMC
67
68
69 # IPv6 address Prefix length
70 ${test_ipv6_addr} ${test_prefix_length}
71
72
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060073*** Keywords ***
74
Prashanth Katti3270fd02021-06-11 08:02:22 -050075Suite Setup Execution
76 [Documentation] Do suite setup execution.
77
78 ${active_channel_config}= Get Active Channel Config
79 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
80
81 Set Suite variable ${ethernet_interface}
82
83
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060084Test Setup Execution
85 [Documentation] Test setup execution.
86
87 Redfish.Login
88
89 @{ipv6_network_configurations}= Get IPv6 Network Configuration
90 Set Test Variable @{ipv6_network_configurations}
91
92 # Get BMC IPv6 address and prefix length.
93 ${ipv6_data}= Get BMC IPv6 Info
94 Set Test Variable ${ipv6_data}
95
96
97Test Teardown Execution
98 [Documentation] Test teardown execution.
99
100 FFDC On Test Case Fail
101 Redfish.Logout
102
103
104Get IPv6 Network Configuration
105 [Documentation] Get Ipv6 network configuration.
106 # Sample output:
107 # {
ganesanb4d430282023-04-27 14:33:23 +0000108 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0",
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600109 # "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface",
110 # "DHCPv4": {
111 # "DHCPEnabled": false,
112 # "UseDNSServers": false,
113 # "UseDomainName": true,
114 # "UseNTPServers": false
115 # },
116 # "DHCPv6": {
117 # "OperatingMode": "Disabled",
118 # "UseDNSServers": false,
119 # "UseDomainName": true,
120 # "UseNTPServers": false
121 # },
122 # "Description": "Management Network Interface",
123 # "FQDN": "localhost",
124 # "HostName": "localhost",
125 # "IPv4Addresses": [
126 # {
127 # "Address": "xx.xx.xx.xx",
128 # "AddressOrigin": "Static",
129 # "Gateway": "xx.xx.xx.1",
130 # "SubnetMask": "xx.xx.xx.0"
131 # },
132 # {
133 # "Address": "169.254.xx.xx",
134 # "AddressOrigin": "IPv4LinkLocal",
135 # "Gateway": "0.0.0.0",
136 # "SubnetMask": "xx.xx.0.0"
137 # },
138 # ],
139 # "IPv4StaticAddresses": [
140 # {
141 # "Address": "xx.xx.xx.xx",
142 # "AddressOrigin": "Static",
143 # "Gateway": "xx.xx.xx.1",
144 # "SubnetMask": "xx.xx.0.0"
145 # }
146 # }
147 # ],
148 # "IPv6AddressPolicyTable": [],
149 # "IPv6Addresses": [
150 # {
151 # "Address": "fe80::xxxx:xxxx:xxxx:xxxx",
152 # "AddressOrigin": "LinkLocal",
153 # "AddressState": null,
154 # "PrefixLength": xx
155 # }
156 # ],
157 # "IPv6DefaultGateway": "",
158 # "IPv6StaticAddresses": [
159 # { "Address": "xxxx:xxxx:xxxx:xxxx::xxxx",
160 # "AddressOrigin": "Static",
161 # "AddressState": null,
162 # "PrefixLength": xxx
163 # }
164 # ],
165 # "Id": "eth0",
166 # "InterfaceEnabled": true,
167 # "LinkStatus": "LinkUp",
168 # "MACAddress": "xx:xx:xx:xx:xx:xx",
169 # "Name": "Manager Ethernet Interface",
170 # "NameServers": [],
171 # "SpeedMbps": 0,
172 # "StaticNameServers": [],
173 # "Status": {
174 # "Health": "OK",
175 # "HealthRollup": "OK",
176 # "State": "Enabled"
177 # },
178 # "VLANs": {
ganesanb4d430282023-04-27 14:33:23 +0000179 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0/VLANs"
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600180
181
182 ${active_channel_config}= Get Active Channel Config
183 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
184
185 @{ipv6_network_configurations}= Get From Dictionary ${resp.dict} IPv6StaticAddresses
186 [Return] @{ipv6_network_configurations}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500187
188
189Verify IPv6 And PrefixLength
190 [Documentation] Verify IPv6 address and prefix length on BMC.
191 [Arguments] ${ipv6_addr} ${prefix_len}
192
193 # Description of the argument(s):
194 # ipv6_addr IPv6 address to be verified.
195 # prefix_len PrefixLength value to be verified.
196
197 # Catenate IPv6 address and its prefix length.
198 ${ipv6_with_prefix}= Catenate ${ipv6_addr}/${prefix_len}
199
200 # Get IPv6 address details on BMC using IP command.
201 @{ip_data}= Get BMC IPv6 Info
202
203 # Verify if IPv6 and prefix length is configured on BMC.
204
205 Should Contain ${ip_data} ${ipv6_with_prefix}
206 ... msg=IPv6 and prefix length pair does not exist.
207
208
209Configure IPv6 Address On BMC
210 [Documentation] Add IPv6 Address on BMC.
211 [Arguments] ${ipv6_addr} ${prefix_len} ${valid_status_codes}=${HTTP_OK}
212
213 # Description of argument(s):
214 # ipv6_addr IPv6 address to be added (e.g. "2001:EEEE:2222::2022").
215 # prefix_len Prefix length for the IPv6 to be added
216 # (e.g. "64").
217 # valid_status_codes Expected return code from patch operation
218 # (e.g. "200").
219
220 ${empty_dict}= Create Dictionary
221 ${ipv6_data}= Create Dictionary Address=${ipv6_addr}
222 ... PrefixLength=${prefix_len}
223
224 ${patch_list}= Create List
225
226 # Get existing static IPv6 configurations on BMC.
227 ${ipv6_network_configurations}= Get IPv6 Network Configuration
228 ${num_entries}= Get Length ${ipv6_network_configurations}
229
230 FOR ${INDEX} IN RANGE 0 ${num_entries}
231 Append To List ${patch_list} ${empty_dict}
232 END
233
234 ${valid_status_codes}= Run Keyword If '${valid_status_codes}' == '${HTTP_OK}'
235 ... Set Variable ${HTTP_OK},${HTTP_NO_CONTENT}
236 ... ELSE Set Variable ${valid_status_codes}
237
238 # We need not check for existence of IPv6 on BMC while adding.
239 Append To List ${patch_list} ${ipv6_data}
240 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list}
241
242 ${active_channel_config}= Get Active Channel Config
243 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
244
245 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data}
246 ... valid_status_codes=[${valid_status_codes}]
247
248 Return From Keyword If '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
249
250 # Note: Network restart takes around 15-18s after patch request processing.
251 Sleep ${NETWORK_TIMEOUT}s
252 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
253
254 Verify IPv6 And PrefixLength ${ipv6_addr} ${prefix_len}
255
256 # Verify if existing static IPv6 addresses still exist.
257 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
258 Verify IPv6 On BMC ${ipv6_network_configuration['Address']}
259 END
260
261 Validate IPv6 Network Config On BMC
262
263
264Validate IPv6 Network Config On BMC
265 [Documentation] Check that IPv6 network info obtained via redfish matches info
266 ... obtained via CLI.
267 @{network_configurations}= Get IPv6 Network Configuration
268 ${ipv6_data}= Get BMC IPv6 Info
269 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
270 Should Contain Match ${ipv6_data} ${ipv6_network_configuration['Address']}/*
271 ... msg=IPv6 address does not exist.
272 END
273