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