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.
14 """Keywords to manipulate interface configuration using Honeycomb REST API.
16 The keywords make possible to put and get configuration data and to get
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
28 class InterfaceKeywords(object):
29 """Keywords for Interface manipulation.
31 Implements keywords which get configuration and operational data about
32 vpp interfaces and set the interface's parameters using Honeycomb REST API.
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 VHOST_USER_PARAMS = ("socket", "role")
55 def _configure_interface(node, interface, data,
56 data_representation=DataRepresentation.JSON):
57 """Send interface configuration data and check the response.
59 :param node: Honeycomb node.
60 :param interface: The name of interface.
61 :param data: Configuration data to be sent in PUT request.
62 :param data_representation: How the data is represented.
66 :type data_representation: DataRepresentation
67 :return: Content of response.
69 :raises HoneycombError: If the status code in response on PUT is not
73 status_code, resp = HcUtil.\
74 put_honeycomb_data(node, "config_vpp_interfaces", data,
75 data_representation=data_representation)
76 if status_code != HTTPCodes.OK:
78 "The configuration of interface '{0}' was not successful. "
79 "Status code: {1}.".format(interface, status_code))
83 def get_all_interfaces_cfg_data(node):
84 """Get configuration data about all interfaces from Honeycomb.
86 :param node: Honeycomb node.
88 :return: Configuration data about all interfaces from Honeycomb.
90 :raises HoneycombError: If it is not possible to get configuration data.
93 status_code, resp = HcUtil.\
94 get_honeycomb_data(node, "config_vpp_interfaces")
95 if status_code != HTTPCodes.OK:
97 "Not possible to get configuration information about the "
98 "interfaces. Status code: {0}.".format(status_code))
100 return resp["interfaces"]["interface"]
102 except (KeyError, TypeError):
106 def get_interface_cfg_data(node, interface):
107 """Get configuration data about the given interface from Honeycomb.
109 :param node: Honeycomb node.
110 :param interface: The name of interface.
113 :return: Configuration data about the given interface from Honeycomb.
117 intfs = InterfaceKeywords.get_all_interfaces_cfg_data(node)
119 if intf["name"] == interface:
124 def get_all_interfaces_oper_data(node):
125 """Get operational data about all interfaces from Honeycomb.
127 :param node: Honeycomb node.
129 :return: Operational data about all interfaces from Honeycomb.
131 :raises HoneycombError: If it is not possible to get operational data.
134 status_code, resp = HcUtil.\
135 get_honeycomb_data(node, "oper_vpp_interfaces")
136 if status_code != HTTPCodes.OK:
137 raise HoneycombError(
138 "Not possible to get operational information about the "
139 "interfaces. Status code: {0}.".format(status_code))
141 return resp["interfaces-state"]["interface"]
143 except (KeyError, TypeError):
147 def get_interface_oper_data(node, interface):
148 """Get operational data about the given interface from Honeycomb.
150 :param node: Honeycomb node.
151 :param interface: The name of interface.
154 :return: Operational data about the given interface from Honeycomb.
158 intfs = InterfaceKeywords.get_all_interfaces_oper_data(node)
160 if intf["name"] == interface:
165 def _set_interface_properties(node, interface, path, new_value=None):
166 """Set interface properties.
168 This method reads interface configuration data, creates, changes or
169 removes the requested data and puts it back to Honeycomb.
171 :param node: Honeycomb node.
172 :param interface: The name of interface.
173 :param path: Path to data we want to change / create / remove.
174 :param new_value: The new value to be set. If None, the item will be
179 :type new_value: str, dict or list
180 :return: Content of response.
182 :raises HoneycombError: If it is not possible to get or set the data.
185 status_code, resp = HcUtil.\
186 get_honeycomb_data(node, "config_vpp_interfaces")
187 if status_code != HTTPCodes.OK:
188 raise HoneycombError(
189 "Not possible to get configuration information about the "
190 "interfaces. Status code: {0}.".format(status_code))
193 new_data = HcUtil.set_item_value(resp, path, new_value)
195 new_data = HcUtil.remove_item(resp, path)
196 return InterfaceKeywords._configure_interface(node, interface, new_data)
199 def set_interface_state(node, interface, state="up"):
200 """Set VPP interface state.
202 The keyword changes the administration state of interface to up or down
203 depending on the parameter "state".
205 :param node: Honeycomb node.
206 :param interface: The name of interface.
207 :param state: The requested state, only "up" and "down" are valid
212 :return: Content of response.
214 :raises KeyError: If the argument "state" is nor "up" or "down".
215 :raises HoneycombError: If the interface is not present on the node.
218 intf_state = {"up": "true",
221 path = ("interfaces", ("interface", "name", str(interface)), "enabled")
222 return InterfaceKeywords._set_interface_properties(
223 node, interface, path, intf_state[state.lower()])
226 def set_interface_up(node, interface):
227 """Set the administration state of VPP interface to up.
229 :param node: Honeycomb node.
230 :param interface: The name of interface.
233 :return: Content of response
237 return InterfaceKeywords.set_interface_state(node, interface, "up")
240 def set_interface_down(node, interface):
241 """Set the administration state of VPP interface to down.
243 :param node: Honeycomb node.
244 :param interface: The name of interface.
247 :return: Content of response.
251 return InterfaceKeywords.set_interface_state(node, interface, "down")
254 def add_bridge_domain_to_interface(node, interface, bd_name,
255 split_horizon_group=None, bvi=None):
256 """Add a new bridge domain to an interface and set its parameters.
258 :param node: Honeycomb node.
259 :param interface: The name of interface.
260 :param bd_name: Bridge domain name.
261 :param split_horizon_group: Split-horizon group name.
262 :param bvi: The bridged virtual interface.
266 :type split_horizon_group: str
268 :return: Content of response.
270 :raises HoneycombError: If the interface is not present on the node.
273 v3po_l2 = {"bridge-domain": str(bd_name)}
274 if split_horizon_group:
275 v3po_l2["split-horizon-group"] = str(split_horizon_group)
277 v3po_l2["bridged-virtual-interface"] = str(bvi)
279 path = ("interfaces", ("interface", "name", str(interface)), "v3po:l2")
281 return InterfaceKeywords._set_interface_properties(
282 node, interface, path, v3po_l2)
285 def configure_interface_base(node, interface, param, value):
286 """Configure the base parameters of interface.
288 :param node: Honeycomb node.
289 :param interface: The name of interface.
290 :param param: Parameter to configure (set, change, remove)
291 :param value: The value of parameter. If None, the parameter will be
297 :return: Content of response.
299 :raises HoneycombError: If the parameter is not valid.
302 if param not in InterfaceKeywords.INTF_PARAMS:
303 raise HoneycombError("The parameter {0} is invalid.".format(param))
305 path = ("interfaces", ("interface", "name", interface), param)
306 return InterfaceKeywords._set_interface_properties(
307 node, interface, path, value)
310 def configure_interface_ipv4(node, interface, param, value):
311 """Configure IPv4 parameters of interface
313 :param node: Honeycomb node.
314 :param interface: The name of interface.
315 :param param: Parameter to configure (set, change, remove)
316 :param value: The value of parameter. If None, the parameter will be
322 :return: Content of response.
324 :raises HoneycombError: If the parameter is not valid.
327 if param not in InterfaceKeywords.IPV4_PARAMS:
328 raise HoneycombError("The parameter {0} is invalid.".format(param))
330 path = ("interfaces", ("interface", "name", interface),
331 "ietf-ip:ipv4", param)
332 return InterfaceKeywords._set_interface_properties(
333 node, interface, path, value)
336 def add_first_ipv4_address(node, interface, ip_addr, network):
337 """Add the first IPv4 address.
339 If there are any other addresses configured, they will be removed.
341 :param node: Honeycomb node.
342 :param interface: The name of interface.
343 :param ip_addr: IPv4 address to be set.
344 :param network: Netmask or length of network prefix.
348 :type network: str or int
349 :return: Content of response.
353 path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv4")
354 if isinstance(network, basestring):
355 address = {"address": [{"ip": ip_addr, "netmask": network}, ]}
356 elif isinstance(network, int) and (0 < network < 33):
357 address = {"address": [{"ip": ip_addr, "prefix-length": network}, ]}
359 raise HoneycombError("Value {0} is not a valid netmask or network "
360 "prefix length.".format(network))
361 return InterfaceKeywords._set_interface_properties(
362 node, interface, path, address)
365 def add_ipv4_address(node, interface, ip_addr, network):
368 :param node: Honeycomb node.
369 :param interface: The name of interface.
370 :param ip_addr: IPv4 address to be set.
371 :param network: Netmask or length of network prefix.
375 :type network: str or int
376 :return: Content of response.
380 path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv4",
382 if isinstance(network, basestring):
383 address = {"address": [{"ip": ip_addr, "netmask": network}, ]}
384 elif isinstance(network, int) and (0 < network < 33):
385 address = {"address": [{"ip": ip_addr, "prefix-length": network}, ]}
387 raise HoneycombError("Value {0} is not a valid netmask or network "
388 "prefix length.".format(network))
389 return InterfaceKeywords._set_interface_properties(
390 node, interface, path, address)
393 def remove_all_ipv4_addresses(node, interface):
394 """Remove all IPv4 addresses from interface.
396 :param node: Honeycomb node.
397 :param interface: The name of interface.
400 :return: Content of response.
404 path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv4",
406 return InterfaceKeywords._set_interface_properties(
407 node, interface, path, None)
410 def add_first_ipv4_neighbor(node, interface, ip_addr, link_layer_address):
411 """Add the first IPv4 neighbour.
413 If there are any other neighbours configured, they will be removed.
415 :param node: Honeycomb node.
416 :param interface: The name of interface.
417 :param ip_addr: IPv4 address of neighbour to be set.
418 :param link_layer_address: Link layer address.
422 :type link_layer_address: str
423 :return: Content of response.
427 path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv4")
428 neighbor = {"neighbor": [{"ip": ip_addr,
429 "link-layer-address": link_layer_address}, ]}
430 return InterfaceKeywords._set_interface_properties(
431 node, interface, path, neighbor)
434 def add_ipv4_neighbor(node, interface, ip_addr, link_layer_address):
435 """Add the IPv4 neighbour.
437 :param node: Honeycomb node.
438 :param interface: The name of interface.
439 :param ip_addr: IPv4 address of neighbour to be set.
440 :param link_layer_address: Link layer address.
444 :type link_layer_address: str
445 :return: Content of response.
449 path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv4",
451 neighbor = [{"ip": ip_addr, "link-layer-address": link_layer_address}, ]
452 return InterfaceKeywords._set_interface_properties(
453 node, interface, path, neighbor)
456 def remove_all_ipv4_neighbors(node, interface):
457 """Remove all IPv4 neighbours.
459 :param node: Honeycomb node.
460 :param interface: The name of interface.
463 :return: Content of response.
467 path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv4",
469 return InterfaceKeywords._set_interface_properties(
470 node, interface, path, None)
473 def configure_interface_ipv6(node, interface, param, value):
474 """Configure IPv6 parameters of interface
476 :param node: Honeycomb node.
477 :param interface: The name of interface.
478 :param param: Parameter to configure (set, change, remove)
479 :param value: The value of parameter. If None, the parameter will be
485 :return: Content of response.
487 :raises HoneycombError: If the parameter is not valid.
490 if param in InterfaceKeywords.IPV6_PARAMS:
491 path = ("interfaces", ("interface", "name", interface),
492 "ietf-ip:ipv6", param)
493 elif param in InterfaceKeywords.IPV6_AUTOCONF_PARAMS:
494 path = ("interfaces", ("interface", "name", interface),
495 "ietf-ip:ipv6", "autoconf", param)
497 raise HoneycombError("The parameter {0} is invalid.".format(param))
499 return InterfaceKeywords._set_interface_properties(
500 node, interface, path, value)
503 def add_first_ipv6_address(node, interface, ip_addr, prefix_len):
504 """Add the first IPv6 address.
506 If there are any other addresses configured, they will be removed.
508 :param node: Honeycomb node.
509 :param interface: The name of interface.
510 :param ip_addr: IPv6 address to be set.
511 :param prefix_len: Prefix length.
515 :type prefix_len: str
516 :return: Content of response.
520 path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv6")
521 address = {"address": [{"ip": ip_addr, "prefix-length": prefix_len}, ]}
522 return InterfaceKeywords._set_interface_properties(
523 node, interface, path, address)
526 def add_ipv6_address(node, interface, ip_addr, prefix_len):
529 :param node: Honeycomb node.
530 :param interface: The name of interface.
531 :param ip_addr: IPv6 address to be set.
532 :param prefix_len: Prefix length.
536 :type prefix_len: str
537 :return: Content of response.
541 path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv6",
543 address = [{"ip": ip_addr, "prefix-length": prefix_len}, ]
544 return InterfaceKeywords._set_interface_properties(
545 node, interface, path, address)
548 def remove_all_ipv6_addresses(node, interface):
549 """Remove all IPv6 addresses from interface.
551 :param node: Honeycomb node.
552 :param interface: The name of interface.
555 :return: Content of response.
559 path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv6",
561 return InterfaceKeywords._set_interface_properties(
562 node, interface, path, None)
565 def add_first_ipv6_neighbor(node, interface, ip_addr, link_layer_address):
566 """Add the first IPv6 neighbour.
568 If there are any other neighbours configured, they will be removed.
570 :param node: Honeycomb node.
571 :param interface: The name of interface.
572 :param ip_addr: IPv6 address of neighbour to be set.
573 :param link_layer_address: Link layer address.
577 :type link_layer_address: str
578 :return: Content of response.
582 path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv6")
583 neighbor = {"neighbor": [{"ip": ip_addr,
584 "link-layer-address": link_layer_address}, ]}
585 return InterfaceKeywords._set_interface_properties(
586 node, interface, path, neighbor)
589 def add_ipv6_neighbor(node, interface, ip_addr, link_layer_address):
590 """Add the IPv6 neighbour.
592 :param node: Honeycomb node.
593 :param interface: The name of interface.
594 :param ip_addr: IPv6 address of neighbour to be set.
595 :param link_layer_address: Link layer address.
599 :type link_layer_address: str
600 :return: Content of response.
604 path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv6",
606 neighbor = [{"ip": ip_addr, "link-layer-address": link_layer_address}, ]
607 return InterfaceKeywords._set_interface_properties(
608 node, interface, path, neighbor)
611 def remove_all_ipv6_neighbors(node, interface):
612 """Remove all IPv6 neighbours.
614 :param node: Honeycomb node.
615 :param interface: The name of interface.
618 :return: Content of response.
622 path = ("interfaces", ("interface", "name", interface), "ietf-ip:ipv6",
624 return InterfaceKeywords._set_interface_properties(
625 node, interface, path, None)
628 def configure_interface_ethernet(node, interface, param, value):
629 """Configure the ethernet parameters of interface.
631 :param node: Honeycomb node.
632 :param interface: The name of interface.
633 :param param: Parameter to configure (set, change, remove)
634 :param value: The value of parameter. If None, the parameter will be
640 :return: Content of response.
642 :raises HoneycombError: If the parameter is not valid.
645 if param not in InterfaceKeywords.ETH_PARAMS:
646 raise HoneycombError("The parameter {0} is invalid.".format(param))
647 path = ("interfaces", ("interface", "name", interface), "v3po:ethernet",
649 return InterfaceKeywords._set_interface_properties(
650 node, interface, path, value)
653 def configure_interface_routing(node, interface, param, value):
654 """Configure the routing parameters of interface.
656 :param node: Honeycomb node.
657 :param interface: The name of interface.
658 :param param: Parameter to configure (set, change, remove)
659 :param value: The value of parameter. If None, the parameter will be
665 :return: Content of response.
667 :raises HoneycombError: If the parameter is not valid.
670 if param not in InterfaceKeywords.ROUTING_PARAMS:
671 raise HoneycombError("The parameter {0} is invalid.".format(param))
673 path = ("interfaces", ("interface", "name", interface), "v3po:routing",
675 return InterfaceKeywords._set_interface_properties(
676 node, interface, path, value)
679 def create_vxlan_interface(node, interface, **kwargs):
680 """Create a new VxLAN interface.
682 :param node: Honeycomb node.
683 :param interface: The name of interface.
684 :param kwargs: Parameters and their values. The accepted parameters are
685 defined in InterfaceKeywords.VXLAN_PARAMS.
689 :return: Content of response.
691 :raises HoneycombError: If the parameter is not valid.
696 "type": "v3po:vxlan-tunnel",
699 for param, value in kwargs.items():
700 if param not in InterfaceKeywords.VXLAN_PARAMS:
701 raise HoneycombError("The parameter {0} is invalid.".
703 new_vx_lan["v3po:vxlan"][param] = value
705 path = ("interfaces", "interface")
706 vx_lan_structure = [new_vx_lan, ]
707 return InterfaceKeywords._set_interface_properties(
708 node, interface, path, vx_lan_structure)
711 def delete_interface(node, interface):
712 """Delete an interface.
714 :param node: Honeycomb node.
715 :param interface: The name of interface.
718 :return: Content of response.
720 :raises HoneycombError: If it is not possible to get information about
721 interfaces or it is not possible to delete the interface.
724 path = ("interfaces", ("interface", "name", interface))
726 status_code, resp = HcUtil.\
727 get_honeycomb_data(node, "config_vpp_interfaces")
728 if status_code != HTTPCodes.OK:
729 raise HoneycombError(
730 "Not possible to get configuration information about the "
731 "interfaces. Status code: {0}.".format(status_code))
733 new_data = HcUtil.remove_item(resp, path)
734 status_code, resp = HcUtil.\
735 put_honeycomb_data(node, "config_vpp_interfaces", new_data)
736 if status_code != HTTPCodes.OK:
737 raise HoneycombError("Not possible to remove interface {0}. "
739 format(interface, status_code))
743 def configure_interface_vxlan(node, interface, **kwargs):
744 """Configure VxLAN on the interface.
746 The keyword configures VxLAN parameters on the given interface. The type
747 of interface must be set to "v3po:vxlan-tunnel".
748 The new VxLAN parameters overwrite the current configuration. If a
749 parameter in new configuration is missing, it is removed from VxLAN
751 If the dictionary kwargs is empty, VxLAN configuration is removed.
753 :param node: Honeycomb node.
754 :param interface: The name of interface.
755 :param kwargs: Parameters and their values. The accepted parameters are
756 defined in InterfaceKeywords.VXLAN_PARAMS.
760 :return: Content of response.
762 :raises HoneycombError: If the parameter is not valid.
765 vx_lan_structure = dict()
766 for param, value in kwargs.items():
767 if param not in InterfaceKeywords.VXLAN_PARAMS:
768 raise HoneycombError("The parameter {0} is invalid.".
770 vx_lan_structure[param] = value
772 path = ("interfaces", ("interface", "name", interface), "v3po:vxlan")
773 return InterfaceKeywords._set_interface_properties(
774 node, interface, path, vx_lan_structure)
777 def configure_interface_l2(node, interface, param, value):
778 """Configure the L2 parameters of interface.
780 :param node: Honeycomb node.
781 :param interface: The name of interface.
782 :param param: Parameter to configure (set, change, remove)
783 :param value: The value of parameter. If None, the parameter will be
789 :return: Content of response.
791 :raises HoneycombError: If the parameter is not valid.
794 if param not in InterfaceKeywords.L2_PARAMS:
795 raise HoneycombError("The parameter {0} is invalid.".format(param))
796 path = ("interfaces", ("interface", "name", interface), "v3po:l2",
798 return InterfaceKeywords._set_interface_properties(
799 node, interface, path, value)
802 def create_tap_interface(node, interface, **kwargs):
803 """Create a new TAP interface.
805 :param node: Honeycomb node.
806 :param interface: The name of interface.
807 :param kwargs: Parameters and their values. The accepted parameters are
808 defined in InterfaceKeywords.TAP_PARAMS.
812 :return: Content of response.
814 :raises HoneycombError: If the parameter is not valid.
822 for param, value in kwargs.items():
823 if param not in InterfaceKeywords.TAP_PARAMS:
824 raise HoneycombError("The parameter {0} is invalid.".
826 new_tap["v3po:tap"][param] = value
828 path = ("interfaces", "interface")
829 new_tap_structure = [new_tap, ]
830 return InterfaceKeywords._set_interface_properties(
831 node, interface, path, new_tap_structure)
834 def configure_interface_tap(node, interface, **kwargs):
835 """Configure TAP on the interface.
837 The keyword configures TAP parameters on the given interface. The type
838 of interface must be set to "v3po:tap".
839 The new TAP parameters overwrite the current configuration. If a
840 parameter in new configuration is missing, it is removed from TAP
842 If the dictionary kwargs is empty, TAP configuration is removed.
844 :param node: Honeycomb node.
845 :param interface: The name of interface.
846 :param kwargs: Parameters and their values. The accepted parameters are
847 defined in InterfaceKeywords.TAP_PARAMS.
851 :return: Content of response.
853 :raises HoneycombError: If the parameter is not valid.
856 tap_structure = dict()
857 for param, value in kwargs.items():
858 if param not in InterfaceKeywords.TAP_PARAMS:
859 raise HoneycombError("The parameter {0} is invalid.".
861 tap_structure[param] = value
863 path = ("interfaces", ("interface", "name", interface), "v3po:tap")
864 return InterfaceKeywords._set_interface_properties(
865 node, interface, path, tap_structure)
868 def configure_interface_vhost_user(node, interface, **kwargs):
869 """Configure vhost-user on the interface.
871 The keyword configures vhost-user parameters on the given interface.
872 The type of interface must be set to "v3po:vhost-user".
873 The new vhost-user parameters overwrite the current configuration. If a
874 parameter in new configuration is missing, it is removed from vhost-user
876 If the dictionary kwargs is empty, vhost-user configuration is removed.
878 :param node: Honeycomb node.
879 :param interface: The name of interface.
880 :param kwargs: Parameters and their values. The accepted parameters are
881 defined in InterfaceKeywords.VHOST_USER_PARAMS.
885 :return: Content of response.
887 :raises HoneycombError: If the parameter is not valid.
890 vhost_structure = dict()
891 for param, value in kwargs.items():
892 if param not in InterfaceKeywords.VHOST_USER_PARAMS:
893 raise HoneycombError("The parameter {0} is invalid.".
895 vhost_structure[param] = value
897 path = ("interfaces", ("interface", "name", interface),
899 return InterfaceKeywords._set_interface_properties(
900 node, interface, path, vhost_structure)
903 def create_vhost_user_interface(node, interface, **kwargs):
904 """Create a new vhost-user interface.
906 :param node: Honeycomb node.
907 :param interface: The name of interface.
908 :param kwargs: Parameters and their values. The accepted parameters are
909 defined in InterfaceKeywords.VHOST_USER_PARAMS.
913 :return: Content of response.
915 :raises HoneycombError: If the parameter is not valid.
920 "type": "v3po:vhost-user",
921 "v3po:vhost-user": {}
923 for param, value in kwargs.items():
924 if param not in InterfaceKeywords.VHOST_USER_PARAMS:
925 raise HoneycombError("The parameter {0} is invalid.".
927 new_vhost["v3po:vhost-user"][param] = value
929 path = ("interfaces", "interface")
930 new_vhost_structure = [new_vhost, ]
931 return InterfaceKeywords._set_interface_properties(
932 node, interface, path, new_vhost_structure)