diff options
author | Tibor Frank <tifrank@cisco.com> | 2016-05-13 10:25:16 +0200 |
---|---|---|
committer | Tibor Frank <tifrank@cisco.com> | 2016-05-13 14:39:44 +0200 |
commit | 981bc57e281bc2f6920f7690eccc3106419474d2 (patch) | |
tree | 3a87f2be9fad0b8341786a86db7ff3833baf9097 /resources/libraries/python/honeycomb | |
parent | 97c8c74e4f813a259ca825e831f83d546d96a171 (diff) |
Add possibility to create a VxLAN interface.
JIRA: CSIT-51
- add a keyword which adds a new VxLAN interface
- change InterfaceUtil.vxlan_dump to be able to return info about all VxLAN
interfaces.
Change-Id: I8ad3dc1d414924e74ea1ecea1f316ca5c648e2d0
Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/libraries/python/honeycomb')
-rw-r--r-- | resources/libraries/python/honeycomb/HcAPIKwInterfaces.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py index 854bc07ee6..7bdfa19831 100644 --- a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py +++ b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py @@ -674,6 +674,70 @@ class InterfaceKeywords(object): node, interface, path, value) @staticmethod + def create_vxlan_interface(node, interface, **kwargs): + """Create a new VxLAN interface. + + :param node: Honeycomb node. + :param interface: The name of interface. + :param kwargs: Parameters and their values. The accepted parameters are + defined in InterfaceKeywords.VXLAN_PARAMS. + :type node: dict + :type interface: str + :type kwargs: dict + :return: Content of response. + :rtype: bytearray + :raises HoneycombError: If the parameter is not valid. + """ + + new_vx_lan = { + "name": interface, + "type": "v3po:vxlan-tunnel", + "v3po:vxlan": {} + } + for param, value in kwargs.items(): + if param not in InterfaceKeywords.VXLAN_PARAMS: + raise HoneycombError("The parameter {0} is invalid.". + format(param)) + new_vx_lan["v3po:vxlan"][param] = value + + path = ("interfaces", "interface") + vx_lan_structure = [new_vx_lan, ] + return InterfaceKeywords._set_interface_properties( + node, interface, path, vx_lan_structure) + + @staticmethod + def delete_interface(node, interface): + """Delete an interface. + + :param node: Honeycomb node. + :param interface: The name of interface. + :type node: dict + :type interface: str + :return: Content of response. + :rtype: bytearray + :raises HoneycombError: If it is not possible to get information about + interfaces or it is not possible to delete the interface. + """ + + path = ("interfaces", ("interface", "name", interface)) + + status_code, resp = HcUtil.\ + get_honeycomb_data(node, "config_vpp_interfaces") + if status_code != HTTPCodes.OK: + raise HoneycombError( + "Not possible to get configuration information about the " + "interfaces. Status code: {0}.".format(status_code)) + + new_data = HcUtil.remove_item(resp, path) + status_code, resp = HcUtil.\ + put_honeycomb_data(node, "config_vpp_interfaces", new_data) + if status_code != HTTPCodes.OK: + raise HoneycombError("Not possible to remove interface {0}. " + "Status code: {1}.". + format(interface, status_code)) + return resp + + @staticmethod def configure_interface_vxlan(node, interface, **kwargs): """Configure VxLAN on the interface. |