1*** Settings *** 2 3Documentation VMI static/dynamic IP config tests. 4 5Resource ../../lib/resource.robot 6Resource ../../lib/bmc_redfish_resource.robot 7Resource ../../lib/openbmc_ffdc.robot 8Resource ../../lib/bmc_redfish_utils.robot 9Resource ../../lib/state_manager.robot 10Library ../../lib/bmc_network_utils.py 11 12Suite Setup Suite Setup Execution 13Test Teardown FFDC On Test Case Fail 14Suite Teardown Redfish.Logout 15 16*** Variables *** 17 18# users User Name password 19@{ADMIN} admin_user TestPwd123 20@{OPERATOR} operator_user TestPwd123 21@{ReadOnly} readonly_user TestPwd123 22@{NoAccess} noaccess_user TestPwd123 23&{USERS} Administrator=${ADMIN} Operator=${OPERATOR} ReadOnly=${ReadOnly} 24... NoAccess=${NoAccess} 25 26${test_ipv4} 10.6.6.6 27${test_gateway} 10.6.6.1 28${test_netmask} 255.255.252.0 29 30&{DHCP_ENABLED} DHCPEnabled=${${True}} 31&{DHCP_DISABLED} DHCPEnabled=${${False}} 32 33&{ENABLE_DHCP} DHCPv4=&{DHCP_ENABLED} 34&{DISABLE_DHCP} DHCPv4=&{DHCP_DISABLED} 35${wait_time} 10s 36 37 38*** Test Cases *** 39 40Verify All VMI EthernetInterfaces 41 [Documentation] Verify all VMI ethernet interfaces. 42 [Tags] Verify_All_VMI_EthernetINterfaces 43 44 Verify VMI EthernetInterfaces 45 46 47Verify Existing VMI Network Interface Details 48 [Documentation] Verify existing VMI network interface details. 49 [Tags] Verify_VMI_Network_Interface_Details 50 51 ${vmi_ip}= Get VMI Network Interface Details 52 ${origin}= Set Variable If ${vmi_ip["DHCPv4"]} == ${False} Static DHCP 53 54 Should Not Be Equal ${vmi_ip["DHCPv4"]} ${vmi_ip["IPv4StaticAddresses"]} 55 Should Be Equal As Strings ${origin} ${vmi_ip["IPv4_AddressOrigin"]} 56 Should Be Equal As Strings ${vmi_ip["Id"]} intf0 57 Should Be Equal As Strings ${vmi_ip["Description"]} 58 ... Ethernet Interface for Virtual Management Interface 59 Should Be Equal As Strings ${vmi_ip["Name"]} Virtual Management Interface 60 Should Be True ${vmi_ip["InterfaceEnabled"]} 61 62 63Delete Existing Static VMI IP Address 64 [Documentation] Delete existing static VMI IP address. 65 [Tags] Delete_Existing_Static_VMI_IP_Address 66 67 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled 68 Run Keyword If ${curr_origin} == ${True} Set VMI IPv4 Origin ${False} ${HTTP_ACCEPTED} 69 70 Delete VMI IPv4 Address IPv4StaticAddresses valid_status_code=${HTTP_ACCEPTED} 71 ${default}= Set Variable 0.0.0.0 72 Verify VMI Network Interface Details ${default} Static ${default} ${default} 73 74 75Verify User Cannot Delete ReadOnly Property IPv4Addresses 76 [Documentation] Verify user cannot delete readonly property IPv4Addresses. 77 [Tags] Verify_User_Cannot_Delete_ReadOnly_Property_IPv4Addresses 78 79 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled 80 Run Keyword If ${curr_origin} == ${False} Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED} 81 Delete VMI IPv4 Address IPv4Addresses valid_status_code=${HTTP_BAD_REQUEST} 82 83 84Assign Valid And Invalid Static IPv4 Address To VMI 85 [Documentation] Assign static IPv4 address to VMI. 86 [Tags] Assign_Valid_And_Invalid_Static_IPv4_Address_To_VMI 87 [Template] Set Static IPv4 Address To VMI And Verify 88 [Teardown] Run keywords Delete VMI IPv4 Address AND Test Teardown Execution 89 90 # ip gateway netmask valid_status_code 91 10.5.20.30 0.0.0.0 255.255.252.0 ${HTTP_ACCEPTED} 92 a.3.118.94 0.0.0.0 255.255.252.0 ${HTTP_BAD_REQUEST} 93 94 95Add Multiple IP Addreses On VMI Interface And Verify 96 [Documentation] Add multiple IP addreses on VMI interface and verify. 97 [Tags] Add_Multiple_IP_Addreses_On_VMI_Interface_And_Verify 98 [Teardown] Run keywords Delete VMI IPv4 Address AND Test Teardown Execution 99 100 ${ip1}= Create dictionary Address=10.5.5.10 SubnetMask=255.255.252.0 Gateway=0.0.0.0 101 ${ip2}= Create dictionary Address=10.5.5.11 SubnetMask=255.255.252.0 Gateway=0.0.0.0 102 ${ip3}= Create dictionary Address=10.5.5.12 SubnetMask=255.255.252.0 Gateway=0.0.0.0 103 ${ips}= Create List ${ip1} ${ip2} ${ip3} 104 105 Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 106 ... body={'IPv4StaticAddresses':${ips}} valid_status_codes=[${HTTP_ACCEPTED}] 107 Verify VMI Network Interface Details ${ip1["Address"]} Static ${ip1["Gateway"]} ${ip1["SubnetMask"]} 108 109 110Modify IP Addresses On VMI Interface And Verify 111 [Documentation] Modify IP addresses on VMI interface and verify. 112 [Tags] Modify_IP_Addresses_On_VMI_Interface_And_Verify 113 [Template] Set Static IPv4 Address To VMI And Verify 114 [Teardown] Run keywords Delete VMI IPv4 Address AND Test Teardown Execution 115 116 # ip gateway netmask valid_status_code 117 10.5.5.10 0.0.0.0 255.255.252.0 ${HTTP_ACCEPTED} 118 10.5.5.11 0.0.0.0 255.255.252.0 ${HTTP_ACCEPTED} 119 120Switch Between IP Origins On VMI And Verify Details 121 [Documentation] Switch between IP origins on VMI and verify details. 122 [Tags] Switch_Between_IP_Origins_On_VMI_And_Verify_Details 123 124 Switch VMI IPv4 Origin And Verify Details 125 Switch VMI IPv4 Origin And Verify Details 126 127 128Verify Persistency Of VMI IPv4 Details After Host Reboot 129 [Documentation] Verify persistency of VMI IPv4 details after host reboot. 130 [Tags] Verify_Persistency_Of_VMI_IPv4_Details_After_Host_Reboot 131 132 # Verifying persistency of dynamic address. 133 Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED} 134 ${default}= Set Variable 0.0.0.0 135 Verify VMI Network Interface Details ${default} DHCP ${default} ${default} 136 137 # Verifying persistency of static address. 138 Switch VMI IPv4 Origin And Verify Details 139 Set Static IPv4 Address To VMI And Verify ${test_ipv4} ${test_gateway} ${test_netmask} 140 141 142Delete VMI Static IP Address And Verify 143 [Documentation] Delete VMI static IP address and verify. 144 [Tags] Delete_VMI_Static_IP_Address_And_Verify 145 [Teardown] Test Teardown Execution 146 147 Set Static IPv4 Address To VMI And Verify ${test_ipv4} ${test_gateway} ${test_netmask} 148 Delete VMI IPv4 Address 149 ${resp}= Redfish.Get 150 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 151 Should Be Empty ${resp.dict["IPv4Addresses"]} 152 153 154Verify Successful VMI IP Static Configuration On HOST Boot After Session Delete 155 [Documentation] Verify VMI IP static Configuration On HOST Boot After session deleted. 156 [Tags] Verify_Successful_VMI_IP_Static_Configuration_On_HOST_Boot_After_Session_Delete 157 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses AND Test Teardown Execution 158 159 Set Static IPv4 Address To VMI And Verify ${test_ipv4} ${test_gateway} ${test_netmask} 160 161 ${session_info}= Get Redfish Session Info 162 Redfish.Delete ${session_info["location"]} 163 164 # Create a new Redfish session 165 Redfish Power Off 166 Redfish Power On 167 168 Verify VMI Network Interface Details ${test_ipv4} Static ${test_gateway} ${test_netmask} 169 170 171Verify Persistency Of VMI DHCP IP Configuration After Multiple HOST Reboots 172 [Documentation] Verify Persistency Of VMI DHCP IP configuration After Multiple HOST Reboots 173 [Tags] Verify_Persistency_Of_VMI_DHCP_IP_Configuration_After_Multiple_HOST_Reboots 174 [Teardown] Test Teardown Execution 175 176 Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED} 177 ${vmi_ip_config}= Get VMI Network Interface Details 178 # Verifying persistency of dynamic address after multiple reboots. 179 FOR ${i} IN RANGE ${2} 180 Redfish Power Off 181 Redfish Power On 182 Verify VMI Network Interface Details ${vmi_ip_config["IPv4_Address"]} DHCP ${vmi_ip_config["IPv4_Gateway"]} 183 ... ${vmi_ip_config["IPv4_SubnetMask"]} 184 END 185 186 187Enable DHCP When Static IP Configured And Verify Static IP 188 [Documentation] Enable DHCP when static ip configured and verify static ip 189 [Tags] Enable_DHCP_when_Static_IP_Configured_And_Verify_Static_IP 190 [Teardown] Test Teardown Execution 191 192 Set Static IPv4 Address To VMI And Verify ${test_ipv4} ${test_gateway} ${test_netmask} 193 Set VMI IPv4 Origin ${True} 194 ${vmi_network_conf}= Get VMI Network Interface Details 195 Should Not Be Equal As Strings ${test_ipv4} ${vmi_network_conf["IPv4_Address"]} 196 197 198Verify VMI Static IP Configuration Persist On BMC Reset Before Host Boot 199 [Documentation] Verify VMI static IP configuration persist on BMC reset. 200 [Tags] Verify_VMI_Static_IP_Configuration_Persist_On_BMC_Reset_Before_Host_Boot 201 [Teardown] Run keywords Delete VMI IPv4 Address AND FFDC On Test Case Fail 202 203 Set Static IPv4 Address To VMI And Verify ${test_ipv4} ${test_gateway} ${test_netmask} 204 OBMC Reboot (off) 205 Redfish Power On 206 # Verifying the VMI static configuration 207 Verify VMI Network Interface Details ${test_ipv4} Static ${test_gateway} ${test_netmask} 208 209Add Static IP When Host Poweroff And Verify On Poweron 210 [Documentation] Add Static IP When Host Poweroff And Verify on power on 211 [Tags] Add_Static_IP_When_Host_Poweroff_And_Verify_On_Poweron 212 [Setup] Redfish Power Off 213 [Teardown] Run keywords Delete VMI IPv4 Address AND FFDC On Test Case Fail 214 215 Set Static IPv4 Address To VMI And Verify ${test_ipv4} ${test_gateway} ${test_netmask} 216 Redfish Power On 217 Verify VMI Network Interface Details ${test_ipv4} Static ${test_gateway} ${test_netmask} 218 219Add VMI Static IP When Host Poweroff And Verify Static IP On BMC Reset 220 [Documentation] Add Static IP When Host Poweroff And Verify Static IP On BMC Reset. 221 [Tags] Add_VMI_Static_IP_When_Host_Poweroff_And_Verify_Static_IP_On_BMC_Reset 222 [Setup] Redfish Power Off 223 [Teardown] Run keywords Delete VMI IPv4 Address AND FFDC On Test Case Fail 224 225 Set Static IPv4 Address To VMI And Verify ${test_ipv4} ${test_gateway} ${test_netmask} 226 OBMC Reboot (off) 227 Redfish Power On 228 Verify VMI Network Interface Details ${test_ipv4} Static ${test_gateway} ${test_netmask} 229 230Enable DHCP When No Static IP Configured And Verify DHCP IP 231 [Documentation] Enable DHCP when no static ip configured and verify dhcp ip 232 [Tags] Enable_DHCP_When_No_Static_IP_Configured_And_Verify_DHCP_IP 233 [Setup] Run Keyword And Ignore Error Delete VMI IPv4 Address 234 [Teardown] Test Teardown Execution 235 236 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled 237 Run Keyword If ${curr_origin} == ${False} Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED} 238 ${vmi_ip_config}= Get VMI Network Interface Details 239 Verify VMI Network Interface Details ${vmi_ip_config["IPv4_Address"]} DHCP ${vmi_ip_config["IPv4_Gateway"]} 240 ... ${vmi_ip_config["IPv4_SubnetMask"]} 241 242Verify User Cannot Delete VMI DHCP IP Address 243 [Documentation] Verify user cannot delete VMI DHCP IP Address 244 [Tags] Verify_User_Cannot_Delete_VMI_DHCP_IP_Address 245 [Setup] Set VMI IPv4 Origin ${True} 246 [Teardown] Test Teardown Execution 247 248 Delete VMI IPv4 Address IPv4Addresses valid_status_code=${HTTP_BAD_REQUEST} 249 ${active_channel_config}= Get Active Channel Config 250 ${resp}= Redfish.Get 251 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 252 Should Not Be Empty ${resp.dict["IPv4Addresses"]} 253 254Enable DHCP When Static IP Configured DHCP Server Unavailable And Verify IP 255 [Documentation] Enable DHCP When Static IP Configured And DHCP Server Unavailable And Verify No IP. 256 [Tags] Enable_DHCP_When_Static_IP_Configured_DHCP_Server_Unavailable_And_Verify_IP 257 [Teardown] Test Teardown Execution 258 259 Set Static IPv4 Address To VMI And Verify ${test_ipv4} ${test_gateway} ${test_netmask} 260 Set VMI IPv4 Origin ${True} 261 ${default}= Set Variable 0.0.0.0 262 Verify VMI Network Interface Details ${default} DHCP ${default} ${default} 263 264 265Verify To Configure VMI Static IP Address With Different User Roles 266 [Documentation] Verify to configure vmi static ip address with different user roles. 267 [Tags] Verify_To_Configure_VMI_Static_IP_Address_With_Different_User_Roles 268 [Setup] Create Users With Different Roles users=${USERS} force=${True} 269 [Template] Config VMI Static IP Address Using Different Users 270 [Teardown] Delete BMC Users Using Redfish 271 272 # username password ip_address gateway nemask valid_status_code 273 admin_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_ACCEPTED} 274 operator_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_FORBIDDEN} 275 readonly_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_FORBIDDEN} 276 noaccess_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_FORBIDDEN} 277 278 279Verify To Delete VMI Static IP Address With Different User Roles 280 [Documentation] Verify to delete vmi static IP address with different user roles. 281 [Tags] Verify_To_Delete_VMI_Static_IP_Address_With_Different_User_Roles 282 [Setup] Create Users With Different Roles users=${USERS} force=${True} 283 [Template] Delete VMI Static IP Address Using Different Users 284 [Teardown] Delete BMC Users Using Redfish 285 286 # username password valid_status_code 287 admin_user TestPwd123 ${HTTP_ACCEPTED} 288 operator_user TestPwd123 ${HTTP_FORBIDDEN} 289 readonly_user TestPwd123 ${HTTP_FORBIDDEN} 290 noaccess_user TestPwd123 ${HTTP_FORBIDDEN} 291 292 293Verify To Update VMI Static IP Address With Different User Roles 294 [Documentation] Verify to update vmi static IP address with different user roles. 295 [Tags] Verify_To_Update_VMI_Static_IP_Address_With_Different_User_Roles_And_Verify 296 [Setup] Create Users With Different Roles users=${USERS} force=${True} 297 [Template] Config VMI Static IP Address Using Different Users 298 [Teardown] Delete BMC Users Using Redfish 299 300 # username password ip_address gateway nemask valid_status_code 301 admin_user TestPwd123 10.5.10.20 0.0.0.0 255.255.0.0 ${HTTP_ACCEPTED} 302 operator_user TestPwd123 10.5.10.30 0.0.0.0 255.255.0.0 ${HTTP_FORBIDDEN} 303 readonly_user TestPwd123 10.5.20.40 0.0.0.0 255.255.0.0 ${HTTP_FORBIDDEN} 304 noaccess_user TestPwd123 10.5.30.50 0.0.0.0 255.255.0.0 ${HTTP_FORBIDDEN} 305 306 307Verify To Read VMI Network Configuration With Different User Roles 308 [Documentation] Verify to read vmi network configuration with different user roles. 309 [Tags] Verify_To_Read_VMI_Network_Configuration_Via_Different_User_Roles 310 [Setup] Create Users With Different Roles users=${USERS} force=${True} 311 [Template] Read VMI Static IP Address Using Different Users 312 [Teardown] Delete BMC Users Using Redfish 313 314 # username password valid_status_code 315 admin_user TestPwd123 ${HTTP_OK} 316 operator_user TestPwd123 ${HTTP_OK} 317 readonly_user TestPwd123 ${HTTP_OK} 318 noaccess_user TestPwd123 ${HTTP_FORBIDDEN} 319 320Enable DHCP On VMI Network Via Different Users Roles And Verify 321 [Documentation] Enable DHCP On VMI Network Via Different Users Roles And Verify. 322 [Tags] Enable_DHCP_On_VMI_Network_Via_Different_Users_Roles_And_Verify 323 [Setup] Create Users With Different Roles users=${USERS} force=${True} 324 [Template] Update User Role And Set VMI IPv4 Origin 325 [Teardown] Delete BMC Users Using Redfish 326 327 # username password dhcp_enabled valid_status_code 328 admin_user TestPwd123 ${True} ${HTTP_ACCEPTED} 329 operator_user TestPwd123 ${True} ${HTTP_FORBIDDEN} 330 readonly_user TestPwd123 ${True} ${HTTP_FORBIDDEN} 331 noaccess_user TestPwd123 ${True} ${HTTP_FORBIDDEN} 332 333Disable DHCP On VMI Network Via Different Users Roles And Verify 334 [Documentation] Disable DHCP On VMI Network Via Different Users Roles And Verify. 335 [Tags] Disable_DHCP_On_VMI_Network_Via_Different_Users_Roles_And_Verify 336 [Setup] Create Users With Different Roles users=${USERS} force=${True} 337 [Template] Update User Role And Set VMI IPv4 Origin 338 [Teardown] Delete BMC Users Using Redfish 339 340 # username password dhcp_enabled valid_status_code 341 admin_user TestPwd123 ${False} ${HTTP_ACCEPTED} 342 operator_user TestPwd123 ${False} ${HTTP_FORBIDDEN} 343 readonly_user TestPwd123 ${False} ${HTTP_FORBIDDEN} 344 noaccess_user TestPwd123 ${False} ${HTTP_FORBIDDEN} 345 346 347Enable And Disable DHCP And Verify 348 [Documentation] verify enable DHCP and disable DHCP. 349 [Tags] Enabled_And_Disabled_DHCP_Verify 350 351 Set VMI IPv4 Origin ${True} 352 ${default}= Set Variable 0.0.0.0 353 Verify VMI Network Interface Details ${default} DHCP ${default} ${default} 354 Set VMI IPv4 Origin ${False} 355 ${resp}= Redfish.Get 356 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 357 Should Be Empty ${resp.dict["IPv4Addresses"]} 358 359 360Multiple Times Enable And Disable DHCP And Verify 361 [Documentation] Enable and Disable DHCP in a loop and verify VMI gets an IP address from DHCP 362 ... each time when DHCP is enabled 363 [Tags] Multiple_Times_Enable_And_Disable_DHCP_And_Verify 364 365 ${default}= Set Variable 0.0.0.0 366 FOR ${i} IN RANGE ${2} 367 Set VMI IPv4 Origin ${True} 368 Verify VMI Network Interface Details ${default} DHCP ${default} ${default} 369 Set VMI IPv4 Origin ${False} 370 ${resp}= Redfish.Get 371 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 372 Should Be Empty ${resp.dict["IPv4Addresses"]} 373 END 374 375 376*** Keywords *** 377 378Suite Setup Execution 379 [Documentation] Do test setup execution task. 380 381 Redfish.Login 382 Redfish Power On 383 ${active_channel_config}= Get Active Channel Config 384 Set Suite Variable ${active_channel_config} 385 ${resp}= Redfish.Get 386 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 387 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json 388 ${length}= Get Length ${ip_resp["IPv4StaticAddresses"]} 389 ${vmi_network_conf}= Run Keyword If ${length} != ${0} Get VMI Network Interface Details 390 Set Suite Variable ${vmi_network_conf} 391 392 393Test Teardown Execution 394 [Documentation] Do test teardown execution task. 395 396 FFDC On Test Case Fail 397 ${curr_mode}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled 398 Run Keyword If ${curr_mode} == ${True} Set VMI IPv4 Origin ${False} 399 Run Keyword If ${vmi_network_conf} != ${None} 400 ... Set Static IPv4 Address To VMI And Verify ${vmi_network_conf["IPv4_Address"]} 401 ... ${vmi_network_conf["IPv4_Gateway"]} ${vmi_network_conf["IPv4_SubnetMask"]} 402 403 404Get VMI Network Interface Details 405 [Documentation] Get VMI network interface details. 406 [Arguments] ${valid_status_code}=${HTTP_OK} 407 408 # Description of argument(s): 409 # valid_status_code Expected valid status code from GET request. 410 411 # Note: It returns a dictionary of VMI eth0 parameters. 412 413 ${active_channel_config}= Get Active Channel Config 414 ${resp}= Redfish.Get 415 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 416 ... valid_status_codes=[${valid_status_code}] 417 418 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json 419 420 ${static_exists}= Run Keyword And Ignore Error 421 ... Set Variable ${ip_resp["IPv4StaticAddresses"][0]["Address"]} 422 ${static_exists}= Set Variable If '${static_exists[0]}' == 'PASS' ${True} ${False} 423 424 ${vmi_ip}= Create Dictionary DHCPv4=${${ip_resp["DHCPv4"]["DHCPEnabled"]}} Id=${ip_resp["Id"]} 425 ... Description=${ip_resp["Description"]} IPv4_Address=${ip_resp["IPv4Addresses"][0]["Address"]} 426 ... IPv4_AddressOrigin=${ip_resp["IPv4Addresses"][0]["AddressOrigin"]} Name=${ip_resp["Name"]} 427 ... IPv4_Gateway=${ip_resp["IPv4Addresses"][0]["Gateway"]} 428 ... InterfaceEnabled=${${ip_resp["InterfaceEnabled"]}} 429 ... IPv4_SubnetMask=${ip_resp["IPv4Addresses"][0]["SubnetMask"]} 430 ... IPv4StaticAddresses=${${static_exists}} 431 432 [Return] &{vmi_ip} 433 434 435Get Immediate Child Parameter From VMI Network Interface 436 [Documentation] Get immediate child parameter from VMI network interface. 437 [Arguments] ${parameter} ${valid_status_code}=${HTTP_OK} 438 439 # Description of argument(s): 440 # parameter parameter for which value is required. Ex: DHCPEnabled, MACAddress etc. 441 # valid_status_code Expected valid status code from GET request. 442 443 ${active_channel_config}= Get Active Channel Config 444 ${resp}= Redfish.Get 445 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 446 ... valid_status_codes=[${valid_status_code}] 447 448 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json 449 ${value}= Set Variable If '${parameter}' != 'DHCPEnabled' ${ip_resp["${parameter}"]} 450 ... ${ip_resp["DHCPv4"]["${parameter}"]} 451 452 [Return] ${value} 453 454 455Verify VMI EthernetInterfaces 456 [Documentation] Verify VMI ethernet interfaces. 457 [Arguments] ${valid_status_code}=${HTTP_OK} 458 459 # Description of argument(s): 460 # valid_status_code Expected valid status code from GET request. 461 462 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces 463 ... valid_status_codes=[${valid_status_code}] 464 465 ${resp}= Evaluate json.loads('''${resp.text}''') json 466 ${interfaces}= Set Variable ${resp["Members"]} 467 468 Should Be Equal As Strings ${interfaces[0]}[@odata.id] 469 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0 470 Should Be Equal As Strings ${interfaces[1]}[@odata.id] 471 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth1 472 473 Should Be Equal ${resp["Members@odata.count"]} ${2} 474 475 476Verify VMI Network Interface Details 477 [Documentation] Verify VMI network interface details. 478 [Arguments] ${ip} ${origin} ${gateway} ${netmask} 479 ... ${valid_status_code}=${HTTP_OK} 480 481 # Description of argument(s): 482 # ip VMI IPv4 address. 483 # origin Origin of IPv4 address eg. Static or DHCP. 484 # gateway Gateway for VMI IP. 485 # netmask Subnetmask for VMI IP. 486 # valid_status_code Expected valid status code from GET request. Default is HTTP_OK. 487 488 ${vmi_ip}= Get VMI Network Interface Details ${valid_status_code} 489 Should Be Equal As Strings ${origin} ${vmi_ip["IPv4_AddressOrigin"]} 490 Should Be Equal As Strings ${gateway} ${vmi_ip["IPv4_Gateway"]} 491 Should Be Equal As Strings ${netmask} ${vmi_ip["IPv4_SubnetMask"]} 492 Should Be Equal As Strings ${ip} ${vmi_ip["IPv4_Address"]} 493 494 495Set Static IPv4 Address To VMI And Verify 496 [Documentation] Set static IPv4 address to VMI. 497 [Arguments] ${ip} ${gateway} ${netmask} ${valid_status_code}=${HTTP_ACCEPTED} 498 499 # Description of argument(s): 500 # ip VMI IPv4 address. 501 # gateway Gateway for VMI IP. 502 # netmask Subnetmask for VMI IP. 503 # valid_status_code Expected valid status code from GET request. Default is HTTP_ACCEPTED. 504 505 ${data}= Set Variable 506 ... {"IPv4StaticAddresses": [{"Address": "${ip}","SubnetMask": "${netmask}","Gateway": "${gateway}"}]} 507 508 ${active_channel_config}= Get Active Channel Config 509 ${resp}= Redfish.Patch 510 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 511 ... body=${data} valid_status_codes=[${valid_status_code}] 512 513 # Wait few seconds for new configuration to get populated on runtime. 514 Sleep ${wait_time} 515 516 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED} 517 ${host_power_state} ${host_state}= Redfish Get Host State 518 Run Keyword If '${host_power_state}' == 'On' and '${host_state}' == 'Enabled' 519 ... Verify VMI Network Interface Details ${ip} Static ${gateway} ${netmask} 520 521 522Delete VMI IPv4 Address 523 [Documentation] Delete VMI IPv4 address. 524 [Arguments] ${delete_param}=IPv4StaticAddresses ${valid_status_code}=${HTTP_ACCEPTED} 525 526 # Description of argument(s): 527 # delete_param Parameter to be deleted eg. IPv4StaticAddresses or IPv4Addresses. 528 # Default is IPv4StaticAddresses. 529 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK. 530 531 ${data}= Set Variable {"${delete_param}": [${Null}]} 532 ${active_channel_config}= Get Active Channel Config 533 ${resp}= Redfish.Patch 534 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 535 ... body=${data} valid_status_codes=[${valid_status_code}] 536 537 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED} 538 ${resp}= Redfish.Get 539 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 540 Should Be Empty ${resp.dict["IPv4StaticAddresses"]} 541 542 543Set VMI IPv4 Origin 544 [Documentation] Set VMI IPv4 origin. 545 [Arguments] ${dhcp_enabled}=${False} ${valid_status_code}=${HTTP_ACCEPTED} 546 547 # Description of argument(s): 548 # dhcp_enabled True if user wants to enable DHCP. Default is Static, hence value is set to False. 549 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK. 550 551 ${data}= Set Variable If ${dhcp_enabled} == ${False} ${DISABLE_DHCP} ${ENABLE_DHCP} 552 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0 body=${data} 553 ... valid_status_codes=[${valid_status_code}] 554 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED} 555 ${resp}= Redfish.Get 556 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 557 Should Be Equal ${resp.dict["DHCPv4"]["DHCPEnabled"]} ${dhcp_enabled} 558 559 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED} 560 ${resp}= Redfish.Get 561 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 562 Should Be Equal ${resp.dict["DHCPv4"]["DHCPEnabled"]} ${dhcp_enabled} 563 564 565Switch VMI IPv4 Origin And Verify Details 566 [Documentation] Switch VMI IPv4 origin and verify details. 567 568 ${curr_mode}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled 569 ${dhcp_enabled}= Set Variable If ${curr_mode} == ${False} ${True} ${False} 570 571 ${default}= Set Variable 0.0.0.0 572 ${origin}= Set Variable If ${curr_mode} == ${False} DHCP Static 573 Set VMI IPv4 Origin ${dhcp_enabled} ${HTTP_ACCEPTED} 574 Verify VMI Network Interface Details ${default} ${origin} ${default} ${default} 575 576 577Delete VMI Static IP Address Using Different Users 578 [Documentation] Update user role and delete vmi static IP address. 579 [Arguments] ${username} ${password} ${valid_status_code} 580 [Teardown] Run Keywords Redfish.Login AND 581 ... Set Static IPv4 Address To VMI And Verify ${test_ipv4} ${test_gateway} 582 ... ${test_netmask} ${HTTP_ACCEPTED} AND Redfish.Logout 583 584 # Description of argument(s): 585 # username The host username. 586 # password The host password. 587 # valid_status_code The expected valid status code. 588 589 Redfish.Login ${username} ${password} 590 Delete VMI IPv4 Address delete_param=IPv4StaticAddresses valid_status_code=${valid_status_code} 591 Redfish.Logout 592 593 594Config VMI Static IP Address Using Different Users 595 [Documentation] Update user role and update vmi static ip address. 596 [Arguments] ${username} ${password} ${ip} ${gateway} ${netmask} 597 ... ${valid_status_code} 598 599 # Description of argument(s): 600 # username The host username. 601 # password The host password. 602 # ip IP address to be added (e.g. "10.7.7.7"). 603 # subnet_mask Subnet mask for the IP to be added 604 # (e.g. "255.255.0.0"). 605 # gateway Gateway for the IP to be added (e.g. "10.7.7.1"). 606 # valid_status_code The expected valid status code. 607 608 Redfish.Login ${username} ${password} 609 Set Static IPv4 Address To VMI And Verify ${ip} ${gateway} ${netmask} ${valid_status_code} 610 Redfish.Logout 611 612 613Read VMI Static IP Address Using Different Users 614 [Documentation] Update user role and read vmi static ip address. 615 [Arguments] ${username} ${password} ${valid_status_code} 616 617 # Description of argument(s): 618 # username The host username. 619 # password The host password. 620 # valid_status_code The expected valid status code. 621 622 Redfish.Login ${username} ${password} 623 Redfish.Get 624 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 625 ... valid_status_codes=[${valid_status_code}] 626 Redfish.Logout 627 628 629Delete BMC Users Using Redfish 630 [Documentation] Delete BMC users via redfish. 631 632 Redfish.Login 633 Delete BMC Users Via Redfish users=${USERS} 634 635Update User Role And Set VMI IPv4 Origin 636 [Documentation] Update User Role And Set VMI IPv4 Origin. 637 [Arguments] ${username} ${password} ${dhcp_enabled} ${valid_status_code} 638 639 # Description of argument(s): 640 # username The host username. 641 # password The host password. 642 # dhcp_enabled Indicates whether dhcp should be enabled 643 # (${True}, ${False}). 644 # valid_status_code The expected valid status code. 645 646 Redfish.Login ${username} ${password} 647 Set VMI IPv4 Origin ${dhcp_enabled} ${valid_status_code} 648 Redfish.Logout 649