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 8Library ../../lib/bmc_network_utils.py 9 10Suite Setup Suite Setup Execution 11Test Teardown FFDC On Test Case Fail 12Suite Teardown Redfish.Logout 13 14*** Variables *** 15 16${test_ipv4} 10.10.20.30 17${test_gateway} 0.0.0.0 18${test_netmask} 255.255.252.0 19 20&{DHCP_ENABLED} DHCPEnabled=${${True}} 21&{DHCP_DISABLED} DHCPEnabled=${${False}} 22 23&{ENABLE_DHCP} DHCPv4=&{DHCP_ENABLED} 24&{DISABLE_DHCP} DHCPv4=&{DHCP_DISABLED} 25 26 27*** Test Cases *** 28 29Verify All VMI EthernetInterfaces 30 [Documentation] Verify all VMI ethernet interfaces. 31 [Tags] Verify_All_VMI_EthernetINterfaces 32 33 Verify VMI EthernetInterfaces 34 35 36Verify Existing VMI Network Interface Details 37 [Documentation] Verify existing VMI network interface details. 38 [Tags] Verify_VMI_Network_Interface_Details 39 40 ${vmi_ip}= Get VMI Network Interface Details 41 ${origin}= Set Variable If ${vmi_ip["DHCPv4"]} == ${False} Static DHCP 42 43 Should Not Be Equal ${vmi_ip["DHCPv4"]} ${vmi_ip["IPv4StaticAddresses"]} 44 Should Be Equal As Strings ${origin} ${vmi_ip["IPv4_AddressOrigin"]} 45 Should Be Equal As Strings ${vmi_ip["Id"]} intf0 46 Should Be Equal As Strings ${vmi_ip["Description"]} 47 ... Ethernet Interface for Virtual Management Interface 48 Should Be Equal As Strings ${vmi_ip["Name"]} Virtual Management Interface 49 Should Be True ${vmi_ip["InterfaceEnabled"]} 50 51 52Delete Existing Static VMI IP Address 53 [Documentation] Delete existing static VMI IP address. 54 [Tags] Delete_Existing_Static_VMI_IP_Address 55 56 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled 57 Run Keyword If ${curr_origin} == ${True} Set VMI IPv4 Origin ${False} ${HTTP_ACCEPTED} 58 59 Delete VMI IPv4 Address IPv4StaticAddresses valid_status_code=${HTTP_ACCEPTED} 60 ${default}= Set Variable 0.0.0.0 61 Verify VMI Network Interface Details ${default} Static ${default} ${default} ${True} 62 63 64Verify User Cannot Delete ReadOnly Property IPv4Addresses 65 [Documentation] Verify user cannot delete readonly property IPv4Addresses. 66 [Tags] Verify_User_Cannot_Delete_ReadOnly_Property_IPv4Addresses 67 68 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled 69 Run Keyword If ${curr_origin} == ${False} Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED} 70 Delete VMI IPv4 Address IPv4Addresses valid_status_code=${HTTP_BAD_REQUEST} 71 72 73Assign Valid And Invalid Static IPv4 Address To VMI 74 [Documentation] Assign static IPv4 address to VMI. 75 [Tags] Assign_Valid_And_Invalid_Static_IPv4_Address_To_VMI 76 [Template] Verify Assigning Static IPv4 Address To VMI 77 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses 78 ... AND Test Teardown Execution 79 80 # ip gateway netmask valid_status_code 81 10.5.20.30 0.0.0.0 255.255.252.0 ${HTTP_ACCEPTED} 82 a.3.118.94 0.0.0.0 255.255.252.0 ${HTTP_BAD_REQUEST} 83 84 85Add Multiple IP Addreses On VMI Interface And Verify 86 [Documentation] Add multiple IP addreses on VMI interface and verify. 87 [Tags] Add_Multiple_IP_Addreses_On_VMI_Interface_And_Verify 88 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses 89 ... AND Test Teardown Execution 90 91 ${ip1}= Create dictionary Address=10.5.5.10 SubnetMask=255.255.252.0 Gateway=0.0.0.0 92 ${ip2}= Create dictionary Address=10.5.5.11 SubnetMask=255.255.252.0 Gateway=0.0.0.0 93 ${ip3}= Create dictionary Address=10.5.5.12 SubnetMask=255.255.252.0 Gateway=0.0.0.0 94 ${ips}= Create List ${ip1} ${ip2} ${ip3} 95 96 ${active_channel_config}= Get Active Channel Config 97 Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 98 ... body={'IPv4StaticAddresses':${ips}} valid_status_codes=[${HTTP_ACCEPTED}] 99 Verify VMI Network Interface Details ${ip1["Address"]} Static ${ip1["Gateway"]} ${ip1["SubnetMask"]} ${True} 100 101 102Modify IP Addresses On VMI Interface And Verify 103 [Documentation] Modify IP addresses on VMI interface and verify. 104 [Tags] Modify_IP_Addresses_On_VMI_Interface_And_Verify 105 [Template] Verify Assigning Static IPv4 Address To VMI 106 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses 107 ... AND Test Teardown Execution 108 109 # ip gateway netmask del_curr_ip host_reboot valid_status_code 110 10.5.5.10 0.0.0.0 255.255.252.0 ${False} ${True} ${HTTP_ACCEPTED} 111 10.5.5.11 0.0.0.0 255.255.252.0 ${False} ${True} ${HTTP_ACCEPTED} 112 113Switch Between IP Origins On VMI And Verify Details 114 [Documentation] Switch between IP origins on VMI and verify details. 115 [Tags] Switch_Between_IP_Origins_On_VMI_And_Verify_Details 116 117 Switch VMI IPv4 Origin And Verify Details 118 Switch VMI IPv4 Origin And Verify Details 119 120 121Verify Persistency Of VMI IPv4 Details After Host Reboot 122 [Documentation] Verify persistency of VMI IPv4 details after host reboot. 123 [Tags] Verify_Persistency_Of_VMI_IPv4_Details_After_Host_Reboot 124 125 # Verifying persistency of dynamic address. 126 Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED} 127 ${default}= Set Variable 0.0.0.0 128 Verify VMI Network Interface Details ${default} DHCP ${default} ${default} ${True} 129 Verify VMI Network Interface Details ${default} DHCP ${default} ${default} ${True} 130 131 # Verifying persistency of static address. 132 Switch VMI IPv4 Origin And Verify Details ${True} 133 Verify Assigning Static IPv4 Address To VMI ${VMI_IP} ${VMI_GATEWAY} ${VMI_NETMASK} ${False} 134 Verify VMI Network Interface Details ${VMI_IP} Static ${VMI_GATEWAY} ${VMI_NETMASK} ${True} 135 136 137Delete VMI Static IP Address And Verify 138 [Documentation] Delete VMI static IP address and verify. 139 [Tags] Delete_VMI_Static_IP_Address_And_Verify 140 [Teardown] Test Teardown Execution 141 142 Verify Assigning Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask} 143 Delete VMI IPv4 Address IPv4Addresses ${HTTP_ACCEPTED} 144 ${active_channel_config}= Get Active Channel Config 145 ${resp}= Redfish.Get 146 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 147 Should Be Empty ${resp.dict["IPv4Addresses"]} 148 149 150Verify Successful VMI IP Static Configuration On HOST Boot After Session Delete 151 [Documentation] Verify VMI IP static Configuration On HOST Boot After session deleted. 152 [Tags] Verify_Successful_VMI_IP_Static_Configuration_On_HOST_Boot_After_Session_Delete 153 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses AND Test Teardown Execution 154 155 Set Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask} 156 157 ${session_info}= Get Redfish Session Info 158 Redfish.Delete ${session_info["location"]} 159 160 # Create a new Redfish session 161 Redfish Power Off 162 Redfish Power On 163 164 Verify VMI Network Interface Details ${test_ipv4} Static ${test_gateway} ${test_netmask} 165 166 167Verify Persistency Of VMI DHCP IP Configuration After Multiple HOST Reboots 168 [Documentation] Verify Persistency Of VMI DHCP IP configuration After Multiple HOST Reboots 169 [Tags] Verify_Persistency_Of_VMI_DHCP_IP_Configuration_After_Multiple_HOST_Reboots 170 [Teardown] Test Teardown Execution 171 172 ${LOOP_COUNT}= Set Variable ${3} 173 Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED} 174 Run Keywords Redfish Power Off AND Redfish Power On 175 ${vmi_ip_config}= Get VMI Network Interface Details 176 # Verifying persistency of dynamic address after multiple reboots. 177 Repeat Keyword ${LOOP_COUNT} times 178 ... Verify VMI Network Interface Details ${vmi_ip_config["IPv4_Address"]} DHCP ${vmi_ip_config["IPv4_Gateway"]} 179 ... ${vmi_ip_config["IPv4_SubnetMask"]} 180 181 182Enable DHCP When Static IP Configured And Verify Static IP 183 [Documentation] Enable DHCP when static ip configured and verify static ip 184 [Tags] Enable_DHCP_when_Static_IP_Configured_And_Verify_Static_IP 185 [Teardown] Test Teardown Execution 186 187 Verify Assigning Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask} 188 Set VMI IPv4 Origin ${True} 189 Redfish Power Off 190 Redfish Power On 191 ${vmi_network_conf}= Get VMI Network Interface Details 192 Should Not Be Equal As Strings ${test_ipv4} ${vmi_network_conf["IPv4_Address"]} 193 194 195Verify VMI Static IP Configuration Persist On BMC Reset Before Host Boot 196 [Documentation] Verify VMI static IP configuration persist on BMC reset. 197 [Tags] Verify_VMI_Static_IP_Configuration_Persist_On_BMC_Reset_Before_Host_Boot 198 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses AND FFDC On Test Case Fail 199 200 Set Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask} 201 OBMC Reboot (off) 202 Redfish Power On 203 # Verifying the VMI static configuration 204 Verify VMI Network Interface Details ${test_ipv4} Static ${test_gateway} ${test_netmask} 205 206 207 208*** Keywords *** 209 210Suite Setup Execution 211 [Documentation] Do test setup execution task. 212 213 Redfish.Login 214 Redfish Power On 215 ${active_channel_config}= Get Active Channel Config 216 Set Suite Variable ${active_channel_config} 217 ${resp}= Redfish.Get 218 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 219 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json 220 ${length}= Get Length ${ip_resp["IPv4StaticAddresses"]} 221 ${vmi_network_conf}= Run Keyword If ${length} != ${0} Get VMI Network Interface Details 222 Set Suite Variable ${vmi_network_conf} 223 224 225Test Teardown Execution 226 [Documentation] Do test teardown execution task. 227 228 FFDC On Test Case Fail 229 ${curr_mode}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled 230 Run Keyword If ${curr_mode} == ${True} Set VMI IPv4 Origin ${False} 231 Run Keyword If ${vmi_network_conf} != ${None} 232 ... Verify Assigning Static IPv4 Address To VMI ${vmi_network_conf["IPv4_Address"]} 233 ... ${vmi_network_conf["IPv4_Gateway"]} ${vmi_network_conf["IPv4_SubnetMask"]} 234 235 236Get VMI Network Interface Details 237 [Documentation] Get VMI network interface details. 238 [Arguments] ${valid_status_code}=${HTTP_OK} 239 240 # Description of argument(s): 241 # valid_status_code Expected valid status code from GET request. 242 243 # Note: It returns a dictionary of VMI eth0 parameters. 244 245 ${active_channel_config}= Get Active Channel Config 246 ${resp}= Redfish.Get 247 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 248 ... valid_status_codes=[${valid_status_code}] 249 250 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json 251 252 ${static_exists}= Run Keyword And Ignore Error 253 ... Set Variable ${ip_resp["IPv4StaticAddresses"][0]["Address"]} 254 ${static_exists}= Set Variable If '${static_exists[0]}' == 'PASS' ${True} ${False} 255 256 ${vmi_ip}= Create Dictionary DHCPv4=${${ip_resp["DHCPv4"]["DHCPEnabled"]}} Id=${ip_resp["Id"]} 257 ... Description=${ip_resp["Description"]} IPv4_Address=${ip_resp["IPv4Addresses"][0]["Address"]} 258 ... IPv4_AddressOrigin=${ip_resp["IPv4Addresses"][0]["AddressOrigin"]} Name=${ip_resp["Name"]} 259 ... IPv4_Gateway=${ip_resp["IPv4Addresses"][0]["Gateway"]} 260 ... InterfaceEnabled=${${ip_resp["InterfaceEnabled"]}} 261 ... IPv4_SubnetMask=${ip_resp["IPv4Addresses"][0]["SubnetMask"]} MACAddress=${ip_resp["MACAddress"]} 262 ... IPv4StaticAddresses=${${static_exists}} 263 264 [Return] &{vmi_ip} 265 266 267Get Immediate Child Parameter From VMI Network Interface 268 [Documentation] Get immediate child parameter from VMI network interface. 269 [Arguments] ${parameter} ${valid_status_code}=${HTTP_OK} 270 271 # Description of argument(s): 272 # parameter parameter for which value is required. Ex: DHCPEnabled, MACAddress etc. 273 # valid_status_code Expected valid status code from GET request. 274 275 ${active_channel_config}= Get Active Channel Config 276 ${resp}= Redfish.Get 277 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 278 ... valid_status_codes=[${valid_status_code}] 279 280 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json 281 ${value}= Set Variable If '${parameter}' != 'DHCPEnabled' ${ip_resp["${parameter}"]} 282 ... ${ip_resp["DHCPv4"]["${parameter}"]} 283 284 [Return] ${value} 285 286Verify VMI EthernetInterfaces 287 [Documentation] Verify VMI ethernet interfaces. 288 [Arguments] ${valid_status_code}=${HTTP_OK} 289 290 # Description of argument(s): 291 # valid_status_code Expected valid status code from GET request. 292 293 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces 294 ... valid_status_codes=[${valid_status_code}] 295 296 ${resp}= Evaluate json.loads('''${resp.text}''') json 297 ${interfaces}= Set Variable ${resp["Members"]} 298 299 Should Be Equal As Strings ${interfaces[0]}[@odata.id] 300 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0 301 Should Be Equal As Strings ${interfaces[1]}[@odata.id] 302 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth1 303 304 Should Be Equal ${resp["Members@odata.count"]} ${2} 305 306 307Verify VMI Network Interface Details 308 [Documentation] Verify VMI network interface details. 309 [Arguments] ${ip} ${origin} ${gateway} ${netmask} 310 ... ${valid_status_code}=${HTTP_OK} 311 312 # Description of argument(s): 313 # ip VMI IPv4 address. 314 # origin Origin of IPv4 address eg. Static or DHCP. 315 # gateway Gateway for VMI IP. 316 # netmask Subnetmask for VMI IP. 317 # valid_status_code Expected valid status code from GET request. Default is HTTP_OK. 318 319 Run Keywords Redfish Power Off AND Redfish Power On 320 ${vmi_ip}= Get VMI Network Interface Details ${valid_status_code} 321 Should Be Equal As Strings ${origin} ${vmi_ip["IPv4_AddressOrigin"]} 322 Should Be Equal As Strings ${gateway} ${vmi_ip["IPv4_Gateway"]} 323 Should Be Equal As Strings ${netmask} ${vmi_ip["IPv4_SubnetMask"]} 324 Should Be Equal As Strings ${ip} ${vmi_ip["IPv4_Address"]} 325 326Set Static IPv4 Address To VMI 327 [Documentation] Set static IPv4 address to VMI. 328 [Arguments] ${ip} ${gateway} ${netmask} ${valid_status_code}=${HTTP_ACCEPTED} 329 330 # Description of argument(s): 331 # ip VMI IPv4 address. 332 # gateway Gateway for VMI IP. 333 # netmask Subnetmask for VMI IP. 334 # valid_status_code Expected valid status code from GET request. Default is HTTP_ACCEPTED. 335 336 ${data}= Set Variable 337 ... {"IPv4StaticAddresses": [{"Address": "${ip}","SubnetMask": "${netmask}","Gateway": "${gateway}"}]} 338 339 ${active_channel_config}= Get Active Channel Config 340 ${resp}= Redfish.Patch 341 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 342 ... body=${data} valid_status_codes=[${valid_status_code}] 343 Log To Console ${resp.text} 344 345 346Verify Assigning Static IPv4 Address To VMI 347 [Documentation] Verify assigning static IPv4 address to VMI. 348 [Arguments] ${ip} ${gateway} ${netmask} ${valid_status_code}=${HTTP_ACCEPTED} 349 350 # Description of argument(s): 351 # ip VMI IPv4 address. 352 # gateway Gateway for VMI IP. 353 # netmask Subnetmask for VMI IP. 354 # valid_status_code Expected valid status code from GET request. Default is HTTP_ACCEPTED. 355 356 357 Set Static IPv4 Address To VMI ${ip} ${gateway} ${netmask} valid_status_code=${valid_status_code} 358 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED} 359 360 Verify VMI Network Interface Details ${ip} Static ${gateway} ${netmask} 361 362 363Delete VMI IPv4 Address 364 [Documentation] Delete VMI IPv4 address. 365 [Arguments] ${delete_param}=IPv4StaticAddresses ${valid_status_code}=${HTTP_ACCEPTED} 366 367 # Description of argument(s): 368 # delete_param Parameter to be deleted eg. IPv4StaticAddresses or IPv4Addresses. 369 # Default is IPv4StaticAddresses. 370 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK. 371 372 ${data}= Set Variable {"${delete_param}": [${Null}]} 373 ${active_channel_config}= Get Active Channel Config 374 ${resp}= Redfish.Patch 375 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 376 ... body=${data} valid_status_codes=[${valid_status_code}] 377 378 379Set VMI IPv4 Origin 380 [Documentation] Set VMI IPv4 origin. 381 [Arguments] ${dhcp_enabled}=${False} ${valid_status_code}=${HTTP_ACCEPTED} 382 383 # Description of argument(s): 384 # dhcp_enabled True if user wants to enable DHCP. Default is Static, hence value is set to False. 385 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK. 386 387 ${data}= Set Variable If ${dhcp_enabled} == ${False} ${DISABLE_DHCP} ${ENABLE_DHCP} 388 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0 body=${data} 389 ... valid_status_codes=[${valid_status_code}] 390 391 392Switch VMI IPv4 Origin And Verify Details 393 [Documentation] Switch VMI IPv4 origin and verify details. 394 [Arguments] ${host_reboot}=${False} 395 396 # Description of argument(s): 397 # host_reboot Reboot HOST if True. 398 399 ${curr_mode}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled 400 ${dhcp_enabled}= Set Variable If ${curr_mode} == ${False} ${True} ${False} 401 402 ${default}= Set Variable 0.0.0.0 403 ${origin}= Set Variable If ${curr_mode} == ${False} DHCP Static 404 Set VMI IPv4 Origin ${dhcp_enabled} ${HTTP_ACCEPTED} 405 Verify VMI Network Interface Details ${default} ${origin} ${default} ${default} 406 407 [Return] ${origin} 408 409