X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2Fhoneycomb%2FHcAPIKwInterfaces.py;h=92b58308471ca35eff7b1c34ff4520b0c085f7dc;hb=e8c787b699661f00e8358cc711bb20b8993dc87a;hp=c143b069db38901c210d02c0d18f7e5435117448;hpb=036f36181c177e4c77f22cdbdcb87fb2f94df3bf;p=csit.git diff --git a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py index c143b069db..92b5830847 100644 --- a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py +++ b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py @@ -35,7 +35,7 @@ class InterfaceKeywords(object): """ INTF_PARAMS = ("name", "description", "type", "enabled", - "link-up-down-trap-enable", "v3po:l2") + "link-up-down-trap-enable", "v3po:l2", "v3po:vxlan-gpe") IPV4_PARAMS = ("enabled", "forwarding", "mtu") IPV6_PARAMS = ("enabled", "forwarding", "mtu", "dup-addr-detect-transmits") IPV6_AUTOCONF_PARAMS = ("create-global-addresses", @@ -63,6 +63,12 @@ class InterfaceKeywords(object): "match-any-inner-id", "exact-match", "default-subif") + VXLAN_GPE_PARAMS = ("local", + "remote", + "vni", + "next-protocol", + "encap-vrf-id", + "decap-vrf-id") def __init__(self): pass @@ -1047,3 +1053,63 @@ class InterfaceKeywords(object): "vlan-tag-rewrite") return InterfaceKeywords._set_interface_properties( node, sub_interface, path, None) + + @staticmethod + def compare_interface_lists(list1, list2): + """Compare provided lists of interfaces by name. + + :param list1: List of interfaces. + :param list2: List of interfaces. + :type list1: list + :type list2: list + :raises HoneycombError: If an interface exists in only one of the lists. + """ + + ignore = ["vx_tunnel0", "vxlan_gpe_tunnel0"] + # these have no equivalent in config data and no effect on VPP + + names1 = [x['name'] for x in list1] + names2 = [x['name'] for x in list2] + + for name in names1: + if name not in names2 and name not in ignore: + raise HoneycombError("Interface {0} not present in list {1}" + .format(name, list2)) + for name in names2: + if name not in names1 and name not in ignore: + raise HoneycombError("Interface {0} not present in list {1}" + .format(name, list1)) + + @staticmethod + def create_vxlan_gpe_interface(node, interface, **kwargs): + """Create a new VxLAN GPE interface. + + :param node: Honeycomb node. + :param interface: The name of interface to be created. + :param kwargs: Parameters and their values. The accepted parameters are + defined in InterfaceKeywords.VXLAN_GPE_PARAMS. + :type node: dict + :type interface: str + :type kwargs: dict + :return: Content of response. + :rtype: bytearray + :raises HoneycombError: If a parameter in kwargs is not valid. + """ + + new_vxlan_gpe = { + "name": interface, + "type": "v3po:vxlan-gpe-tunnel", + "v3po:vxlan-gpe": {} + } + for param, value in kwargs.items(): + if param in InterfaceKeywords.INTF_PARAMS: + new_vxlan_gpe[param] = value + elif param in InterfaceKeywords.VXLAN_GPE_PARAMS: + new_vxlan_gpe["v3po:vxlan-gpe"][param] = value + else: + raise HoneycombError("The parameter {0} is invalid.". + format(param)) + path = ("interfaces", "interface") + vxlan_gpe_structure = [new_vxlan_gpe, ] + return InterfaceKeywords._set_interface_properties( + node, interface, path, vxlan_gpe_structure)