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