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
21 | Honeycomb sets interface state
22 | | [Documentation] | Uses Honeycomb API to change the admin state\
23 | | ... | of the specified interface.
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 | | ... | \| Honeycomb sets interface state \| ${nodes['DUT1']} \
33 | | ... | \| GigabitEthernet0/8/0 \| up \|
34 | | [Arguments] | ${node} | ${interface} | ${state}
35 | | interfaceAPI.Set interface state | ${node} | ${interface} | ${state}
37 | Interface state from Honeycomb should be
38 | | [Documentation] | Retrieves interface admin state through Honeycomb and\
39 | | ... | compares with state supplied in argument.
41 | | ... | *Arguments:*
42 | | ... | - node - information about a DUT node. Type: dictionary
43 | | ... | - interface - name of an interface on the specified node. Type: string
44 | | ... | - state - expected interface state. Type: string
48 | | ... | \| Interface state from Honeycomb should be \| ${nodes['DUT1']} \
49 | | ... | \| GigabitEthernet0/8/0 \| up \|
50 | | [Arguments] | ${node} | ${interface} | ${state}
51 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
52 | | ${api_state}= | Set Variable | ${api_data['admin-status']}
53 | | Should be equal | ${api_state} | ${state}
55 | Interface state from VAT should be
56 | | [Documentation] | Retrieves interface admin state through VAT and compares\
57 | | ... | with state supplied in argument.
59 | | ... | *Arguments:*
60 | | ... | - node - information about a DUT node. Type: dictionary
61 | | ... | - interface - name of an interface on the specified node. Type: string
62 | | ... | - state - expected interface state. Type: string
64 | | ... | _NOTE:_ Vat returns state as int (1/0) instead of string (up/down).
65 | | ... | This keyword also handles translation.
69 | | ... | \| Interface state from VAT should be \| ${nodes['DUT1']} \
70 | | ... | \| GigabitEthernet0/8/0 \| up \|
71 | | [Arguments] | ${node} | ${interface} | ${state}
72 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
73 | | ${vat_state}= | Set Variable if
74 | | ... | ${vat_data['admin_up_down']} == 1 | up | down
75 | | Should be equal | ${vat_state} | ${state}
77 | Honeycomb sets interface ipv4 address
78 | | [Documentation] | Uses Honeycomb API to change ipv4 address\
79 | | ... | of the specified interface.
81 | | ... | *Arguments:*
82 | | ... | - node - information about a DUT node. Type: dictionary
83 | | ... | - interface - name of an interface on the specified node. Type: string
84 | | ... | - address - IP address to set. Type: string
85 | | ... | - netmask - subnet mask to set. Type: string
89 | | ... | \| Honeycomb sets interface ipv4 address \| ${nodes['DUT1']} \
90 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \|
91 | | [Arguments] | ${node} | ${interface} | ${address} | ${netmask}
92 | | interfaceAPI.Add first ipv4 address
93 | | ... | ${node} | ${interface} | ${address} | ${netmask}
95 | Honeycomb sets interface ipv4 address with prefix
96 | | [Documentation] | Uses Honeycomb API to assign an ipv4 address to the\
97 | | ... | specified interface. Any existing addresses will be removed.
99 | | ... | *Arguments:*
100 | | ... | - node - information about a DUT node. Type: dictionary
101 | | ... | - interface - name of an interface on the specified node. Type: string
102 | | ... | - address - IP address to set. Type: string
103 | | ... | - prefix - length of address network prefix. Type: int
107 | | ... | \| Honeycomb sets interface ipv4 address with prefix \
108 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 24 \|
109 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
110 | | interfaceAPI.Add first ipv4 address
111 | | ... | ${node} | ${interface} | ${address} | ${prefix}
113 | IPv4 address from Honeycomb should be
114 | | [Documentation] | Retrieves interface ipv4 address through Honeycomb\
115 | | ... | and compares with state supplied in argument.
117 | | ... | *Arguments:*
118 | | ... | - node - information about a DUT node. Type: dictionary
119 | | ... | - interface - name of an interface on the specified node. Type: string
120 | | ... | - address - IP address to expect. Type: string
121 | | ... | - prefix - prefix length to expect. Type: string
125 | | ... | \| IPv4 address from Honeycomb should be \| ${nodes['DUT1']} \
126 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \
127 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
128 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
129 | | Should be equal | ${address}
130 | | ... | ${api_data['ietf-ip:ipv4']['address'][0]['ip']}
131 | | Should be equal | ${prefix}
132 | | ... | ${api_data['ietf-ip:ipv4']['address'][0]['prefix-length']}
134 | IPv4 address from VAT should be
135 | | [Documentation] | Retrieves interface ipv4 address through VAT and\
136 | | ... | compares with state supplied in argument.
138 | | ... | *Arguments:*
139 | | ... | - node - information about a DUT node. Type: dictionary
140 | | ... | - interface - name of an interface on the specified node. Type: string
141 | | ... | - address - IP address to expect. Type: string
142 | | ... | - netmask - subnet mask to expect. Type: string
146 | | ... | \| IPv4 address from VAT should be \| ${nodes['DUT1']} \
147 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.2 \| 255.255.255.0 \|
148 | | [Arguments] | ${node} | ${interface} | ${address} | ${netmask}
149 | | ${vpp_data}= | interfaceCLI.VPP get interface ip addresses
150 | | ... | ${node} | ${interface} | ipv4
151 | | Should be equal | ${vpp_data[0]['ip']} | ${address}
152 | | Should be equal | ${vpp_data[0]['netmask']} | ${netmask}
154 | Honeycomb removes interface ipv4 addresses
155 | | [Documentation] | Removes all configured ipv4 addresses from the specified\
158 | | ... | *Arguments:*
159 | | ... | - node - information about a DUT node. Type: dictionary
160 | | ... | - interface - name of an interface on the specified node. Type: string
164 | | ... | \| Honeycomb removes interface ipv4 addresses \| ${nodes['DUT1']} \
165 | | ... | \| GigabitEthernet0/8/0 \|
166 | | [Arguments] | ${node} | ${interface}
167 | | Remove all ipv4 addresses | ${node} | ${interface}
169 | IPv4 address from Honeycomb should be empty
170 | | [Documentation] | Retrieves interface ipv4 configuration through Honeycomb\
171 | | ... | and expects to find no IPv4 addresses.
173 | | ... | *Arguments:*
174 | | ... | - node - information about a DUT node. Type: dictionary
175 | | ... | - interface - name of an interface on the specified node. Type: string
179 | | ... | \| IPv4 address from Honeycomb should be empty\| ${nodes['DUT1']} \
180 | | ... | \| GigabitEthernet0/8/0 \|
181 | | [Arguments] | ${node} | ${interface}
182 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
183 | | Run keyword and expect error | *KeyError: 'ietf-ip:ipv4'
184 | | ... | Set Variable | ${api_data['ietf-ip:ipv4']['address']}
186 | IPv4 address from VAT should be empty
187 | | [Documentation] | Retrieves interface ipv4 configuration through VAT and\
188 | | ... | and expects to find no ipv4 addresses.
190 | | ... | *Arguments:*
191 | | ... | - node - information about a DUT node. Type: dictionary
192 | | ... | - interface - name of an interface on the specified node. Type: string
196 | | ... | \| IPv4 config from VAT should be empty \| ${nodes['DUT1']} \
197 | | ... | \| GigabitEthernet0/8/0 \|
198 | | [Arguments] | ${node} | ${interface}
199 | | Run keyword and expect error | *No JSON object could be decoded*
200 | | ... | InterfaceCLI.VPP get interface ip addresses
201 | | ... | ${node} | ${interface} | ipv4
203 | Honeycomb adds interface ipv4 neighbor
204 | | [Documentation] | Uses Honeycomb API to assign an ipv4 neighbor to the\
205 | | ... | specified interface.
207 | | ... | *Arguments:*
208 | | ... | - node - information about a DUT node. Type: dictionary
209 | | ... | - interface - name of an interface on the specified node. Type: string
210 | | ... | - fib_address - IP address to add to fib table. Type: string
211 | | ... | - fib_mac - MAC address to add to fib table. Type: string
215 | | ... | \| Honeycomb adds interface ipv4 neighbor \| ${nodes['DUT1']} \
216 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.3 \| 08:00:27:c0:5d:37 \
217 | | [Arguments] | ${node} | ${interface} | ${fib_address} | ${fib_mac}
218 | | interfaceAPI.Add ipv4 neighbor
219 | | ... | ${node} | ${interface} | ${fib_address} | ${fib_mac}
221 | IPv4 neighbor from Honeycomb should be
222 | | [Documentation] | Retrieves ipv4 neighbor list through Honeycomb\
223 | | ... | and compares with neighbor list supplied in argument.
225 | | ... | *Arguments:*
226 | | ... | - node - information about a DUT node. Type: dictionary
227 | | ... | - interface - name of an interface on the specified node. Type: string
228 | | ... | - neighbors - list of ipv4 neighbor dictionaries. Type: list
232 | | ... | \| IPv4 neighbor from Honeycomb should be \| ${nodes['DUT1']} \
233 | | ... | \| GigabitEthernet0/8/0 \| 192.168.0.4 \| 08:00:27:60:26:ab \|
234 | | [Arguments] | ${node} | ${interface} | @{neighbors}
235 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
236 | | ${data_neighbors}= | Set Variable | ${api_data['ietf-ip:ipv4']['neighbor']}
237 | | Compare data structures
238 | | ... | ${data_neighbors} | ${neighbors} | list_order=${False}
239 | | Should be equal | ${neighbor['fib_address']}
240 | | ... | ${api_data['ietf-ip:ipv4']['neighbor'][0]['ip']}
241 | | Should be equal | ${neighbor['fib_mac']}
242 | | ... | ${api_data['ietf-ip:ipv4']['neighbor'][0]['link-layer-address']}
244 | Honeycomb clears all interface ipv4 neighbors
245 | | [Documentation] | Uses Honeycomb API to assign an ipv4 neighbor to the\
246 | | ... | specified interface.
248 | | ... | *Arguments:*
249 | | ... | - node - information about a DUT node. Type: dictionary
250 | | ... | - interface - name of an interface on the specified node. Type: string
254 | | ... | \| Honeycomb clears all interface ipv4 neighbors \| ${nodes['DUT1']} \
255 | | ... | \| GigabitEthernet0/8/0 \|
256 | | [Arguments] | ${node} | ${interface}
257 | | interfaceAPI.Remove all ipv4 neighbors | ${node} | ${interface}
259 | Honeycomb sets interface ipv6 address
260 | | [Documentation] | Uses Honeycomb API to change ipv6 address\
261 | | ... | of the specified interface.
263 | | ... | *Arguments:*
264 | | ... | - node - information about a DUT node. Type: dictionary
265 | | ... | - interface - name of an interface on the specified node. Type: string
266 | | ... | - address - IP address to set. Type: string
267 | | ... | - prefix - length of subnet prefix to set. Type: string
271 | | ... | \| Honeycomb sets interface ipv6 address \| ${nodes['DUT1']} \
272 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \|
273 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
274 | | interfaceAPI.Add first ipv6 address
275 | | ... | ${node} | ${interface} | ${address} | ${prefix}
277 | IPv6 address from Honeycomb should be
278 | | [Documentation] | Retrieves interface ipv6 address through Honeycomb\
279 | | ... | and compares with state supplied in argument.
281 | | ... | *Arguments:*
282 | | ... | - node - information about a DUT node. Type: dictionary
283 | | ... | - interface - name of an interface on the specified node. Type: string
284 | | ... | - address - IP address to expect. Type: string
285 | | ... | - prefix - length of subnet prefix to expect. Type: string
289 | | ... | \| IPv6 address from Honeycomb should be \| ${nodes['DUT1']} \
290 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \|
291 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
292 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
293 | | Should be equal | ${address}
294 | | ... | ${api_data['ietf-ip:ipv6']['address'][0]['ip']}
295 | | Should be equal | ${prefix}
296 | | ... | ${api_data['ietf-ip:ipv6']['address'][0]['prefix-length']}
297 | | Should be equal | ${fib_address}
299 | IPv6 address from VAT should be
300 | | [Documentation] | Retrieves interface ipv6 address through VAT and\
301 | | ... | compares with state supplied in argument.
303 | | ... | *Arguments:*
304 | | ... | - node - information about a DUT node. Type: dictionary
305 | | ... | - interface - name of an interface on the specified node. Type: string
306 | | ... | - address - IP address to expect. Type: string
307 | | ... | - prefix - length of subnet prefix to expect. Type: string
311 | | ... | \| IPv6 address from VAT should be \| ${nodes['DUT1']} \
312 | | ... | \| GigabitEthernet0/8/0 \| 10::10 \| 64 \|
313 | | [Arguments] | ${node} | ${interface} | ${address} | ${prefix}
314 | | ${vpp_data}= | interfaceCLI.VPP get interface ip addresses
315 | | ... | ${node} | ${interface} | ipv6
316 | | Should be equal | ${vpp_data[0]['ip']} | ${address}
317 | | Should be equal | ${vpp_data[0]['prefix-length']} | ${prefix}
319 | Honeycomb sets interface ethernet configuration
320 | | [Documentation] | Uses Honeycomb API to change interface ethernet\
321 | | ... | configuration.
323 | | ... | *Arguments:*
324 | | ... | - node - information about a DUT node. Type: dictionary
325 | | ... | - interface - name of an interface on the specified node. Type: string
326 | | ... | - ethernet - interface ethernet settings. Type: dictionary
330 | | ... | \| Honeycomb sets interface ethernet and routing configuration \
331 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${{'mtu': 1500}} \
332 | | [Arguments] | ${node} | ${interface} | ${ethernet}
333 | | :FOR | ${key} | IN | @{ethernet.keys()}
334 | | | interfaceAPI.Configure interface ethernet
335 | | | ... | ${node} | ${interface} | ${key} | ${ethernet['${key}']}
337 | Interface ethernet configuration from Honeycomb should be
338 | | [Documentation] | Retrieves interface ethernet configuration\
339 | | ... | through Honeycomb and compares with settings supplied in arguments.
341 | | ... | *Arguments:*
342 | | ... | - node - information about a DUT node. Type: dictionary
343 | | ... | - interface - name of an interface on the specified node. Type: string
344 | | ... | - ethernet - interface ethernet settings. Type: dictionary
348 | | ... | \| Interface ethernet and routing configuration from Honeycomb \
349 | | ... | should be \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \
350 | | ... | \| ${{'mtu': 1500}} \|
351 | | [Arguments] | ${node} | ${interface} | ${ethernet}
352 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
353 | | :FOR | ${key} | IN | @{ethernet.keys()}
354 | | | Should be equal
355 | | | ... | ${api_data['v3po:ethernet']['${key}']} | ${ethernet['${key}']}
357 | Interface ethernet configuration from VAT should be
358 | | [Documentation] | Retrieves interface ethernet configuration\
359 | | ... | through VAT and compares with settings supplied in arguments.
361 | | ... | *Arguments:*
362 | | ... | - node - information about a DUT node. Type: dictionary
363 | | ... | - interface - name of an interface on the specified node. Type: string
364 | | ... | - mtu - value of maximum transmission unit expected. Type: integer
368 | | ... | \| Interface ethernet and routing configuration from VAT \
369 | | ... | should be \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${1500} \|
370 | | [Arguments] | ${node} | ${interface} | ${mtu}
371 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
372 | | Should be equal | ${vat_data['mtu']} | ${mtu}
374 | Interface configuration from Honeycomb should be empty
375 | | [Documentation] | Attempts to retrieve interface configuration through\
376 | | ... | Honeycomb and expects to get empty dictionary.
378 | | ... | *Arguments:*
379 | | ... | - node - information about a DUT node. Type: dictionary
380 | | ... | - interface - name of a interface on the specified node. Type:\
384 | | ... | \| Interface configuration from Honeycomb should be empty\
385 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \|
387 | | [Arguments] | ${node} | ${interface}
388 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
389 | | Should be empty | ${api_data}
391 | Interface configuration from VAT should be empty
392 | | [Documentation] | Attempts to retrieve Interface configuration through\
393 | | ... | VAT and expects to get empty dictionary.
395 | | ... | *Arguments:*
396 | | ... | - node - information about a DUT node. Type: dictionary
397 | | ... | - interface - name of a Interface on the specified node. Type:\
401 | | ... | \| Interface configuration from VAT should be empty\
402 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \|
404 | | [Arguments] | ${node} | ${interface} |
405 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
406 | | Should be empty | ${vat_data}
408 | Interface indices from Honeycomb and VAT should correspond
409 | | [Documentation] | Uses VAT and Honeycomb to get operational data about the\
410 | | ... | given interface and compares the interface indexes. The interface
411 | | ... | index from Honeycomb should be greater than index from VAT by one.
413 | | ... | *Arguments:*
414 | | ... | - node - information about a DUT node. Type: dictionary
415 | | ... | - interface - name of the interface to be checked. Type: string
419 | | ... | \| Interface indices from Honeycomb and VAT should correspond \
420 | | ... | \| ${nodes['DUT1']} \| vxlan_gpe_tunnel0 \|
422 | | [Arguments] | ${node} | ${interface}
424 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
425 | | ${vat_data}= | InterfaceCLI.VPP get interface data | ${node} | ${interface}
426 | | ${sw_if_index}= | EVALUATE | ${vat_data['sw_if_index']} + 1
427 | | Should be equal as strings
428 | | ... | ${api_data['if-index']} | ${sw_if_index}
430 | Get Interface index from oper data
431 | | [Documentation] | Retrieves interface operational data and returns\
432 | | ... | if-index of the specified interface.
434 | | ... | *Arguments:*
435 | | ... | - node - information about a DUT node. Type: dictionary
436 | | ... | - interface - name of the interface. Type: string
440 | | ... | \| Get Interface index from oper data \| ${nodes['DUT1']} \| local0 \|
441 | | [Arguments] | ${node} | ${interface}
442 | | ${data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
443 | | Return from keyword | ${data['if-index']}
445 | Honeycomb should show disabled interface in oper data
446 | | [Documentation] | Retrieves list of disabled interfaces\
447 | | ... | and verifies that there is at least one.
449 | | ... | *Arguments:*
450 | | ... | - node - information about a DUT node. Type: dictionary
451 | | ... | - index - index of the interface to be checked. Type: string
455 | | ... | \| Honeycomb should show disabled interface in oper data \
456 | | ... | \|${nodes['DUT1']} \| ${vx_interface} \|
457 | | [Arguments] | ${node} | ${index}
458 | | interfaceAPI.check disabled interface | ${node} | ${index}
460 | Honeycomb should not show disabled interface in oper data
461 | | [Documentation] | Retrieves list of disabled interfaces\
462 | | ... | and expects to fail with a 404 - not found.
464 | | ... | *Arguments:*
465 | | ... | - node - information about a DUT node. Type: dictionary
466 | | ... | - index - index of the interface to be checked. Type: string
470 | | ... | \| Honeycomb should not show disabled interface in oper data \
471 | | ... | \|${nodes['DUT1']} \| ${vx_interface} \|
472 | | [Arguments] | ${node} | ${index}
473 | | Run keyword and expect error | *
474 | | ... | Honeycomb should show disabled interface in oper data
475 | | ... | ${node} | ${index}