Run codestyle script on HA test suite

Change-Id: Ib59ce54b5f5596a1d33845f05b86a117d42a4d32
diff --git a/TestON/tests/HA/HAstopNodes/HAstopNodes.py b/TestON/tests/HA/HAstopNodes/HAstopNodes.py
index 6c32b16..0ec3b5d 100644
--- a/TestON/tests/HA/HAstopNodes/HAstopNodes.py
+++ b/TestON/tests/HA/HAstopNodes/HAstopNodes.py
@@ -23,8 +23,6 @@
 CASE16: Install Distributed Primitives app
 CASE17: Check for basic functionality with distributed primitives
 """
-
-
 class HAstopNodes:
 
     def __init__( self ):
@@ -149,7 +147,7 @@
                             filePath + topoName,
                             main.Mininet1.home,
                             direction="to" )
-        mnResult = main.Mininet1.startNet( )
+        mnResult = main.Mininet1.startNet()
         utilities.assert_equals( expect=main.TRUE, actual=mnResult,
                                  onpass="Mininet Started",
                                  onfail="Error starting Mininet" )
@@ -192,7 +190,7 @@
                   'seamless="seamless"></iframe>\n'
         graphs += ']]></ac:plain-text-body>\n'
         graphs += '</ac:structured-macro>\n'
-        main.log.wiki(graphs)
+        main.log.wiki( graphs )
 
         main.step( "Creating ONOS package" )
         # copy gen-partions file to ONOS
@@ -259,9 +257,9 @@
         cliResults = main.TRUE
         threads = []
         for i in range( main.numCtrls ):
-            t = main.Thread( target=main.CLIs[i].startOnosCli,
+            t = main.Thread( target=main.CLIs[ i ].startOnosCli,
                              name="startOnosCli-" + str( i ),
-                             args=[main.nodes[i].ip_address] )
+                             args=[ main.nodes[ i ].ip_address ] )
             threads.append( t )
             t.start()
 
@@ -286,7 +284,7 @@
         main.step( "Checking ONOS nodes" )
         nodeResults = utilities.retry( main.HA.nodesCheck,
                                        False,
-                                       args=[main.activeNodes],
+                                       args=[ main.activeNodes ],
                                        attempts=5 )
 
         utilities.assert_equals( expect=True, actual=nodeResults,
@@ -295,7 +293,7 @@
 
         if not nodeResults:
             for i in main.activeNodes:
-                cli = main.CLIs[i]
+                cli = main.CLIs[ i ]
                 main.log.debug( "{} components not ACTIVE: \n{}".format(
                     cli.name,
                     cli.sendline( "scr:list | grep -v ACTIVE" ) ) )
@@ -307,7 +305,7 @@
         # get data from the params
         apps = main.params.get( 'apps' )
         if apps:
-            apps = apps.split(',')
+            apps = apps.split( ',' )
             main.log.warn( apps )
             activateResult = True
             for app in apps:
@@ -334,8 +332,8 @@
             main.log.debug( config )
             checkResult = main.TRUE
             for component in config:
-                for setting in config[component]:
-                    value = config[component][setting]
+                for setting in config[ component ]:
+                    value = config[ component ][ setting ]
                     check = main.CLIs[ 0 ].setCfg( component, setting, value )
                     main.log.info( "Value was changed? {}".format( main.TRUE == check ) )
                     checkResult = check and checkResult
@@ -350,7 +348,7 @@
         appCheck = main.TRUE
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].appToIDCheck,
+            t = main.Thread( target=main.CLIs[ i ].appToIDCheck,
                              name="appToIDCheck-" + str( i ),
                              args=[] )
             threads.append( t )
@@ -360,9 +358,9 @@
             t.join()
             appCheck = appCheck and t.result
         if appCheck != main.TRUE:
-            node = main.activeNodes[0]
-            main.log.warn( main.CLIs[node].apps() )
-            main.log.warn( main.CLIs[node].appIDs() )
+            node = main.activeNodes[ 0 ]
+            main.log.warn( main.CLIs[ node ].apps() )
+            main.log.warn( main.CLIs[ node ].appIDs() )
         utilities.assert_equals( expect=main.TRUE, actual=appCheck,
                                  onpass="App Ids seem to be correct",
                                  onfail="Something is wrong with app Ids" )
@@ -447,9 +445,9 @@
         # Manually assign mastership to the controller we want
         roleCall = main.TRUE
 
-        ipList = [ ]
+        ipList = []
         deviceList = []
-        onosCli = main.CLIs[ main.activeNodes[0] ]
+        onosCli = main.CLIs[ main.activeNodes[ 0 ] ]
         try:
             # Assign mastership to specific controllers. This assignment was
             # determined for a 7 node cluser, but will work with any sized
@@ -523,8 +521,8 @@
         #       atomic and is actually a multi step process
         time.sleep( 5 )
         for i in range( len( ipList ) ):
-            ip = ipList[i]
-            deviceId = deviceList[i]
+            ip = ipList[ i ]
+            deviceId = deviceList[ i ]
             # Check assignment
             master = onosCli.getRole( deviceId ).get( 'master' )
             if ip in master:
@@ -562,7 +560,7 @@
 
         # install onos-app-fwd
         main.step( "Install reactive forwarding app" )
-        onosCli = main.CLIs[ main.activeNodes[0] ]
+        onosCli = main.CLIs[ main.activeNodes[ 0 ] ]
         installResults = onosCli.activateApp( "org.onosproject.fwd" )
         utilities.assert_equals( expect=main.TRUE, actual=installResults,
                                  onpass="Install fwd successful",
@@ -572,7 +570,7 @@
         appCheck = main.TRUE
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].appToIDCheck,
+            t = main.Thread( target=main.CLIs[ i ].appToIDCheck,
                              name="appToIDCheck-" + str( i ),
                              args=[] )
             threads.append( t )
@@ -597,13 +595,13 @@
         pingResult = main.Mininet1.pingall()
         time2 = time.time()
         if not pingResult:
-            main.log.warn("First pingall failed. Trying again...")
+            main.log.warn( "First pingall failed. Trying again..." )
             pingResult = main.Mininet1.pingall()
             passMsg += " on the second try"
         utilities.assert_equals(
             expect=main.TRUE,
             actual=pingResult,
-            onpass= passMsg,
+            onpass=passMsg,
             onfail="Reactive Pingall failed, " +
                    "one or more ping pairs failed" )
         main.log.info( "Time for pingall: %2f seconds" %
@@ -612,8 +610,8 @@
         time.sleep( 11 )
         # uninstall onos-app-fwd
         main.step( "Uninstall reactive forwarding app" )
-        node = main.activeNodes[0]
-        uninstallResult = main.CLIs[node].deactivateApp( "org.onosproject.fwd" )
+        node = main.activeNodes[ 0 ]
+        uninstallResult = main.CLIs[ node ].deactivateApp( "org.onosproject.fwd" )
         utilities.assert_equals( expect=main.TRUE, actual=uninstallResult,
                                  onpass="Uninstall fwd successful",
                                  onfail="Uninstall fwd failed" )
@@ -622,7 +620,7 @@
         threads = []
         appCheck2 = main.TRUE
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].appToIDCheck,
+            t = main.Thread( target=main.CLIs[ i ].appToIDCheck,
                              name="appToIDCheck-" + str( i ),
                              args=[] )
             threads.append( t )
@@ -632,9 +630,9 @@
             t.join()
             appCheck2 = appCheck2 and t.result
         if appCheck2 != main.TRUE:
-            node = main.activeNodes[0]
-            main.log.warn( main.CLIs[node].apps() )
-            main.log.warn( main.CLIs[node].appIDs() )
+            node = main.activeNodes[ 0 ]
+            main.log.warn( main.CLIs[ node ].apps() )
+            main.log.warn( main.CLIs[ node ].appIDs() )
         utilities.assert_equals( expect=main.TRUE, actual=appCheck2,
                                  onpass="App Ids seem to be correct",
                                  onfail="Something is wrong with app Ids" )
@@ -662,8 +660,8 @@
                 host2Id = host2Dict.get( 'id', None )
             if host1Id and host2Id:
                 nodeNum = ( i % len( main.activeNodes ) )
-                node = main.activeNodes[nodeNum]
-                tmpId = main.CLIs[node].addHostIntent( host1Id, host2Id )
+                node = main.activeNodes[ nodeNum ]
+                tmpId = main.CLIs[ node ].addHostIntent( host1Id, host2Id )
                 if tmpId:
                     main.log.info( "Added intent with id: " + tmpId )
                     intentIds.append( tmpId )
@@ -673,8 +671,8 @@
             else:
                 main.log.error( "Error, getHost() failed for h" + str( i ) +
                                 " and/or h" + str( i + 10 ) )
-                node = main.activeNodes[0]
-                hosts = main.CLIs[node].hosts()
+                node = main.activeNodes[ 0 ]
+                hosts = main.CLIs[ node ].hosts()
                 main.log.warn( "Hosts output: " )
                 try:
                     main.log.warn( json.dumps( json.loads( hosts ),
@@ -742,7 +740,7 @@
                 for i in range( 14 ):
                     topics.append( "work-partition-" + str( i ) )
                 main.log.debug( topics )
-                ONOStopics = [ j['topic'] for j in parsedLeaders ]
+                ONOStopics = [ j[ 'topic' ] for j in parsedLeaders ]
                 for topic in topics:
                     if topic not in ONOStopics:
                         main.log.error( "Error: " + topic +
@@ -756,13 +754,13 @@
         # Check all nodes
         if missing:
             for i in main.activeNodes:
-                response = main.CLIs[i].leaders( jsonFormat=False)
-                main.log.warn( str( main.CLIs[i].name ) + " leaders output: \n" +
+                response = main.CLIs[ i ].leaders( jsonFormat=False )
+                main.log.warn( str( main.CLIs[ i ].name ) + " leaders output: \n" +
                                str( response ) )
 
         partitions = onosCli.partitions()
         try:
-            if partitions :
+            if partitions:
                 parsedPartitions = json.loads( partitions )
                 main.log.warn( json.dumps( parsedPartitions,
                                            sort_keys=True,
@@ -777,7 +775,7 @@
             main.log.error( repr( partitions ) )
         pendingMap = onosCli.pendingMap()
         try:
-            if pendingMap :
+            if pendingMap:
                 parsedPending = json.loads( pendingMap )
                 main.log.warn( json.dumps( parsedPending,
                                            sort_keys=True,
@@ -796,21 +794,21 @@
             main.log.error( "Error in pushing host intents to ONOS" )
 
         main.step( "Intent Anti-Entropy dispersion" )
-        for j in range(100):
+        for j in range( 100 ):
             correct = True
             main.log.info( "Submitted intents: " + str( sorted( intentIds ) ) )
             for i in main.activeNodes:
                 onosIds = []
-                ids = main.CLIs[i].getAllIntentsId()
+                ids = main.CLIs[ i ].getAllIntentsId()
                 onosIds.append( ids )
-                main.log.debug( "Intents in " + main.CLIs[i].name + ": " +
+                main.log.debug( "Intents in " + main.CLIs[ i ].name + ": " +
                                 str( sorted( onosIds ) ) )
                 if sorted( ids ) != sorted( intentIds ):
                     main.log.warn( "Set of intent IDs doesn't match" )
                     correct = False
                     break
                 else:
-                    intents = json.loads( main.CLIs[i].intents() )
+                    intents = json.loads( main.CLIs[ i ].intents() )
                     for intent in intents:
                         if intent[ 'state' ] != "INSTALLED":
                             main.log.warn( "Intent " + intent[ 'id' ] +
@@ -820,14 +818,14 @@
             if correct:
                 break
             else:
-                time.sleep(1)
+                time.sleep( 1 )
         if not intentStop:
             intentStop = time.time()
         global gossipTime
         gossipTime = intentStop - intentStart
         main.log.info( "It took about " + str( gossipTime ) +
                         " seconds for all intents to appear in each node" )
-        gossipPeriod = int( main.params['timers']['gossip'] )
+        gossipPeriod = int( main.params[ 'timers' ][ 'gossip' ] )
         maxGossipTime = gossipPeriod * len( main.activeNodes )
         utilities.assert_greater_equals(
                 expect=maxGossipTime, actual=gossipTime,
@@ -889,7 +887,7 @@
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
-                    ONOStopics = [ j['topic'] for j in parsedLeaders ]
+                    ONOStopics = [ j[ 'topic' ] for j in parsedLeaders ]
                     for topic in topics:
                         if topic not in ONOStopics:
                             main.log.error( "Error: " + topic +
@@ -903,14 +901,14 @@
             # Check all nodes
             if missing:
                 for i in main.activeNodes:
-                    node = main.CLIs[i]
-                    response = node.leaders( jsonFormat=False)
+                    node = main.CLIs[ i ]
+                    response = node.leaders( jsonFormat=False )
                     main.log.warn( str( node.name ) + " leaders output: \n" +
                                    str( response ) )
 
             partitions = onosCli.partitions()
             try:
-                if partitions :
+                if partitions:
                     parsedPartitions = json.loads( partitions )
                     main.log.warn( json.dumps( parsedPartitions,
                                                sort_keys=True,
@@ -925,7 +923,7 @@
                 main.log.error( repr( partitions ) )
             pendingMap = onosCli.pendingMap()
             try:
-                if pendingMap :
+                if pendingMap:
                     parsedPending = json.loads( pendingMap )
                     main.log.warn( json.dumps( parsedPending,
                                                sort_keys=True,
@@ -954,7 +952,7 @@
                                 "functionality and check the state of " +\
                                 "the intent"
 
-        onosCli = main.CLIs[ main.activeNodes[0] ]
+        onosCli = main.CLIs[ main.activeNodes[ 0 ] ]
         main.step( "Check Intent state" )
         installedCheck = False
         loopCount = 0
@@ -1040,7 +1038,7 @@
                 # FIXME: topics.append( "org.onosproject.election" )
                 # Print leaders output
                 main.log.debug( topics )
-                ONOStopics = [ j['topic'] for j in parsedLeaders ]
+                ONOStopics = [ j[ 'topic' ] for j in parsedLeaders ]
                 for topic in topics:
                     if topic not in ONOStopics:
                         main.log.error( "Error: " + topic +
@@ -1057,8 +1055,8 @@
         # Check all nodes
         if topicCheck:
             for i in main.activeNodes:
-                node = main.CLIs[i]
-                response = node.leaders( jsonFormat=False)
+                node = main.CLIs[ i ]
+                response = node.leaders( jsonFormat=False )
                 main.log.warn( str( node.name ) + " leaders output: \n" +
                                str( response ) )
 
@@ -1068,7 +1066,7 @@
         # Print partitions
         partitions = onosCli.partitions()
         try:
-            if partitions :
+            if partitions:
                 parsedPartitions = json.loads( partitions )
                 main.log.warn( json.dumps( parsedPartitions,
                                            sort_keys=True,
@@ -1084,7 +1082,7 @@
         # Print Pending Map
         pendingMap = onosCli.pendingMap()
         try:
-            if pendingMap :
+            if pendingMap:
                 parsedPending = json.loads( pendingMap )
                 main.log.warn( json.dumps( parsedPending,
                                            sort_keys=True,
@@ -1138,7 +1136,7 @@
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
-                    ONOStopics = [ j['topic'] for j in parsedLeaders ]
+                    ONOStopics = [ j[ 'topic' ] for j in parsedLeaders ]
                     for topic in topics:
                         if topic not in ONOStopics:
                             main.log.error( "Error: " + topic +
@@ -1151,14 +1149,14 @@
                 main.log.error( repr( leaders ) )
             if missing:
                 for i in main.activeNodes:
-                    node = main.CLIs[i]
-                    response = node.leaders( jsonFormat=False)
+                    node = main.CLIs[ i ]
+                    response = node.leaders( jsonFormat=False )
                     main.log.warn( str( node.name ) + " leaders output: \n" +
                                    str( response ) )
 
             partitions = onosCli.partitions()
             try:
-                if partitions :
+                if partitions:
                     parsedPartitions = json.loads( partitions )
                     main.log.warn( json.dumps( parsedPartitions,
                                                sort_keys=True,
@@ -1173,7 +1171,7 @@
                 main.log.error( repr( partitions ) )
             pendingMap = onosCli.pendingMap()
             try:
-                if pendingMap :
+                if pendingMap:
                     parsedPending = json.loads( pendingMap )
                     main.log.warn( json.dumps( parsedPending,
                                                sort_keys=True,
@@ -1244,7 +1242,7 @@
         rolesNotNull = main.TRUE
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].rolesNotNull,
+            t = main.Thread( target=main.CLIs[ i ].rolesNotNull,
                              name="rolesNotNull-" + str( i ),
                              args=[] )
             threads.append( t )
@@ -1266,7 +1264,7 @@
         rolesResults = True
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].roles,
+            t = main.Thread( target=main.CLIs[ i ].roles,
                              name="roles-" + str( i ),
                              args=[] )
             threads.append( t )
@@ -1277,11 +1275,11 @@
             ONOSMastership.append( t.result )
 
         for i in range( len( ONOSMastership ) ):
-            node = str( main.activeNodes[i] + 1 )
-            if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
+            node = str( main.activeNodes[ i ] + 1 )
+            if not ONOSMastership[ i ] or "Error" in ONOSMastership[ i ]:
                 main.log.error( "Error in getting ONOS" + node + " roles" )
                 main.log.warn( "ONOS" + node + " mastership response: " +
-                               repr( ONOSMastership[i] ) )
+                               repr( ONOSMastership[ i ] ) )
                 rolesResults = False
         utilities.assert_equals(
             expect=True,
@@ -1290,7 +1288,7 @@
             onfail="Error in reading roles from ONOS" )
 
         main.step( "Check for consistency in roles from each controller" )
-        if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
+        if all( [ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
             main.log.info(
                 "Switch roles are consistent across all ONOS nodes" )
         else:
@@ -1303,7 +1301,7 @@
 
         if rolesResults and not consistentMastership:
             for i in range( len( main.activeNodes ) ):
-                node = str( main.activeNodes[i] + 1 )
+                node = str( main.activeNodes[ i ] + 1 )
                 try:
                     main.log.warn(
                         "ONOS" + node + " roles: ",
@@ -1327,7 +1325,7 @@
         intentsResults = True
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].intents,
+            t = main.Thread( target=main.CLIs[ i ].intents,
                              name="intents-" + str( i ),
                              args=[],
                              kwargs={ 'jsonFormat': True } )
@@ -1339,7 +1337,7 @@
             ONOSIntents.append( t.result )
 
         for i in range( len( ONOSIntents ) ):
-            node = str( main.activeNodes[i] + 1 )
+            node = str( main.activeNodes[ i ] + 1 )
             if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
                 main.log.error( "Error in getting ONOS" + node + " intents" )
                 main.log.warn( "ONOS" + node + " intents response: " +
@@ -1352,7 +1350,7 @@
             onfail="Error in reading intents from ONOS" )
 
         main.step( "Check for consistency in Intents from each controller" )
-        if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
+        if all( [ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
             main.log.info( "Intents are consistent across all ONOS " +
                              "nodes" )
         else:
@@ -1400,17 +1398,17 @@
 
         if intentsResults and not consistentIntents:
             # print the json objects
-            n = str( main.activeNodes[-1] + 1 )
+            n = str( main.activeNodes[ -1 ] + 1 )
             main.log.debug( "ONOS" + n + " intents: " )
             main.log.debug( json.dumps( json.loads( ONOSIntents[ -1 ] ),
                                         sort_keys=True,
                                         indent=4,
                                         separators=( ',', ': ' ) ) )
             for i in range( len( ONOSIntents ) ):
-                node = str( main.activeNodes[i] + 1 )
+                node = str( main.activeNodes[ i ] + 1 )
                 if ONOSIntents[ i ] != ONOSIntents[ -1 ]:
                     main.log.debug( "ONOS" + node + " intents: " )
-                    main.log.debug( json.dumps( json.loads( ONOSIntents[i] ),
+                    main.log.debug( json.dumps( json.loads( ONOSIntents[ i ] ),
                                                 sort_keys=True,
                                                 indent=4,
                                                 separators=( ',', ': ' ) ) )
@@ -1431,7 +1429,7 @@
         flowsResults = True
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].flows,
+            t = main.Thread( target=main.CLIs[ i ].flows,
                              name="flows-" + str( i ),
                              args=[],
                              kwargs={ 'jsonFormat': True } )
@@ -1439,14 +1437,14 @@
             t.start()
 
         # NOTE: Flows command can take some time to run
-        time.sleep(30)
+        time.sleep( 30 )
         for t in threads:
             t.join()
             result = t.result
             ONOSFlows.append( result )
 
         for i in range( len( ONOSFlows ) ):
-            num = str( main.activeNodes[i] + 1 )
+            num = str( main.activeNodes[ i ] + 1 )
             if not ONOSFlows[ i ] or "Error" in ONOSFlows[ i ]:
                 main.log.error( "Error in getting ONOS" + num + " flows" )
                 main.log.warn( "ONOS" + num + " flows response: " +
@@ -1483,11 +1481,11 @@
 
         if flowsResults and not consistentFlows:
             for i in range( len( ONOSFlows ) ):
-                node = str( main.activeNodes[i] + 1 )
+                node = str( main.activeNodes[ i ] + 1 )
                 try:
                     main.log.warn(
                         "ONOS" + node + " flows: " +
-                        json.dumps( json.loads( ONOSFlows[i] ), sort_keys=True,
+                        json.dumps( json.loads( ONOSFlows[ i ] ), sort_keys=True,
                                     indent=4, separators=( ',', ': ' ) ) )
                 except ( ValueError, TypeError ):
                     main.log.warn( "ONOS" + node + " flows: " +
@@ -1552,9 +1550,9 @@
         devices = []
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].devices,
+            t = main.Thread( target=main.CLIs[ i ].devices,
                              name="devices-" + str( i ),
-                             args=[ ] )
+                             args=[] )
             threads.append( t )
             t.start()
 
@@ -1564,9 +1562,9 @@
         hosts = []
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].hosts,
+            t = main.Thread( target=main.CLIs[ i ].hosts,
                              name="hosts-" + str( i ),
-                             args=[ ] )
+                             args=[] )
             threads.append( t )
             t.start()
 
@@ -1584,9 +1582,9 @@
         ports = []
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].ports,
+            t = main.Thread( target=main.CLIs[ i ].ports,
                              name="ports-" + str( i ),
-                             args=[ ] )
+                             args=[] )
             threads.append( t )
             t.start()
 
@@ -1596,9 +1594,9 @@
         links = []
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].links,
+            t = main.Thread( target=main.CLIs[ i ].links,
                              name="links-" + str( i ),
-                             args=[ ] )
+                             args=[] )
             threads.append( t )
             t.start()
 
@@ -1608,9 +1606,9 @@
         clusters = []
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].clusters,
+            t = main.Thread( target=main.CLIs[ i ].clusters,
                              name="clusters-" + str( i ),
-                             args=[ ] )
+                             args=[] )
             threads.append( t )
             t.start()
 
@@ -1623,7 +1621,7 @@
         main.step( "Host view is consistent across ONOS nodes" )
         consistentHostsResult = main.TRUE
         for controller in range( len( hosts ) ):
-            controllerStr = str( main.activeNodes[controller] + 1 )
+            controllerStr = str( main.activeNodes[ controller ] + 1 )
             if hosts[ controller ] and "Error" not in hosts[ controller ]:
                 if hosts[ controller ] == hosts[ 0 ]:
                     continue
@@ -1650,10 +1648,10 @@
         main.step( "Each host has an IP address" )
         ipResult = main.TRUE
         for controller in range( 0, len( hosts ) ):
-            controllerStr = str( main.activeNodes[controller] + 1 )
+            controllerStr = str( main.activeNodes[ controller ] + 1 )
             if hosts[ controller ]:
                 for host in hosts[ controller ]:
-                    if not host.get( 'ipAddresses', [ ] ):
+                    if not host.get( 'ipAddresses', [] ):
                         main.log.error( "Error with host ips on controller" +
                                         controllerStr + ": " + str( host ) )
                         ipResult = main.FALSE
@@ -1667,7 +1665,7 @@
         main.step( "Cluster view is consistent across ONOS nodes" )
         consistentClustersResult = main.TRUE
         for controller in range( len( clusters ) ):
-            controllerStr = str( main.activeNodes[controller] + 1 )
+            controllerStr = str( main.activeNodes[ controller ] + 1 )
             if "Error" not in clusters[ controller ]:
                 if clusters[ controller ] == clusters[ 0 ]:
                     continue
@@ -1716,14 +1714,14 @@
         mnLinks = main.Mininet1.getLinks()
         mnHosts = main.Mininet1.getHosts()
         for controller in main.activeNodes:
-            controllerStr = str( main.activeNodes[controller] + 1 )
+            controllerStr = str( main.activeNodes[ controller ] + 1 )
             if devices[ controller ] and ports[ controller ] and\
-                "Error" not in devices[ controller ] and\
-                "Error" not in ports[ controller ]:
-                    currentDevicesResult = main.Mininet1.compareSwitches(
-                            mnSwitches,
-                            json.loads( devices[ controller ] ),
-                            json.loads( ports[ controller ] ) )
+                    "Error" not in devices[ controller ] and\
+                    "Error" not in ports[ controller ]:
+                currentDevicesResult = main.Mininet1.compareSwitches(
+                        mnSwitches,
+                        json.loads( devices[ controller ] ),
+                        json.loads( ports[ controller ] ) )
             else:
                 currentDevicesResult = main.FALSE
             utilities.assert_equals( expect=main.TRUE,
@@ -1810,7 +1808,7 @@
         killResults = main.TRUE
         for i in main.kill:
             killResults = killResults and\
-                          main.ONOSbench.onosStop( main.nodes[i].ip_address )
+                          main.ONOSbench.onosStop( main.nodes[ i ].ip_address )
             main.activeNodes.remove( i )
         utilities.assert_equals( expect=main.TRUE, actual=killResults,
                                  onpass="ONOS nodes stopped successfully",
@@ -1819,7 +1817,7 @@
         main.step( "Checking ONOS nodes" )
         nodeResults = utilities.retry( main.HA.nodesCheck,
                                        False,
-                                       args=[main.activeNodes],
+                                       args=[ main.activeNodes ],
                                        sleep=15,
                                        attempts=5 )
 
@@ -1829,7 +1827,7 @@
 
         if not nodeResults:
             for i in main.activeNodes:
-                cli = main.CLIs[i]
+                cli = main.CLIs[ i ]
                 main.log.debug( "{} components not ACTIVE: \n{}".format(
                     cli.name,
                     cli.sendline( "scr:list | grep -v ACTIVE" ) ) )
@@ -1855,7 +1853,7 @@
         restartTime = time.time()
         for i in main.kill:
             startResults = startResults and\
-                           main.ONOSbench.onosStart( main.nodes[i].ip_address )
+                           main.ONOSbench.onosStart( main.nodes[ i ].ip_address )
         utilities.assert_equals( expect=main.TRUE, actual=startResults,
                                  onpass="ONOS nodes started successfully",
                                  onfail="ONOS nodes NOT successfully started" )
@@ -1867,7 +1865,7 @@
             onosIsupResult = main.TRUE
             for i in main.kill:
                 onosIsupResult = onosIsupResult and\
-                                 main.ONOSbench.isup( main.nodes[i].ip_address )
+                                 main.ONOSbench.isup( main.nodes[ i ].ip_address )
             count = count + 1
         utilities.assert_equals( expect=main.TRUE, actual=onosIsupResult,
                                  onpass="ONOS restarted successfully",
@@ -1877,7 +1875,7 @@
         cliResults = main.TRUE
         for i in main.kill:
             cliResults = cliResults and\
-                         main.CLIs[i].startOnosCli( main.nodes[i].ip_address )
+                         main.CLIs[ i ].startOnosCli( main.nodes[ i ].ip_address )
             main.activeNodes.append( i )
         utilities.assert_equals( expect=main.TRUE, actual=cliResults,
                                  onpass="ONOS cli restarted",
@@ -1899,7 +1897,7 @@
         main.step( "Checking ONOS nodes" )
         nodeResults = utilities.retry( main.HA.nodesCheck,
                                        False,
-                                       args=[main.activeNodes],
+                                       args=[ main.activeNodes ],
                                        sleep=15,
                                        attempts=5 )
 
@@ -1909,23 +1907,23 @@
 
         if not nodeResults:
             for i in main.activeNodes:
-                cli = main.CLIs[i]
+                cli = main.CLIs[ i ]
                 main.log.debug( "{} components not ACTIVE: \n{}".format(
                     cli.name,
                     cli.sendline( "scr:list | grep -v ACTIVE" ) ) )
             main.log.error( "Failed to start ONOS, stopping test" )
             main.cleanup()
             main.exit()
-        node = main.activeNodes[0]
-        main.log.debug( main.CLIs[node].nodes( jsonFormat=False ) )
-        main.log.debug( main.CLIs[node].leaders( jsonFormat=False ) )
-        main.log.debug( main.CLIs[node].partitions( jsonFormat=False ) )
+        node = main.activeNodes[ 0 ]
+        main.log.debug( main.CLIs[ node ].nodes( jsonFormat=False ) )
+        main.log.debug( main.CLIs[ node ].leaders( jsonFormat=False ) )
+        main.log.debug( main.CLIs[ node ].partitions( jsonFormat=False ) )
 
         main.step( "Rerun for election on the node(s) that were killed" )
         runResults = main.TRUE
         for i in main.kill:
             runResults = runResults and\
-                         main.CLIs[i].electionTestRun()
+                         main.CLIs[ i ].electionTestRun()
         utilities.assert_equals( expect=main.TRUE, actual=runResults,
                                  onpass="ONOS nodes reran for election topic",
                                  onfail="Errror rerunning for election" )
@@ -1952,9 +1950,9 @@
         rolesNotNull = main.TRUE
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].rolesNotNull,
+            t = main.Thread( target=main.CLIs[ i ].rolesNotNull,
                              name="rolesNotNull-" + str( i ),
-                             args=[ ] )
+                             args=[] )
             threads.append( t )
             t.start()
 
@@ -1974,7 +1972,7 @@
         rolesResults = True
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].roles,
+            t = main.Thread( target=main.CLIs[ i ].roles,
                              name="roles-" + str( i ),
                              args=[] )
             threads.append( t )
@@ -1985,11 +1983,11 @@
             ONOSMastership.append( t.result )
 
         for i in range( len( ONOSMastership ) ):
-            node = str( main.activeNodes[i] + 1 )
-            if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
+            node = str( main.activeNodes[ i ] + 1 )
+            if not ONOSMastership[ i ] or "Error" in ONOSMastership[ i ]:
                 main.log.error( "Error in getting ONOS" + node + " roles" )
                 main.log.warn( "ONOS" + node + " mastership response: " +
-                               repr( ONOSMastership[i] ) )
+                               repr( ONOSMastership[ i ] ) )
                 rolesResults = False
         utilities.assert_equals(
             expect=True,
@@ -1998,7 +1996,7 @@
             onfail="Error in reading roles from ONOS" )
 
         main.step( "Check for consistency in roles from each controller" )
-        if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
+        if all( [ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
             main.log.info(
                 "Switch roles are consistent across all ONOS nodes" )
         else:
@@ -2011,7 +2009,7 @@
 
         if rolesResults and not consistentMastership:
             for i in range( len( ONOSMastership ) ):
-                node = str( main.activeNodes[i] + 1 )
+                node = str( main.activeNodes[ i ] + 1 )
                 main.log.warn( "ONOS" + node + " roles: ",
                                json.dumps( json.loads( ONOSMastership[ i ] ),
                                            sort_keys=True,
@@ -2027,7 +2025,7 @@
         intentsResults = True
         threads = []
         for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[i].intents,
+            t = main.Thread( target=main.CLIs[ i ].intents,
                              name="intents-" + str( i ),
                              args=[],
                              kwargs={ 'jsonFormat': True } )
@@ -2038,8 +2036,8 @@
             t.join()
             ONOSIntents.append( t.result )
 
-        for i in range( len( ONOSIntents) ):
-            node = str( main.activeNodes[i] + 1 )
+        for i in range( len( ONOSIntents ) ):
+            node = str( main.activeNodes[ i ] + 1 )
             if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
                 main.log.error( "Error in getting ONOS" + node + " intents" )
                 main.log.warn( "ONOS" + node + " intents response: " +
@@ -2052,7 +2050,7 @@
             onfail="Error in reading intents from ONOS" )
 
         main.step( "Check for consistency in Intents from each controller" )
-        if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
+        if all( [ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
             main.log.info( "Intents are consistent across all ONOS " +
                              "nodes" )
         else:
@@ -2101,12 +2099,12 @@
                 main.log.exception( "Error in parsing intents" )
                 main.log.error( repr( node ) )
             intentStates.append( nodeStates )
-            out = [ (i, nodeStates.count( i ) ) for i in set( nodeStates ) ]
+            out = [ ( i, nodeStates.count( i ) ) for i in set( nodeStates ) ]
             main.log.info( dict( out ) )
 
         if intentsResults and not consistentIntents:
             for i in range( len( main.activeNodes ) ):
-                node = str( main.activeNodes[i] + 1 )
+                node = str( main.activeNodes[ i ] + 1 )
                 main.log.warn( "ONOS" + node + " intents: " )
                 main.log.warn( json.dumps(
                     json.loads( ONOSIntents[ i ] ),
@@ -2145,7 +2143,7 @@
                             main.log.debug( json.dumps( intent ) )
                 except ( ValueError, TypeError ):
                     main.log.exception( "Exception printing intents" )
-                    main.log.debug( repr( ONOSIntents[0] ) )
+                    main.log.debug( repr( ONOSIntents[ 0 ] ) )
                     main.log.debug( repr( intentState ) )
             if sameIntents == main.FALSE:
                 try:
@@ -2159,7 +2157,7 @@
                                                 separators=( ',', ': ' ) ) )
                 except ( ValueError, TypeError ):
                     main.log.exception( "Exception printing intents" )
-                    main.log.debug( repr( ONOSIntents[0] ) )
+                    main.log.debug( repr( ONOSIntents[ 0 ] ) )
                     main.log.debug( repr( intentState ) )
             utilities.assert_equals(
                 expect=main.TRUE,
@@ -2174,7 +2172,7 @@
         for i in range( 28 ):
             main.log.info( "Checking flow table on s" + str( i + 1 ) )
             tmpFlows = main.Mininet1.getFlowTable( "s" + str( i + 1 ), version="1.3", debug=False )
-            curSwitch = main.Mininet1.flowTableComp( flows[i], tmpFlows )
+            curSwitch = main.Mininet1.flowTableComp( flows[ i ], tmpFlows )
             FlowTables = FlowTables and curSwitch
             if curSwitch == main.FALSE:
                 main.log.warn( "Differences in flow table for switch: s{}".format( i + 1 ) )
@@ -2185,7 +2183,7 @@
             onfail="Changes were found in the flow tables" )
 
         main.Mininet2.pingLongKill()
-        '''
+        """
         main.step( "Check the continuous pings to ensure that no packets " +
                    "were dropped during component failure" )
         main.Mininet2.pingKill( main.params[ 'TESTONUSER' ],
@@ -2211,19 +2209,18 @@
             actual=LossInPings,
             onpass="No Loss of connectivity",
             onfail="Loss of dataplane connectivity detected" )
-        '''
-
+        """
         main.step( "Leadership Election is still functional" )
         # Test of LeadershipElection
         leaderList = []
 
         restarted = []
         for i in main.kill:
-            restarted.append( main.nodes[i].ip_address )
+            restarted.append( main.nodes[ i ].ip_address )
         leaderResult = main.TRUE
 
         for i in main.activeNodes:
-            cli = main.CLIs[i]
+            cli = main.CLIs[ i ]
             leaderN = cli.electionTestLeader()
             leaderList.append( leaderN )
             if leaderN == main.FALSE:
@@ -2287,8 +2284,8 @@
             for i in main.activeNodes:
                 t = main.Thread( target=utilities.retry,
                                  name="devices-" + str( i ),
-                                 args=[ main.CLIs[i].devices, [ None ] ],
-                                 kwargs= { 'sleep': 5, 'attempts': 5,
+                                 args=[ main.CLIs[ i ].devices, [ None ] ],
+                                 kwargs={ 'sleep': 5, 'attempts': 5,
                                            'randomTime': True } )
                 threads.append( t )
                 t.start()
@@ -2302,8 +2299,8 @@
             for i in main.activeNodes:
                 t = main.Thread( target=utilities.retry,
                                  name="hosts-" + str( i ),
-                                 args=[ main.CLIs[i].hosts, [ None ] ],
-                                 kwargs= { 'sleep': 5, 'attempts': 5,
+                                 args=[ main.CLIs[ i ].hosts, [ None ] ],
+                                 kwargs={ 'sleep': 5, 'attempts': 5,
                                            'randomTime': True } )
                 threads.append( t )
                 t.start()
@@ -2317,7 +2314,7 @@
                     main.log.error( repr( t.result ) )
                     hosts.append( None )
             for controller in range( 0, len( hosts ) ):
-                controllerStr = str( main.activeNodes[controller] + 1 )
+                controllerStr = str( main.activeNodes[ controller ] + 1 )
                 if hosts[ controller ]:
                     for host in hosts[ controller ]:
                         if host is None or host.get( 'ipAddresses', [] ) == []:
@@ -2330,8 +2327,8 @@
             for i in main.activeNodes:
                 t = main.Thread( target=utilities.retry,
                                  name="ports-" + str( i ),
-                                 args=[ main.CLIs[i].ports, [ None ] ],
-                                 kwargs= { 'sleep': 5, 'attempts': 5,
+                                 args=[ main.CLIs[ i ].ports, [ None ] ],
+                                 kwargs={ 'sleep': 5, 'attempts': 5,
                                            'randomTime': True } )
                 threads.append( t )
                 t.start()
@@ -2344,8 +2341,8 @@
             for i in main.activeNodes:
                 t = main.Thread( target=utilities.retry,
                                  name="links-" + str( i ),
-                                 args=[ main.CLIs[i].links, [ None ] ],
-                                 kwargs= { 'sleep': 5, 'attempts': 5,
+                                 args=[ main.CLIs[ i ].links, [ None ] ],
+                                 kwargs={ 'sleep': 5, 'attempts': 5,
                                            'randomTime': True } )
                 threads.append( t )
                 t.start()
@@ -2358,8 +2355,8 @@
             for i in main.activeNodes:
                 t = main.Thread( target=utilities.retry,
                                  name="clusters-" + str( i ),
-                                 args=[ main.CLIs[i].clusters, [ None ] ],
-                                 kwargs= { 'sleep': 5, 'attempts': 5,
+                                 args=[ main.CLIs[ i ].clusters, [ None ] ],
+                                 kwargs={ 'sleep': 5, 'attempts': 5,
                                            'randomTime': True } )
                 threads.append( t )
                 t.start()
@@ -2378,18 +2375,18 @@
                all( e is None for e in ports ) and\
                all( e is None for e in links ) and\
                all( e is None for e in clusters ):
-                   topoFailMsg = "Could not get topology from ONOS"
-                   main.log.error( topoFailMsg )
-                   continue  # Try again, No use trying to compare
+                topoFailMsg = "Could not get topology from ONOS"
+                main.log.error( topoFailMsg )
+                continue  # Try again, No use trying to compare
 
             mnSwitches = main.Mininet1.getSwitches()
             mnLinks = main.Mininet1.getLinks()
             mnHosts = main.Mininet1.getHosts()
             for controller in range( len( main.activeNodes ) ):
-                controllerStr = str( main.activeNodes[controller] + 1 )
+                controllerStr = str( main.activeNodes[ controller ] + 1 )
                 if devices[ controller ] and ports[ controller ] and\
-                    "Error" not in devices[ controller ] and\
-                    "Error" not in ports[ controller ]:
+                        "Error" not in devices[ controller ] and\
+                        "Error" not in ports[ controller ]:
 
                     try:
                         currentDevicesResult = main.Mininet1.compareSwitches(
@@ -2442,29 +2439,29 @@
                 mappings = {}
                 for i in range( 1, 29 ):  # hosts 1 through 28
                     # set up correct variables:
-                    macId = "00:" * 5 + hex( i ).split( "0x" )[1].upper().zfill(2)
+                    macId = "00:" * 5 + hex( i ).split( "0x" )[ 1 ].upper().zfill( 2 )
                     if i == 1:
-                        deviceId = "1000".zfill(16)
+                        deviceId = "1000".zfill( 16 )
                     elif i == 2:
-                        deviceId = "2000".zfill(16)
+                        deviceId = "2000".zfill( 16 )
                     elif i == 3:
-                        deviceId = "3000".zfill(16)
+                        deviceId = "3000".zfill( 16 )
                     elif i == 4:
-                        deviceId = "3004".zfill(16)
+                        deviceId = "3004".zfill( 16 )
                     elif i == 5:
-                        deviceId = "5000".zfill(16)
+                        deviceId = "5000".zfill( 16 )
                     elif i == 6:
-                        deviceId = "6000".zfill(16)
+                        deviceId = "6000".zfill( 16 )
                     elif i == 7:
-                        deviceId = "6007".zfill(16)
+                        deviceId = "6007".zfill( 16 )
                     elif i >= 8 and i <= 17:
                         dpid = '3' + str( i ).zfill( 3 )
-                        deviceId = dpid.zfill(16)
+                        deviceId = dpid.zfill( 16 )
                     elif i >= 18 and i <= 27:
                         dpid = '6' + str( i ).zfill( 3 )
-                        deviceId = dpid.zfill(16)
+                        deviceId = dpid.zfill( 16 )
                     elif i == 28:
-                        deviceId = "2800".zfill(16)
+                        deviceId = "2800".zfill( 16 )
                     mappings[ macId ] = deviceId
                 if hosts[ controller ] is not None and "Error" not in hosts[ controller ]:
                     if hosts[ controller ] == []:
@@ -2484,7 +2481,7 @@
                                 assert location, "location field could not be found for this host object"
 
                                 # Trim the protocol identifier off deviceId
-                                device = str( location.get( 'elementId' ) ).split(':')[1]
+                                device = str( location.get( 'elementId' ) ).split( ':' )[ 1 ]
                                 assert device, "elementId field could not be found for this host location object"
 
                                 port = location.get( 'port' )
@@ -2495,7 +2492,7 @@
                                     if str( port ) != "1":
                                         main.log.error( "The attachment port is incorrect for " +
                                                         "host " + str( mac ) +
-                                                        ". Expected: 1 Actual: " + str( port) )
+                                                        ". Expected: 1 Actual: " + str( port ) )
                                         hostAttachment = False
                                     if device != mappings[ str( mac ) ]:
                                         main.log.error( "The attachment device is incorrect for " +
@@ -2537,7 +2534,7 @@
         main.step( "Hosts view is consistent across all ONOS nodes" )
         consistentHostsResult = main.TRUE
         for controller in range( len( hosts ) ):
-            controllerStr = str( main.activeNodes[controller] + 1 )
+            controllerStr = str( main.activeNodes[ controller ] + 1 )
             if hosts[ controller ] is not None and "Error" not in hosts[ controller ]:
                 if hosts[ controller ] == hosts[ 0 ]:
                     continue
@@ -2579,7 +2576,7 @@
         main.step( "Clusters view is consistent across all ONOS nodes" )
         consistentClustersResult = main.TRUE
         for controller in range( len( clusters ) ):
-            controllerStr = str( main.activeNodes[controller] + 1 )
+            controllerStr = str( main.activeNodes[ controller ] + 1 )
             if "Error" not in clusters[ controller ]:
                 if clusters[ controller ] == clusters[ 0 ]:
                     continue
@@ -2609,7 +2606,7 @@
             numClusters = len( json.loads( clusters[ 0 ] ) )
         except ( ValueError, TypeError ):
             main.log.exception( "Error parsing clusters[0]: " +
-                                repr( clusters[0] ) )
+                                repr( clusters[ 0 ] ) )
             numClusters = "ERROR"
         clusterResults = main.FALSE
         if numClusters == 1:
@@ -2659,7 +2656,7 @@
         main.step( "Checking ONOS nodes" )
         nodeResults = utilities.retry( main.HA.nodesCheck,
                                        False,
-                                       args=[main.activeNodes],
+                                       args=[ main.activeNodes ],
                                        attempts=5 )
 
         utilities.assert_equals( expect=True, actual=nodeResults,
@@ -2668,8 +2665,8 @@
         if not nodeResults:
             for i in main.activeNodes:
                 main.log.debug( "{} components not ACTIVE: \n{}".format(
-                    main.CLIs[i].name,
-                    main.CLIs[i].sendline( "scr:list | grep -v ACTIVE" ) ) )
+                    main.CLIs[ i ].name,
+                    main.CLIs[ i ].sendline( "scr:list | grep -v ACTIVE" ) ) )
 
         if not topoResult:
             main.cleanup()
@@ -2746,7 +2743,7 @@
         switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
 
         description = "Killing a switch to ensure it is discovered correctly"
-        onosCli = main.CLIs[ main.activeNodes[0] ]
+        onosCli = main.CLIs[ main.activeNodes[ 0 ] ]
         main.case( description )
         switch = main.params[ 'kill' ][ 'switch' ]
         switchDPID = main.params[ 'kill' ][ 'dpid' ]
@@ -2791,7 +2788,7 @@
         switch = main.params[ 'kill' ][ 'switch' ]
         switchDPID = main.params[ 'kill' ][ 'dpid' ]
         links = main.params[ 'kill' ][ 'links' ].split()
-        onosCli = main.CLIs[ main.activeNodes[0] ]
+        onosCli = main.CLIs[ main.activeNodes[ 0 ] ]
         description = "Adding a switch to ensure it is discovered correctly"
         main.case( description )
 
@@ -2878,14 +2875,14 @@
             main.log.warn( main.ONOSbench.checkLogs( node.ip_address ) )
 
         try:
-            timerLog = open( main.logdir + "/Timers.csv", 'w')
+            timerLog = open( main.logdir + "/Timers.csv", 'w' )
             # Overwrite with empty line and close
             labels = "Gossip Intents, Restart"
             data = str( gossipTime ) + ", " + str( main.restartTime )
             timerLog.write( labels + "\n" + data )
             timerLog.close()
-        except NameError, e:
-            main.log.exception(e)
+        except NameError as e:
+            main.log.exception( e )
 
     def CASE14( self, main ):
         """
@@ -2897,9 +2894,9 @@
         assert main.CLIs, "main.CLIs not defined"
         assert main.nodes, "main.nodes not defined"
 
-        main.case("Start Leadership Election app")
+        main.case( "Start Leadership Election app" )
         main.step( "Install leadership election app" )
-        onosCli = main.CLIs[ main.activeNodes[0] ]
+        onosCli = main.CLIs[ main.activeNodes[ 0 ] ]
         appResult = onosCli.activateApp( "org.onosproject.election" )
         utilities.assert_equals(
             expect=main.TRUE,
@@ -2909,9 +2906,9 @@
 
         main.step( "Run for election on each node" )
         for i in main.activeNodes:
-            main.CLIs[i].electionTestRun()
-        time.sleep(5)
-        activeCLIs = [ main.CLIs[i] for i in main.activeNodes ]
+            main.CLIs[ i ].electionTestRun()
+        time.sleep( 5 )
+        activeCLIs = [ main.CLIs[ i ] for i in main.activeNodes ]
         sameResult, leaders = main.HA.consistentLeaderboards( activeCLIs )
         utilities.assert_equals(
             expect=True,
@@ -2921,7 +2918,7 @@
 
         if sameResult:
             leader = leaders[ 0 ][ 0 ]
-            if main.nodes[main.activeNodes[0]].ip_address in leader:
+            if main.nodes[ main.activeNodes[ 0 ] ].ip_address in leader:
                 correctLeader = True
             else:
                 correctLeader = False
@@ -2971,7 +2968,7 @@
         electionResult = main.TRUE
 
         for i in main.activeNodes:  # run test election on each node
-            if main.CLIs[i].electionTestRun() == main.FALSE:
+            if main.CLIs[ i ].electionTestRun() == main.FALSE:
                 electionResult = main.FALSE
         utilities.assert_equals(
             expect=main.TRUE,
@@ -2986,7 +2983,7 @@
 
         main.step( "Check that each node shows the same leader and candidates" )
         failMessage = "Nodes have different leaderboards"
-        activeCLIs = [ main.CLIs[i] for i in main.activeNodes ]
+        activeCLIs = [ main.CLIs[ i ] for i in main.activeNodes ]
         sameResult, oldLeaders = main.HA.consistentLeaderboards( activeCLIs )
         if sameResult:
             oldLeader = oldLeaders[ 0 ][ 0 ]
@@ -3036,7 +3033,7 @@
         if newLeader == oldLeader:
             newLeaderResult = False
             main.log.error( "All nodes still see old leader: " + str( oldLeader ) +
-                " as the current leader" )
+                            " as the current leader" )
         utilities.assert_equals(
             expect=True,
             actual=newLeaderResult,
@@ -3053,7 +3050,7 @@
             else:
                 main.log.info( "Expected no leader, got: " + str( newLeader ) )
                 correctCandidateResult = main.FALSE
-        elif len( oldLeaders[0] ) >= 3:
+        elif len( oldLeaders[ 0 ] ) >= 3:
             if newLeader == oldLeaders[ 0 ][ 2 ]:
                 # correct leader was elected
                 correctCandidateResult = main.TRUE
@@ -3093,10 +3090,10 @@
         positionResult, reRunLeaders = main.HA.consistentLeaderboards( activeCLIs )
 
         # Check that the re-elected node is last on the candidate List
-        if not reRunLeaders[0]:
+        if not reRunLeaders[ 0 ]:
             positionResult = main.FALSE
         elif oldLeader != reRunLeaders[ 0 ][ -1 ]:
-            main.log.error( "Old Leader ({}) not in the proper position: {} ".format( str( oldLeader),
+            main.log.error( "Old Leader ({}) not in the proper position: {} ".format( str( oldLeader ),
                                                                                       str( reRunLeaders[ 0 ] ) ) )
             positionResult = main.FALSE
         utilities.assert_equals(
@@ -3120,15 +3117,15 @@
         # Variables for the distributed primitives tests
         main.pCounterName = "TestON-Partitions"
         main.pCounterValue = 0
-        main.onosSet = set([])
+        main.onosSet = set( [] )
         main.onosSetName = "TestON-set"
 
         description = "Install Primitives app"
         main.case( description )
         main.step( "Install Primitives app" )
         appName = "org.onosproject.distributedprimitives"
-        node = main.activeNodes[0]
-        appResults = main.CLIs[node].activateApp( appName )
+        node = main.activeNodes[ 0 ]
+        appResults = main.CLIs[ node ].activateApp( appName )
         utilities.assert_equals( expect=main.TRUE,
                                  actual=appResults,
                                  onpass="Primitives app activated",