1*** Settings *** 2 3Documentation VMI static/dynamic IP config and certificate exchange tests. 4 5Resource ../../lib/resource.robot 6Resource ../../lib/bmc_redfish_resource.robot 7Resource ../../lib/openbmc_ffdc.robot 8 9Suite Setup Redfish.Login 10Test Teardown FFDC On Test Case Fail 11Suite Teardown Redfish.Logout 12 13*** Variables *** 14 15&{DHCP_ENABLED} DHCPEnabled=${${True}} 16&{DHCP_DISABLED} DHCPEnabled=${${False}} 17 18&{ENABLE_DHCP} DHCPv4=&{DHCP_ENABLED} 19&{DISABLE_DHCP} DHCPv4=&{DHCP_DISABLED} 20 21 22*** Test Cases *** 23 24Verify All VMI EthernetInterfaces 25 [Documentation] Verify all VMI ethernet interfaces. 26 [Tags] Verify_All_VMI_EthernetINterfaces 27 28 Verify VMI EthernetInterfaces 29 30 31Verify Existing VMI Network Interface Details 32 [Documentation] Verify existing VMI network interface details. 33 [Tags] Verify_VMI_Network_Interface_Details 34 35 ${vmi_ip}= Get VMI Network Interface Details 36 ${origin}= Set Variable If ${vmi_ip["DHCPv4"]} == ${False} Static DHCP 37 38 Should Not Be Equal ${vmi_ip["DHCPv4"]} ${vmi_ip["IPv4StaticAddresses"]} 39 Should Be Equal As Strings ${origin} ${vmi_ip["IPv4_AddressOrigin"]} 40 Should Be Equal As Strings ${vmi_ip["Id"]} intf0 41 Should Be Equal As Strings ${vmi_ip["Description"]} Virtual Interface Management Network Interface 42 Should Be Equal As Strings ${vmi_ip["Name"]} Virtual Management Ethernet Interface 43 Should Be True ${vmi_ip["InterfaceEnabled"]} 44 45 46Delete Existing Static VMI IP Address 47 [Documentation] Delete existing static VMI IP address. 48 [Tags] Delete_Existing_Static_VMI_IP_Address 49 50 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled 51 Run Keyword If ${curr_origin} == ${True} Set VMI IPv4 Origin ${False} ${HTTP_ACCEPTED} 52 53 Delete VMI IPv4 Address IPv4StaticAddresses valid_status_code=${HTTP_ACCEPTED} 54 ${default}= Set Variable 0.0.0.0 55 Verify VMI Network Interface Details ${default} Static ${default} ${default} ${True} 56 57 58Verify User Cannot Delete ReadOnly Property IPv4Addresses 59 [Documentation] Verify user cannot delete readonly property IPv4Addresses. 60 [Tags] Verify_User_Cannot_Delete_ReadOnly_Property_IPv4Addresses 61 62 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled 63 Run Keyword If ${curr_origin} == ${False} Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED} 64 Delete VMI IPv4 Address IPv4Addresses valid_status_code=${HTTP_BAD_REQUEST} 65 66 67Assign Static IPv4 Address To VMI 68 [Documentation] Assign static IPv4 address to VMI. 69 [Tags] Assign_Static_IPv4_Address_To_VMI 70 [Template] Verify Assigning Static IPv4 Address To VMI 71 72 # ip gateway netmask del_curr_ip host_reboot valid_status_code 73 ${VMI_IP} ${VMI_GATEWAY} ${VMI_NETMASK} ${False} ${True} ${HTTP_ACCEPTED} 74 a.3.118.94 ${VMI_GATEWAY} ${VMI_NETMASK} ${False} ${False} ${HTTP_BAD_REQUEST} 75 10.118.94 10.118.3.Z ${VMI_NETMASK} ${False} ${False} ${HTTP_BAD_REQUEST} 76 77 78Switch Between IP Origins On VMI And Verify Details 79 [Documentation] Switch between IP origins on VMI and verify details. 80 [Tags] Switch_Between_IP_Origins_On_VMI_And_Verify_Details 81 82 Switch VMI IPv4 Origin And Verify Details 83 Switch VMI IPv4 Origin And Verify Details 84 85 86Verify Persistency Of VMI IPv4 Details After Host Reboot 87 [Documentation] Verify persistency of VMI IPv4 details after host reboot. 88 [Tags] Verify_Persistency_Of_VMI_IPv4_Details_After_Host_Reboot 89 90 # Verifying persistency of dynamic address. 91 Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED} 92 ${default}= Set Variable 0.0.0.0 93 Verify VMI Network Interface Details ${default} DHCP ${default} ${default} ${True} 94 Verify VMI Network Interface Details ${default} DHCP ${default} ${default} ${True} 95 96 # Verifying persistency of static address. 97 Switch VMI IPv4 Origin And Verify Details ${True} 98 Verify Assigning Static IPv4 Address To VMI ${VMI_IP} ${VMI_GATEWAY} ${VMI_NETMASK} ${False} 99 Verify VMI Network Interface Details ${VMI_IP} Static ${VMI_GATEWAY} ${VMI_NETMASK} ${True} 100 101 102*** Keywords *** 103 104Get VMI Network Interface Details 105 [Documentation] Get VMI network interface details. 106 [Arguments] ${valid_status_code}=${HTTP_OK} 107 108 # Description of argument(s): 109 # valid_status_code Expected valid status code from GET request. 110 111 # Note: It returns a dictionary of VMI intf0 parameters. 112 113 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf0 114 ... valid_status_codes=[${valid_status_code}] 115 116 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json 117 118 ${static_exists}= Run Keyword And Ignore Error 119 ... Set Variable ${ip_resp["IPv4StaticAddresses"][0]["Address"]} 120 ${static_exists}= Set Variable If '${static_exists[0]}' == 'PASS' ${True} ${False} 121 122 ${vmi_ip}= Create Dictionary DHCPv4=${${ip_resp["DHCPv4"]["DHCPEnabled"]}} Id=${ip_resp["Id"]} 123 ... Description=${ip_resp["Description"]} IPv4_Address=${ip_resp["IPv4Addresses"][0]["Address"]} 124 ... IPv4_AddressOrigin=${ip_resp["IPv4Addresses"][0]["AddressOrigin"]} Name=${ip_resp["Name"]} 125 ... IPv4_Gateway=${ip_resp["IPv4Addresses"][0]["Gateway"]} 126 ... InterfaceEnabled=${${ip_resp["InterfaceEnabled"]}} 127 ... IPv4_SubnetMask=${ip_resp["IPv4Addresses"][0]["SubnetMask"]} MACAddress=${ip_resp["MACAddress"]} 128 ... IPv4StaticAddresses=${${static_exists}} 129 130 [Return] &{vmi_ip} 131 132 133Get Immediate Child Parameter From VMI Network Interface 134 [Documentation] Get immediate child parameter from VMI network interface. 135 [Arguments] ${parameter} ${valid_status_code}=${HTTP_OK} 136 137 # Description of argument(s): 138 # parameter parameter for which value is required. Ex: DHCPEnabled, MACAddress etc. 139 # valid_status_code Expected valid status code from GET request. 140 141 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf0 142 ... valid_status_codes=[${valid_status_code}] 143 144 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json 145 ${value}= Set Variable If '${parameter}' != 'DHCPEnabled' ${ip_resp["${parameter}"]} 146 ... ${ip_resp["DHCPv4"]["${parameter}"]} 147 148 [Return] ${value} 149 150 151Verify VMI EthernetInterfaces 152 [Documentation] Verify VMI ethernet interfaces. 153 [Arguments] ${valid_status_code}=${HTTP_OK} 154 155 # Description of argument(s): 156 # valid_status_code Expected valid status code from GET request. 157 158 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces 159 ... valid_status_codes=[${valid_status_code}] 160 161 ${resp}= Evaluate json.loads('''${resp.text}''') json 162 ${interfaces}= Set Variable ${resp["Members"]} 163 164 Should Be Equal As Strings ${interfaces[0]}[@odata.id] 165 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf0 166 Should Be Equal As Strings ${interfaces[1]}[@odata.id] 167 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf1 168 169 Should Be Equal ${resp["Members@odata.count"]} ${2} 170 171 172Verify VMI Network Interface Details 173 [Documentation] Verify VMI network interface details. 174 [Arguments] ${ip} ${origin} ${gateway} ${netmask} 175 ... ${host_reboot}=${False} ${valid_status_code}=${HTTP_OK} 176 177 # Description of argument(s): 178 # ip VMI IPv4 address. 179 # origin Origin of IPv4 address eg. Static or DHCP. 180 # gateway Gateway for VMI IP. 181 # netmask Subnetmask for VMI IP. 182 # valid_status_code Expected valid status code from GET request. Default is HTTP_OK. 183 # host_reboot Reboot HOST if True. 184 185 Run Keyword If ${host_reboot} == ${True} Run Keywords 186 ... Redfish Power Off AND Redfish Power On AND Redfish.Login 187 188 ${vmi_ip}= Get VMI Network Interface Details ${valid_status_code} 189 Should Be Equal As Strings ${origin} ${vmi_ip["IPv4_AddressOrigin"]} 190 Should Be Equal As Strings ${gateway} ${vmi_ip["IPv4_Gateway"]} 191 Should Be Equal As Strings ${netmask} ${vmi_ip["IPv4_SubnetMask"]} 192 193 Return From Keyword If '${origin}' == 'DHCP' 194 Should Be Equal As Strings ${ip} ${vmi_ip["IPv4_Address"]} 195 196 197Set Static IPv4 Address To VMI 198 [Documentation] Set static IPv4 address to VMI. 199 [Arguments] ${ip} ${gateway} ${netmask} ${valid_status_code}=${HTTP_ACCEPTED} 200 201 # Description of argument(s): 202 # ip VMI IPv4 address. 203 # gateway Gateway for VMI IP. 204 # netmask Subnetmask for VMI IP. 205 # valid_status_code Expected valid status code from GET request. Default is HTTP_ACCEPTED. 206 207 ${data}= Set Variable 208 ... {"IPv4StaticAddresses": [{"Address": "${ip}","SubnetMask": "${netmask}","Gateway": "${gateway}"}]} 209 210 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf0 body=${data} 211 ... valid_status_codes=[${valid_status_code}] 212 Redfish Power On stack_mode=skip 213 Log To Console ${resp.text} 214 215 216Verify Assigning Static IPv4 Address To VMI 217 [Documentation] Verify assigning static IPv4 address to VMI. 218 [Arguments] ${ip} ${gateway} ${netmask} ${del_curr_ip}=${True} ${host_reboot}=${True} 219 ... ${valid_status_code}=${HTTP_ACCEPTED} 220 221 # Description of argument(s): 222 # ip VMI IPv4 address. 223 # gateway Gateway for VMI IP. 224 # netmask Subnetmask for VMI IP. 225 # del_curr_ip Delete current VMI static IP if True. 226 # host_reboot True when HOST reboot is required. 227 # valid_status_code Expected valid status code from GET request. Default is HTTP_ACCEPTED. 228 229 # Delete current static IP based on user input. 230 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled 231 Run Keyword If ${curr_origin} == ${False} and ${del_curr_ip} == ${True} Delete VMI IPv4 Address 232 233 Set Static IPv4 Address To VMI ${ip} ${gateway} ${netmask} valid_status_code=${valid_status_code} 234 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED} 235 236 Verify VMI Network Interface Details ${ip} Static ${gateway} ${netmask} host_reboot=${host_reboot} 237 238 239Delete VMI IPv4 Address 240 [Documentation] Delete VMI IPv4 address. 241 [Arguments] ${delete_param}=IPv4StaticAddresses ${valid_status_code}=${HTTP_ACCEPTED} 242 243 # Description of argument(s): 244 # delete_param Parameter to be deleted eg. IPv4StaticAddresses or IPv4Addresses. 245 # Default is IPv4StaticAddresses. 246 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK. 247 248 ${data}= Set Variable {"${delete_param}": [${Null}]} 249 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf0 body=${data} 250 ... valid_status_codes=[${valid_status_code}] 251 252 253Set VMI IPv4 Origin 254 [Documentation] Set VMI IPv4 origin. 255 [Arguments] ${dhcp_enabled}=${False} ${valid_status_code}=${HTTP_ACCEPTED} 256 257 # Description of argument(s): 258 # dhcp_enabled True if user wants to enable DHCP. Default is Static, hence value is set to False. 259 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK. 260 261 ${data}= Set Variable If ${dhcp_enabled} == ${False} ${DISABLE_DHCP} ${ENABLE_DHCP} 262 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf0 body=${data} 263 ... valid_status_codes=[${valid_status_code}] 264 265 266Switch VMI IPv4 Origin And Verify Details 267 [Documentation] Switch VMI IPv4 origin and verify details. 268 [Arguments] ${host_reboot}=${False} 269 270 # Description of argument(s): 271 # host_reboot Reboot HOST if True. 272 273 ${curr_mode}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled 274 ${dhcp_enabled}= Set Variable If ${curr_mode} == ${False} ${True} ${False} 275 276 ${default}= Set Variable 0.0.0.0 277 ${origin}= Set Variable If ${curr_mode} == ${False} DHCP Static 278 Set VMI IPv4 Origin ${dhcp_enabled} ${HTTP_ACCEPTED} 279 Verify VMI Network Interface Details ${default} ${origin} ${default} ${default} ${host_reboot} 280 281 [Return] ${origin} 282