X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FPolicer.py;h=9e14a4fd582ee69da2b00d46f8438806cd5db654;hp=6098ac04021ec72da45df6ef2b160ed404cd013a;hb=545216fdee77b0b9ddc8d5e8c0f2e5662cacea76;hpb=c9d198a9f6494558574238dd055a14ef3a251d31 diff --git a/resources/libraries/python/Policer.py b/resources/libraries/python/Policer.py index 6098ac0402..9e14a4fd58 100644 --- a/resources/libraries/python/Policer.py +++ b/resources/libraries/python/Policer.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -22,7 +22,6 @@ from resources.libraries.python.VatJsonUtil import VatJsonUtil from resources.libraries.python.topology import Topology -# pylint: disable=too-few-public-methods class PolicerRateType(Enum): """Policer rate types.""" KBPS = 'kbps' @@ -110,8 +109,6 @@ class PolicerClassifyTableType(Enum): self.string = string -# pylint: disable=too-many-instance-attributes -# pylint: disable=too-many-public-methods class Policer(object): """Policer utilities.""" @@ -147,7 +144,6 @@ class Policer(object): # create policer color_aware = 'color-aware' if self._color_aware else '' - # pylint: disable=no-member conform_action = self._conform_action.value if PolicerAction.MARK_AND_TRANSMIT == self._conform_action: @@ -175,7 +171,6 @@ class Policer(object): exceed_action=exceed_action, violate_action=violate_action, color_aware=color_aware) - # pylint: enable=no-member VatJsonUtil.verify_vat_retval( out[0], @@ -187,7 +182,7 @@ class Policer(object): # create classify table direction = 'src' if self._classify_match_is_src else 'dst' - if 6 == ip_address(unicode(self._classify_match_ip)).version: + if ip_address(unicode(self._classify_match_ip)).version == 6: ip_version = 'ip6' table_type = PolicerClassifyTableType.IP6_TABLE else: @@ -216,7 +211,7 @@ class Policer(object): node, "policer/policer_classify_add_session.vat", policer_index=policer_index, - pre_color=self._classify_precolor.value, # pylint: disable=no-member + pre_color=self._classify_precolor.value, table_index=new_table_index, skip_n=skip_n_vectors, match_n=match_n_vectors, @@ -231,7 +226,7 @@ class Policer(object): node, "policer/policer_classify_set_interface.vat", sw_if_index=self._sw_if_index, - table_type=table_type.value, # pylint: disable=no-member + table_type=table_type.value, table_index=new_table_index) VatJsonUtil.verify_vat_retval( @@ -297,17 +292,23 @@ class Policer(object): """Set policer CB. :param cb: Committed Burst size. - :type cb: int + :type cb: int or str """ - self._cb = cb + if cb == "IMIX_v4_1": + self._cb = 1518 + else: + self._cb = cb def policer_set_eb(self, eb): """Set policer EB. :param eb: Excess Burst size. - :type eb: int + :type eb: int or str """ - self._eb = eb + if eb == "IMIX_v4_1": + self._eb = 1518 + else: + self._eb = eb def policer_set_rate_type_kbps(self): """Set policer rate type to kbps.""" @@ -415,9 +416,10 @@ class Policer(object): def policer_classify_set_interface(self, interface): """Set policer classify interface. + .. note:: First set node with policer_set_node. + :param interface: Interface name or sw_if_index. :type interface: str or int - .. note:: First set node with policer_set_node. """ if isinstance(interface, basestring): self._sw_if_index = Topology.get_interface_sw_index(self._node, @@ -440,7 +442,7 @@ class Policer(object): def dscp_cs0(): """Return DSCP CS0. - :return: DSCP enum CS0 object. + :returns: DSCP enum CS0 object. :rtype: DSCP """ return DSCP.CS0 @@ -449,7 +451,7 @@ class Policer(object): def dscp_cs1(): """Return DSCP CS1. - :return: DSCP enum CS1 object. + :returns: DSCP enum CS1 object. :rtype: DSCP """ return DSCP.CS1 @@ -458,7 +460,7 @@ class Policer(object): def dscp_cs2(): """Return DSCP CS2. - :return: DSCP enum CS2 object. + :returns: DSCP enum CS2 object. :rtype: DSCP """ return DSCP.CS2 @@ -467,7 +469,7 @@ class Policer(object): def dscp_cs3(): """Return DSCP CS3. - :return: DSCP enum CS3 object. + :returns: DSCP enum CS3 object. :rtype: DSCP """ return DSCP.CS3 @@ -476,7 +478,7 @@ class Policer(object): def dscp_cs4(): """Return DSCP CS4. - :return: DSCP enum CS4 object. + :returns: DSCP enum CS4 object. :rtype: DSCP """ return DSCP.CS4 @@ -485,7 +487,7 @@ class Policer(object): def dscp_cs5(): """Return DSCP CS5. - :return: DSCP enum CS5 object. + :returns: DSCP enum CS5 object. :rtype: DSCP """ return DSCP.CS5 @@ -494,7 +496,7 @@ class Policer(object): def dscp_cs6(): """Return DSCP CS6. - :return: DSCP enum CS6 object. + :returns: DSCP enum CS6 object. :rtype: DSCP """ return DSCP.CS6 @@ -503,7 +505,7 @@ class Policer(object): def dscp_cs7(): """Return DSCP CS7. - :return: DSCP enum CS7 object. + :returns: DSCP enum CS7 object. :rtype: DSCP """ return DSCP.CS7 @@ -512,7 +514,7 @@ class Policer(object): def dscp_ef(): """Return DSCP EF. - :return: DSCP enum EF object. + :returns: DSCP enum EF object. :rtype: DSCP """ return DSCP.EF @@ -521,7 +523,7 @@ class Policer(object): def dscp_af11(): """Return DSCP AF11. - :return: DSCP enum AF11 object. + :returns: DSCP enum AF11 object. :rtype: DSCP """ return DSCP.AF11 @@ -530,7 +532,7 @@ class Policer(object): def dscp_af12(): """Return DSCP AF12. - :return: DSCP enum AF12 object. + :returns: DSCP enum AF12 object. :rtype: DSCP """ return DSCP.AF12 @@ -539,7 +541,7 @@ class Policer(object): def dscp_af13(): """Return DSCP AF13. - :return: DSCP enum AF13 object. + :returns: DSCP enum AF13 object. :rtype: DSCP """ return DSCP.AF13 @@ -548,7 +550,7 @@ class Policer(object): def dscp_af21(): """Return DSCP AF21. - :return: DSCP enum AF21 object. + :returns: DSCP enum AF21 object. :rtype: DSCP """ return DSCP.AF21 @@ -557,7 +559,7 @@ class Policer(object): def dscp_af22(): """Return DSCP AF22. - :return: DSCP enum AF22 object. + :returns: DSCP enum AF22 object. :rtype: DSCP """ return DSCP.AF22 @@ -566,7 +568,7 @@ class Policer(object): def dscp_af23(): """Return DSCP AF23. - :return: DSCP enum AF23 object. + :returns: DSCP enum AF23 object. :rtype: DSCP """ return DSCP.AF23 @@ -575,7 +577,7 @@ class Policer(object): def dscp_af31(): """Return DSCP AF31. - :return: DSCP enum AF31 object. + :returns: DSCP enum AF31 object. :rtype: DSCP """ return DSCP.AF31 @@ -584,7 +586,7 @@ class Policer(object): def dscp_af32(): """Return DSCP AF32. - :return: DSCP enum AF32 object. + :returns: DSCP enum AF32 object. :rtype: DSCP """ return DSCP.AF32 @@ -593,7 +595,7 @@ class Policer(object): def dscp_af33(): """Return DSCP AF33. - :return: DSCP enum AF33 object. + :returns: DSCP enum AF33 object. :rtype: DSCP """ return DSCP.AF33 @@ -604,7 +606,7 @@ class Policer(object): :param dscp: DSCP enum object. :type dscp: DSCP - :return: DSCP numeric value. + :returns: DSCP numeric value. :rtype: int """ return dscp.num