Add keyword to manipulate interface TAP parameters
[csit.git] / resources / libraries / python / honeycomb / HcAPIKwInterfaces.py
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:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
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.
13
14 """Keywords to manipulate interface configuration using Honeycomb REST API.
15
16 The keywords make possible to put and get configuration data and to get
17 operational data.
18 """
19
20 from resources.libraries.python.HTTPRequest import HTTPCodes
21 from resources.libraries.python.honeycomb.HoneycombSetup import HoneycombError
22 from resources.libraries.python.honeycomb.HoneycombUtil \
23     import DataRepresentation
24 from resources.libraries.python.honeycomb.HoneycombUtil \
25     import HoneycombUtil as HcUtil
26
27
28 class InterfaceKeywords(object):
29     """Keywords for Interface manipulation.
30
31     Implements keywords which get configuration and operational data about
32     vpp interfaces and set the interface's parameters using Honeycomb REST API.
33     """
34
35     INTF_PARAMS = ("name", "description", "type", "enabled",
36                    "link-up-down-trap-enable")
37     IPV4_PARAMS = ("enabled", "forwarding", "mtu")
38     IPV6_PARAMS = ("enabled", "forwarding", "mtu", "dup-addr-detect-transmits")
39     IPV6_AUTOCONF_PARAMS = ("create-global-addresses",
40                             "create-temporary-addresses",
41                             "temporary-valid-lifetime",
42                             "temporary-preferred-lifetime")
43     ETH_PARAMS = ("mtu", )
44     ROUTING_PARAMS = ("vrf-id", )
45     VXLAN_PARAMS = ("src", "dst", "vni", "encap-vrf-id")
46     L2_PARAMS = ("bridge-domain", "split-horizon-group",
47                  "bridged-virtual-interface")
48     TAP_PARAMS = ("tap-name", "mac", "device-instance")
49
50     def __init__(self):
51         pass
52
53     @staticmethod
54     def _configure_interface(node, interface, data,
55                              data_representation=DataRepresentation.JSON):
56         """Send interface configuration data and check the response.
57
58         :param node: Honeycomb node.
59         :param interface: The name of interface.
60         :param data: Configuration data to be sent in PUT request.
61         :param data_representation: How the data is represented.
62         :type node: dict
63         :type interface: str
64         :type data: dict
65         :type data_representation: DataRepresentation
66         :return: Content of response.
67         :rtype: bytearray
68         :raises HoneycombError: If the status code in response on PUT is not
69         200 = OK.
70         """
71
72         status_code, resp = HcUtil.\
73             put_honeycomb_data(node, "config_vpp_interfaces", data,
74                                data_representation=data_representation)
75         if status_code != HTTPCodes.OK:
76             raise HoneycombError(
77                 "The configuration of interface '{0}' was not successful. "
78                 "Status code: {1}.".format(interface, status_code))
79         return resp
80
81     @staticmethod
82     def get_all_interfaces_cfg_data(node):
83         """Get configuration data about all interfaces from Honeycomb.
84
85         :param node: Honeycomb node.
86         :type node: dict
87         :return: Configuration data about all interfaces from Honeycomb.
88         :rtype: list
89         :raises HoneycombError: If it is not possible to get configuration data.
90         """
91
92         status_code, resp = HcUtil.\
93             get_honeycomb_data(node, "config_vpp_interfaces")
94         if status_code != HTTPCodes.OK:
95             raise HoneycombError(
96                 "Not possible to get configuration information about the "
97                 "interfaces. Status code: {0}.".format(status_code))
98         try:
99             return resp["interfaces"]["interface"]
100
101         except (KeyError, TypeError):
102             return []
103
104     @staticmethod
105     def get_interface_cfg_data(node, interface):
106         """Get configuration data about the given interface from Honeycomb.
107
108         :param node: Honeycomb node.
109         :param interface: The name of interface.
110         :type node: dict
111         :type interface: str
112         :return: Configuration data about the given interface from Honeycomb.
113         :rtype: dict
114         """
115
116         intfs = InterfaceKeywords.get_all_interfaces_cfg_data(node)
117         for intf in intfs:
118             if intf["name"] == interface:
119                 return intf
120         return {}
121
122     @staticmethod
123     def get_all_interfaces_oper_data(node):
124         """Get operational data about all interfaces from Honeycomb.
125
126         :param node: Honeycomb node.
127         :type node: dict
128         :return: Operational data about all interfaces from Honeycomb.
129         :rtype: list
130         :raises HoneycombError: If it is not possible to get operational data.
131         """
132
133         status_code, resp = HcUtil.\
134             get_honeycomb_data(node, "oper_vpp_interfaces")
135         if status_code != HTTPCodes.OK:
136             raise HoneycombError(
137                 "Not possible to get operational information about the "
138                 "interfaces. Status code: {0}.".format(status_code))
139         try:
140             return resp["interfaces-state"]["interface"]
141
142         except (KeyError, TypeError):
143             return []
144
145     @staticmethod
146     def get_interface_oper_data(node, interface):
147         """Get operational data about the given interface from Honeycomb.
148
149         :param node: Honeycomb node.
150         :param interface: The name of interface.
151         :type node: dict
152         :type interface: str
153         :return: Operational data about the given interface from Honeycomb.
154         :rtype: dict
155         """
156
157         intfs = InterfaceKeywords.get_all_interfaces_oper_data(node)
158         for intf in intfs:
159             if intf["name"] == interface:
160                 return intf
161         return {}
162
163     @staticmethod
164     def _set_interface_properties(node, interface, path, new_value=None):
165         """Set interface properties.
166
167         This method reads interface configuration data, creates, changes or
168         removes the requested data and puts it back to Honeycomb.
169
170         :param node: Honeycomb node.
171         :param interface: The name of interface.
172         :param path:  Path to data we want to change / create / remove.
173         :param new_value: The new value to be set. If None, the item will be
174         removed.
175         :type node: dict
176         :type interface: str
177         :type path: tuple
178         :type new_value: str, dict or list
179         :return: Content of response.
180         :rtype: bytearray
181         :raises HoneycombError: If it is not possible to get or set the data.
182         """
183
184         status_code, resp = HcUtil.\
185             get_honeycomb_data(node, "config_vpp_interfaces")
186         if status_code != HTTPCodes.OK:
187             raise HoneycombError(
188                 "Not possible to get configuration information about the "
189                 "interfaces. Status code: {0}.".format(status_code))
190
191         if new_value:
192             new_data = HcUtil.set_item_value(resp, path, new_value)
193         else:
194             new_data = HcUtil.remove_item(resp, path)
195         return InterfaceKeywords._configure_interface(node, interface, new_data)
196
197     @staticmethod
198     def set_interface_state(node, interface, state="up"):
199         """Set VPP interface state.
200
201         The keyword changes the administration state of interface to up or down
202         depending on the parameter "state".
203
204         :param node: Honeycomb node.
205         :param interface: The name of interface.
206         :param state: The requested state, only "up" and "down" are valid
207         values.
208         :type node: dict
209         :type interface: str
210         :type state: str
211         :return: Content of response.
212         :rtype: bytearray
213         :raises KeyError: If the argument "state" is nor "up" or "down".
214         :raises HoneycombError: If the interface is not present on the node.
215         """
216
217         intf_state = {"up": "true",
218                       "down": "false"}
219
220         path = ("interfaces", ("interface", "name", str(interface)), "enabled")
221         return InterfaceKeywords._set_interface_properties(
222             node, interface, path, intf_state[state.lower()])
223
224     @staticmethod
225     def set_interface_up(node, interface):
226         """Set the administration state of VPP interface to up.
227
228         :param node: Honeycomb node.
229         :param interface: The name of interface.
230         :type node: dict
231         :type interface: str
232         :return: Content of response
233         :rtype: bytearray
234         """
235
236         return InterfaceKeywords.set_interface_state(node, interface, "up")
237
238     @staticmethod
239     def set_interface_down(node, interface):
240         """Set the administration state of VPP interface to down.
241
242         :param node: Honeycomb node.
243         :param interface: The name of interface.
244         :type node: dict
245         :type interface: str
246         :return: Content of response.
247         :rtype: bytearray
248         """
249
250         return InterfaceKeywords.set_interface_state(node, interface, "down")
251
252     @staticmethod
253     def add_bridge_domain_to_interface(node, interface, bd_name,
254                                        split_horizon_group=None, bvi=None):
255         """Add a new bridge domain to an interface and set its parameters.
256
257         :param node: Honeycomb node.
258         :param interface: The name of interface.
259         :param bd_name: Bridge domain name.
260         :param split_horizon_group: Split-horizon group name.
261         :param bvi: The bridged virtual interface.
262         :type node: dict
263         :type interface: str
264         :type bd_name: str
265         :type split_horizon_group: str
266         :type bvi: str
267         :return: Content of response.
268         :rtype: bytearray
269         :raises HoneycombError: If the interface is not present on the node.
270         """
271
272         v3po_l2 = {"bridge-domain": str(bd_name)}
273         if split_horizon_group:
274             v3po_l2["split-horizon-group"] = str(split_horizon_group)
275         if bvi:
276             v3po_l2["bridged-virtual-interface"] = str(bvi)
277
278         path = ("interfaces", ("interface", "name", str(interface)), "v3po:l2")
279
280         return InterfaceKeywords._set_interface_properties(
281             node, interface, path, v3po_l2)
282
283     @staticmethod
284     def configure_interface_base(node, interface, param, value):
285         """Configure the base parameters of interface.
286
287         :param node: Honeycomb node.
288         :param interface: The name of interface.
289         :param param: Parameter to configure (set, change, remove)
290         :param value: The value of parameter. If None, the parameter will be
291         removed.
292         :type node: dict
293         :type interface: str
294         :type param: str
295         :type value: str
296         :return: Content of response.
297         :rtype: bytearray
298         :raises HoneycombError: If the parameter is not valid.
299         """
300
301         if param not in InterfaceKeywords.INTF_PARAMS:
302             raise HoneycombError("The parameter {0} is invalid.".format(param))
303
304         path = ("interfaces", ("interface", "name", interface), param)
305         return InterfaceKeywords._set_interface_properties(
306             node, interface, path, value)
307
308     @staticmethod
309     def configure_interface_ipv4(node, interface, param, value):
310         """Configure IPv4 parameters of interface
311
312         :param node: Honeycomb node.
313         :param interface: The name of interface.
314         :param param: Parameter to configure (set, change, remove)
315         :param value: The value of parameter. If None, the parameter will be
316         removed.
317         :type node: dict
318         :type interface: str
319         :type param: str
320         :type value: str
321         :return: Content of response.
322         :rtype: bytearray
323         :raises HoneycombError: If the parameter is not valid.
324         """
325
326         if param not in InterfaceKeywords.IPV4_PARAMS:
327             raise HoneycombError("The parameter {0} is invalid.".format(param))
328
329         path = ("interfaces", ("interface", "name", interface),
330                 "ietf-ip:ipv4", param)
331         return InterfaceKeywords._set_interface_properties(
332             node, interface, path, value)
333
334     @staticmethod
335     def add_first_ipv4_address(node, interface, ip_addr, network):
336         """Add the first IPv4 address.
337
338         If there are any other addresses configured, they will be removed.
339
340         :param node: Honeycomb node.
341         :param interface: The name of interface.
342         :param ip_addr: IPv4 address to be set.
343         :param network: Netmask or length of network prefix.
344         :type node: dict
345         :type interface: str
346         :type ip_addr: str
347         :type network: str or int
348         :return: Content of response.
349         :rtype: bytearray
350         """
351
352         path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv4")
353         if isinstance(network, basestring):
354             address = {"address": [{"ip": ip_addr, "netmask": network}, ]}
355         elif isinstance(network, int) and (0 < network < 33):
356             address = {"address": [{"ip": ip_addr, "prefix-length": network}, ]}
357         else:
358             raise HoneycombError("Value {0} is not a valid netmask or network "
359                                  "prefix length.".format(network))
360         return InterfaceKeywords._set_interface_properties(
361             node, interface, path, address)
362
363     @staticmethod
364     def add_ipv4_address(node, interface, ip_addr, network):
365         """Add IPv4 address.
366
367         :param node: Honeycomb node.
368         :param interface: The name of interface.
369         :param ip_addr: IPv4 address to be set.
370         :param network: Netmask or length of network prefix.
371         :type node: dict
372         :type interface: str
373         :type ip_addr: str
374         :type network: str or int
375         :return: Content of response.
376         :rtype: bytearray
377         """
378
379         path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv4",
380                 "address")
381         if isinstance(network, basestring):
382             address = {"address": [{"ip": ip_addr, "netmask": network}, ]}
383         elif isinstance(network, int) and (0 < network < 33):
384             address = {"address": [{"ip": ip_addr, "prefix-length": network}, ]}
385         else:
386             raise HoneycombError("Value {0} is not a valid netmask or network "
387                                  "prefix length.".format(network))
388         return InterfaceKeywords._set_interface_properties(
389             node, interface, path, address)
390
391     @staticmethod
392     def remove_all_ipv4_addresses(node, interface):
393         """Remove all IPv4 addresses from interface.
394
395         :param node: Honeycomb node.
396         :param interface: The name of interface.
397         :type node: dict
398         :type interface: str
399         :return: Content of response.
400         :rtype: bytearray
401         """
402
403         path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv4",
404                 "address")
405         return InterfaceKeywords._set_interface_properties(
406             node, interface, path, None)
407
408     @staticmethod
409     def add_first_ipv4_neighbor(node, interface, ip_addr, link_layer_address):
410         """Add the first IPv4 neighbour.
411
412         If there are any other neighbours configured, they will be removed.
413
414         :param node: Honeycomb node.
415         :param interface: The name of interface.
416         :param ip_addr: IPv4 address of neighbour to be set.
417         :param link_layer_address: Link layer address.
418         :type node: dict
419         :type interface: str
420         :type ip_addr: str
421         :type link_layer_address: str
422         :return: Content of response.
423         :rtype: bytearray
424         """
425
426         path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv4")
427         neighbor = {"neighbor": [{"ip": ip_addr,
428                                   "link-layer-address": link_layer_address}, ]}
429         return InterfaceKeywords._set_interface_properties(
430             node, interface, path, neighbor)
431
432     @staticmethod
433     def add_ipv4_neighbor(node, interface, ip_addr, link_layer_address):
434         """Add the IPv4 neighbour.
435
436         :param node: Honeycomb node.
437         :param interface: The name of interface.
438         :param ip_addr: IPv4 address of neighbour to be set.
439         :param link_layer_address: Link layer address.
440         :type node: dict
441         :type interface: str
442         :type ip_addr: str
443         :type link_layer_address: str
444         :return: Content of response.
445         :rtype: bytearray
446         """
447
448         path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv4",
449                 "neighbor")
450         neighbor = [{"ip": ip_addr, "link-layer-address": link_layer_address}, ]
451         return InterfaceKeywords._set_interface_properties(
452             node, interface, path, neighbor)
453
454     @staticmethod
455     def remove_all_ipv4_neighbors(node, interface):
456         """Remove all IPv4 neighbours.
457
458         :param node: Honeycomb node.
459         :param interface: The name of interface.
460         :type node: dict
461         :type interface: str
462         :return: Content of response.
463         :rtype: bytearray
464         """
465
466         path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv4",
467                 "neighbor")
468         return InterfaceKeywords._set_interface_properties(
469             node, interface, path, None)
470
471     @staticmethod
472     def configure_interface_ipv6(node, interface, param, value):
473         """Configure IPv6 parameters of interface
474
475         :param node: Honeycomb node.
476         :param interface: The name of interface.
477         :param param: Parameter to configure (set, change, remove)
478         :param value: The value of parameter. If None, the parameter will be
479         removed.
480         :type node: dict
481         :type interface: str
482         :type param: str
483         :type value: str
484         :return: Content of response.
485         :rtype: bytearray
486         :raises HoneycombError: If the parameter is not valid.
487         """
488
489         if param in InterfaceKeywords.IPV6_PARAMS:
490             path = ("interfaces", ("interface", "name", interface),
491                     "ietf-ip:ipv6", param)
492         elif param in InterfaceKeywords.IPV6_AUTOCONF_PARAMS:
493             path = ("interfaces", ("interface", "name", interface),
494                     "ietf-ip:ipv6", "autoconf", param)
495         else:
496             raise HoneycombError("The parameter {0} is invalid.".format(param))
497
498         return InterfaceKeywords._set_interface_properties(
499             node, interface, path, value)
500
501     @staticmethod
502     def add_first_ipv6_address(node, interface, ip_addr, prefix_len):
503         """Add the first IPv6 address.
504
505         If there are any other addresses configured, they will be removed.
506
507         :param node: Honeycomb node.
508         :param interface: The name of interface.
509         :param ip_addr: IPv6 address to be set.
510         :param prefix_len: Prefix length.
511         :type node: dict
512         :type interface: str
513         :type ip_addr: str
514         :type prefix_len: str
515         :return: Content of response.
516         :rtype: bytearray
517         """
518
519         path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv6")
520         address = {"address": [{"ip": ip_addr, "prefix-length": prefix_len}, ]}
521         return InterfaceKeywords._set_interface_properties(
522             node, interface, path, address)
523
524     @staticmethod
525     def add_ipv6_address(node, interface, ip_addr, prefix_len):
526         """Add IPv6 address.
527
528         :param node: Honeycomb node.
529         :param interface: The name of interface.
530         :param ip_addr: IPv6 address to be set.
531         :param prefix_len: Prefix length.
532         :type node: dict
533         :type interface: str
534         :type ip_addr: str
535         :type prefix_len: str
536         :return: Content of response.
537         :rtype: bytearray
538         """
539
540         path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv6",
541                 "address")
542         address = [{"ip": ip_addr, "prefix-length": prefix_len}, ]
543         return InterfaceKeywords._set_interface_properties(
544             node, interface, path, address)
545
546     @staticmethod
547     def remove_all_ipv6_addresses(node, interface):
548         """Remove all IPv6 addresses from interface.
549
550         :param node: Honeycomb node.
551         :param interface: The name of interface.
552         :type node: dict
553         :type interface: str
554         :return: Content of response.
555         :rtype: bytearray
556         """
557
558         path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv6",
559                 "address")
560         return InterfaceKeywords._set_interface_properties(
561             node, interface, path, None)
562
563     @staticmethod
564     def add_first_ipv6_neighbor(node, interface, ip_addr, link_layer_address):
565         """Add the first IPv6 neighbour.
566
567         If there are any other neighbours configured, they will be removed.
568
569         :param node: Honeycomb node.
570         :param interface: The name of interface.
571         :param ip_addr: IPv6 address of neighbour to be set.
572         :param link_layer_address: Link layer address.
573         :type node: dict
574         :type interface: str
575         :type ip_addr: str
576         :type link_layer_address: str
577         :return: Content of response.
578         :rtype: bytearray
579         """
580
581         path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv6")
582         neighbor = {"neighbor": [{"ip": ip_addr,
583                                   "link-layer-address": link_layer_address}, ]}
584         return InterfaceKeywords._set_interface_properties(
585             node, interface, path, neighbor)
586
587     @staticmethod
588     def add_ipv6_neighbor(node, interface, ip_addr, link_layer_address):
589         """Add the IPv6 neighbour.
590
591         :param node: Honeycomb node.
592         :param interface: The name of interface.
593         :param ip_addr: IPv6 address of neighbour to be set.
594         :param link_layer_address: Link layer address.
595         :type node: dict
596         :type interface: str
597         :type ip_addr: str
598         :type link_layer_address: str
599         :return: Content of response.
600         :rtype: bytearray
601         """
602
603         path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv6",
604                 "neighbor")
605         neighbor = [{"ip": ip_addr, "link-layer-address": link_layer_address}, ]
606         return InterfaceKeywords._set_interface_properties(
607             node, interface, path, neighbor)
608
609     @staticmethod
610     def remove_all_ipv6_neighbors(node, interface):
611         """Remove all IPv6 neighbours.
612
613         :param node: Honeycomb node.
614         :param interface: The name of interface.
615         :type node: dict
616         :type interface: str
617         :return: Content of response.
618         :rtype: bytearray
619         """
620
621         path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv6",
622                 "neighbor")
623         return InterfaceKeywords._set_interface_properties(
624             node, interface, path, None)
625
626     @staticmethod
627     def configure_interface_ethernet(node, interface, param, value):
628         """Configure the ethernet parameters of interface.
629
630         :param node: Honeycomb node.
631         :param interface: The name of interface.
632         :param param: Parameter to configure (set, change, remove)
633         :param value: The value of parameter. If None, the parameter will be
634         removed.
635         :type node: dict
636         :type interface: str
637         :type param: str
638         :type value: str
639         :return: Content of response.
640         :rtype: bytearray
641         :raises HoneycombError: If the parameter is not valid.
642         """
643
644         if param not in InterfaceKeywords.ETH_PARAMS:
645             raise HoneycombError("The parameter {0} is invalid.".format(param))
646         path = ("interfaces", ("interface", "name", interface), "v3po:ethernet",
647                 param)
648         return InterfaceKeywords._set_interface_properties(
649             node, interface, path, value)
650
651     @staticmethod
652     def configure_interface_routing(node, interface, param, value):
653         """Configure the routing parameters of interface.
654
655         :param node: Honeycomb node.
656         :param interface: The name of interface.
657         :param param: Parameter to configure (set, change, remove)
658         :param value: The value of parameter. If None, the parameter will be
659         removed.
660         :type node: dict
661         :type interface: str
662         :type param: str
663         :type value: str
664         :return: Content of response.
665         :rtype: bytearray
666         :raises HoneycombError: If the parameter is not valid.
667         """
668
669         if param not in InterfaceKeywords.ROUTING_PARAMS:
670             raise HoneycombError("The parameter {0} is invalid.".format(param))
671
672         path = ("interfaces", ("interface", "name", interface), "v3po:routing",
673                 param)
674         return InterfaceKeywords._set_interface_properties(
675             node, interface, path, value)
676
677     @staticmethod
678     def create_vxlan_interface(node, interface, **kwargs):
679         """Create a new VxLAN interface.
680
681         :param node: Honeycomb node.
682         :param interface: The name of interface.
683         :param kwargs: Parameters and their values. The accepted parameters are
684         defined in InterfaceKeywords.VXLAN_PARAMS.
685         :type node: dict
686         :type interface: str
687         :type kwargs: dict
688         :return: Content of response.
689         :rtype: bytearray
690         :raises HoneycombError: If the parameter is not valid.
691         """
692
693         new_vx_lan = {
694             "name": interface,
695             "type": "v3po:vxlan-tunnel",
696             "v3po:vxlan": {}
697         }
698         for param, value in kwargs.items():
699             if param not in InterfaceKeywords.VXLAN_PARAMS:
700                 raise HoneycombError("The parameter {0} is invalid.".
701                                      format(param))
702             new_vx_lan["v3po:vxlan"][param] = value
703
704         path = ("interfaces", "interface")
705         vx_lan_structure = [new_vx_lan, ]
706         return InterfaceKeywords._set_interface_properties(
707             node, interface, path, vx_lan_structure)
708
709     @staticmethod
710     def delete_interface(node, interface):
711         """Delete an interface.
712
713         :param node: Honeycomb node.
714         :param interface: The name of interface.
715         :type node: dict
716         :type interface: str
717         :return: Content of response.
718         :rtype: bytearray
719         :raises HoneycombError: If it is not possible to get information about
720         interfaces or it is not possible to delete the interface.
721         """
722
723         path = ("interfaces", ("interface", "name", interface))
724
725         status_code, resp = HcUtil.\
726             get_honeycomb_data(node, "config_vpp_interfaces")
727         if status_code != HTTPCodes.OK:
728             raise HoneycombError(
729                 "Not possible to get configuration information about the "
730                 "interfaces. Status code: {0}.".format(status_code))
731
732         new_data = HcUtil.remove_item(resp, path)
733         status_code, resp = HcUtil.\
734             put_honeycomb_data(node, "config_vpp_interfaces", new_data)
735         if status_code != HTTPCodes.OK:
736             raise HoneycombError("Not possible to remove interface {0}. "
737                                  "Status code: {1}.".
738                                  format(interface, status_code))
739         return resp
740
741     @staticmethod
742     def configure_interface_vxlan(node, interface, **kwargs):
743         """Configure VxLAN on the interface.
744
745         The keyword configures VxLAN parameters on the given interface. The type
746         of interface must be set to "v3po:vxlan-tunnel".
747         The new VxLAN parameters overwrite the current configuration. If a
748         parameter in new configuration is missing, it is removed from VxLAN
749         configuration.
750         If the dictionary kwargs is empty, VxLAN configuration is removed.
751
752         :param node: Honeycomb node.
753         :param interface: The name of interface.
754         :param kwargs: Parameters and their values. The accepted parameters are
755         defined in InterfaceKeywords.VXLAN_PARAMS.
756         :type node: dict
757         :type interface: str
758         :type kwargs: dict
759         :return: Content of response.
760         :rtype: bytearray
761         :raises HoneycombError: If the parameter is not valid.
762         """
763
764         vx_lan_structure = dict()
765         for param, value in kwargs.items():
766             if param not in InterfaceKeywords.VXLAN_PARAMS:
767                 raise HoneycombError("The parameter {0} is invalid.".
768                                      format(param))
769             vx_lan_structure[param] = value
770
771         path = ("interfaces", ("interface", "name", interface), "v3po:vxlan")
772         return InterfaceKeywords._set_interface_properties(
773             node, interface, path, vx_lan_structure)
774
775     @staticmethod
776     def configure_interface_l2(node, interface, param, value):
777         """Configure the L2 parameters of interface.
778
779         :param node: Honeycomb node.
780         :param interface: The name of interface.
781         :param param: Parameter to configure (set, change, remove)
782         :param value: The value of parameter. If None, the parameter will be
783         removed.
784         :type node: dict
785         :type interface: str
786         :type param: str
787         :type value: str
788         :return: Content of response.
789         :rtype: bytearray
790         :raises HoneycombError: If the parameter is not valid.
791         """
792
793         if param not in InterfaceKeywords.L2_PARAMS:
794             raise HoneycombError("The parameter {0} is invalid.".format(param))
795         path = ("interfaces", ("interface", "name", interface), "v3po:l2",
796                 param)
797         return InterfaceKeywords._set_interface_properties(
798             node, interface, path, value)
799
800     @staticmethod
801     def create_tap_interface(node, interface, **kwargs):
802         """Create a new TAP interface.
803
804         :param node: Honeycomb node.
805         :param interface: The name of interface.
806         :param kwargs: Parameters and their values. The accepted parameters are
807         defined in InterfaceKeywords.TAP_PARAMS.
808         :type node: dict
809         :type interface: str
810         :type kwargs: dict
811         :return: Content of response.
812         :rtype: bytearray
813         :raises HoneycombError: If the parameter is not valid.
814         """
815
816         new_tap = {
817             "name": interface,
818             "type": "v3po:tap",
819             "v3po:tap": {}
820         }
821         for param, value in kwargs.items():
822             if param not in InterfaceKeywords.TAP_PARAMS:
823                 raise HoneycombError("The parameter {0} is invalid.".
824                                      format(param))
825             new_tap["v3po:tap"][param] = value
826
827         path = ("interfaces", "interface")
828         new_tap_structure = [new_tap, ]
829         return InterfaceKeywords._set_interface_properties(
830             node, interface, path, new_tap_structure)
831
832     @staticmethod
833     def configure_interface_tap(node, interface, **kwargs):
834         """Configure TAP on the interface.
835
836         The keyword configures TAP parameters on the given interface. The type
837         of interface must be set to "v3po:tap".
838         The new TAP parameters overwrite the current configuration. If a
839         parameter in new configuration is missing, it is removed from TAP
840         configuration.
841         If the dictionary kwargs is empty, TAP configuration is removed.
842
843         :param node: Honeycomb node.
844         :param interface: The name of interface.
845         :param kwargs: Parameters and their values. The accepted parameters are
846         defined in InterfaceKeywords.TAP_PARAMS.
847         :type node: dict
848         :type interface: str
849         :type kwargs: dict
850         :return: Content of response.
851         :rtype: bytearray
852         :raises HoneycombError: If the parameter is not valid.
853         """
854
855         tap_structure = dict()
856         for param, value in kwargs.items():
857             if param not in InterfaceKeywords.TAP_PARAMS:
858                 raise HoneycombError("The parameter {0} is invalid.".
859                                      format(param))
860             tap_structure[param] = value
861
862         path = ("interfaces", ("interface", "name", interface), "v3po:tap")
863         return InterfaceKeywords._set_interface_properties(
864             node, interface, path, tap_structure)