1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
15 | Library | resources.libraries.python.InterfaceUtil
16 | ... | WITH NAME | interfaceCLI
17 | Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
18 | ... | WITH NAME | InterfaceAPI
22 | | [Documentation] | Uses VPP binary API to ensure that the interface under\
23 | | ... | test is in the specified admin state.
25 | | ... | *Arguments:*
26 | | ... | - node - information about a DUT node. Type: dictionary
27 | | ... | - interface - name of an interface on the specified node. Type: string
28 | | ... | - state - state to set on interface. Type:string
32 | | ... | \| Interface state is \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \
34 | | [Arguments] | ${node} | ${interface} | ${state}
35 | | interfaceCLI.Set interface state | ${node} | ${interface} | ${state}
36 | | ... | if_type=name
38 | Honeycomb sets interface state
39 | | [Documentation] | Uses Honeycomb API to change the admin state\
40 | | ... | of the specified interface.
42 | | ... | *Arguments:*
43 | | ... | - node - information about a DUT node. Type: dictionary
44 | | ... | - interface - name of an interface on the specified node. Type: string
45 | | ... | - state - state to set on interface. Type:string
49 | | ... | \| Honeycomb sets interface state \| ${nodes['DUT1']} \
50 | | ... | \| GigabitEthernet0/8/0 \| up \|
51 | | [Arguments] | ${node} | ${interface} | ${state}
52 | | interfaceAPI.Set interface state | ${node} | ${interface} | ${state}
54 | Interface state from Honeycomb should be
55 | | [Documentation] | Retrieves interface admin state through Honeycomb and\
56 | | ... | compares with state supplied in argument.
58 | | ... | *Arguments:*
59 | | ... | - node - information about a DUT node. Type: dictionary
60 | | ... | - interface - name of an interface on the specified node. Type: string
61 | | ... | - state - expected interface state. Type: string
65 | | ... | \| Interface state from Honeycomb should be \| ${nodes['DUT1']} \
66 | | ... | \| GigabitEthernet0/8/0 \| up \|
67 | | [Arguments] | ${node} | ${interface} | ${state}
68 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
69 | | ${api_state}= | Set Variable | ${api_data['admin-status']}
70 | | Should be equal | ${api_state} | ${state}
72 | Interface state from VAT should be
73 | | [Documentation] | Retrieves interface admin state through VAT and compares\
74 | | ... | with state supplied in argument.
76 | | ... | *Arguments:*
77 | | ... | - node - information about a DUT node. Type: dictionary
78 | | ... | - interface - name of an interface on the specified node. Type: string
79 | | ... | - state - expected interface state. Type: string
81 | | ... | _NOTE:_ Vat returns state as int (1/0) instead of string (up/down).
82 | | ... | This keyword also handles translation.
86 | | ... | \| Interface state from VAT should be \| ${nodes['DUT1']} \
87 | | ... | \| GigabitEthernet0/8/0 \| up \|
88 | | [Arguments] | ${node} | ${interface} | ${state}
89 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
90 | | ${vat_state}= | Set Variable if
91 | | ... | ${vat_data['admin_up_down']} == 1 | up | down
92 | | Should be equal | ${vat_state} | ${state}
94 | Honeycomb sets interface ipv4 address
95 | | [Documentation] | Uses Honeycomb API to change ipv4 configuration\
96 | | ... | of the specified interface.
98 | | ... | *Arguments:*
99 | | ... | - node - information about a DUT node. Type: dictionary
100 | | ... | - interface - name of an interface on the specified node. Type: string
101 | | ... | - address - IP address to set. Type: string
102 | | ... | - netmask - subnet mask to set. Type: string
103 | | ... | - settings - ipv4 interface settings. Type: dictionary
107 | | ... | \| Honeycomb sets interface ipv4 configuration \| ${nodes['DUT1']} \
108 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \
109 | | ... | \| ${{'enabled': True, 'mtu': 1500}} \|
110 | | [Arguments] | ${node} | ${interface} | ${address} | ${netmask}
111 | | ... | ${settings}
112 | | interfaceAPI.Add first ipv4 address
113 | | ... | ${node} | ${interface} | ${address} | ${netmask}
114 | | :FOR | ${key} | IN | @{settings.keys()}
115 | | | interfaceAPI.Configure interface ipv4
116 | | | ... | ${node} | ${interface} | ${key} | ${settings['${key}']}
117 | | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
119 | Honeycomb sets interface ipv4 address with prefix
120 | | [Documentation] | Uses Honeycomb API to assign an ipv4 address to the\
121 | | ... | specified interface. Any existing addresses will be removed.
123 | | ... | *Arguments:*
124 | | ... | - node - information about a DUT node. Type: dictionary
125 | | ... | - interface - name of an interface on the specified node. Type: string
126 | | ... | - address - IP address to set. Type: string
127 | | ... | - prefix - length of address network prefix. Type: int
128 | | ... | - settings - ipv4 interface settings. Type: dictionary
132 | | ... | \| Honeycomb sets interface ipv4 address with prefix \
133 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 24 \|
134 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
135 | | ... | ${settings}
136 | | interfaceAPI.Add first ipv4 address
137 | | ... | ${node} | ${interface} | ${address} | ${prefix}
138 | | :FOR | ${key} | IN | @{settings.keys()}
139 | | | interfaceAPI.Configure interface ipv4
140 | | | ... | ${node} | ${interface} | ${key} | ${settings['${key}']}
142 | Honeycomb adds interface ipv4 neighbor
143 | | [Documentation] | Uses Honeycomb API to assign an ipv4 neighbor to the\
144 | | ... | specified interface.
146 | | ... | *Arguments:*
147 | | ... | - node - information about a DUT node. Type: dictionary
148 | | ... | - interface - name of an interface on the specified node. Type: string
149 | | ... | - fib_address - IP address to add to fib table. Type: string
150 | | ... | - fib_mac - MAC address to add to fib table. Type: string
154 | | ... | \| Honeycomb adds interface ipv4 neighbor \| ${nodes['DUT1']} \
155 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.3 \| 08:00:27:c0:5d:37 \
156 | | ... | \| ${{'enabled': True, 'mtu': 1500}} \|
157 | | [Arguments] | ${node} | ${interface} | ${fib_address} | ${fib_mac}
158 | | interfaceAPI.Add ipv4 neighbor
159 | | ... | ${node} | ${interface} | ${fib_address} | ${fib_mac}
161 | IPv4 config from Honeycomb should be
162 | | [Documentation] | Retrieves interface ipv4 configuration through Honeycomb\
163 | | ... | and compares with state supplied in argument.
165 | | ... | *Arguments:*
166 | | ... | - node - information about a DUT node. Type: dictionary
167 | | ... | - interface - name of an interface on the specified node. Type: string
168 | | ... | - address - IP address to expect. Type: string
169 | | ... | - prefix - prefix length to expect. Type: string
170 | | ... | - fib_address - IP address to expect in fib table. Type: string
171 | | ... | - fib_mac - MAC address to expect in fib table. Type: string
172 | | ... | - settings - ipv4 interface settings to expect. Type: dictionary
176 | | ... | \| IPv4 config from Honeycomb should be \| ${nodes['DUT1']} \
177 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \
178 | | ... | \| 192.168.0.3 \| 08:00:27:c0:5d:37 \
179 | | ... | \| ${{'enabled': True, 'mtu': 1500}} \|
180 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
181 | | ... | ${fib_address} | ${fib_mac} | ${settings}
182 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
183 | | Should be equal | ${address}
184 | | ... | ${api_data['ietf-ip:ipv4']['address'][0]['ip']}
185 | | Should be equal | ${prefix}
186 | | ... | ${api_data['ietf-ip:ipv4']['address'][0]['prefix-length']}
187 | | Should be equal | ${fib_address}
188 | | ... | ${api_data['ietf-ip:ipv4']['neighbor'][0]['ip']}
189 | | Should be equal | ${fib_mac}
190 | | ... | ${api_data['ietf-ip:ipv4']['neighbor'][0]['link-layer-address']}
191 | | :FOR | ${key} | IN | @{settings.keys()}
192 | | | Should be equal
193 | | | ... | ${settings['${key}']} | ${api_data['ietf-ip:ipv4']['${key}']}
195 | IPv4 config from VAT should be
196 | | [Documentation] | Retrieves interface ipv4 configuration through VAT and\
197 | | ... | compares with state supplied in argument.
199 | | ... | *Arguments:*
200 | | ... | - node - information about a DUT node. Type: dictionary
201 | | ... | - interface - name of an interface on the specified node. Type: string
202 | | ... | - address - IP address to expect. Type: string
203 | | ... | - netmask - subnet mask to expect. Type: string
207 | | ... | \| IPv4 config from VAT should be \| ${nodes['DUT1']} \
208 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \|
209 | | [Arguments] | ${node} | ${interface} | ${address} | ${netmask}
210 | | ${vpp_data}= | interfaceCLI.VPP get interface ip addresses
211 | | ... | ${node} | ${interface} | ipv4
212 | | Should be equal | ${vpp_data[0]['ip']} | ${address}
213 | | Should be equal | ${vpp_data[0]['netmask']} | ${netmask}
215 | Honeycomb removes interface ipv4 addresses
216 | | [Documentation] | Removes all configured ipv4 addresses from the specified\
219 | | ... | *Arguments:*
220 | | ... | - node - information about a DUT node. Type: dictionary
221 | | ... | - interface - name of an interface on the specified node. Type: string
225 | | ... | \| Honeycomb removes interface ipv4 addresses \| ${nodes['DUT1']} \
226 | | ... | \| GigabitEthernet0/8/0 \|
227 | | [Arguments] | ${node} | ${interface}
228 | | Remove all ipv4 addresses | ${node} | ${interface}
230 | IPv4 address from Honeycomb should be empty
231 | | [Documentation] | Retrieves interface ipv4 configuration through Honeycomb\
232 | | ... | and expects to find no IPv4 addresses.
234 | | ... | *Arguments:*
235 | | ... | - node - information about a DUT node. Type: dictionary
236 | | ... | - interface - name of an interface on the specified node. Type: string
240 | | ... | \| IPv4 address from Honeycomb should be empty\| ${nodes['DUT1']} \
241 | | ... | \| GigabitEthernet0/8/0 \|
242 | | [Arguments] | ${node} | ${interface}
243 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
244 | | Should be empty | ${api_data['ietf-ip:ipv4']['address']
246 | IPv4 address from VAT should be empty
247 | | [Documentation] | Retrieves interface ipv4 configuration through VAT and\
248 | | ... | and expects to find no ipv4 addresses.
250 | | ... | *Arguments:*
251 | | ... | - node - information about a DUT node. Type: dictionary
252 | | ... | - interface - name of an interface on the specified node. Type: string
256 | | ... | \| IPv4 config from VAT should be empty \| ${nodes['DUT1']} \
257 | | ... | \| GigabitEthernet0/8/0 \|
258 | | [Arguments] | ${node} | ${interface}
259 | | Run keyword and expect error | *No JSON object could be decoded.*
260 | | ... | InterfaceCLI.VPP get interface ip addresses
261 | | ... | ${node} | ${interface} | ipv4
263 | Honeycomb sets interface ipv6 configuration
264 | | [Documentation] | Uses Honeycomb API to change ipv6 configuration\
265 | | ... | of the specified interface.
267 | | ... | *Arguments:*
268 | | ... | - node - information about a DUT node. Type: dictionary
269 | | ... | - interface - name of an interface on the specified node. Type: string
270 | | ... | - address - IP address to set. Type: string
271 | | ... | - prefix - length of subnet prefix to set. Type: string
272 | | ... | - fib_address - IP address to add to fib table. Type: string
273 | | ... | - fib_mac - MAC address to add to fib table. Type: string
274 | | ... | - settings - ipv6 interface settings. Type: dictionary
278 | | ... | \| Honeycomb sets interface ipv6 configuration \| ${nodes['DUT1']} \
279 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \
280 | | ... | \| 10::11 \| 08:00:27:c0:5d:37 \| ${{'enabled': True, 'mtu': 1500}} \|
281 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
282 | | ... | ${fib_address} | ${fib_mac} | ${settings}
283 | | interfaceAPI.Add first ipv6 address
284 | | ... | ${node} | ${interface} | ${address} | ${prefix}
285 | | interfaceAPI.Add first ipv6 neighbor
286 | | ... | ${node} | ${interface} | ${fib_address} | ${fib_mac}
287 | | :FOR | ${key} | IN | @{settings.keys()}
288 | | | interfaceAPI.Configure interface ipv6
289 | | | ... | ${node} | ${interface} | ${key} | ${settings['${key}']}
291 | IPv6 config from Honeycomb should be
292 | | [Documentation] | Retrieves interface ipv6 configuration through Honeycomb\
293 | | ... | and compares with state supplied in argument.
295 | | ... | *Arguments:*
296 | | ... | - node - information about a DUT node. Type: dictionary
297 | | ... | - interface - name of an interface on the specified node. Type: string
298 | | ... | - address - IP address to expect. Type: string
299 | | ... | - prefix - length of subnet prefix to expect. Type: string
300 | | ... | - fib_address - IP address to expect in fib table. Type: string
301 | | ... | - fib_mac - MAC address to expect in fib table. Type: string
302 | | ... | - settings - ipv6 interface settings to expect. Type: dictionary
306 | | ... | \| IPv6 config from Honeycomb should be \| ${nodes['DUT1']} \
307 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \
308 | | ... | \| 10::11 \| 08:00:27:c0:5d:37 \| ${{'enabled': True, 'mtu': 1500}} \|
309 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
310 | | ... | ${fib_address} | ${fib_mac} | ${settings}
311 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
312 | | Should be equal | ${address}
313 | | ... | ${api_data['ietf-ip:ipv6']['address'][0]['ip']}
314 | | Should be equal | ${prefix}
315 | | ... | ${api_data['ietf-ip:ipv6']['address'][0]['prefix-length']}
316 | | Should be equal | ${fib_address}
317 | | ... | ${api_data['ietf-ip:ipv6']['neighbor'][0]['ip']
318 | | Should be equal | ${fib_mac}
319 | | ... | ${api_data['ietf-ip:ipv6']['neighbor'][0]['link-layer-address']
320 | | :FOR | ${key} | IN | @{settings.keys()}
321 | | | Should be equal
322 | | ... | ${settings['{key']} | ${api_data['ietf-ip:ipv6']['{$key}']}
324 | IPv6 config from VAT should be
325 | | [Documentation] | Retrieves interface ipv6 configuration through VAT and\
326 | | ... | compares with state supplied in argument.
328 | | ... | *Arguments:*
329 | | ... | - node - information about a DUT node. Type: dictionary
330 | | ... | - interface - name of an interface on the specified node. Type: string
331 | | ... | - address - IP address to expect. Type: string
332 | | ... | - prefix - length of subnet prefix to expect. Type: string
336 | | ... | \| IPv6 config from VAT should be \| ${nodes['DUT1']} \
337 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \|
338 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
339 | | ${vpp_data}= | interfaceCLI.VPP get interface ip addresses
340 | | ... | ${node} | ${interface} | ipv6
341 | | Should be equal | ${vpp_data[0]['ip']} | ${address}
342 | | Should be equal | ${vpp_data[0]['prefix-length']} | ${prefix}
344 | Honeycomb sets interface ethernet and routing configuration
345 | | [Documentation] | Uses Honeycomb API to change interface configuration.
347 | | ... | *Arguments:*
348 | | ... | - node - information about a DUT node. Type: dictionary
349 | | ... | - interface - name of an interface on the specified node. Type: string
350 | | ... | - ethernet - interface ethernet settings. Type: dictionary
351 | | ... | - routing - interface routing settings. Type: dictionary
355 | | ... | \| Honeycomb sets interface ethernet and routing configuration \
356 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${{'mtu': 1500}} \
357 | | ... | \| ${{'vrf-if': 2}} \|
358 | | [Arguments] | ${node} | ${interface} | ${ethernet} | ${routing}
359 | | :FOR | ${key} | IN | @{ethernet.keys()}
360 | | | interfaceAPI.Configure interface ethernet
361 | | | ... | ${node} | ${interface} | ${key} | ${ethernet['${key}']}
362 | | :FOR | ${key} | IN | @{routing.keys()}
363 | | | interfaceAPI.Configure interface routing
364 | | | ... | ${node} | ${interface} | ${key} | ${routing['${key}']}
366 | Interface ethernet and routing configuration from Honeycomb should be
367 | | [Documentation] | Retrieves interface routing and ethernet configuration\
368 | | ... | through Honeycomb and compares with settings supplied in arguments.
370 | | ... | *Arguments:*
371 | | ... | - node - information about a DUT node. Type: dictionary
372 | | ... | - interface - name of an interface on the specified node. Type: string
373 | | ... | - ethernet - interface ethernet settings. Type: dictionary
374 | | ... | - routing - interface routing settings. Type: dictionary
378 | | ... | \| Interface ethernet and routing configuration from Honeycomb \
379 | | ... | should be \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \
380 | | ... | \| ${{'mtu': 1500}} \| ${{'vrf-id': 2}} \|
381 | | [Arguments] | ${node} | ${interface} | ${ethernet} | ${routing}
382 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
383 | | :FOR | ${key} | IN | @{ethernet.keys()}
384 | | | Should be equal
385 | | | ... | ${api_data['v3po:ethernet']['${key}']} | ${ethernet['${key}']}
386 | | :FOR | ${key} | IN | @{routing.keys()}
387 | | | Should be equal | ${api_data['${key}']} | ${routing['${key}']}
389 | Interface ethernet and routing configuration from VAT should be
390 | | [Documentation] | Retrieves interface routing and ethernet configuration\
391 | | ... | through VAT and compares with settings supplied in arguments.
393 | | ... | *Arguments:*
394 | | ... | - node - information about a DUT node. Type: dictionary
395 | | ... | - interface - name of an interface on the specified node. Type: string
396 | | ... | - mtu - value of maximum transmission unit expected. Type: integer
397 | | ... | - vrf-id - ID number of a VPN expected on interface. Type: integer
401 | | ... | \| Interface ethernet and routing configuration from VAT \
402 | | ... | should be \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${1500} \
404 | | [Arguments] | ${node} | ${interface} | ${mtu} | ${vrf-id}
405 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
406 | | Should be equal | ${vat_data['mtu']} | ${mtu}
408 | Interface configuration from Honeycomb should be empty
409 | | [Documentation] | Attempts to retrieve interface configuration through\
410 | | ... | Honeycomb and expects to get empty dictionary.
412 | | ... | *Arguments:*
413 | | ... | - node - information about a DUT node. Type: dictionary
414 | | ... | - interface - name of a interface on the specified node. Type:\
418 | | ... | \| Interface configuration from Honeycomb should be empty\
419 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \|
421 | | [Arguments] | ${node} | ${interface}
422 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
423 | | Should be empty | ${api_data}
425 | Interface configuration from VAT should be empty
426 | | [Documentation] | Attempts to retrieve Interface configuration through\
427 | | ... | VAT and expects to get empty dictionary.
429 | | ... | *Arguments:*
430 | | ... | - node - information about a DUT node. Type: dictionary
431 | | ... | - interface - name of a Interface on the specified node. Type:\
435 | | ... | \| Interface configuration from VAT should be empty\
436 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \|
438 | | [Arguments] | ${node} | ${interface} |
439 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
440 | | Should be empty | ${vat_data}
442 | Interface indices from Honeycomb and VAT should correspond
443 | | [Documentation] | Uses VAT and Honeycomb to get operational data about the\
444 | | ... | given interface and compares the interface indexes. The interface
445 | | ... | index from Honeycomb should be greater than index from VAT by one.
447 | | ... | *Arguments:*
448 | | ... | - node - information about a DUT node. Type: dictionary
449 | | ... | - interface - name of the interface to be checked. Type: string
453 | | ... | \| Interface indices from Honeycomb and VAT should correspond \
454 | | ... | \| ${nodes['DUT1']} \| vxlan_gpe_tunnel0 \|
456 | | [Arguments] | ${node} | ${interface}
458 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
459 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
460 | | ${sw_if_index}= | EVALUATE | ${vat_data['sw_if_index']} + 1
461 | | Should be equal as strings
462 | | ... | ${api_data['if-index']} | ${sw_if_index}