Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Network interface configuration and verification |
| 3 | ... tests. |
| 4 | |
George Keishing | 5d46755 | 2019-02-08 23:30:48 -0600 | [diff] [blame] | 5 | Resource ../../lib/bmc_redfish_resource.robot |
| 6 | Resource ../../lib/bmc_network_utils.robot |
| 7 | Resource ../../lib/openbmc_ffdc.robot |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 8 | Library ../../lib/bmc_network_utils.py |
Vijay | de3bf7b | 2019-04-16 04:56:09 -0500 | [diff] [blame] | 9 | Library Collections |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 10 | |
| 11 | Test Setup Test Setup Execution |
| 12 | Test Teardown Test Teardown Execution |
| 13 | |
Prashanth Katti | 23efc6e | 2019-03-13 06:07:15 -0500 | [diff] [blame] | 14 | *** Variables *** |
Vijay | de3bf7b | 2019-04-16 04:56:09 -0500 | [diff] [blame] | 15 | ${test_hostname} openbmc |
| 16 | ${test_ipv4_addr} 10.7.7.7 |
| 17 | ${test_ipv4_invalid_addr} 0.0.1.a |
| 18 | ${test_subnet_mask} 255.255.0.0 |
| 19 | ${test_gateway} 10.7.7.1 |
Prashanth Katti | 23efc6e | 2019-03-13 06:07:15 -0500 | [diff] [blame] | 20 | |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 21 | *** Test Cases *** |
| 22 | |
| 23 | Get IP Address And Verify |
| 24 | [Documentation] Get IP Address And Verify. |
George Keishing | 5d46755 | 2019-02-08 23:30:48 -0600 | [diff] [blame] | 25 | [Tags] Get_IP_Address_And_Verify |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 26 | |
| 27 | : FOR ${network_configuration} IN @{network_configurations} |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 28 | \ Verify IP On BMC ${network_configuration['Address']} |
| 29 | |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 30 | Get Netmask And Verify |
| 31 | [Documentation] Get Netmask And Verify. |
George Keishing | 5d46755 | 2019-02-08 23:30:48 -0600 | [diff] [blame] | 32 | [Tags] Get_Netmask_And_Verify |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 33 | |
| 34 | : FOR ${network_configuration} IN @{network_configurations} |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 35 | \ Verify Netmask On BMC ${network_configuration['SubnetMask']} |
| 36 | |
Prashanth Katti | 2ec9d8b | 2019-02-12 05:20:19 -0600 | [diff] [blame] | 37 | Get Gateway And Verify |
| 38 | [Documentation] Get gateway and verify it's existence on the BMC. |
| 39 | [Tags] Get_Gateway_And_Verify |
| 40 | |
| 41 | : FOR ${network_configuration} IN @{network_configurations} |
| 42 | \ Verify Gateway On BMC ${network_configuration['Gateway']} |
| 43 | |
| 44 | Get MAC Address And Verify |
| 45 | [Documentation] Get MAC address and verify it's existence on the BMC. |
| 46 | [Tags] Get_MAC_Address_And_Verify |
| 47 | |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 48 | ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI} |
Prashanth Katti | 2ec9d8b | 2019-02-12 05:20:19 -0600 | [diff] [blame] | 49 | ${macaddr}= Get From Dictionary ${resp.dict} MACAddress |
| 50 | Validate MAC On BMC ${macaddr} |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 51 | |
Prashanth Katti | 2c5c3bb | 2019-02-14 04:23:07 -0600 | [diff] [blame] | 52 | Verify All Configured IP And Netmask |
| 53 | [Documentation] Verify all configured IP and netmask on BMC. |
| 54 | [Tags] Verify_All_Configured_IP_And_Netmask |
| 55 | |
| 56 | : FOR ${network_configuration} IN @{network_configurations} |
| 57 | \ Verify IP And Netmask On BMC ${network_configuration['Address']} |
| 58 | ... ${network_configuration['SubnetMask']} |
| 59 | |
Prashanth Katti | 23efc6e | 2019-03-13 06:07:15 -0500 | [diff] [blame] | 60 | Get Hostname And Verify |
| 61 | [Documentation] Get hostname via Redfish and verify. |
| 62 | [Tags] Get_Hostname_And_Verify |
| 63 | |
| 64 | ${hostname}= Redfish_Utils.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName |
| 65 | |
| 66 | Validate Hostname On BMC ${hostname} |
| 67 | |
| 68 | Configure Hostname And Verify |
| 69 | [Documentation] Configure hostname via Redfish and verify. |
| 70 | [Tags] Configure_Hostname_And_Verify |
| 71 | |
| 72 | Configure Hostname ${test_hostname} |
| 73 | |
| 74 | Validate Hostname On BMC ${test_hostname} |
| 75 | |
Vijay | de3bf7b | 2019-04-16 04:56:09 -0500 | [diff] [blame] | 76 | Add Valid IPv4 Address And Verify |
| 77 | [Documentation] Add IPv4 Address via Redfish and verify. |
| 78 | [Tags] Add_Valid_IPv4_Addres_And_Verify |
| 79 | |
| 80 | Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway} |
| 81 | Delete IP Address ${test_ipv4_addr} |
| 82 | |
| 83 | Add Invalid IPv4 Address And Verify |
| 84 | [Documentation] Add Invalid IPv4 Address via Redfish and verify. |
| 85 | [Tags] Add_Invalid_IPv4_Addres_And_Verify |
| 86 | |
| 87 | Add IP Address ${test_ipv4_invalid_addr} ${test_subnet_mask} |
| 88 | ... ${test_gateway} valid_status_codes=${HTTP_BAD_REQUEST} |
| 89 | |
| 90 | |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 91 | *** Keywords *** |
| 92 | |
| 93 | Test Setup Execution |
| 94 | [Documentation] Test setup execution. |
| 95 | |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 96 | Redfish.Login |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 97 | |
| 98 | @{network_configurations}= Get Network Configuration |
| 99 | Set Test Variable @{network_configurations} |
| 100 | |
| 101 | # Get BMC IP address and prefix length. |
| 102 | ${ip_data}= Get BMC IP Info |
| 103 | Set Test Variable ${ip_data} |
| 104 | |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 105 | |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 106 | Get Network Configuration |
| 107 | [Documentation] Get network configuration. |
| 108 | |
| 109 | # Sample output: |
| 110 | #{ |
| 111 | # "@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface", |
| 112 | # "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0", |
| 113 | # "@odata.type": "#EthernetInterface.v1_2_0.EthernetInterface", |
| 114 | # "Description": "Management Network Interface", |
| 115 | # "IPv4Addresses": [ |
| 116 | # { |
| 117 | # "Address": "169.254.xx.xx", |
| 118 | # "AddressOrigin": "IPv4LinkLocal", |
| 119 | # "Gateway": "0.0.0.0", |
| 120 | # "SubnetMask": "255.255.0.0" |
| 121 | # }, |
| 122 | # { |
| 123 | # "Address": "xx.xx.xx.xx", |
| 124 | # "AddressOrigin": "Static", |
| 125 | # "Gateway": "xx.xx.xx.1", |
| 126 | # "SubnetMask": "xx.xx.xx.xx" |
| 127 | # } |
| 128 | # ], |
| 129 | # "Id": "eth0", |
| 130 | # "MACAddress": "xx:xx:xx:xx:xx:xx", |
| 131 | # "Name": "Manager Ethernet Interface", |
| 132 | # "SpeedMbps": 0, |
| 133 | # "VLAN": { |
| 134 | # "VLANEnable": false, |
| 135 | # "VLANId": 0 |
| 136 | # } |
| 137 | |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 138 | ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI} |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 139 | @{network_configurations}= Get From Dictionary ${resp.dict} IPv4Addresses |
| 140 | [Return] @{network_configurations} |
| 141 | |
George Keishing | 5d46755 | 2019-02-08 23:30:48 -0600 | [diff] [blame] | 142 | |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 143 | Verify IP On BMC |
| 144 | [Documentation] Verify IP on BMC. |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 145 | [Arguments] ${ip} |
| 146 | |
Vijay | de3bf7b | 2019-04-16 04:56:09 -0500 | [diff] [blame] | 147 | # Description of argument(s): |
| 148 | # ip IP address to be verified (e.g. "10.7.7.7"). |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 149 | |
| 150 | # Get IP address details on BMC using IP command. |
| 151 | @{ip_data}= Get BMC IP Info |
| 152 | Should Contain Match ${ip_data} ${ip}/* |
| 153 | ... msg=IP address does not exist. |
| 154 | |
Vijay | de3bf7b | 2019-04-16 04:56:09 -0500 | [diff] [blame] | 155 | Add IP Address |
| 156 | [Documentation] Add IP Address To BMC. |
| 157 | [Arguments] ${ip} ${subnet_mask} ${gateway} |
| 158 | ... ${valid_status_codes}=${HTTP_OK} |
| 159 | |
| 160 | # Description of argument(s): |
| 161 | # ip IP address to be added (e.g. "10.7.7.7"). |
| 162 | # subnet_mask Subnet mask for the IP to be added |
| 163 | # (e.g. "255.255.0.0"). |
| 164 | # gateway Gateway for the IP to be added (e.g. "10.7.7.1"). |
| 165 | # valid_status_codes Expected return code from patch operation |
| 166 | # (e.g. "200"). See prolog of rest_request |
| 167 | # method in redfish_plut.py for details. |
| 168 | |
| 169 | ${empty_dict}= Create Dictionary |
| 170 | ${ip_data}= Create Dictionary Address=${ip} |
| 171 | ... AddressOrigin=Static SubnetMask=${subnet_mask} |
| 172 | ... Gateway=${gateway} |
| 173 | |
| 174 | ${patch_list}= Create List |
| 175 | ${network_configurations}= Get Network Configuration |
| 176 | ${num_entries}= Get Length ${network_configurations} |
| 177 | |
| 178 | : FOR ${INDEX} IN RANGE 0 ${num_entries} |
| 179 | \ Append To List ${patch_list} ${empty_dict} |
| 180 | |
| 181 | # We need not check for existance of IP on BMC while adding. |
| 182 | Append To List ${patch_list} ${ip_data} |
| 183 | ${data}= Create Dictionary IPv4Addresses=${patch_list} |
| 184 | |
| 185 | Redfish.patch ${REDFISH_NW_ETH0_URI} body=&{data} |
| 186 | ... valid_status_codes=[${valid_status_codes}] |
| 187 | |
| 188 | Return From Keyword If '${valid_status_codes}' != '${HTTP_OK}' |
| 189 | |
| 190 | # Note: Network restart takes around 15-18s after patch request processing. |
| 191 | Sleep ${NETWORK_TIMEOUT}s |
| 192 | Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} |
| 193 | |
| 194 | Verify IP On BMC ${ip} |
| 195 | Validate Network Config On BMC |
| 196 | |
| 197 | |
| 198 | Delete IP Address |
| 199 | [Documentation] Delete IP Address Of BMC. |
| 200 | [Arguments] ${ip} ${valid_status_codes}=${HTTP_OK} |
| 201 | |
| 202 | # Description of argument(s): |
| 203 | # ip IP address to be deleted (e.g. "10.7.7.7"). |
| 204 | # valid_status_codes Expected return code from patch operation |
| 205 | # (e.g. "200"). See prolog of rest_request |
| 206 | # method in redfish_plut.py for details. |
| 207 | |
| 208 | ${empty_dict}= Create Dictionary |
| 209 | ${patch_list}= Create List |
| 210 | |
| 211 | @{network_configurations}= Get Network Configuration |
| 212 | : FOR ${network_configuration} IN @{network_configurations} |
| 213 | \ Run Keyword If '${network_configuration['Address']}' == '${ip}' |
| 214 | ... Append To List ${patch_list} ${null} |
| 215 | ... ELSE Append To List ${patch_list} ${empty_dict} |
| 216 | |
| 217 | ${ip_found}= Run Keyword And Return Status List Should Contain Value |
| 218 | ... ${patch_list} ${null} msg=${ip} does not exist on BMC |
| 219 | Pass Execution If ${ip_found} == ${False} ${ip} does not exist on BMC |
| 220 | |
| 221 | # Run patch command only if given IP is found on BMC |
| 222 | ${data}= Create Dictionary IPv4Addresses=${patch_list} |
| 223 | |
| 224 | Redfish.patch ${REDFISH_NW_ETH0_URI} body=&{data} |
| 225 | ... valid_status_codes=[${valid_status_codes}] |
| 226 | |
| 227 | # Note: Network restart takes around 15-18s after patch request processing |
| 228 | Sleep ${NETWORK_TIMEOUT}s |
| 229 | Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} |
| 230 | |
| 231 | ${delete_status}= Run Keyword And Return Status Verify IP On BMC ${ip} |
| 232 | Run Keyword If '${valid_status_codes}' == '${HTTP_OK}' |
| 233 | ... Should Be True ${delete_status} == ${False} |
| 234 | ... ELSE Should Be True ${delete_status} == ${True} |
| 235 | |
| 236 | Validate Network Config On BMC |
| 237 | |
| 238 | |
| 239 | Validate Network Config On BMC |
| 240 | [Documentation] Check that network info obtained via redfish matches info |
| 241 | ... obtained via CLI. |
| 242 | |
| 243 | @{network_configurations}= Get Network Configuration |
| 244 | ${ip_data}= Get BMC IP Info |
| 245 | : FOR ${network_configuration} IN @{network_configurations} |
| 246 | \ Should Contain Match ${ip_data} ${network_configuration['Address']}/* |
| 247 | ... msg=IP address does not exist. |
| 248 | |
George Keishing | 5d46755 | 2019-02-08 23:30:48 -0600 | [diff] [blame] | 249 | |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 250 | Verify Netmask On BMC |
| 251 | [Documentation] Verify netmask on BMC. |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 252 | [Arguments] ${netmask} |
| 253 | |
| 254 | # Description of the argument(s): |
| 255 | # netmask netmask value to be verified. |
| 256 | |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 257 | ${prefix_length}= Netmask Prefix Length ${netmask} |
| 258 | |
| 259 | Should Contain Match ${ip_data} */${prefix_length} |
| 260 | ... msg=Prefix length does not exist. |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 261 | |
Prashanth Katti | 2ec9d8b | 2019-02-12 05:20:19 -0600 | [diff] [blame] | 262 | Verify Gateway On BMC |
| 263 | [Documentation] Verify gateway on BMC. |
| 264 | [Arguments] ${gateway_ip}=0.0.0.0 |
| 265 | |
| 266 | # Description of argument(s): |
| 267 | # gateway_ip Gateway IP address. |
| 268 | |
| 269 | ${route_info}= Get BMC Route Info |
| 270 | |
| 271 | # If gateway IP is empty or 0.0.0.0 it will not have route entry. |
| 272 | |
| 273 | Run Keyword If '${gateway_ip}' == '0.0.0.0' |
| 274 | ... Pass Execution Gateway IP is "0.0.0.0". |
| 275 | ... ELSE |
| 276 | ... Should Contain ${route_info} ${gateway_ip} |
| 277 | ... msg=Gateway IP address not matching. |
George Keishing | 5d46755 | 2019-02-08 23:30:48 -0600 | [diff] [blame] | 278 | |
Prashanth Katti | 2c5c3bb | 2019-02-14 04:23:07 -0600 | [diff] [blame] | 279 | Verify IP And Netmask On BMC |
| 280 | [Documentation] Verify IP and netmask on BMC. |
| 281 | [Arguments] ${ip} ${netmask} |
| 282 | |
| 283 | # Description of the argument(s): |
| 284 | # ip IP address to be verified. |
| 285 | # netmask netmask value to be verified. |
| 286 | |
| 287 | ${prefix_length}= Netmask Prefix Length ${netmask} |
| 288 | @{ip_data}= Get BMC IP Info |
| 289 | |
| 290 | ${ip_with_netmask}= Catenate ${ip}/${prefix_length} |
| 291 | Should Contain ${ip_data} ${ip_with_netmask} |
| 292 | ... msg=IP and netmask pair does not exist. |
| 293 | |
Prashanth Katti | 23efc6e | 2019-03-13 06:07:15 -0500 | [diff] [blame] | 294 | Configure Hostname |
| 295 | [Documentation] Configure hostname on BMC via Redfish. |
| 296 | [Arguments] ${hostname} |
| 297 | |
| 298 | # Description of argument(s): |
| 299 | # hostname A hostname value which is to be configured on BMC. |
| 300 | |
| 301 | ${data}= Create Dictionary HostName=${hostname} |
| 302 | Redfish.patch ${REDFISH_NW_PROTOCOL_URI} body=&{data} |
| 303 | |
| 304 | Validate Hostname On BMC |
| 305 | [Documentation] Verify that the hostname read via Redfish is the same as the |
| 306 | ... hostname configured on system. |
| 307 | [Arguments] ${hostname} |
| 308 | |
| 309 | # Description of argument(s): |
| 310 | # hostname A hostname value which is to be compared to the hostname |
| 311 | # configured on system. |
| 312 | |
| 313 | ${sys_hostname}= Get BMC Hostname |
Prashanth Katti | 466d834 | 2019-03-21 08:58:50 -0500 | [diff] [blame] | 314 | Should Be Equal ${sys_hostname} ${hostname} |
Prashanth Katti | 23efc6e | 2019-03-13 06:07:15 -0500 | [diff] [blame] | 315 | ... ignore_case=True msg=Hostname does not exist. |
| 316 | |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 317 | Test Teardown Execution |
| 318 | [Documentation] Test teardown execution. |
| 319 | |
| 320 | FFDC On Test Case Fail |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 321 | Redfish.Logout |