1*** 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 13Suite Setup Suite Setup Execution 14 15Test Tags BMC_IPv6 16 17*** Variables *** 18${test_ipv6_addr} 2001:db8:3333:4444:5555:6666:7777:8888 19${test_ipv6_invalid_addr} 2001:db8:3333:4444:5555:6666:7777:JJKK 20${test_ipv6_addr1} 2001:db8:3333:4444:5555:6666:7777:9999 21 22# Valid prefix length is a integer ranges from 1 to 128. 23${test_prefix_length} 64 24 25*** Test Cases *** 26 27Get IPv6 Address And Verify 28 [Documentation] Get IPv6 Address And Verify. 29 [Tags] Get_IPv6_Address_And_Verify 30 31 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 32 Verify IPv6 On BMC ${ipv6_network_configuration['Address']} 33 END 34 35 36Get PrefixLength And Verify 37 [Documentation] Get IPv6 prefix length and verify. 38 [Tags] Get_PrefixLength_And_Verify 39 40 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 41 Verify IPv6 On BMC ${ipv6_network_configuration['PrefixLength']} 42 END 43 44 45Get IPv6 Default Gateway And Verify 46 [Documentation] Get IPv6 default gateway and verify. 47 [Tags] Get_IPv6_Default_Gateway_And_Verify 48 49 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 50 ${ipv6_gateway}= Get From Dictionary ${resp.dict} IPv6DefaultGateway 51 Verify IPv6 Default Gateway On BMC ${ipv6_gateway} 52 53 54Verify All Configured IPv6 And PrefixLength On BMC 55 [Documentation] Verify IPv6 address and its prefix length on BMC. 56 [Tags] Verify_All_Configured_IPv6_And_PrefixLength_On_BMC 57 58 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 59 Verify IPv6 And PrefixLength ${ipv6_network_configuration['Address']} 60 ... ${ipv6_network_configuration['PrefixLength']} 61 END 62 63 64Configure IPv6 Address And Verify 65 [Documentation] Configure IPv6 address and verify. 66 [Tags] Configure_IPv6_Address_And_Verify 67 [Template] Configure IPv6 Address On BMC 68 69 70 # IPv6 address Prefix length 71 ${test_ipv6_addr} ${test_prefix_length} 72 73 74Delete IPv6 Address And Verify 75 [Documentation] Delete IPv6 address and verify. 76 [Tags] Delete_IPv6_Address_And_Verify 77 78 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length} 79 80 Delete IPv6 Address ${test_ipv6_addr} 81 82 83 84Modify IPv6 Address And Verify 85 [Documentation] Modify IPv6 address and verify. 86 [Tags] Modify_IPv6_Address_And_Verify 87 88 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length} 89 90 Modify IPv6 Address ${test_ipv6_addr} ${test_ipv6_addr1} ${test_prefix_length} 91 92 93Verify Persistency Of IPv6 After BMC Reboot 94 [Documentation] Verify persistency of IPv6 after BMC reboot. 95 [Tags] Verify_Persistency_Of_IPv6_After_BMC_Reboot 96 [Teardown] Run Keywords 97 ... Delete IPv6 Address ${test_ipv6_addr} AND Test Teardown Execution 98 99 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length} 100 101 Redfish OBMC Reboot (off) stack_mode=skip 102 103 # Verifying persistency of IPv6. 104 Verify IPv6 On BMC ${test_ipv6_addr} 105 106 107*** Keywords *** 108 109Suite Setup Execution 110 [Documentation] Do suite setup execution. 111 112 ${active_channel_config}= Get Active Channel Config 113 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']} 114 115 Set Suite variable ${ethernet_interface} 116 117 118Test Setup Execution 119 [Documentation] Test setup execution. 120 121 Redfish.Login 122 123 @{ipv6_network_configurations}= Get IPv6 Network Configuration 124 Set Test Variable @{ipv6_network_configurations} 125 126 # Get BMC IPv6 address and prefix length. 127 ${ipv6_data}= Get BMC IPv6 Info 128 Set Test Variable ${ipv6_data} 129 130 131Test Teardown Execution 132 [Documentation] Test teardown execution. 133 134 FFDC On Test Case Fail 135 Redfish.Logout 136 137 138Get IPv6 Network Configuration 139 [Documentation] Get Ipv6 network configuration. 140 # Sample output: 141 # { 142 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0", 143 # "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface", 144 # "DHCPv4": { 145 # "DHCPEnabled": false, 146 # "UseDNSServers": false, 147 # "UseDomainName": true, 148 # "UseNTPServers": false 149 # }, 150 # "DHCPv6": { 151 # "OperatingMode": "Disabled", 152 # "UseDNSServers": false, 153 # "UseDomainName": true, 154 # "UseNTPServers": false 155 # }, 156 # "Description": "Management Network Interface", 157 # "FQDN": "localhost", 158 # "HostName": "localhost", 159 # "IPv4Addresses": [ 160 # { 161 # "Address": "xx.xx.xx.xx", 162 # "AddressOrigin": "Static", 163 # "Gateway": "xx.xx.xx.1", 164 # "SubnetMask": "xx.xx.xx.0" 165 # }, 166 # { 167 # "Address": "169.254.xx.xx", 168 # "AddressOrigin": "IPv4LinkLocal", 169 # "Gateway": "0.0.0.0", 170 # "SubnetMask": "xx.xx.0.0" 171 # }, 172 # ], 173 # "IPv4StaticAddresses": [ 174 # { 175 # "Address": "xx.xx.xx.xx", 176 # "AddressOrigin": "Static", 177 # "Gateway": "xx.xx.xx.1", 178 # "SubnetMask": "xx.xx.0.0" 179 # } 180 # } 181 # ], 182 # "IPv6AddressPolicyTable": [], 183 # "IPv6Addresses": [ 184 # { 185 # "Address": "fe80::xxxx:xxxx:xxxx:xxxx", 186 # "AddressOrigin": "LinkLocal", 187 # "AddressState": null, 188 # "PrefixLength": xx 189 # } 190 # ], 191 # "IPv6DefaultGateway": "", 192 # "IPv6StaticAddresses": [ 193 # { "Address": "xxxx:xxxx:xxxx:xxxx::xxxx", 194 # "AddressOrigin": "Static", 195 # "AddressState": null, 196 # "PrefixLength": xxx 197 # } 198 # ], 199 # "Id": "eth0", 200 # "InterfaceEnabled": true, 201 # "LinkStatus": "LinkUp", 202 # "MACAddress": "xx:xx:xx:xx:xx:xx", 203 # "Name": "Manager Ethernet Interface", 204 # "NameServers": [], 205 # "SpeedMbps": 0, 206 # "StaticNameServers": [], 207 # "Status": { 208 # "Health": "OK", 209 # "HealthRollup": "OK", 210 # "State": "Enabled" 211 # }, 212 # "VLANs": { 213 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0/VLANs" 214 215 216 ${active_channel_config}= Get Active Channel Config 217 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']} 218 219 @{ipv6_network_configurations}= Get From Dictionary ${resp.dict} IPv6StaticAddresses 220 RETURN @{ipv6_network_configurations} 221 222 223Verify IPv6 And PrefixLength 224 [Documentation] Verify IPv6 address and prefix length on BMC. 225 [Arguments] ${ipv6_addr} ${prefix_len} 226 227 # Description of the argument(s): 228 # ipv6_addr IPv6 address to be verified. 229 # prefix_len PrefixLength value to be verified. 230 231 # Catenate IPv6 address and its prefix length. 232 ${ipv6_with_prefix}= Catenate ${ipv6_addr}/${prefix_len} 233 234 # Get IPv6 address details on BMC using IP command. 235 @{ip_data}= Get BMC IPv6 Info 236 237 # Verify if IPv6 and prefix length is configured on BMC. 238 239 Should Contain ${ip_data} ${ipv6_with_prefix} 240 ... msg=IPv6 and prefix length pair does not exist. 241 242 243Configure IPv6 Address On BMC 244 [Documentation] Add IPv6 Address on BMC. 245 [Arguments] ${ipv6_addr} ${prefix_len} ${valid_status_codes}=${HTTP_OK} 246 247 # Description of argument(s): 248 # ipv6_addr IPv6 address to be added (e.g. "2001:EEEE:2222::2022"). 249 # prefix_len Prefix length for the IPv6 to be added 250 # (e.g. "64"). 251 # valid_status_codes Expected return code from patch operation 252 # (e.g. "200"). 253 254 ${prefix_length}= Convert To Integer ${prefix_len} 255 ${empty_dict}= Create Dictionary 256 ${ipv6_data}= Create Dictionary Address=${ipv6_addr} 257 ... PrefixLength=${prefix_length} 258 259 ${patch_list}= Create List 260 261 # Get existing static IPv6 configurations on BMC. 262 ${ipv6_network_configurations}= Get IPv6 Network Configuration 263 ${num_entries}= Get Length ${ipv6_network_configurations} 264 265 FOR ${INDEX} IN RANGE 0 ${num_entries} 266 Append To List ${patch_list} ${empty_dict} 267 END 268 269 ${valid_status_codes}= Run Keyword If '${valid_status_codes}' == '${HTTP_OK}' 270 ... Set Variable ${HTTP_OK},${HTTP_NO_CONTENT} 271 ... ELSE Set Variable ${valid_status_codes} 272 273 # We need not check for existence of IPv6 on BMC while adding. 274 Append To List ${patch_list} ${ipv6_data} 275 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list} 276 277 ${active_channel_config}= Get Active Channel Config 278 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']} 279 280 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data} 281 ... valid_status_codes=[${valid_status_codes}] 282 283 Return From Keyword If '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}' 284 285 # Note: Network restart takes around 15-18s after patch request processing. 286 Sleep ${NETWORK_TIMEOUT}s 287 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} 288 289 Verify IPv6 And PrefixLength ${ipv6_addr} ${prefix_len} 290 291 # Verify if existing static IPv6 addresses still exist. 292 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 293 Verify IPv6 On BMC ${ipv6_network_configuration['Address']} 294 END 295 296 Validate IPv6 Network Config On BMC 297 298 299Validate IPv6 Network Config On BMC 300 [Documentation] Check that IPv6 network info obtained via redfish matches info 301 ... obtained via CLI. 302 @{ipv6_network_configurations}= Get IPv6 Network Configuration 303 ${ipv6_data}= Get BMC IPv6 Info 304 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 305 Should Contain Match ${ipv6_data} ${ipv6_network_configuration['Address']}/* 306 ... msg=IPv6 address does not exist. 307 END 308 309 310Delete IPv6 Address 311 [Documentation] Delete IPv6 address of BMC. 312 [Arguments] ${ipv6_addr} ${valid_status_codes}=${HTTP_OK} 313 314 # Description of argument(s): 315 # ipv6_addr IPv6 address to be deleted (e.g. "2001:1234:1234:1234::1234"). 316 # valid_status_codes Expected return code from patch operation 317 # (e.g. "200"). See prolog of rest_request 318 # method in redfish_plus.py for details. 319 320 ${empty_dict}= Create Dictionary 321 ${patch_list}= Create List 322 323 @{ipv6_network_configurations}= Get IPv6 Network Configuration 324 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 325 IF '${ipv6_network_configuration['Address']}' == '${ipv6_addr}' 326 Append To List ${patch_list} ${null} 327 ELSE 328 Append To List ${patch_list} ${empty_dict} 329 END 330 END 331 332 ${ip_found}= Run Keyword And Return Status List Should Contain Value 333 ... ${patch_list} ${null} msg=${ipv6_addr} does not exist on BMC 334 Pass Execution If ${ip_found} == ${False} ${ipv6_addr} does not exist on BMC 335 336 # Run patch command only if given IP is found on BMC 337 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list} 338 339 ${active_channel_config}= Get Active Channel Config 340 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']} 341 342 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data} 343 ... valid_status_codes=[${valid_status_codes}] 344 345 # Note: Network restart takes around 15-18s after patch request processing 346 Sleep ${NETWORK_TIMEOUT}s 347 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} 348 349 # IPv6 address that is deleted should not be there on BMC. 350 ${delete_status}= Run Keyword And Return Status Verify IPv6 On BMC ${ipv6_addr} 351 IF '${valid_status_codes}' == '${HTTP_OK}' 352 Should Be True '${delete_status}' == '${False}' 353 ELSE 354 Should Be True '${delete_status}' == '${True}' 355 END 356 357 Validate IPv6 Network Config On BMC 358 359 360Modify IPv6 Address 361 [Documentation] Modify and verify IPv6 address of BMC. 362 [Arguments] ${ipv6} ${new_ipv6} ${prefix_len} 363 ... ${valid_status_codes}=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 364 365 # Description of argument(s): 366 # ipv6 IPv6 address to be replaced (e.g. "2001:AABB:CCDD::AAFF"). 367 # new_ipv6 New IPv6 address to be configured. 368 # prefix_len Prefix length value (Range 1 to 128). 369 # valid_status_codes Expected return code from patch operation 370 # (e.g. "200", "201"). 371 372 ${empty_dict}= Create Dictionary 373 ${patch_list}= Create List 374 ${prefix_length}= Convert To Integer ${prefix_len} 375 ${ipv6_data}= Create Dictionary 376 ... Address=${new_ipv6} PrefixLength=${prefix_length} 377 378 # Sample IPv6 network configurations: 379 # "IPv6AddressPolicyTable": [], 380 # "IPv6Addresses": [ 381 # { 382 # "Address": "X002:db8:0:2::XX0", 383 # "AddressOrigin": "DHCPv6", 384 # "PrefixLength": 128 385 # }, 386 # { 387 # "Address": “X002:db8:0:2:a94:XXff:fe82:XXXX", 388 # "AddressOrigin": "SLAAC", 389 # "PrefixLength": 64 390 # }, 391 # { 392 # "Address": “Y002:db8:0:2:a94:efff:fe82:5000", 393 # "AddressOrigin": "Static", 394 # "PrefixLength": 56 395 # }, 396 # { 397 # "Address": “Z002:db8:0:2:a94:efff:fe82:5000", 398 # "AddressOrigin": "Static", 399 # "PrefixLength": 56 400 # }, 401 # { 402 # "Address": “Xe80::a94:efff:YYYY:XXXX", 403 # "AddressOrigin": "LinkLocal", 404 # "PrefixLength": 64 405 # }, 406 # { 407 # "Address": “X002:db8:1:2:eff:233:fee:546", 408 # "AddressOrigin": "Static", 409 # "PrefixLength": 56 410 # } 411 # ], 412 # "IPv6DefaultGateway": “XXXX::ab2e:80fe:87df:XXXX”, 413 # "IPv6StaticAddresses": [ 414 # { 415 # "Address": “X002:db8:0:2:a94:efff:fe82:5000", 416 # "PrefixLength": 56 417 # }, 418 # { 419 # "Address": “Y002:db8:0:2:a94:efff:fe82:5000", 420 # "PrefixLength": 56 421 # }, 422 # { 423 # "Address": “Z002:db8:1:2:eff:233:fee:546", 424 # "PrefixLength": 56 425 # } 426 # ], 427 # "IPv6StaticDefaultGateways": [], 428 429 # Find the position of IPv6 address to be modified. 430 @{ipv6_network_configurations}= Get IPv6 Network Configuration 431 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 432 Run Keyword If '${ipv6_network_configuration['Address']}' == '${ipv6}' 433 ... Append To List ${patch_list} ${ipv6_data} 434 ... ELSE Append To List ${patch_list} ${empty_dict} 435 END 436 437 # Modify the IPv6 address only if given IPv6 is found 438 ${ip_found}= Run Keyword And Return Status List Should Contain Value 439 ... ${patch_list} ${ipv6_data} msg=${ipv6} does not exist on BMC 440 Pass Execution If ${ip_found} == ${False} ${ipv6} does not exist on BMC 441 442 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list} 443 444 ${active_channel_config}= Get Active Channel Config 445 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']} 446 447 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 448 ... body=&{data} valid_status_codes=${valid_status_codes} 449 450 # Note: Network restart takes around 15-18s after patch request processing. 451 Sleep ${NETWORK_TIMEOUT}s 452 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} 453 454 # Verify if new IPv6 address is configured on BMC. 455 Verify IPv6 On BMC ${new_ipv6} 456 457 # Verify if old IPv6 address is erased. 458 ${cmd_status}= Run Keyword And Return Status 459 ... Verify IPv6 On BMC ${ipv6} 460 Should Be Equal ${cmd_status} ${False} msg=Old IPv6 address is not deleted. 461 462 Validate IPv6 Network Config On BMC 463