-class LispSetup:
- """Lisp setup in topology."""
-
- @staticmethod
- def vpp_set_lisp_locator_set(node, locator_set_list):
- """Set lisp locator_sets on VPP node in topology.
-
- :param node: VPP node.
- :param locator_set_list: List of locator_set.
- :type node: dict
- :type locator_set_list: list
- """
-
- if node[u"type"] != NodeType.DUT:
- raise ValueError(u"Node is not DUT")
-
- lisp_locator = LispLocator()
- lisp_locator_set = LispLocatorSet()
- for locator_set in locator_set_list:
- locator_set_name = locator_set.get(u"locator-set")
- locator_list = locator_set.get(u"locator")
- lisp_locator_set.vpp_add_lisp_locator_set(node, locator_set_name)
- for locator in locator_list:
- sw_if_index = locator.get(u"locator-index")
- priority = locator.get(u"priority")
- weight = locator.get(u"weight")
- lisp_locator.vpp_add_lisp_locator(
- node, locator_set_name, sw_if_index, priority, weight
- )
-
- @staticmethod
- def vpp_unset_lisp_locator_set(node, locator_set_list):
- """Unset lisp locator_sets on VPP node in topology.
-
- :param node: VPP node.
- :param locator_set_list: List of locator_set.
- :type node: dict
- :type locator_set_list: list
- """
- if node[u"type"] != NodeType.DUT:
- raise ValueError(u"Lisp locator set, node is not DUT")
-
- lisp_locator = LispLocator()
- lisp_locator_set = LispLocatorSet()
- for locator_set in locator_set_list:
- locator_set_name = locator_set.get(u"locator-set")
- locator_list = locator_set.get(u"locator")
- for locator in locator_list:
- sw_if_index = locator.get(u"locator-index")
- priority = locator.get(u"priority")
- weight = locator.get(u"weight")
- lisp_locator.vpp_del_lisp_locator(
- node, locator_set_name, sw_if_index, priority, weight
- )
-
- lisp_locator_set.vpp_del_lisp_locator_set(node, locator_set_name)
-
- @staticmethod
- def vpp_set_lisp_eid_table(node, eid_table):
- """Set lisp eid tables on VPP node in topology.
-
- :param node: VPP node.
- :param eid_table: Dictionary containing information of eid_table.
- :type node: dict
- :type eid_table: dict
- """
- if node[u"type"] != NodeType.DUT:
- raise ValueError(u"Node is not DUT")
-
- lisp_locator_set = LispLocatorSet()
- lisp_eid = LispLocalEid()
- for eid in eid_table:
- vni = eid.get(u"vni")
- eid_address = eid.get(u"eid")
- eid_prefix_len = eid.get(u"eid-prefix-len")
- locator_set_name = eid.get(u"locator-set")
- lisp_locator_set.vpp_add_lisp_locator_set(node, locator_set_name)
- lisp_eid.vpp_add_lisp_local_eid(
- node, locator_set_name, vni, eid_address, eid_prefix_len
- )
-
- @staticmethod
- def vpp_unset_lisp_eid_table(node, eid_table):
- """Unset lisp eid tables on VPP node in topology.
-
- :param node: VPP node.
- :param eid_table: Dictionary containing information of eid_table.
- :type node: dict
- :type eid_table: dict
- """
- if node[u"type"] != NodeType.DUT:
- raise ValueError(u"Node is not DUT")
-
- locator_set_list = []
- lisp_locator_set = LispLocatorSet()
- lisp_eid = LispLocalEid()
- for eid in eid_table:
- vni = eid.get(u"vni")
- eid_address = eid.get(u"eid")
- eid_prefix_len = eid.get(u"eid-prefix-len")
- locator_set_name = eid.get(u"locator-set")
- if locator_set_name not in locator_set_list:
- locator_set_list.append(locator_set_name)
-
- lisp_eid.vpp_del_lisp_local_eid(
- node, locator_set_name, vni, eid_address, eid_prefix_len
- )
-
- for locator_set_name in locator_set_list:
- lisp_locator_set.vpp_del_lisp_locator_set(node, locator_set_name)
-
- @staticmethod
- def vpp_set_lisp_map_resolver(node, map_resolver):
- """Set lisp map resolvers on VPP node in topology.
-
- :param node: VPP node.
- :param map_resolver: Dictionary containing information of map resolver.
- :type node: dict
- :type map_resolver: dict
- """
- lisp_map_res = LispMapResolver()
- for map_ip in map_resolver:
- lisp_map_res.vpp_add_map_resolver(node, map_ip.get(u"map resolver"))
-
- @staticmethod
- def vpp_unset_lisp_map_resolver(node, map_resolver):
- """Unset lisp map resolvers on VPP node in topology.
-
- :param node: VPP node.
- :param map_resolver: Dictionary containing information of map resolver.
- :type node: dict
- :type map_resolver: dict
- """
- lisp_map_res = LispMapResolver()
- for map_ip in map_resolver:
- lisp_map_res.vpp_del_map_resolver(node, map_ip.get(u"map resolver"))