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