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