X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FPolicer.py;h=2c4cc66d2cc1dc84c1cdd88a2c75a3bf4c3b6bd7;hb=e916ab4db7dec2cc0bb21dcc31460f819d68b0d5;hp=f6a852e417308591ce7580445323c964d97d8b0f;hpb=d68951ac245150eeefa6e0f4156e4c1b5c9e9325;p=csit.git diff --git a/resources/libraries/python/Policer.py b/resources/libraries/python/Policer.py index f6a852e417..2c4cc66d2c 100644 --- a/resources/libraries/python/Policer.py +++ b/resources/libraries/python/Policer.py @@ -84,7 +84,11 @@ class DSCP(IntEnum): class Policer: """Policer utilities.""" - # pylint: disable=too-many-arguments, too-many-locals + # TODO: Pylint says too-many-arguments and too-many-locals. + # It is right, we should refactor the code + # and group similar arguments together (into documented classes). + # Note that even the call from Robot Framework + # is not very readable with this many arguments. @staticmethod def policer_set_configuration( node, policer_name, cir, eir, cbs, ebs, rate_type, round_type, @@ -176,7 +180,7 @@ class Policer: def policer_classify_set_interface( node, interface, ip4_table_index=Constants.BITWISE_NON_ZERO, ip6_table_index=Constants.BITWISE_NON_ZERO, - l2_table_index=Constants.BITWISE_NON_ZERO, is_add=1): + l2_table_index=Constants.BITWISE_NON_ZERO, is_add=True): """Set/unset policer classify interface. :param node: VPP node. @@ -188,12 +192,13 @@ class Policer: (Default value = ~0) :param l2_table_index: L2 classify table index (~0 to skip). (Default value = ~0) - :param is_add: Set if non-zero, else unset. + :param is_add: Set if True, else unset. :type node: dict :type interface: str or int :type ip4_table_index: int :type ip6_table_index: int :type l2_table_index: int + :type is_add: bool """ if isinstance(interface, str): sw_if_index = Topology.get_interface_sw_index(node, interface) @@ -202,8 +207,8 @@ class Policer: cmd = u"policer_classify_set_interface" args = dict( - is_add=int(is_add), - sw_if_index=sw_if_index, + is_add=is_add, + sw_if_index=int(sw_if_index), ip4_table_index=int(ip4_table_index), ip6_table_index=int(ip6_table_index), l2_table_index=int(l2_table_index)