Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test setting VLAN and its configuration. |
| 3 | |
| 4 | |
| 5 | Resource ../lib/rest_client.robot |
| 6 | Resource ../lib/ipmi_client.robot |
| 7 | Resource ../lib/utils.robot |
| 8 | Resource ../lib/common_utils.robot |
| 9 | Resource ../lib/openbmc_ffdc.robot |
| 10 | Resource ../lib/ipmi_client.robot |
| 11 | Resource ../lib/bmc_network_utils.robot |
| 12 | Resource ../lib/state_manager.robot |
| 13 | Library ../lib/utilities.py |
| 14 | Library ../lib/ipmi_utils.py |
| 15 | Library ../lib/var_funcs.py |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 16 | Library ../lib/func_args.py |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 17 | Library Collections |
| 18 | |
| 19 | Suite Teardown Suite Teardown Execution |
| 20 | |
George Keishing | 87dc442 | 2023-10-20 12:56:30 +0530 | [diff] [blame] | 21 | Force Tags VLAN_Network |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 22 | |
| 23 | *** Variables *** |
George Keishing | 87dc442 | 2023-10-20 12:56:30 +0530 | [diff] [blame] | 24 | |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 25 | ${vlan_id} ${53} |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 26 | @{vlan_ids} ${35} ${55} |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 27 | ${invalid_vlan_id} abc |
| 28 | ${vlan_resource} ${NETWORK_MANAGER}action/VLAN |
| 29 | ${network_resource} xyz.openbmc_project.Network.IP.Protocol.IPv4 |
| 30 | ${static_network_resource} xyz.openbmc_project.Network.IP.AddressOrigin.Static |
| 31 | ${ip} 10.6.6.10 |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 32 | @{ip_addresses} 10.5.5.10 10.4.5.7 |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 33 | ${netmask} ${24} |
| 34 | ${gateway} 0.0.0.0 |
| 35 | ${initial_vlan_config} @{EMPTY} |
| 36 | |
| 37 | |
| 38 | *** Test Cases *** |
| 39 | |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 40 | Add VLAN Via REST And Verify |
| 41 | [Documentation] Add VLAN via REST and verify it via REST and IPMI. |
| 42 | [Tags] Add_VLAN_Via_REST_And_Verify |
| 43 | [Setup] Test Setup Execution |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 44 | [Teardown] Delete VLANs [${vlan_id}] |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 45 | |
| 46 | Create VLAN ${vlan_id} |
| 47 | Verify Existence Of VLAN ${vlan_id} |
| 48 | |
| 49 | ${lan_config}= Get LAN Print Dict |
| 50 | Valid Value lan_config['802.1q VLAN ID'] ["${vlan_id}"] |
| 51 | |
| 52 | |
| 53 | Add Invalid VLAN Via REST And Verify |
| 54 | [Documentation] Add Invalid VLAN via REST and verify. |
| 55 | [Tags] Add_Invalid_VLAN_Via_REST_And_Verify |
| 56 | |
| 57 | Create VLAN ${invalid_vlan_id} expected_result=error |
| 58 | |
| 59 | |
| 60 | Delete VLAN Via REST |
| 61 | [Documentation] Delete VLAN via REST and verify it via REST and IPMI. |
| 62 | [Tags] Delete_VLAN_Via_REST |
| 63 | [Setup] Run Keywords Test Setup Execution AND Create VLAN ${vlan_id} |
| 64 | |
| 65 | Verify Existence Of VLAN ${vlan_id} |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 66 | Delete VLANs [${vlan_id}] |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 67 | Verify Existence Of VLAN ${vlan_id} expected_result=error |
| 68 | |
| 69 | ${lan_config}= Get LAN Print Dict |
| 70 | Valid Value lan_config['802.1q VLAN ID'] ["Disabled"] |
| 71 | |
| 72 | |
| 73 | Configure Network Settings On VLAN Via REST |
| 74 | [Documentation] Configure IP on VLAN and verify it via REST and IPMI. |
| 75 | [Tags] Configure_Network_Settings_On_VLAN_Via_REST |
| 76 | [Setup] Run Keywords Test Setup Execution AND Create VLAN ${vlan_id} |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 77 | [Teardown] Delete VLANs [${vlan_id}] |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 78 | |
| 79 | Configure Network Settings On VLAN ${vlan_id} ${ip} ${netmask} |
| 80 | Get VLAN URI For IP ${vlan_id} ${ip} |
| 81 | |
| 82 | ${lan_config}= Get LAN Print Dict |
| 83 | Valid Value lan_config['IP Address'] ["${ip}"] |
| 84 | |
| 85 | |
| 86 | Delete IP On VLAN Via REST |
| 87 | [Documentation] Delete IP on VLAN and verify it via REST and IPMI. |
| 88 | [Tags] Delete_IP_On_VLAN_Via_REST |
| 89 | [Setup] Run Keywords Test Setup Execution AND Create VLAN ${vlan_id} |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 90 | [Teardown] Delete VLANs [${vlan_id}] |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 91 | |
| 92 | Configure Network Settings On VLAN ${vlan_id} ${ip} ${netmask} |
| 93 | ${lan_config}= Get LAN Print Dict |
| 94 | Valid Value lan_config['IP Address'] ["${ip}"] |
| 95 | |
| 96 | ${vlan_ip_uri}= Get VLAN URI For IP ${vlan_id} ${ip} |
| 97 | Delete IP And Object ${ip} ${vlan_ip_uri} |
| 98 | |
| 99 | Get VLAN URI For IP ${vlan_id} ${ip} expected_result=error |
| 100 | |
| 101 | ${lan_config}= Get LAN Print Dict |
| 102 | Should Not Match ${lan_config['IP Address']} ${ip} |
| 103 | |
| 104 | |
| 105 | Delete VLAN When IP Is Configured Via REST |
| 106 | [Documentation] Delete IP on VLAN and verify using IPMI. |
| 107 | [Tags] Delete_VLAN_When_IP_Is_Configured_Via_REST |
| 108 | [Setup] Run Keywords Test Setup Execution AND Create VLAN ${vlan_id} |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 109 | [Teardown] Delete VLANs [${vlan_id}] |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 110 | |
| 111 | Configure Network Settings On VLAN ${vlan_id} ${ip} ${netmask} |
| 112 | ${lan_config}= Get LAN Print Dict |
| 113 | Valid Value lan_config['IP Address'] ["${ip}"] |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 114 | Delete VLANs [${vlan_id}] |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 115 | |
| 116 | Verify Existence Of VLAN ${vlan_id} expected_result=error |
| 117 | |
| 118 | ${lan_config}= Get LAN Print Dict |
| 119 | Valid Value lan_config['802.1q VLAN ID'] ["Disabled"] |
| 120 | |
| 121 | |
| 122 | Configure VLAN And Check Persistency On Reboot |
| 123 | [Documentation] Create VLAN ID & IP , reboot and verify. |
| 124 | [Tags] Configure_VLAN_And_Check_Persistency_On_Reboot |
| 125 | [Setup] Test Setup Execution |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 126 | [Teardown] Delete VLANs [${vlan_id}] |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 127 | |
| 128 | Create VLAN ${vlan_id} |
| 129 | Configure Network Settings On VLAN ${vlan_id} ${ip} ${netmask} |
| 130 | ${lan_config}= Get LAN Print Dict |
| 131 | Valid Value lan_config['IP Address'] ["${ip}"] |
| 132 | Valid Value lan_config['802.1q VLAN ID'] ["${vlan_id}"] |
| 133 | |
| 134 | Initiate BMC Reboot |
| 135 | |
| 136 | Verify Existence Of VLAN ${vlan_id} |
| 137 | Get VLAN URI For IP ${vlan_id} ${ip} |
| 138 | |
| 139 | ${lan_config}= Get LAN Print Dict |
| 140 | Valid Value lan_config['IP Address'] ["${ip}"] |
| 141 | Valid Value lan_config['802.1q VLAN ID'] ["${vlan_id}"] |
| 142 | |
| 143 | |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 144 | Add Multiple VLANs Via REST And Verify |
| 145 | [Documentation] Add multiple VLANs via REST and verify them via CLI. |
| 146 | [Tags] Add_Multiple_VLANs_Via_REST_And_Verify |
| 147 | [Setup] Test Setup Execution |
| 148 | [Teardown] Delete VLANs ${vlan_ids} |
| 149 | |
| 150 | FOR ${vlan_id} IN @{vlan_ids} |
| 151 | Create VLAN ${vlan_id} |
| 152 | Verify Existence Of VLAN ${vlan_id} |
| 153 | END |
| 154 | |
| 155 | ${lan_config}= Get LAN Print Dict |
| 156 | ${vlan_id_ipmi}= Convert To Integer ${lan_config["802.1q VLAN ID"]} |
| 157 | Valid List vlan_ids required_values=[${vlan_id_ipmi}] |
| 158 | |
| 159 | Delete Multiple IPs On VLAN And Verify |
| 160 | [Documentation] Delete multiple IPs on VLAN and verify each via REST and IPMI. |
George Keishing | b98036a | 2022-01-31 12:39:47 -0600 | [diff] [blame] | 161 | [Tags] Delete_Multiple_IPs_On_VLAN_And_Verify |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 162 | [Setup] Run Keywords Test Setup Execution AND Create VLAN ${vlan_id} |
| 163 | [Teardown] Delete VLANs [${vlan_id}] |
| 164 | |
| 165 | FOR ${ip} IN @{ip_addresses} |
| 166 | Configure Network Settings On VLAN ${vlan_id} ${ip} ${netmask} |
| 167 | ${vlan_ip_uri}= Get VLAN URI For IP ${vlan_id} ${ip} |
| 168 | Delete IP And Object ${ip} ${vlan_ip_uri} |
| 169 | |
| 170 | Get VLAN URI For IP ${vlan_id} ${ip} expected_result=error |
| 171 | |
| 172 | ${lan_config}= Get LAN Print Dict |
| 173 | Should Not Match ${lan_config['IP Address']} ${ip} |
| 174 | END |
| 175 | |
| 176 | Delete Multiple VLANs Via REST |
| 177 | [Documentation] Delete multiple VLANs via REST and verify each via REST and IPMI. |
| 178 | [Tags] Delete_Multiple_VLANs_Via_REST |
| 179 | [Setup] Test Setup Execution |
| 180 | |
| 181 | FOR ${vlan_id} IN @{vlan_ids} |
| 182 | Create VLAN ${vlan_id} |
| 183 | END |
| 184 | |
| 185 | Delete VLANs ${vlan_ids} |
| 186 | |
| 187 | ${lan_config}= Get LAN Print Dict |
| 188 | Valid Value lan_config['802.1q VLAN ID'] ["Disabled"] |
| 189 | |
| 190 | Configure Multiple IPs On VLAN Via REST |
| 191 | [Documentation] Configure Multiple IPs on VLAN and verify each via REST. |
| 192 | [Tags] Configure_Multiple_IPs_On_VLAN_Via_REST |
| 193 | [Setup] Run Keywords Test Setup Execution AND Create VLAN ${vlan_id} |
| 194 | [Teardown] Delete VLANs [${vlan_id}] |
| 195 | |
| 196 | FOR ${ip} IN @{ip_addresses} |
| 197 | Configure Network Settings On VLAN ${vlan_id} ${ip} ${netmask} |
| 198 | END |
| 199 | |
| 200 | ${lan_config}= Get LAN Print Dict |
| 201 | Valid Value lan_config['IP Address'] ["${ip_addresses[0]}"] |
| 202 | |
Anvesh Kumar Rayankula | 80d6b5a | 2020-04-06 05:57:06 -0500 | [diff] [blame] | 203 | |
| 204 | Create And Delete VLAN And IP On It Multiple Times With BMC Reboot |
| 205 | [Documentation] Create and delete VLAN and IP on it multiple times with BMC reboot. |
| 206 | [Tags] Create_And_Delete_VLAN_And_IP_On_It_Multiple_Times_With_BMC_Reboot |
| 207 | [Setup] Test Setup Execution |
| 208 | |
| 209 | FOR ${i} IN RANGE ${5} |
| 210 | Create VLAN ${vlan_id} |
| 211 | Verify Existence Of VLAN ${vlan_id} |
| 212 | Configure Network Settings On VLAN ${vlan_id} ${ip} ${netmask} |
| 213 | ${vlan_ip_uri}= Get VLAN URI For IP ${vlan_id} ${ip} |
| 214 | Delete IP And Object ${ip} ${vlan_ip_uri} |
| 215 | Get VLAN URI For IP ${vlan_id} ${ip} expected_result=error |
| 216 | Delete VLANs [${vlan_id}] |
| 217 | Verify Existence Of VLAN ${vlan_id} expected_result=error |
| 218 | Initiate BMC Reboot |
| 219 | Sleep ${NETWORK_TIMEOUT}s |
| 220 | Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} |
| 221 | Verify Existence Of VLAN ${vlan_id} expected_result=error |
| 222 | END |
| 223 | |
| 224 | ${lan_config}= Get LAN Print Dict |
| 225 | Valid Value lan_config['802.1q VLAN ID'] ["Disabled"] |
| 226 | |
| 227 | |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 228 | *** Keywords *** |
| 229 | |
| 230 | |
| 231 | Test Setup Execution |
| 232 | [Documentation] Check and delete all previously created VLAN if any. |
| 233 | |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 234 | Printn |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 235 | ${lan_config}= Get LAN Print Dict |
| 236 | Return From Keyword If '${lan_config['802.1q VLAN ID']}' == 'Disabled' |
| 237 | |
| 238 | # Get all VLAN ID on interface eth0. |
| 239 | ${vlan_ids}= Get VLAN IDs |
| 240 | |
| 241 | ${initial_vlan_config}= Create List |
| 242 | Set Suite Variable ${initial_vlan_config} |
| 243 | |
| 244 | FOR ${vlan_id} IN @{vlan_ids} |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 245 | ${vlan_records}= Read Properties |
| 246 | ... ${NETWORK_MANAGER}eth0_${vlan_id}${/}enumerate quiet=1 |
| 247 | ${vlan_record}= Filter Struct |
| 248 | ... ${vlan_records} [('Origin', '${static_network_resource}')] |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 249 | |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 250 | ${id}= Convert To Integer ${vlan_id} |
| 251 | Set Initial VLAN Config ${vlan_record} ${id} |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 252 | END |
| 253 | Rprint Vars initial_vlan_config |
| 254 | |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 255 | Delete VLANs ${vlan_ids} |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 256 | |
| 257 | |
| 258 | Set Initial VLAN Config |
| 259 | [Documentation] Set suite level list of Initial VLAN Config. |
| 260 | [Arguments] ${vlan_record} ${id} |
| 261 | |
| 262 | # Description of argument(s): |
| 263 | # vlan_record Dictionary of IP configuration information of a VLAN. |
| 264 | # Example: |
| 265 | # /xyz/openbmc_project/network/eth0_55/ipv4/5fb2cfe6": { |
| 266 | # "Address": "x.x.x.x", |
| 267 | # "Gateway": "", |
| 268 | # "Origin": "xyz.openbmc_project.Network.IP.AddressOrigin.Static", |
| 269 | # "PrefixLength": 16, |
| 270 | # "Type": "xyz.openbmc_project.Network.IP.Protocol.IPv4"} |
| 271 | # |
| 272 | # id The VLAN ID corresponding to the IP Configuration records contained |
| 273 | # in the variable "vlan_record". |
| 274 | |
| 275 | ${uris}= Get Dictionary Keys ${vlan_record} |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 276 | |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 277 | FOR ${uri} IN @{uris} |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 278 | Append To List ${initial_vlan_config} ${id} ${vlan_record['${uri}']['Address']} |
| 279 | ... ${vlan_record['${uri}']['PrefixLength']} |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 280 | END |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 281 | |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 282 | Run Keyword If @{uris} == @{EMPTY} |
| 283 | ... Append To List ${initial_vlan_config} ${id} ${EMPTY} ${EMPTY} |
| 284 | |
| 285 | |
| 286 | Suite Teardown Execution |
| 287 | [Documentation] Restore VLAN configuration. |
| 288 | |
| 289 | ${length}= Get Length ${initial_vlan_config} |
| 290 | Return From Keyword If ${length} == ${0} |
| 291 | |
| 292 | ${previous_id}= Set Variable ${EMPTY} |
| 293 | FOR ${index} IN RANGE 0 ${length} 3 |
| 294 | |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 295 | Run Keyword If '${initial_vlan_config[${index+1}]}' == '${EMPTY}' |
| 296 | ... Create VLAN ${initial_vlan_config[${index}]} |
| 297 | ... ELSE IF '${previous_id}' == '${initial_vlan_config[${index}]}' |
| 298 | ... Configure Network Settings On VLAN ${initial_vlan_config[${index}]} |
| 299 | ... ${initial_vlan_config[${index+1}]} ${initial_vlan_config[${index+2}]} |
| 300 | ... ELSE Run Keywords Create VLAN ${initial_vlan_config[${index}]} AND |
| 301 | ... Configure Network Settings On VLAN ${initial_vlan_config[${index}]} |
| 302 | ... ${initial_vlan_config[${index+1}]} ${initial_vlan_config[${index+2}]} |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 303 | |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 304 | ${previous_id}= Set Variable ${initial_vlan_config[${index}]} |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 305 | END |
| 306 | |
| 307 | |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 308 | Delete VLANs |
| 309 | [Documentation] Delete one or more VLANs. |
| 310 | [Arguments] ${ids} ${interface}=eth0 |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 311 | |
| 312 | # Description of argument(s): |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 313 | # ids A list of VLAN IDs (e.g. ['53'] or ['53', '35', '12']). Note that the |
| 314 | # caller may simply pass a list variable or he/she may specify a |
| 315 | # python-like list specification (see examples below). |
| 316 | # interface The physical interface for the VLAN (e.g. 'eth0'). |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 317 | |
Anvesh Kumar Rayankula | 14455f4 | 2019-12-12 03:06:21 -0600 | [diff] [blame] | 318 | # Example calls: |
| 319 | # Delete VLANs ${vlan_ids} |
| 320 | # Delete Vlans [53, 35] |
| 321 | |
| 322 | # Allow for python-like list specifications (e.g. ids=['53']). |
| 323 | ${vlan_ids}= Source To Object ${ids} |
| 324 | |
| 325 | FOR ${id} IN @{vlan_ids} |
| 326 | OpenBMC Delete Request ${NETWORK_MANAGER}${interface}_${id} |
| 327 | END |
| 328 | Run Key U Sleep \ ${NETWORK_TIMEOUT}s |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 329 | |
| 330 | |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 331 | Get VLAN IDs |
| 332 | [Documentation] Return all VLAN IDs. |
| 333 | |
| 334 | ${vlan_ids} ${stderr} ${rc}= BMC Execute Command |
| 335 | ... /sbin/ip addr | grep @eth0 | cut -f1 -d@ | cut -f2 -d. |
| 336 | ${vlan_ids}= Split String ${vlan_ids} |
| 337 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame^] | 338 | RETURN @{vlan_ids} |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 339 | |
| 340 | |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 341 | Get VLAN URI For IP |
| 342 | [Documentation] Get and return the URI for a VLAN IP. |
| 343 | [Arguments] ${vlan_id} ${vlan_ip} ${expected_result}=valid |
| 344 | |
| 345 | # Description of argument(s): |
| 346 | # vlan_id The VLAN ID (e.g. '53'). |
| 347 | # vlan_ip The VLAN IP (e.g. 'x.x.x.x'). |
| 348 | |
| 349 | ${vlan_records}= Read Properties |
| 350 | ... ${NETWORK_MANAGER}eth0_${vlan_id}${/}enumerate quiet=1 |
| 351 | ${vlan_record}= Filter Struct ${vlan_records} [('Address', '${vlan_ip}')] |
| 352 | ${num_vlan_records}= Get Length ${vlan_record} |
| 353 | ${status}= Run Keyword And Return Status Should Be True ${num_vlan_records} > 0 |
| 354 | ... msg=Could not find a uri for vlan "${vlan_id}" with IP "${vlan_ip}". |
| 355 | |
| 356 | Run Keyword If '${expected_result}' == 'valid' |
| 357 | ... Should Be Equal ${status} ${True} |
George Keishing | f702219 | 2019-12-11 11:30:09 -0600 | [diff] [blame] | 358 | ... msg=VLAN IP URI doesn't exist!. |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 359 | ... ELSE |
| 360 | ... Should Be Equal ${status} ${False} |
| 361 | ... msg=VLAN IP URI exists!. |
| 362 | ${uris}= Get Dictionary Keys ${vlan_record} |
| 363 | Return From Keyword If @{uris} == @{EMPTY} |
| 364 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame^] | 365 | RETURN ${uris[${0}]} |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 366 | |
| 367 | |
| 368 | Verify Existence Of VLAN |
| 369 | [Documentation] Verify VLAN ID exists. |
| 370 | [Arguments] ${id} ${interface}=eth0 ${expected_result}=valid |
| 371 | |
| 372 | # Description of argument(s): |
| 373 | # id The VLAN ID (e.g. id:'53'). |
| 374 | # interface Physical Interface on which the VLAN is defined. |
| 375 | # expected_result Expected status to check existence or non-existence of VLAN. |
| 376 | |
| 377 | ${vlan_ids}= Get VLAN IDs |
| 378 | ${cli_status}= Run Keyword And Return Status |
| 379 | ... Valid List vlan_ids required_values=['${id}'] |
| 380 | |
| 381 | ${network_records}= Read Properties ${NETWORK_MANAGER} |
| 382 | ${rest_status}= Run Keyword And Return Status Valid List network_records |
| 383 | ... required_values=['${NETWORK_MANAGER}${interface}_${id}'] |
| 384 | |
| 385 | Should Be Equal ${rest_status} ${cli_status} |
| 386 | ... msg=REST and CLI Output are not the same. |
| 387 | Run Keyword If '${expected_result}' == 'valid' |
| 388 | ... Should Be Equal ${rest_status} ${True} |
George Keishing | f702219 | 2019-12-11 11:30:09 -0600 | [diff] [blame] | 389 | ... msg=VLAN ID doesn't exist!. |
Naman Navin Hegde | ad14a72 | 2019-11-04 12:28:21 -0600 | [diff] [blame] | 390 | ... ELSE |
| 391 | ... Should Be Equal ${rest_status} ${False} |
| 392 | ... msg=VLAN ID exists!. |