]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: python3 compat fixes for topotests: tabs and misc
authorMark Stapp <mjs@voltanet.io>
Wed, 23 Sep 2020 21:08:36 +0000 (17:08 -0400)
committerMark Stapp <mjs@voltanet.io>
Sat, 26 Sep 2020 19:40:00 +0000 (15:40 -0400)
Use only spaces in python files; no tabs; also a couple of small
api fixes.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
37 files changed:
tests/topotests/all-protocol-startup/test_all_protocol_startup.py [changed mode: 0755->0644]
tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py [changed mode: 0755->0644]
tests/topotests/bgp-evpn-mh/test_evpn_mh.py
tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py [changed mode: 0755->0644]
tests/topotests/bgp-prefix-list-topo1/test_prefix_lists.py [changed mode: 0755->0644]
tests/topotests/bgp-route-map/test_route_map_topo1.py [changed mode: 0755->0644]
tests/topotests/bgp-route-map/test_route_map_topo2.py [changed mode: 0755->0644]
tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py [changed mode: 0755->0644]
tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py [changed mode: 0755->0644]
tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py [changed mode: 0755->0644]
tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py [changed mode: 0755->0644]
tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py [changed mode: 0755->0644]
tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py [changed mode: 0755->0644]
tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py [changed mode: 0755->0644]
tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py [changed mode: 0755->0644]
tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py [changed mode: 0755->0644]
tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py [changed mode: 0755->0644]
tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py [changed mode: 0755->0644]
tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py [changed mode: 0755->0644]
tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py [changed mode: 0755->0644]
tests/topotests/eigrp-topo1/test_eigrp_topo1.py
tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py [changed mode: 0755->0644]
tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py [changed mode: 0755->0644]
tests/topotests/isis-topo1-vrf/test_isis_topo1_vrf.py
tests/topotests/ldp-topo1/test_ldp_topo1.py [changed mode: 0755->0644]
tests/topotests/lib/common_config.py
tests/topotests/lib/ltemplate.py
tests/topotests/lib/lutil.py [changed mode: 0755->0644]
tests/topotests/lib/ospf.py
tests/topotests/lib/topogen.py
tests/topotests/lib/topojson.py
tests/topotests/lib/topolog.py
tests/topotests/lib/topotest.py
tests/topotests/ospf-topo2/test_ospf_topo2.py
tests/topotests/pbr-topo1/test_pbr_topo1.py
tests/topotests/rip-topo1/test_rip_topo1.py [changed mode: 0755->0644]
tests/topotests/ripng-topo1/test_ripng_topo1.py [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 2a00398..136689e
@@ -113,8 +113,8 @@ def setup_module(module):
         net['r%s' % i].loadConf('ospfd', '%s/r%s/ospfd.conf' % (thisDir, i))
         if net['r1'].checkRouterVersion('<', '4.0'):
             net['r%s' % i].loadConf('ospf6d', '%s/r%s/ospf6d.conf-pre-v4' % (thisDir, i))
-       else:
-           net['r%s' % i].loadConf('ospf6d', '%s/r%s/ospf6d.conf' % (thisDir, i))
+        else:
+            net['r%s' % i].loadConf('ospf6d', '%s/r%s/ospf6d.conf' % (thisDir, i))
         net['r%s' % i].loadConf('isisd', '%s/r%s/isisd.conf' % (thisDir, i))
         net['r%s' % i].loadConf('bgpd', '%s/r%s/bgpd.conf' % (thisDir, i))
         if net['r%s' % i].daemon_available('ldpd'):
@@ -611,7 +611,7 @@ def test_ospfv2_interfaces():
             actual = net['r%s' % i].cmd('vtysh -c "show ip ospf interface" 2> /dev/null').rstrip()
             # Mask out Bandwidth portion. They may change..
             actual = re.sub(r"BW [0-9]+ Mbit", "BW XX Mbit", actual)
-           actual = re.sub(r"ifindex [0-9]", "ifindex X", actual)
+            actual = re.sub(r"ifindex [0-9]", "ifindex X", actual)
 
             # Drop time in next due 
             actual = re.sub(r"Hello due in [0-9\.]+s", "Hello due in XX.XXXs", actual)
@@ -882,45 +882,45 @@ def test_bgp_ipv4():
     print("******************************************\n")
     diffresult = {}
     for i in range(1, 2):
-       success = 0
-       for refTableFile in (glob.glob(
-               '%s/r%s/show_bgp_ipv4*.ref' % (thisDir, i))):
-           if os.path.isfile(refTableFile):
-               # Read expected result from file
-               expected = open(refTableFile).read().rstrip()
-               # Fix newlines (make them all the same)
-               expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
-
-               # Actual output from router
-               actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv4" 2> /dev/null').rstrip()
-               # Remove summary line (changed recently)
-               actual = re.sub(r'Total number.*', '', actual)
-               actual = re.sub(r'Displayed.*', '', actual)
-               actual = actual.rstrip()
-               # Fix newlines (make them all the same)
-               actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
-
-               # Generate Diff
-               diff = topotest.get_textdiff(actual, expected,
-                   title1="actual SHOW BGP IPv4",
-                   title2="expected SHOW BGP IPv4")
-
-               # Empty string if it matches, otherwise diff contains unified diff
-               if diff:
-                   diffresult[refTableFile] = diff
-               else:
-                   success = 1
-                   print("template %s matched: r%s ok" % (refTableFile, i))
-                   break
-
-       if not success:
-           resultstr = 'No template matched.\n'
-           for f in diffresult.iterkeys():
-               resultstr += (
-                   'template %s: r%s failed SHOW BGP IPv4 check:\n%s\n'
-                   % (f, i, diffresult[f]))
-           raise AssertionError(
-               "SHOW BGP IPv4 failed for router r%s:\n%s" % (i, resultstr))
+        success = 0
+        for refTableFile in (glob.glob(
+                '%s/r%s/show_bgp_ipv4*.ref' % (thisDir, i))):
+            if os.path.isfile(refTableFile):
+                # Read expected result from file
+                expected = open(refTableFile).read().rstrip()
+                # Fix newlines (make them all the same)
+                expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
+
+                # Actual output from router
+                actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv4" 2> /dev/null').rstrip()
+                # Remove summary line (changed recently)
+                actual = re.sub(r'Total number.*', '', actual)
+                actual = re.sub(r'Displayed.*', '', actual)
+                actual = actual.rstrip()
+                # Fix newlines (make them all the same)
+                actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
+
+                # Generate Diff
+                diff = topotest.get_textdiff(actual, expected,
+                    title1="actual SHOW BGP IPv4",
+                    title2="expected SHOW BGP IPv4")
+
+                # Empty string if it matches, otherwise diff contains unified diff
+                if diff:
+                    diffresult[refTableFile] = diff
+                else:
+                    success = 1
+                    print("template %s matched: r%s ok" % (refTableFile, i))
+                    break
+
+        if not success:
+            resultstr = 'No template matched.\n'
+            for f in diffresult.iterkeys():
+                resultstr += (
+                    'template %s: r%s failed SHOW BGP IPv4 check:\n%s\n'
+                    % (f, i, diffresult[f]))
+            raise AssertionError(
+                "SHOW BGP IPv4 failed for router r%s:\n%s" % (i, resultstr))
 
     # Make sure that all daemons are running
     for i in range(1, 2):
@@ -945,44 +945,44 @@ def test_bgp_ipv6():
     print("******************************************\n")
     diffresult = {}
     for i in range(1, 2):
-       success = 0
-       for refTableFile in (glob.glob(
-               '%s/r%s/show_bgp_ipv6*.ref' % (thisDir, i))):
-           if os.path.isfile(refTableFile):
-               # Read expected result from file
-               expected = open(refTableFile).read().rstrip()
-               # Fix newlines (make them all the same)
-               expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
-
-               # Actual output from router
-               actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv6" 2> /dev/null').rstrip()
-               # Remove summary line (changed recently)
-               actual = re.sub(r'Total number.*', '', actual)
-               actual = re.sub(r'Displayed.*', '', actual)
-               actual = actual.rstrip()
-               # Fix newlines (make them all the same)
-               actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
-
-               # Generate Diff
-               diff = topotest.get_textdiff(actual, expected,
-                   title1="actual SHOW BGP IPv6",
-                   title2="expected SHOW BGP IPv6")
-
-               # Empty string if it matches, otherwise diff contains unified diff
-               if diff:
-                   diffresult[refTableFile] = diff
-               else:
-                   success = 1
-                   print("template %s matched: r%s ok" % (refTableFile, i))
-
-       if not success:
-           resultstr = 'No template matched.\n'
-           for f in diffresult.iterkeys():
-               resultstr += (
-                   'template %s: r%s failed SHOW BGP IPv6 check:\n%s\n'
-                   % (f, i, diffresult[f]))
-           raise AssertionError(
-               "SHOW BGP IPv6 failed for router r%s:\n%s" % (i, resultstr))
+        success = 0
+        for refTableFile in (glob.glob(
+                '%s/r%s/show_bgp_ipv6*.ref' % (thisDir, i))):
+            if os.path.isfile(refTableFile):
+                # Read expected result from file
+                expected = open(refTableFile).read().rstrip()
+                # Fix newlines (make them all the same)
+                expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
+
+                # Actual output from router
+                actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv6" 2> /dev/null').rstrip()
+                # Remove summary line (changed recently)
+                actual = re.sub(r'Total number.*', '', actual)
+                actual = re.sub(r'Displayed.*', '', actual)
+                actual = actual.rstrip()
+                # Fix newlines (make them all the same)
+                actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
+
+                # Generate Diff
+                diff = topotest.get_textdiff(actual, expected,
+                    title1="actual SHOW BGP IPv6",
+                    title2="expected SHOW BGP IPv6")
+
+                # Empty string if it matches, otherwise diff contains unified diff
+                if diff:
+                    diffresult[refTableFile] = diff
+                else:
+                    success = 1
+                    print("template %s matched: r%s ok" % (refTableFile, i))
+
+        if not success:
+            resultstr = 'No template matched.\n'
+            for f in diffresult.iterkeys():
+                resultstr += (
+                    'template %s: r%s failed SHOW BGP IPv6 check:\n%s\n'
+                    % (f, i, diffresult[f]))
+            raise AssertionError(
+                "SHOW BGP IPv6 failed for router r%s:\n%s" % (i, resultstr))
 
     # Make sure that all daemons are running
     for i in range(1, 2):
index ee50a422a73d7deb58edd1869e91bf3c9c70759d..9af22c06bda5e6e9911318c956ae917f43f3696a 100644 (file)
@@ -477,9 +477,9 @@ def check_es(dut):
             vtep_ips.append(vtep["vtep_ip"])
 
         if "local" in types:
-           result = check_local_es(esi, vtep_ips, dut.name, [])
+            result = check_local_es(esi, vtep_ips, dut.name, [])
         else:
-           result = check_remote_es(esi, vtep_ips, dut.name, [])
+            result = check_remote_es(esi, vtep_ips, dut.name, [])
 
         if result:
             return result
old mode 100755 (executable)
new mode 100644 (file)
index 3ad989c..0d99f23
@@ -143,7 +143,7 @@ def setup_module(mod):
         logger.info('result: '+output);
     router = tgen.gears['r1']
 
-    for rname, router in router_list.iteritems():
+    for rname, router in router_list.items():
         if rname == 'r1':
             router.load_config(
                 TopoRouter.RD_ZEBRA,
index 70666a3d612bd33b746b05cb9fd08661188ea4b4..3ce1472ac0ca03653c8721c44f11c42aedde0a4d 100644 (file)
@@ -252,7 +252,7 @@ def ip_eigrp_topo(node):
         if code not in ["P", "A", "U", "Q", "R", "r", "s"]:
             continue
 
-        if not result.has_key(code):
+        if code not in result:
             result[code] = {}
 
         # Split network from the rest
old mode 100755 (executable)
new mode 100644 (file)
index 9e38582..c1eb7d6
@@ -26,9 +26,9 @@ Following tests are covered to test EVPN-Type5 functionality:
 1. RD verification (manual/auto).
 2. RT verification(manual)
 3. In an active/standby EVPN implementation, if active DCG goes down,
-       secondary takes over.
+        secondary takes over.
 4. EVPN routes are advertised/withdrawn, based on VNFs
-       advertising/withdrawing IP prefixes.
+        advertising/withdrawing IP prefixes.
 5. Route-map operations for EVPN address family.
 6. BGP attributes for EVPN address-family.
 """
index 65515f22cc3af9077468255fef768dd12a695466..7943b94189d5ee4d821e354ef58cfead2f2ac4fd 100644 (file)
@@ -210,7 +210,7 @@ def test_isis_linux_route_installation():
     dist = platform.dist()
 
     if (dist[1] == "16.04"):
-       pytest.skip("Kernel not supported for vrf")
+        pytest.skip("Kernel not supported for vrf")
 
     "Check whether all expected routes are present and installed in the OS"
     tgen = get_topogen()
@@ -267,7 +267,7 @@ def test_isis_linux_route6_installation():
     dist = platform.dist()
 
     if (dist[1] == "16.04"):
-       pytest.skip("Kernel not supported for vrf")
+        pytest.skip("Kernel not supported for vrf")
 
     "Check whether all expected routes are present and installed in the OS"
     tgen = get_topogen()
old mode 100755 (executable)
new mode 100644 (file)
index 6dd8d646f3b9fa6a5300ad6e3bbfc6f539fdf2df..c6944c3568afbc4efba54a45889e4160ee963d15 100644 (file)
@@ -31,16 +31,14 @@ from re import search as re_search
 from tempfile import mkdtemp
 
 import os
+import io
 import sys
-import ConfigParser
 import traceback
 import socket
 import ipaddress
 import platform
 
-
 if sys.version_info[0] > 2:
-    import io
     import configparser
 else:
     import StringIO
index 192c121008619b5771c5fa9a07839fd128e3d7f6..3c93e1ac5c065ee87d960a93fcbd47f13714a6ba 100644 (file)
@@ -157,8 +157,8 @@ def ltemplateTest(script, SkipIfFailed=True, CallOnFail=None, CheckFuncStr=None,
     if SkipIfFailed and tgen.routers_have_failure():
         pytest.skip(tgen.errors)
     if numEntry > 0:
-       if not KeepGoing:
-           pytest.skip("Have %d errors" % numEntry)
+        if not KeepGoing:
+            pytest.skip("Have %d errors" % numEntry)
 
     if CheckFuncStr != None:
         check = eval(CheckFuncStr)
@@ -172,8 +172,8 @@ def ltemplateTest(script, SkipIfFailed=True, CallOnFail=None, CheckFuncStr=None,
     if numFail > 0:
         luShowFail()
         fatal_error = "%d tests failed" % numFail
-       if not KeepGoing:
-           assert "scripts/cleanup_all.py failed" == "See summary output above", fatal_error
+        if not KeepGoing:
+            assert "scripts/cleanup_all.py failed" == "See summary output above", fatal_error
 
 # Memory leak test template
 def test_memory_leak():
old mode 100755 (executable)
new mode 100644 (file)
index 4ea97a3..05ed9c0
@@ -204,17 +204,17 @@ Total %-4d                                                           %-4d %d\n\
                     self.log('WARNING: JSON load failed -- confirm command output is in JSON format.')
         self.log('COMMAND OUTPUT:%s:' % report)
 
-       # Experiment: can we achieve the same match behavior via DOTALL
-       # without converting newlines to spaces?
-       out_nl = out
-       search_nl = re.search(regexp, out_nl, re.DOTALL);
-       self.l_last_nl = search_nl
-       # Set up for comparison
-       if search_nl != None:
-           group_nl = search_nl.group()
-           group_nl_converted = " ".join(group_nl.splitlines())
+        # Experiment: can we achieve the same match behavior via DOTALL
+        # without converting newlines to spaces?
+        out_nl = out
+        search_nl = re.search(regexp, out_nl, re.DOTALL);
+        self.l_last_nl = search_nl
+        # Set up for comparison
+        if search_nl != None:
+            group_nl = search_nl.group()
+            group_nl_converted = " ".join(group_nl.splitlines())
         else:
-           group_nl_converted = None
+            group_nl_converted = None
 
         out = " ".join(out.splitlines())
         search = re.search(regexp, out)
@@ -234,9 +234,9 @@ Total %-4d                                                           %-4d %d\n\
                 success = False
                 level = 5
             self.log('found:%s:' % ret, level)
-           # Experiment: compare matched strings obtained each way
-           if self.l_dotall_experiment and (group_nl_converted != ret):
-               self.log('DOTALL experiment: strings differ dotall=[%s] orig=[%s]' % (group_nl_converted, ret), 9)
+            # Experiment: compare matched strings obtained each way
+            if self.l_dotall_experiment and (group_nl_converted != ret):
+                self.log('DOTALL experiment: strings differ dotall=[%s] orig=[%s]' % (group_nl_converted, ret), 9)
         if op == 'pass' or op == 'fail':
             self.result(target, success, result)
         if js != None:
@@ -297,13 +297,13 @@ def luCommand(target, command, regexp='.', op='none', result='', time=10, return
 
 def luLast(usenl=False):
     if usenl:
-       if LUtil.l_last_nl != None:
-           LUtil.log('luLast:%s:' %  LUtil.l_last_nl.group(), 7)
-       return LUtil.l_last_nl
+        if LUtil.l_last_nl != None:
+            LUtil.log('luLast:%s:' %  LUtil.l_last_nl.group(), 7)
+        return LUtil.l_last_nl
     else:
-       if LUtil.l_last != None:
-           LUtil.log('luLast:%s:' %  LUtil.l_last.group(), 7)
-       return LUtil.l_last
+        if LUtil.l_last != None:
+            LUtil.log('luLast:%s:' %  LUtil.l_last.group(), 7)
+        return LUtil.l_last
 
 def luInclude(filename, CallOnFail=None):
     tstFile = LUtil.base_script_dir + '/' + filename
index a2351bf7471597046f4683e924011e883976b533..3596525c5e104c7b580b576fd9b4ddacc8070850 100644 (file)
@@ -516,7 +516,7 @@ def verify_ospf_neighbor(tgen, topo, dut=None, input_dict=None, lan=False):
     logger.debug("Entering lib API: verify_ospf_neighbor()")
     result = False
     if input_dict:
-        for router, rnode in tgen.routers().iteritems():
+        for router, rnode in tgen.routers().items():
             if 'ospf' not in topo['routers'][router]:
                 continue
 
@@ -584,7 +584,7 @@ def verify_ospf_neighbor(tgen, topo, dut=None, input_dict=None, lan=False):
                         return errormsg
                 continue
     else:
-        for router, rnode in tgen.routers().iteritems():
+        for router, rnode in tgen.routers().items():
             if 'ospf' not in topo['routers'][router]:
                 continue
 
@@ -694,7 +694,7 @@ def verify_ospf_rib(tgen, dut, input_dict, next_hop=None,
     additional_nexthops_in_required_nhs = []
     found_hops = []
     for routerInput in input_dict.keys():
-        for router, rnode in router_list.iteritems():
+        for router, rnode in router_list.items():
             if router != dut:
                 continue
 
@@ -927,7 +927,7 @@ def verify_ospf_interface(tgen, topo, dut=None,lan=False, input_dict=None):
 
     logger.debug("Entering lib API: verify_ospf_interface()")
     result = False
-    for router, rnode in tgen.routers().iteritems():
+    for router, rnode in tgen.routers().items():
         if 'ospf' not in topo['routers'][router]:
             continue
 
index 171a894b358f5faf51f356b787f767702536248c..ffdcb683e7f398c5c0341510d03cd484909cd117 100644 (file)
@@ -40,6 +40,7 @@ Basic usage instructions:
 
 import os
 import sys
+import io
 import logging
 import json
 
@@ -97,7 +98,7 @@ tgen_defaults = {
     "verbosity": "info",
     "frrdir": "/usr/lib/frr",
     "routertype": "frr",
-    "memleak_path": None,
+    "memleak_path": "",
 }
 
 
@@ -182,7 +183,7 @@ class Topogen(object):
 
         params["frrdir"] = self.config.get(self.CONFIG_SECTION, "frrdir")
         params["memleak_path"] = self.config.get(self.CONFIG_SECTION, "memleak_path")
-        if not params.has_key("routertype"):
+        if "routertype" not in params:
             params["routertype"] = self.config.get(self.CONFIG_SECTION, "routertype")
 
         self.gears[name] = TopoRouter(self, cls, name, **params)
@@ -360,7 +361,7 @@ class Topogen(object):
         memleak_file = os.environ.get("TOPOTESTS_CHECK_MEMLEAK") or self.config.get(
             self.CONFIG_SECTION, "memleak_path"
         )
-        if memleak_file is None:
+        if memleak_file == "" or memleak_file == None:
             return False
         return True
 
@@ -586,7 +587,7 @@ class TopoRouter(TopoGear):
         self.cls = cls
         self.options = {}
         self.routertype = params.get("routertype", "frr")
-        if not params.has_key("privateDirs"):
+        if "privateDirs" not in params:
             params["privateDirs"] = self.PRIVATE_DIRS
 
         self.options["memleak_path"] = params.get("memleak_path", None)
@@ -822,7 +823,7 @@ class TopoRouter(TopoGear):
         memleak_file = (
             os.environ.get("TOPOTESTS_CHECK_MEMLEAK") or self.options["memleak_path"]
         )
-        if memleak_file is None:
+        if memleak_file == "" or memleak_file == None:
             return
 
         self.stop()
@@ -1011,7 +1012,7 @@ def diagnose_env_linux():
     logger.info("Running environment diagnostics")
 
     # Load configuration
-    config = configparser.ConfigParser(tgen_defaults)
+    config = configparser.ConfigParser(defaults=tgen_defaults)
     pytestini_path = os.path.join(CWD, "../pytest.ini")
     config.read(pytestini_path)
 
@@ -1106,10 +1107,10 @@ def diagnose_env_linux():
 
     # TODO remove me when we start supporting exabgp >= 4
     try:
-        output = subprocess.check_output(["exabgp", "-v"])
-        line = output.split("\n")[0]
-        version = line.split(" ")[2]
-        if topotest.version_cmp(version, "4") >= 0:
+        p = os.popen("exabgp -v")
+        line = p.readlines()
+        version = line[0].split()
+        if topotest.version_cmp(version[2], "4") >= 0:
             logger.warning(
                 "BGP topologies are still using exabgp version 3, expect failures"
             )
index b3af09aa9948ad8f2af303ab8a595f605dbabc23..6535918e3629cfccb8d22fc3c4d7b20c5d8d94ef 100644 (file)
@@ -216,7 +216,7 @@ def build_topo_from_json(tgen, topo):
         # Physical Interfaces
         if "links" in  topo['switches'][curSwitch]:
             for destRouterLink, data in sorted(
-                    topo['switches'][curSwitch]['links'].iteritems()):
+                    topo['switches'][curSwitch]['links'].items()):
 
                 # Loopback interfaces
                 if "dst_node" in data:
index 0dfa87093039c49f31d25e4f1c50b1a1823c804b..9fde01cca09f13f0d35c0970dd0daa0f1ee957ac 100644 (file)
@@ -93,7 +93,7 @@ class Logger(object):
         """
         if log_level is None:
             log_level = self.log_level
-        if self.loggers.has_key(name):
+        if name in self.loggers:
             return self.loggers[name]
 
         nlogger = logging.Logger(name, level=log_level)
index f8843b0f195b8bdd92d988471281e52120932d31..ba6d38ad425c02bd74229c8ceb892e09318f0b6d 100644 (file)
@@ -992,11 +992,11 @@ class Router(Node):
         # Backward compatibility:
         #   Load configuration defaults like topogen.
         self.config_defaults = configparser.ConfigParser(
-            {
+            defaults = {
                 "verbosity": "info",
                 "frrdir": "/usr/lib/frr",
                 "routertype": "frr",
-                "memleak_path": None,
+                "memleak_path": "",
             }
         )
         self.config_defaults.read(
@@ -1523,7 +1523,7 @@ class Router(Node):
         for daemon in self.daemons:
             if (self.daemons[daemon] == 1) and not (daemon in daemonsRunning):
                 sys.stderr.write("%s: Daemon %s not running\n" % (self.name, daemon))
-                if daemon is "staticd":
+                if daemon == "staticd":
                     sys.stderr.write(
                         "You may have a copy of staticd installed but are attempting to test against\n"
                     )
@@ -1589,7 +1589,7 @@ class Router(Node):
             logger.info("{}: running version: {}".format(self.name, self.version))
 
         rversion = self.version
-        if rversion is None:
+        if rversion == None:
             return False
 
         result = version_cmp(rversion, version)
index 0b6f5684625fa96b6f528c82b365aec8263c2771..79e8e6bf5877b5af6a0c2c9621c4957986e1dfa2 100644 (file)
@@ -86,19 +86,19 @@ def setup_module(mod):
             os.path.join(CWD, '{}/ospfd.conf'.format(rname))
         )
 
-       # What is this?  OSPF Unnumbered depends on the rp_filter
-       # being set appropriately( HA! )
-       # Effectively we are putting different /32's on the interface
-       # the multicast packet delivery is somewhat controlled by
-       # the rp_filter.  Setting it to '0' allows the OS to pass
-       # up the mcast packet not destined for the local routers
-       # network.
-       topotest.set_sysctl(tgen.net['r1'],
-                           'net.ipv4.conf.r1-eth1.rp_filter', 0)
+        # What is this?  OSPF Unnumbered depends on the rp_filter
+        # being set appropriately( HA! )
+        # Effectively we are putting different /32's on the interface
+        # the multicast packet delivery is somewhat controlled by
+        # the rp_filter.  Setting it to '0' allows the OS to pass
+        # up the mcast packet not destined for the local routers
+        # network.
+        topotest.set_sysctl(tgen.net['r1'],
+                            'net.ipv4.conf.r1-eth1.rp_filter', 0)
         topotest.set_sysctl(tgen.net['r1'],
                             'net.ipv4.conf.all.rp_filter', 0)
-       topotest.set_sysctl(tgen.net['r2'],
-                           'net.ipv4.conf.r2-eth1.rp_filter', 0)
+        topotest.set_sysctl(tgen.net['r2'],
+                            'net.ipv4.conf.r2-eth1.rp_filter', 0)
         topotest.set_sysctl(tgen.net['r2'],
                             'net.ipv4.conf.all.rp_filter', 0)
 
index 9ae4cce360908261f6e469f8e8f9220308d47dcd..91979a8f04067e32c49e803a37dab88304266998 100644 (file)
@@ -88,8 +88,8 @@ def setup_module(module):
 
     krel = platform.release()
     if topotest.version_cmp(krel, "4.10") < 0:
-       tgen.errors = "Newer kernel than 4.9 needed for pbr tests"
-       pytest.skip(tgen.errors)
+        tgen.errors = "Newer kernel than 4.9 needed for pbr tests"
+        pytest.skip(tgen.errors)
 
     router_list = tgen.routers()
     for rname, router in router_list.items():
@@ -150,8 +150,8 @@ def test_pbr_data():
         test_func = partial(topotest.router_json_cmp, router, "show pbr interface json", expected)
         _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
         assertmsg = '"show pbr interface" mismatches on {}'.format(router.name)
-       if result is not None:
-           gather_pbr_data_on_error(router)
+        if result is not None:
+            gather_pbr_data_on_error(router)
             assert result is None, assertmsg
 
         map_file = "{}/{}/pbr-map.json".format(CWD, router.name)
@@ -164,8 +164,8 @@ def test_pbr_data():
         test_func = partial(topotest.router_json_cmp, router, "show pbr map json", expected)
         _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
         assertmsg = '"show pbr map" mismatches on {}'.format(router.name)
-       if result is not None:
-           gather_pbr_data_on_error(router)
+        if result is not None:
+            gather_pbr_data_on_error(router)
             assert result is None, assertmsg
 
         nexthop_file = "{}/{}/pbr-nexthop-groups.json".format(CWD, router.name)
@@ -178,8 +178,8 @@ def test_pbr_data():
         test_func = partial(topotest.router_json_cmp, router, "show pbr nexthop-groups json", expected)
         _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
         assertmsg = '"show pbr nexthop-groups" mismatches on {}'.format(router.name)
-       if result is not None:
-           gather_pbr_data_on_error(router)
+        if result is not None:
+            gather_pbr_data_on_error(router)
             assert result is None, assertmsg
 
 def test_pbr_flap():
@@ -215,8 +215,8 @@ def test_pbr_flap():
         test_func = partial(topotest.router_json_cmp, router, "show pbr interface json", expected)
         _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
         assertmsg = '"show pbr interface" mismatches on {}'.format(router.name)
-       if result is not None:
-           gather_pbr_data_on_error(router)
+        if result is not None:
+            gather_pbr_data_on_error(router)
             assert result is None, assertmsg
 
 
old mode 100755 (executable)
new mode 100644 (file)
index 7ff18ba..de11b78
@@ -91,11 +91,11 @@ class NetworkTopo(Topo):
         switch[4] = self.addSwitch("sw4", cls=topotest.LegacySwitch)
         self.addLink(switch[4], router[3], intfName2="r3-eth0")
 
-       switch[5] = self.addSwitch("sw5", cls=topotest.LegacySwitch)
-       self.addLink(switch[5], router[1], intfName2="r1-eth2")
+        switch[5] = self.addSwitch("sw5", cls=topotest.LegacySwitch)
+        self.addLink(switch[5], router[1], intfName2="r1-eth2")
 
-       switch[6] = self.addSwitch("sw6", cls=topotest.LegacySwitch)
-       self.addLink(switch[6], router[1], intfName2="r1-eth3")
+        switch[6] = self.addSwitch("sw6", cls=topotest.LegacySwitch)
+        self.addLink(switch[6], router[1], intfName2="r1-eth3")
 
 
 #####################################################
old mode 100755 (executable)
new mode 100644 (file)