X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FLispSetup.py;h=5ef8bc06a9e4f35bb9e0bf895e61b28e6fbdd665;hp=ee2ae5d8a3da9619929cdfb6b79d06996c2defa1;hb=6e25bb5e8b8bcc2a1f741892508a68aec7d791b9;hpb=c3bf9f6ad20223998c1103ba3061a5e338979e2b diff --git a/resources/libraries/python/LispSetup.py b/resources/libraries/python/LispSetup.py index ee2ae5d8a3..5ef8bc06a9 100644 --- a/resources/libraries/python/LispSetup.py +++ b/resources/libraries/python/LispSetup.py @@ -46,16 +46,17 @@ class LispRemoteMapping(object): @staticmethod def vpp_add_lisp_remote_mapping(node, vni, deid, deid_prefix, seid, - seid_prefix, rloc): + seid_prefix, rloc, is_mac=False): """Add lisp remote mapping on the VPP node in topology. :param node: VPP node. :param vni: Vni. :param deid: Destination eid address. - :param deid_predix: Destination eid address prefix_len. + :param deid_prefix: Destination eid address prefix_len. :param seid: Source eid address. :param seid_prefix: Source eid address prefix_len. :param rloc: Receiver locator. + :param is_mac: Set to True if the deid/seid is MAC address. :type node: dict :type vni: int :type deid: str @@ -63,8 +64,14 @@ class LispRemoteMapping(object): :type seid: str :type seid_prefix: int :type rloc: str + :type is_mac: bool """ - + if is_mac: + deid_prefix = '' + seid_prefix = '' + else: + deid_prefix = '/{}'.format(deid_prefix) + seid_prefix = '/{}'.format(seid_prefix) VatExecutor.cmd_from_template(node, 'lisp/add_lisp_remote_mapping.vat', vni=vni, @@ -82,7 +89,7 @@ class LispRemoteMapping(object): :param node: VPP node. :param vni: Vni. :param deid: Destination eid address. - :param deid_predix: Destination eid address prefix_len. + :param deid_prefix: Destination eid address prefix_len. :param seid: Source eid address. :param seid_prefix: Source eid address prefix_len. :param rloc: Receiver locator. @@ -103,6 +110,8 @@ class LispRemoteMapping(object): seid=seid, seid_prefix=seid_prefix, rloc=rloc) + + class LispAdjacency(object): """Class for lisp adjacency API.""" @@ -111,23 +120,30 @@ class LispAdjacency(object): @staticmethod def vpp_add_lisp_adjacency(node, vni, deid, deid_prefix, seid, - seid_prefix): + seid_prefix, is_mac=False): """Add lisp adjacency on the VPP node in topology. :param node: VPP node. :param vni: Vni. :param deid: Destination eid address. - :param deid_predix: Destination eid address prefix_len. + :param deid_prefix: Destination eid address prefix_len. :param seid: Source eid address. :param seid_prefix: Source eid address prefix_len. + :param is_mac: Set to True if the deid/seid is MAC address. :type node: dict :type vni: int :type deid: str :type deid_prefix: int :type seid: str :type seid_prefix: int + :type is_mac: bool """ - + if is_mac: + deid_prefix = '' + seid_prefix = '' + else: + deid_prefix = '/{}'.format(deid_prefix) + seid_prefix = '/{}'.format(seid_prefix) VatExecutor.cmd_from_template(node, 'lisp/add_lisp_adjacency.vat', vni=vni, @@ -144,7 +160,7 @@ class LispAdjacency(object): :param node: VPP node. :param vni: Vni. :param deid: Destination eid address. - :param deid_predix: Destination eid address prefix_len. + :param deid_prefix: Destination eid address prefix_len. :param seid: Source eid address. :param seid_prefix: Source eid address prefix_len. :type node: dict @@ -216,11 +232,13 @@ class LispGpeForwardEntry(object): @staticmethod def add_lisp_gpe_forward_entry(node, *args): + """Not implemented""" # TODO: Implement when VPP-334 is fixed. pass @staticmethod def del_lisp_gpe_forward_entry(node, *args): + """Not implemented""" # TODO: Implement when VPP-334 is fixed. pass @@ -584,3 +602,32 @@ class LispSetup(object): lgi = LispGpeIface() lgi.vpp_lisp_gpe_iface(node, state) + + +class LispEidTableMap(object): + """ + Class for EID table map. + """ + + @staticmethod + def vpp_lisp_eid_table_mapping(node, vni, bd_id=None, vrf=None): + """ + Map LISP VNI to either bridge domain ID, or VRF ID. + + :param node: VPP node. + :param vni: Lisp VNI. + :param bd_id: Bridge domain ID. + :param vrf: VRF id. + :type node: dict + :type vni: int + :type bd_id: int + :type vrf: int + """ + if bd_id: + bd_or_vrf = 'bd_index {}'.format(bd_id) + else: + bd_or_vrf = 'vrf {}'.format(vrf) + VatExecutor.cmd_from_template(node, + 'lisp/lisp_eid_table_add_del_map.vat', + vni=vni, + bd_or_vrf=bd_or_vrf)