X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FLispSetup.py;h=5ef8bc06a9e4f35bb9e0bf895e61b28e6fbdd665;hp=13d0501abb2de858489143a1278e2b7fdc599428;hb=6e25bb5e8b8bcc2a1f741892508a68aec7d791b9;hpb=721f39743c31003ccbdad3c27ffcc3145bfccf90 diff --git a/resources/libraries/python/LispSetup.py b/resources/libraries/python/LispSetup.py index 13d0501abb..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. @@ -99,10 +106,12 @@ class LispRemoteMapping(object): 'lisp/del_lisp_remote_mapping.vat', vni=vni, deid=deid, - deid_predix=deid_prefix, + deid_prefix=deid_prefix, 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 @@ -159,11 +175,31 @@ class LispAdjacency(object): 'lisp/del_lisp_adjacency.vat', vni=vni, deid=deid, - deid_predix=deid_prefix, + deid_prefix=deid_prefix, seid=seid, seid_prefix=seid_prefix) +class LispGpeStatus(object): + """Clas for LISP GPE status manipulation.""" + + def __init__(self): + pass + + @staticmethod + def vpp_lisp_gpe_enable_disable(node, state): + """Change the state of LISP GPE - enable or disable. + + :param node: VPP node. + :param state: Requested state - enable or disable. + :type node: dict + :type state: str + """ + + VatExecutor.cmd_from_template(node, 'lisp/lisp_gpe_status.vat', + state=state) + + class LispGpeIface(object): """Class for Lisp gpe interface API.""" @@ -180,11 +216,33 @@ class LispGpeIface(object): :type state: str """ - VatExecutor.cmd_from_template(node, - 'lisp/lisp_gpe_iface.vat', + VatExecutor.cmd_from_template(node, 'lisp/lisp_gpe_iface.vat', state=state) +class LispGpeForwardEntry(object): + """The functionality needed for these methods is not implemented in VPP + (VAT). Bug https://jira.fd.io/browse/VPP-334 was open to cover this issue. + + TODO: Implement when VPP-334 is fixed. + """ + + def __init__(self): + pass + + @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 + + class LispMapResolver(object): """Class for Lisp map resolver API.""" @@ -544,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)