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 11Library Process 12 13Test Setup Test Setup Execution 14Test Teardown Test Teardown Execution 15Suite Setup Suite Setup Execution 16 17Test Tags BMC_IPv6 18 19*** Variables *** 20${test_ipv6_addr} 2001:db8:3333:4444:5555:6666:7777:8888 21${test_ipv6_invalid_addr} 2001:db8:3333:4444:5555:6666:7777:JJKK 22${test_ipv6_addr1} 2001:db8:3333:4444:5555:6666:7777:9999 23 24# Valid prefix length is a integer ranges from 1 to 128. 25${test_prefix_length} 64 26${ipv6_gw_addr} 2002:903:15F:32:9:3:32:1 27${prefix_length_def} None 28${invalid_staticv6_gateway} 9.41.164.1 29${linklocal_addr_format} fe80::[0-9a-f:]+$ 30 31*** Test Cases *** 32 33Get IPv6 Address And Verify 34 [Documentation] Get IPv6 Address And Verify. 35 [Tags] Get_IPv6_Address_And_Verify 36 37 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 38 Verify IPv6 On BMC ${ipv6_network_configuration['Address']} 39 END 40 41 42Get PrefixLength And Verify 43 [Documentation] Get IPv6 prefix length and verify. 44 [Tags] Get_PrefixLength_And_Verify 45 46 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 47 Verify IPv6 On BMC ${ipv6_network_configuration['PrefixLength']} 48 END 49 50 51Get IPv6 Default Gateway And Verify 52 [Documentation] Get IPv6 default gateway and verify. 53 [Tags] Get_IPv6_Default_Gateway_And_Verify 54 55 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 56 ${ipv6_gateway}= Get From Dictionary ${resp.dict} IPv6DefaultGateway 57 Verify IPv6 Default Gateway On BMC ${ipv6_gateway} 58 59 60Verify All Configured IPv6 And PrefixLength On BMC 61 [Documentation] Verify IPv6 address and its prefix length on BMC. 62 [Tags] Verify_All_Configured_IPv6_And_PrefixLength_On_BMC 63 64 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 65 Verify IPv6 And PrefixLength ${ipv6_network_configuration['Address']} 66 ... ${ipv6_network_configuration['PrefixLength']} 67 END 68 69 70Configure IPv6 Address And Verify 71 [Documentation] Configure IPv6 address and verify. 72 [Tags] Configure_IPv6_Address_And_Verify 73 [Teardown] Run Keywords 74 ... Delete IPv6 Address ${test_ipv6_addr} AND Test Teardown Execution 75 [Template] Configure IPv6 Address On BMC 76 77 78 # IPv6 address Prefix length 79 ${test_ipv6_addr} ${test_prefix_length} 80 81 82Delete IPv6 Address And Verify 83 [Documentation] Delete IPv6 address and verify. 84 [Tags] Delete_IPv6_Address_And_Verify 85 86 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length} 87 88 Delete IPv6 Address ${test_ipv6_addr} 89 90 91Modify IPv6 Address And Verify 92 [Documentation] Modify IPv6 address and verify. 93 [Tags] Modify_IPv6_Address_And_Verify 94 [Teardown] Run Keywords 95 ... Delete IPv6 Address ${test_ipv6_addr1} AND Test Teardown Execution 96 97 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length} 98 99 Modify IPv6 Address ${test_ipv6_addr} ${test_ipv6_addr1} ${test_prefix_length} 100 101 102Verify Persistency Of IPv6 After BMC Reboot 103 [Documentation] Verify persistency of IPv6 after BMC reboot. 104 [Tags] Verify_Persistency_Of_IPv6_After_BMC_Reboot 105 [Teardown] Run Keywords 106 ... Delete IPv6 Address ${test_ipv6_addr} AND Test Teardown Execution 107 108 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length} 109 110 Redfish OBMC Reboot (off) stack_mode=skip 111 112 # Verifying persistency of IPv6. 113 Verify IPv6 On BMC ${test_ipv6_addr} 114 115 116Enable SLAACv6 On BMC And Verify 117 [Documentation] Enable SLAACv6 on BMC and verify. 118 [Tags] Enable_SLAACv6_On_BMC_And_Verify 119 120 Set SLAACv6 Configuration State And Verify ${True} 121 122 123Enable DHCPv6 Property On BMC And Verify 124 [Documentation] Enable DHCPv6 property on BMC and verify. 125 [Tags] Enable_DHCPv6_Property_On_BMC_And_Verify 126 127 Set And Verify DHCPv6 Property Enabled 128 129 130Disable DHCPv6 Property On BMC And Verify 131 [Documentation] Disable DHCPv6 property on BMC and verify. 132 [Tags] Disable_DHCPv6_Property_On_BMC_And_Verify 133 134 Set And Verify DHCPv6 Property Disabled 135 136 137Verify Persistency Of DHCPv6 On Reboot 138 [Documentation] Verify persistency of DHCPv6 property on reboot. 139 [Tags] Verify_Persistency_Of_DHCPv6_On_Reboot 140 141 Set And Verify DHCPv6 Property Enabled 142 Redfish OBMC Reboot (off) stack_mode=skip 143 Verify DHCPv6 Property Enabled 144 145 146Configure Invalid Static IPv6 And Verify 147 [Documentation] Configure invalid static IPv6 and verify. 148 [Tags] Configure_Invalid_Static_IPv6_And_Verify 149 [Template] Configure IPv6 Address On BMC 150 151 #invalid_ipv6 prefix length valid_status_code 152 ${ipv4_hexword_addr} ${test_prefix_length} ${HTTP_BAD_REQUEST} 153 154 155Configure IPv6 Static Default Gateway And Verify 156 [Documentation] Configure IPv6 static default gateway and verify. 157 [Tags] Configure_IPv6_Static_Default_Gateway_And_Verify 158 [Template] Configure IPv6 Static Default Gateway On BMC 159 160 # static_def_gw prefix length valid_status_code 161 ${ipv6_gw_addr} ${prefix_length_def} ${HTTP_OK} 162 ${invalid_staticv6_gateway} ${test_prefix_length} ${HTTP_BAD_REQUEST} 163 164 165Modify Static Default Gateway And Verify 166 [Documentation] Modify static default gateway and verify. 167 [Tags] Modify_Static_Default_Gateway_And_Verify 168 [Setup] Configure IPv6 Static Default Gateway On BMC ${ipv6_gw_addr} ${prefix_length_def} 169 170 Modify IPv6 Static Default Gateway On BMC ${test_ipv6_addr1} ${prefix_length_def} ${HTTP_OK} ${ipv6_gw_addr} 171 172 173Delete IPv6 Static Default Gateway And Verify 174 [Documentation] Delete IPv6 static default gateway and verify. 175 [Tags] Delete_IPv6_Static_Default_Gateway_And_Verify 176 [Setup] Configure IPv6 Static Default Gateway On BMC ${ipv6_gw_addr} ${prefix_length_def} 177 178 Delete IPv6 Static Default Gateway ${ipv6_gw_addr} 179 180 181Verify Coexistence Of Linklocalv6 And Static IPv6 On BMC 182 [Documentation] Verify linklocalv6 And static IPv6 both exist. 183 [Tags] Verify_Coexistence_Of_Linklocalv6_And_Static_IPv6_On_BMC 184 [Setup] Configure IPv6 Address On BMC ${IP_ADDR_TEST} ${test_prefix_length} 185 [Teardown] Delete IPv6 Address ${IP_ADDR_TEST} 186 187 Check Coexistence Of Linklocalv6 And Static IPv6 188 189 190Verify IPv6 Linklocal Address Is In Corrrect Format 191 [Documentation] Verify linklocal address has network part as fe80 and host part as EUI64. 192 [Tags] Verify_IPv6_Linklocal_Address_Is_In_Correct_Format 193 194 Check If Linklocal Address Is In Correct Format 195 196 197Verify BMC Gets SLAAC Address On Enabling SLAAC 198 [Documentation] On enabling SLAAC verify SLAAC address comes up. 199 [Tags] Verify_BMC_Gets_SLAAC_Address_On_Enabling_SLAAC 200 [Setup] Set SLAACv6 Configuration State And Verify ${False} 201 202 Set SLAACv6 Configuration State And Verify ${True} 203 Sleep ${NETWORK_TIMEOUT} 204 Check BMC Gets SLAACv6 Address 205 206 207Enable And Verify DHCPv6 Property On Eth1 When DHCPv6 Property Enabled On Eth0 208 [Documentation] Verify DHCPv6 on eth1 when DHCPv6 property is enabled on eth0. 209 [Tags] Enable_And_Verify_DHCPv6_Property_On_Eth1_When_DHCPv6_Property_Enabled_On_Eth0 210 [Setup] Run Keywords Get The Initial DHCPv6 Setting ${1} dhcpv6_channel_1 211 ... AND Get The Initial DHCPv6 Setting ${2} dhcpv6_channel_2 212 [Teardown] Run Keywords Set And Verify DHCPv6 Property ${dhcpv6_channel_1} ${1} 213 ... AND Set And Verify DHCPv6 Property ${dhcpv6_channel_2} ${2} 214 215 Set And Verify DHCPv6 Property Enabled ${1} 216 Set And Verify DHCPv6 Property Enabled ${2} 217 218 219*** Keywords *** 220 221Suite Setup Execution 222 [Documentation] Do suite setup execution. 223 224 ${active_channel_config}= Get Active Channel Config 225 Set Suite Variable ${active_channel_config} 226 227 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']} 228 229 Set Suite variable ${ethernet_interface} 230 231 232Test Setup Execution 233 [Documentation] Test setup execution. 234 235 Redfish.Login 236 237 @{ipv6_network_configurations}= Get IPv6 Network Configuration 238 Set Test Variable @{ipv6_network_configurations} 239 240 # Get BMC IPv6 address and prefix length. 241 ${ipv6_data}= Get BMC IPv6 Info 242 Set Test Variable ${ipv6_data} 243 244 245Test Teardown Execution 246 [Documentation] Test teardown execution. 247 248 FFDC On Test Case Fail 249 Redfish.Logout 250 251 252Get IPv6 Network Configuration 253 [Documentation] Get Ipv6 network configuration. 254 # Sample output: 255 # { 256 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0", 257 # "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface", 258 # "DHCPv4": { 259 # "DHCPEnabled": false, 260 # "UseDNSServers": false, 261 # "UseDomainName": true, 262 # "UseNTPServers": false 263 # }, 264 # "DHCPv6": { 265 # "OperatingMode": "Disabled", 266 # "UseDNSServers": false, 267 # "UseDomainName": true, 268 # "UseNTPServers": false 269 # }, 270 # "Description": "Management Network Interface", 271 # "FQDN": "localhost", 272 # "HostName": "localhost", 273 # "IPv4Addresses": [ 274 # { 275 # "Address": "xx.xx.xx.xx", 276 # "AddressOrigin": "Static", 277 # "Gateway": "xx.xx.xx.1", 278 # "SubnetMask": "xx.xx.xx.0" 279 # }, 280 # { 281 # "Address": "169.254.xx.xx", 282 # "AddressOrigin": "IPv4LinkLocal", 283 # "Gateway": "0.0.0.0", 284 # "SubnetMask": "xx.xx.0.0" 285 # }, 286 # ], 287 # "IPv4StaticAddresses": [ 288 # { 289 # "Address": "xx.xx.xx.xx", 290 # "AddressOrigin": "Static", 291 # "Gateway": "xx.xx.xx.1", 292 # "SubnetMask": "xx.xx.0.0" 293 # } 294 # } 295 # ], 296 # "IPv6AddressPolicyTable": [], 297 # "IPv6Addresses": [ 298 # { 299 # "Address": "fe80::xxxx:xxxx:xxxx:xxxx", 300 # "AddressOrigin": "LinkLocal", 301 # "AddressState": null, 302 # "PrefixLength": xx 303 # } 304 # ], 305 # "IPv6DefaultGateway": "", 306 # "IPv6StaticAddresses": [ 307 # { "Address": "xxxx:xxxx:xxxx:xxxx::xxxx", 308 # "AddressOrigin": "Static", 309 # "AddressState": null, 310 # "PrefixLength": xxx 311 # } 312 # ], 313 # "Id": "eth0", 314 # "InterfaceEnabled": true, 315 # "LinkStatus": "LinkUp", 316 # "MACAddress": "xx:xx:xx:xx:xx:xx", 317 # "Name": "Manager Ethernet Interface", 318 # "NameServers": [], 319 # "SpeedMbps": 0, 320 # "StaticNameServers": [], 321 # "Status": { 322 # "Health": "OK", 323 # "HealthRollup": "OK", 324 # "State": "Enabled" 325 # }, 326 # "VLANs": { 327 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0/VLANs" 328 329 330 ${active_channel_config}= Get Active Channel Config 331 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']} 332 333 @{ipv6_network_configurations}= Get From Dictionary ${resp.dict} IPv6StaticAddresses 334 RETURN @{ipv6_network_configurations} 335 336 337Verify IPv6 And PrefixLength 338 [Documentation] Verify IPv6 address and prefix length on BMC. 339 [Arguments] ${ipv6_addr} ${prefix_len} 340 341 # Description of the argument(s): 342 # ipv6_addr IPv6 address to be verified. 343 # prefix_len PrefixLength value to be verified. 344 345 # Catenate IPv6 address and its prefix length. 346 ${ipv6_with_prefix}= Catenate ${ipv6_addr}/${prefix_len} 347 348 # Get IPv6 address details on BMC using IP command. 349 @{ip_data}= Get BMC IPv6 Info 350 351 # Verify if IPv6 and prefix length is configured on BMC. 352 353 Should Contain ${ip_data} ${ipv6_with_prefix} 354 ... msg=IPv6 and prefix length pair does not exist. 355 356 357Configure IPv6 Address On BMC 358 [Documentation] Add IPv6 Address on BMC. 359 [Arguments] ${ipv6_addr} ${prefix_len} ${valid_status_codes}=${HTTP_OK} 360 361 # Description of argument(s): 362 # ipv6_addr IPv6 address to be added (e.g. "2001:EEEE:2222::2022"). 363 # prefix_len Prefix length for the IPv6 to be added 364 # (e.g. "64"). 365 # valid_status_codes Expected return code from patch operation 366 # (e.g. "200"). 367 368 ${prefix_length}= Convert To Integer ${prefix_len} 369 ${empty_dict}= Create Dictionary 370 ${ipv6_data}= Create Dictionary Address=${ipv6_addr} 371 ... PrefixLength=${prefix_length} 372 373 ${patch_list}= Create List 374 375 # Get existing static IPv6 configurations on BMC. 376 ${ipv6_network_configurations}= Get IPv6 Network Configuration 377 ${num_entries}= Get Length ${ipv6_network_configurations} 378 379 FOR ${INDEX} IN RANGE 0 ${num_entries} 380 Append To List ${patch_list} ${empty_dict} 381 END 382 383 ${valid_status_codes}= Set Variable If '${valid_status_codes}' == '${HTTP_OK}' 384 ... ${HTTP_OK},${HTTP_NO_CONTENT} 385 ... ${valid_status_codes} 386 387 # We need not check for existence of IPv6 on BMC while adding. 388 Append To List ${patch_list} ${ipv6_data} 389 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list} 390 391 ${active_channel_config}= Get Active Channel Config 392 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']} 393 394 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data} 395 ... valid_status_codes=[${valid_status_codes}] 396 397 Return From Keyword If '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}' 398 399 # Note: Network restart takes around 15-18s after patch request processing. 400 Sleep ${NETWORK_TIMEOUT}s 401 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} 402 403 Verify IPv6 And PrefixLength ${ipv6_addr} ${prefix_len} 404 405 # Verify if existing static IPv6 addresses still exist. 406 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 407 Verify IPv6 On BMC ${ipv6_network_configuration['Address']} 408 END 409 410 Validate IPv6 Network Config On BMC 411 412 413Validate IPv6 Network Config On BMC 414 [Documentation] Check that IPv6 network info obtained via redfish matches info 415 ... obtained via CLI. 416 @{ipv6_network_configurations}= Get IPv6 Network Configuration 417 ${ipv6_data}= Get BMC IPv6 Info 418 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 419 Should Contain Match ${ipv6_data} ${ipv6_network_configuration['Address']}/* 420 ... msg=IPv6 address does not exist. 421 END 422 423 424Delete IPv6 Address 425 [Documentation] Delete IPv6 address of BMC. 426 [Arguments] ${ipv6_addr} 427 ... ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}] 428 429 # Description of argument(s): 430 # ipv6_addr IPv6 address to be deleted (e.g. "2001:1234:1234:1234::1234"). 431 # valid_status_codes Expected return code from patch operation 432 # (e.g. "200"). See prolog of rest_request 433 # method in redfish_plus.py for details. 434 435 ${empty_dict}= Create Dictionary 436 ${patch_list}= Create List 437 438 @{ipv6_network_configurations}= Get IPv6 Network Configuration 439 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 440 IF '${ipv6_network_configuration['Address']}' == '${ipv6_addr}' 441 Append To List ${patch_list} ${null} 442 ELSE 443 Append To List ${patch_list} ${empty_dict} 444 END 445 END 446 447 ${ip_found}= Run Keyword And Return Status List Should Contain Value 448 ... ${patch_list} ${null} msg=${ipv6_addr} does not exist on BMC 449 Pass Execution If ${ip_found} == ${False} ${ipv6_addr} does not exist on BMC 450 451 # Run patch command only if given IP is found on BMC 452 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list} 453 454 ${active_channel_config}= Get Active Channel Config 455 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']} 456 457 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data} 458 ... valid_status_codes=${valid_status_codes} 459 460 # Note: Network restart takes around 15-18s after patch request processing 461 Sleep ${NETWORK_TIMEOUT}s 462 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} 463 464 # IPv6 address that is deleted should not be there on BMC. 465 ${delete_status}= Run Keyword And Return Status Verify IPv6 On BMC ${ipv6_addr} 466 IF '${valid_status_codes}' == '[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]' 467 Should Be True '${delete_status}' == '${False}' 468 ELSE 469 Should Be True '${delete_status}' == '${True}' 470 END 471 472 Validate IPv6 Network Config On BMC 473 474 475Modify IPv6 Address 476 [Documentation] Modify and verify IPv6 address of BMC. 477 [Arguments] ${ipv6} ${new_ipv6} ${prefix_len} 478 ... ${valid_status_codes}=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 479 480 # Description of argument(s): 481 # ipv6 IPv6 address to be replaced (e.g. "2001:AABB:CCDD::AAFF"). 482 # new_ipv6 New IPv6 address to be configured. 483 # prefix_len Prefix length value (Range 1 to 128). 484 # valid_status_codes Expected return code from patch operation 485 # (e.g. "200", "201"). 486 487 ${empty_dict}= Create Dictionary 488 ${patch_list}= Create List 489 ${prefix_length}= Convert To Integer ${prefix_len} 490 ${ipv6_data}= Create Dictionary 491 ... Address=${new_ipv6} PrefixLength=${prefix_length} 492 493 # Sample IPv6 network configurations: 494 # "IPv6AddressPolicyTable": [], 495 # "IPv6Addresses": [ 496 # { 497 # "Address": "X002:db8:0:2::XX0", 498 # "AddressOrigin": "DHCPv6", 499 # "PrefixLength": 128 500 # }, 501 # { 502 # "Address": “X002:db8:0:2:a94:XXff:fe82:XXXX", 503 # "AddressOrigin": "SLAAC", 504 # "PrefixLength": 64 505 # }, 506 # { 507 # "Address": “Y002:db8:0:2:a94:efff:fe82:5000", 508 # "AddressOrigin": "Static", 509 # "PrefixLength": 56 510 # }, 511 # { 512 # "Address": “Z002:db8:0:2:a94:efff:fe82:5000", 513 # "AddressOrigin": "Static", 514 # "PrefixLength": 56 515 # }, 516 # { 517 # "Address": “Xe80::a94:efff:YYYY:XXXX", 518 # "AddressOrigin": "LinkLocal", 519 # "PrefixLength": 64 520 # }, 521 # { 522 # "Address": “X002:db8:1:2:eff:233:fee:546", 523 # "AddressOrigin": "Static", 524 # "PrefixLength": 56 525 # } 526 # ], 527 # "IPv6DefaultGateway": “XXXX::ab2e:80fe:87df:XXXX”, 528 # "IPv6StaticAddresses": [ 529 # { 530 # "Address": “X002:db8:0:2:a94:efff:fe82:5000", 531 # "PrefixLength": 56 532 # }, 533 # { 534 # "Address": “Y002:db8:0:2:a94:efff:fe82:5000", 535 # "PrefixLength": 56 536 # }, 537 # { 538 # "Address": “Z002:db8:1:2:eff:233:fee:546", 539 # "PrefixLength": 56 540 # } 541 # ], 542 # "IPv6StaticDefaultGateways": [], 543 544 # Find the position of IPv6 address to be modified. 545 @{ipv6_network_configurations}= Get IPv6 Network Configuration 546 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations} 547 IF '${ipv6_network_configuration['Address']}' == '${ipv6}' 548 Append To List ${patch_list} ${ipv6_data} 549 ELSE 550 Append To List ${patch_list} ${empty_dict} 551 END 552 END 553 554 # Modify the IPv6 address only if given IPv6 is found 555 ${ip_found}= Run Keyword And Return Status List Should Contain Value 556 ... ${patch_list} ${ipv6_data} msg=${ipv6} does not exist on BMC 557 Pass Execution If ${ip_found} == ${False} ${ipv6} does not exist on BMC 558 559 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list} 560 561 ${active_channel_config}= Get Active Channel Config 562 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']} 563 564 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 565 ... body=&{data} valid_status_codes=${valid_status_codes} 566 567 # Note: Network restart takes around 15-18s after patch request processing. 568 Sleep ${NETWORK_TIMEOUT}s 569 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} 570 571 # Verify if new IPv6 address is configured on BMC. 572 Verify IPv6 On BMC ${new_ipv6} 573 574 # Verify if old IPv6 address is erased. 575 ${cmd_status}= Run Keyword And Return Status 576 ... Verify IPv6 On BMC ${ipv6} 577 Should Be Equal ${cmd_status} ${False} msg=Old IPv6 address is not deleted. 578 579 Validate IPv6 Network Config On BMC 580 581 582Set SLAACv6 Configuration State And Verify 583 [Documentation] Set SLAACv6 configuration state and verify. 584 [Arguments] ${slaac_state} ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}] 585 586 # Description of argument(s): 587 # slaac_state SLAACv6 state('True' or 'False'). 588 # valid_status_code Expected valid status codes. 589 590 ${active_channel_config}= Get Active Channel Config 591 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']} 592 593 ${data}= Set Variable If ${slaac_state} == ${False} ${DISABLE_SLAAC} ${ENABLE_SLAAC} 594 ${resp}= Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 595 ... body=${data} valid_status_codes=${valid_status_codes} 596 597 # Verify SLAACv6 is set correctly. 598 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 599 ${slaac_verify}= Get From Dictionary ${resp.dict} StatelessAddressAutoConfig 600 601 IF '${slaac_verify['IPv6AutoConfigEnabled']}' != '${slaac_state}' 602 Fail msg=SLAACv6 not set properly. 603 END 604 605Set And Verify DHCPv6 Property 606 [Documentation] Set DHCPv6 property and verify. 607 [Arguments] ${dhcpv6_operating_mode}=${Disabled} ${channel_number}=${CHANNEL_NUMBER} 608 609 # Description of argument(s): 610 # dhcpv6_operating_mode Enabled if user wants to enable DHCPv6('Enabled' or 'Disabled'). 611 # channel_number Channel number 1 or 2. 612 613 Set DHCPv6 Property ${dhcpv6_operating_mode} ${channel_number} 614 Verify DHCPv6 Property ${dhcpv6_operating_mode} ${channel_number} 615 616 617Set DHCPv6 Property 618 [Documentation] Set DHCPv6 attribute is enables or disabled. 619 [Arguments] ${dhcpv6_operating_mode}=${Disabled} ${channel_number}=${CHANNEL_NUMBER} 620 621 # Description of argument(s): 622 # dhcpv6_operating_mode Enabled if user wants to enable DHCPv6('Enabled' or 'Disabled'). 623 # channel_number Channel number 1 or 2. 624 625 ${data}= Set Variable If '${dhcpv6_operating_mode}' == 'Disabled' ${DISABLE_DHCPv6} ${ENABLE_DHCPv6} 626 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']} 627 628 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 629 ... body=${data} valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}] 630 631 632Verify DHCPv6 Property 633 [Documentation] Verify DHCPv6 settings is enabled or disabled. 634 [Arguments] ${dhcpv6_operating_mode} ${channel_number}=${CHANNEL_NUMBER} 635 636 # Description of Argument(s): 637 # dhcpv6_operating_mode Enable/ Disable DHCPv6. 638 # channel_number Channel number 1 or 2. 639 640 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']} 641 642 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 643 ${dhcpv6_verify}= Get From Dictionary ${resp.dict} DHCPv6 644 645 Should Be Equal '${dhcpv6_verify['OperatingMode']}' '${dhcpv6_operating_mode}' 646 647 648Get IPv6 Static Default Gateway 649 [Documentation] Get IPv6 static default gateway. 650 651 ${active_channel_config}= Get Active Channel Config 652 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']} 653 654 @{ipv6_static_defgw_configurations}= Get From Dictionary ${resp.dict} IPv6StaticDefaultGateways 655 RETURN @{ipv6_static_defgw_configurations} 656 657 658Configure IPv6 Static Default Gateway On BMC 659 [Documentation] Configure IPv6 static default gateway on BMC. 660 [Arguments] ${ipv6_gw_addr} ${prefix_length_def} 661 ... ${valid_status_codes}=${HTTP_OK} 662 # Description of argument(s): 663 # ipv6_gw_addr IPv6 Static Default Gateway address to be configured. 664 # prefix_len_def Prefix length value (Range 1 to 128). 665 # valid_status_codes Expected return code from patch operation 666 # (e.g. "200", "204".) 667 668 # Prefix Length is passed as None. 669 IF '${prefix_length_def}' == '${None}' 670 ${ipv6_gw}= Create Dictionary Address=${ipv6_gw_addr} 671 ELSE 672 ${ipv6_gw}= Create Dictionary Address=${ipv6_gw_addr} Prefix Length=${prefix_length_def} 673 END 674 675 ${ipv6_static_def_gw}= Get IPv6 Static Default Gateway 676 677 ${num_entries}= Get Length ${ipv6_static_def_gw} 678 679 ${patch_list}= Create List 680 ${empty_dict}= Create Dictionary 681 682 FOR ${INDEX} IN RANGE 0 ${num_entries} 683 Append To List ${patch_list} ${empty_dict} 684 END 685 686 ${valid_status_codes}= Set Variable If '${valid_status_codes}' == '${HTTP_OK}' 687 ... ${HTTP_OK},${HTTP_NO_CONTENT} 688 ... ${valid_status_codes} 689 690 Append To List ${patch_list} ${ipv6_gw} 691 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list} 692 693 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 694 ... body=${data} valid_status_codes=[${valid_status_codes}] 695 696 # Verify the added static default gateway is present in Redfish Get Output. 697 ${ipv6_staticdef_gateway}= Get IPv6 Static Default Gateway 698 699 ${ipv6_static_def_gw_list}= Create List 700 FOR ${ipv6_staticdef_gateway} IN @{ipv6_staticdef_gateway} 701 ${value}= Get From Dictionary ${ipv6_staticdef_gateway} Address 702 Append To List ${ipv6_static_def_gw_list} ${value} 703 END 704 705 IF '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}' 706 Should Not Contain ${ipv6_static_def_gw_list} ${ipv6_gw_addr} 707 ELSE 708 Should Contain ${ipv6_static_def_gw_list} ${ipv6_gw_addr} 709 END 710 711 712Modify Static Default Gateway 713 [Documentation] Modify and verify IPv6 address of BMC. 714 [Arguments] ${ipv6_gw_addr} ${new_static_def_gw} ${prefix_length} 715 ... ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED}] 716 717 # Description of argument(s): 718 # ipv6_gw_addr IPv6 static default gateway address to be replaced (e.g. "2001:AABB:CCDD::AAFF"). 719 # new_static_def_gw New static default gateway address to be configured. 720 # prefix length Prefix length value (Range 1 to 128). 721 # valid_status_codes Expected return code from patch operation 722 # (e.g. "200", "204"). 723 724 ${empty_dict}= Create Dictionary 725 ${patch_list}= Create List 726 # Prefix Length is passed as None. 727 IF '${prefix_length_def}' == '${None}' 728 ${modified_ipv6_gw_addripv6_data}= Create Dictionary Address=${new_static_def_gw} 729 ELSE 730 ${modified_ipv6_gw_addripv6_data}= Create Dictionary Address=${new_static_def_gw} Prefix Length=${prefix_length_def} 731 END 732 733 @{ipv6_static_def_gw_list}= Get IPv6 Static Default Gateway 734 735 FOR ${ipv6_static_def_gw} IN @{ipv6_static_def_gw_list} 736 IF '${ipv6_static_def_gw['Address']}' == '${ipv6_gw_addr}' 737 Append To List ${patch_list} ${modified_ipv6_gw_addripv6_data} 738 ELSE 739 Append To List ${patch_list} ${empty_dict} 740 END 741 END 742 743 # Modify the IPv6 address only if given IPv6 static default gateway is found. 744 ${ip_static_def_gw_found}= Run Keyword And Return Status List Should Contain Value 745 ... ${patch_list} ${modified_ipv6_gw_addripv6_data} msg=${ipv6_gw_addr} does not exist on BMC 746 Pass Execution If ${ip_static_def_gw_found} == ${False} ${ipv6_gw_addr} does not exist on BMC 747 748 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list} 749 750 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 751 ... body=&{data} valid_status_codes=${valid_status_codes} 752 753 ${ipv6_staticdef_gateway}= Get IPv6 Static Default Gateway 754 755 ${ipv6_static_def_gw_list}= Create List 756 FOR ${ipv6_staticdef_gateway} IN @{ipv6_staticdef_gateway} 757 ${value}= Get From Dictionary ${ipv6_staticdef_gateway} Address 758 Append To List ${ipv6_static_def_gw_list} ${value} 759 END 760 761 Should Contain ${ipv6_static_def_gw_list} ${new_static_def_gw} 762 # Verify if old static default gateway address is erased. 763 Should Not Contain ${ipv6_static_def_gw_list} ${ipv6_gw_addr} 764 765 766Delete IPv6 Static Default Gateway 767 [Documentation] Delete IPv6 static default gateway on BMC. 768 [Arguments] ${ipv6_gw_addr} 769 ... ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}] 770 771 # Description of argument(s): 772 # ipv6_gw_addr IPv6 Static Default Gateway address to be deleted. 773 # valid_status_codes Expected return code from patch operation 774 # (e.g. "200"). 775 776 ${patch_list}= Create List 777 ${empty_dict}= Create Dictionary 778 779 ${ipv6_static_def_gw_list}= Create List 780 @{ipv6_static_defgw_configurations}= Get IPv6 Static Default Gateway 781 782 FOR ${ipv6_staticdef_gateway} IN @{ipv6_static_defgw_configurations} 783 ${value}= Get From Dictionary ${ipv6_staticdef_gateway} Address 784 Append To List ${ipv6_static_def_gw_list} ${value} 785 END 786 787 ${defgw_found}= Run Keyword And Return Status List Should Contain Value 788 ... ${ipv6_static_def_gw_list} ${ipv6_gw_addr} msg=${ipv6_gw_addr} does not exist on BMC 789 Skip If ${defgw_found} == ${False} ${ipv6_gw_addr} does not exist on BMC 790 791 FOR ${ipv6_static_def_gw} IN @{ipv6_static_defgw_configurations} 792 IF '${ipv6_static_def_gw['Address']}' == '${ipv6_gw_addr}' 793 Append To List ${patch_list} ${null} 794 ELSE 795 Append To List ${patch_list} ${empty_dict} 796 END 797 END 798 799 # Run patch command only if given IP is found on BMC. 800 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list} 801 802 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data} 803 ... valid_status_codes=${valid_status_codes} 804 805 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list} 806 807 @{ipv6_static_defgw_configurations}= Get IPv6 Static Default Gateway 808 Should Not Contain Match ${ipv6_static_defgw_configurations} ${ipv6_gw_addr} 809 ... msg=IPv6 Static default gateway does not exist. 810 811 812Check Coexistence Of Linklocalv6 And Static IPv6 813 [Documentation] Verify both linklocalv6 and static IPv6 exist. 814 815 # Verify the address origin contains static and linklocal. 816 @{ipv6_addressorigin_list} ${ipv6_linklocal_addr}= Get Address Origin List And Address For Type LinkLocal 817 818 Should Not Be Empty ${ipv6_linklocal_addr} msg=LinkLocal address is not present. 819 Should Match Regexp ${ipv6_linklocal_addr} ${linklocal_addr_format} 820 Should Contain ${ipv6_addressorigin_list} LinkLocal 821 Should Contain ${ipv6_addressorigin_list} Static 822 823 824Check If Linklocal Address Is In Correct Format 825 [Documentation] Linklocal address has network part fe80 and host part EUI64. 826 827 # Fetch the linklocal address. 828 @{ipv6_addressorigin_list} ${ipv6_linklocal_addr}= Get Address Origin List And Address For Type LinkLocal 829 Should Contain ${ipv6_addressorigin_list} LinkLocal 830 Should Not Be Empty ${ipv6_linklocal_addr} msg=LinkLocal address is not present. 831 832 # Follow EUI64 from MAC. 833 ${system_mac}= Get BMC MAC Address 834 ${split_octets}= Split String ${system_mac} : 835 ${first_octet}= Evaluate int('${split_octets[0]}', 16) 836 ${flipped_hex}= Evaluate format(${first_octet} ^ 2, '02x') 837 ${grp1}= Evaluate re.sub(r'^0+', '', '${flipped_hex}${split_octets[1]}') modules=re 838 ${grp2}= Evaluate re.sub(r'^0+', '', '${split_octets[2]}ff') modules=re 839 ${grp3}= Evaluate re.sub(r'^0+', '', '${split_octets[4]}${split_octets[5]}') modules=re 840 ${linklocal}= Set Variable fe80::${grp1}:${grp2}:fe${split_octets[3]}:${grp3} 841 842 # Verify the linklocal obtained is the same as on the machine. 843 Should Be Equal ${linklocal} ${ipv6_linklocal_addr} 844 845 846Check BMC Gets SLAACv6 Address 847 [Documentation] Check BMC gets slaacv6 address. 848 849 @{ipv6_addressorigin_list} ${ipv6_slaac_addr}= Get Address Origin List And Address For Type SLAAC 850 851 Should Contain ${ipv6_addressorigin_list} SLAAC 852 Should Not Be Empty ${ipv6_slaac_addr} msg=SLAACv6 address is not present. 853 854 855Get The Initial DHCPv6 Setting 856 [Documentation] Get the initial DHCPv6 setting and store in a variable. 857 [Arguments] ${channel_number} ${initial_dhcpv6_before} 858 859 # Description of the argument(s): 860 # channel_number Channel number 1 or 2. 861 # initial_dhcpv6_before Variable to store initial DHCPv6 setting. 862 863 ${ethernet_interface}= Set Variable ${active_channel_config['${channel_number}']['name']} 864 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 865 ${initial_dhcpv6_iface}= Get From Dictionary ${resp.dict} DHCPv6 866 Set Test Variable ${${initial_dhcpv6_before}} ${initial_dhcpv6_iface['OperatingMode']} 867 868 869Get Address Origin List And Address For Type 870 [Documentation] Get address origin list and address for type. 871 [Arguments] ${ipv6_address_type} 872 873 # Description of the argument(s): 874 # ipv6_address_type Type of IPv6 address to be checked. 875 876 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']} 877 @{ipv6_addresses}= Get From Dictionary ${resp.dict} IPv6Addresses 878 879 ${ipv6_addressorigin_list}= Create List 880 ${ipv6_slaac_addr}= Set Variable ${None} 881 FOR ${ipv6_address} IN @{ipv6_addresses} 882 ${ipv6_addressorigin}= Get From Dictionary ${ipv6_address} AddressOrigin 883 Append To List ${ipv6_addressorigin_list} ${ipv6_addressorigin} 884 IF '${ipv6_addressorigin}' == '${ipv6_address_type}' 885 Set Test Variable ${ipv6_type_addr} ${ipv6_address['Address']} 886 END 887 END 888 RETURN @{ipv6_addressorigin_list} ${ipv6_type_addr} 889