FIX: Pylint 13/21113/7
authorPeter Mikus <pmikus@cisco.com>
Wed, 7 Aug 2019 13:58:59 +0000 (13:58 +0000)
committerVratko Polak <vrpolak@cisco.com>
Wed, 7 Aug 2019 16:20:35 +0000 (16:20 +0000)
- my bad

Signed-off-by: Peter Mikus <pmikus@cisco.com>
Change-Id: I8c1f57f6b648b99338f3f6a6ff9ec943082e9bc4

resources/libraries/python/GBP.py
resources/libraries/python/InterfaceUtil.py
resources/libraries/python/PapiExecutor.py
resources/libraries/python/TestConfig.py
resources/libraries/python/topology.py
resources/tools/integrated/check_crc.py

index 4dd5486..ff0c133 100644 (file)
@@ -19,7 +19,6 @@ from ipaddress import ip_address
 from resources.libraries.python.IPUtil import IPUtil
 from resources.libraries.python.L2Util import L2Util
 from resources.libraries.python.PapiExecutor import PapiSocketExecutor
-from resources.libraries.python.topology import Topology
 
 
 class GBPEndpointFlags(IntEnum):
@@ -89,12 +88,12 @@ class GBP(object):
                   .format(node=node['host'])
 
         args_in = dict(
-            rd = dict (
-                rd_id = rd_id,
-                ip4_table_id = ip4_table_id,
-                ip6_table_id = ip6_table_id,
-                ip4_uu_sw_if_index = ip4_uu_sw_if_index,
-                ip6_uu_sw_if_index = ip6_uu_sw_if_index
+            rd=dict(
+                rd_id=rd_id,
+                ip4_table_id=ip4_table_id,
+                ip6_table_id=ip6_table_id,
+                ip4_uu_sw_if_index=ip4_uu_sw_if_index,
+                ip6_uu_sw_if_index=ip6_uu_sw_if_index
             )
         )
 
@@ -125,14 +124,14 @@ class GBP(object):
                   .format(node=node['host'])
 
         args_in = dict(
-            bd = dict(
-                flags = getattr(GBPBridgeDomainFlags,
-                                'GBP_BD_API_FLAG_NONE').value,
-                bvi_sw_if_index = bvi_sw_if_index,
-                uu_fwd_sw_if_index = uu_fwd_sw_if_index,
-                bm_flood_sw_if_index = bm_flood_sw_if_index,
-                bd_id = bd_id,
-                rd_id = rd_id
+            bd=dict(
+                flags=getattr(GBPBridgeDomainFlags,
+                              'GBP_BD_API_FLAG_NONE').value,
+                bvi_sw_if_index=bvi_sw_if_index,
+                uu_fwd_sw_if_index=uu_fwd_sw_if_index,
+                bm_flood_sw_if_index=bm_flood_sw_if_index,
+                bd_id=bd_id,
+                rd_id=rd_id
             )
         )
 
@@ -165,14 +164,14 @@ class GBP(object):
                   .format(node=node['host'])
 
         args_in = dict(
-            epg = dict (
-                uplink_sw_if_index = uplink_sw_if_index,
-                bd_id = bd_id,
-                rd_id = rd_id,
-                vnid = vnid,
-                sclass = sclass,
-                retention = dict (
-                    remote_ep_timeout = remote_ep_timeout
+            epg=dict(
+                uplink_sw_if_index=uplink_sw_if_index,
+                bd_id=bd_id,
+                rd_id=rd_id,
+                vnid=vnid,
+                sclass=sclass,
+                retention=dict(
+                    remote_ep_timeout=remote_ep_timeout
                 )
             )
         )
@@ -208,17 +207,17 @@ class GBP(object):
             ip_address(unicode('0.0.0.0')))
 
         args_in = dict(
-            endpoint = dict(
-                sw_if_index = sw_if_index,
-                ips = ips,
-                n_ips = len(ips),
-                mac = L2Util.mac_to_bin(mac_addr),
-                sclass = sclass,
-                flags = getattr(GBPEndpointFlags,
-                                'GBP_API_ENDPOINT_FLAG_EXTERNAL').value,
-                tun = dict(
-                    src = tun_src,
-                    dst = tun_dst
+            endpoint=dict(
+                sw_if_index=sw_if_index,
+                ips=ips,
+                n_ips=len(ips),
+                mac=L2Util.mac_to_bin(mac_addr),
+                sclass=sclass,
+                flags=getattr(GBPEndpointFlags,
+                              'GBP_API_ENDPOINT_FLAG_EXTERNAL').value,
+                tun=dict(
+                    src=tun_src,
+                    dst=tun_dst
                 )
             )
         )
@@ -244,13 +243,13 @@ class GBP(object):
                   .format(node=node['host'])
 
         args_in = dict(
-            is_add = 1,
-            ext_itf = dict(
-                sw_if_index = sw_if_index,
-                bd_id = bd_id,
-                rd_id = rd_id,
-                flags = getattr(GBPExtItfFlags,
-                                'GBP_API_EXT_ITF_F_NONE').value
+            is_add=1,
+            ext_itf=dict(
+                sw_if_index=sw_if_index,
+                bd_id=bd_id,
+                rd_id=rd_id,
+                flags=getattr(GBPExtItfFlags,
+                              'GBP_API_EXT_ITF_F_NONE').value
             )
         )
 
@@ -281,18 +280,18 @@ class GBP(object):
                   .format(node=node['host'])
 
         args_in = dict(
-            is_add = 1,
-            subnet = dict(
-                type = getattr(GBPSubnetType,
-                               'GBP_API_SUBNET_L3_OUT').value,
-                sw_if_index = sw_if_index,
-                sclass = sclass,
-                prefix = dict(
-                    address = IPUtil.create_ip_address_object(
+            is_add=1,
+            subnet=dict(
+                type=getattr(GBPSubnetType,
+                             'GBP_API_SUBNET_L3_OUT').value,
+                sw_if_index=sw_if_index,
+                sclass=sclass,
+                prefix=dict(
+                    address=IPUtil.create_ip_address_object(
                         ip_address(unicode(address))),
-                    len = int(subnet_length)
+                    len=int(subnet_length)
                 ),
-                rd_id = rd_id
+                rd_id=rd_id
             )
         )
 
@@ -317,26 +316,26 @@ class GBP(object):
                   .format(node=node['host'])
 
         rule_permit = dict(
-            action = getattr(GBPRuleAction,
-                             'GBP_API_RULE_PERMIT').value,
-            nh_set = dict(
-                hash_mode = list(),
-                n_nhs = 8,
-                nhs = [dict()]*8,
+            action=getattr(GBPRuleAction,
+                           'GBP_API_RULE_PERMIT').value,
+            nh_set=dict(
+                hash_mode=list(),
+                n_nhs=8,
+                nhs=[dict()]*8,
             )
         )
         rules = [rule_permit, rule_permit]
 
         args_in = dict(
-            is_add = 1,
-            contract = dict(
-                acl_index = acl_index,
-                sclass = sclass,
-                dclass = dclass,
-                n_rules = len(rules),
-                rules = rules,
-                n_ether_types = 16,
-                allowed_ethertypes = [0x800, 0x86dd] + [0]*14
+            is_add=1,
+            contract=dict(
+                acl_index=acl_index,
+                sclass=sclass,
+                dclass=dclass,
+                n_rules=len(rules),
+                rules=rules,
+                n_ether_types=16,
+                allowed_ethertypes=[0x800, 0x86dd] + [0]*14
             )
         )
 
index 7024e85..1f79d7e 100644 (file)
@@ -1161,10 +1161,8 @@ class InterfaceUtil(object):
 
         for bond in details:
             data += ('{b}\n'.format(b=bond['interface_name'].rstrip('\x00')))
-            data += ('  mode: {m}\n'.format(m=LinkBondMode(
-                bond['mode']).name.lower()))
-            data += ('  load balance: {lb}\n'.format(lb=LinkBondLoadBalance(
-                bond['lb']).name.lower()))
+            data += ('  mode: {m}\n'.format(m=bond['mode']).lower())
+            data += ('  load balance: {lb}\n'.format(lb=bond['lb']).lower())
             data += ('  number of active slaves: {n}\n'.format(
                 n=bond['active_slaves']))
             if verbose:
index d7130eb..adafa88 100644 (file)
@@ -148,8 +148,7 @@ class PapiSocketExecutor(object):
         self._ssh_control_socket = None
         self._local_vpp_socket = None
 
-    @property
-    def crc_checker(self):
+    def create_crc_checker(self):
         """Return the cached instance or create new one from directory.
 
         It is assumed self.api_json_directory is set, as a class variable.
@@ -204,7 +203,7 @@ class PapiSocketExecutor(object):
             cls.api_json_directory = tmp_dir + "/usr/share/vpp/api"
             # Perform initial checks before .api.json files are gone,
             # by accessing the property (which also creates its instance).
-            self.crc_checker
+            self.create_crc_checker()
             # When present locally, we finally can find the installation path.
             package_path = glob.glob(tmp_dir + installed_papi_glob)[0]
             # Package path has to be one level above the vpp_papi directory.
index 787f27b..5887c11 100644 (file)
@@ -166,8 +166,6 @@ class TestConfig(object):
             sw_if_index=InterfaceUtil.get_interface_index(
                 node, node_vlan_if),
             vlan_id=None)
-        err_msg = 'Failed to create VXLAN and VLAN interfaces on host {host}'.\
-            format(host=node['host'])
 
         with PapiSocketExecutor(node) as papi_exec:
             for i in xrange(0, vxlan_count):
@@ -256,8 +254,6 @@ class TestConfig(object):
         args2 = dict(
             sw_if_index=None,
             admin_up_down=1)
-        err_msg = 'Failed to put VXLAN and VLAN interfaces up on host {host}'. \
-            format(host=node['host'])
 
         with PapiSocketExecutor(node) as papi_exec:
             for i in xrange(0, vxlan_count):
@@ -394,8 +390,6 @@ class TestConfig(object):
             shg=0,
             port_type=0,
             enable=1)
-        err_msg = 'Failed to put VXLAN and VLAN interfaces to bridge domain ' \
-                  'on host {host}'.format(host=node['host'])
 
         with PapiSocketExecutor(node) as papi_exec:
             for i in xrange(0, vxlan_count):
index 68045bb..698c97b 100644 (file)
@@ -403,7 +403,8 @@ class Topology(object):
         interface index assigned to the interface by vpp for a given node.
 
         :param node: The node topology dictionary.
-        :param sw_if_index: sw_if_index of the link that a interface is connected to.
+        :param sw_if_index: sw_if_index of the link that a interface is
+            connected to.
         :type node: dict
         :type sw_if_index: int
         :returns: Interface name of the interface connected to the given link.
index 3e2836c..3d5c30a 100644 (file)
@@ -27,12 +27,12 @@ from resources.libraries.python.VppApiCrc import VppApiCrcChecker
 # TODO: Read FDIO_VPP_DIR environment variable, or some other input,
 # instead of using hardcoded relative path?
 
-api_dir = op.normpath(op.join(
+API_DIR = op.normpath(op.join(
     op.dirname(op.abspath(__file__)), "..", "..", "..", "..",
     "build-root", "install-vpp-native", "vpp", "share", "vpp", "api"))
-checker = VppApiCrcChecker(api_dir)
+CHECKER = VppApiCrcChecker(API_DIR)
 try:
-    checker.report_initial_conflicts(report_missing=True)
+    CHECKER.report_initial_conflicts(report_missing=True)
 except RuntimeError as err:
     sys.stderr.write("{err!r}\n".format(err=err))
     sys.stderr.write(