[ONOS-7039] [ONOS-7044] Fix PEP8 Warnings in TestON

Change-Id: Ied79ff9caff5487a6df50466307f757468d7ca3a
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
old mode 100755
new mode 100644
index d83585a..f542554
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -1,5 +1,5 @@
 """
-Copyright 2016 Open Networking Foundation (ONF)
+Copyright 2016 Open Networking Foundation ( ONF )
 
 Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
 the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
     TestON is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation, either version 2 of the License, or
-    (at your option) any later version.
+    ( at your option ) any later version.
 
     TestON is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,6 @@
     You should have received a copy of the GNU General Public License
     along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 """
-
 import os
 import imp
 import time
@@ -29,7 +28,7 @@
 
 class Testcaselib:
 
-    useSSH=True
+    useSSH = True
 
     @staticmethod
     def initTest( main ):
@@ -60,7 +59,7 @@
             main.dependencyPath = main.path + "/../dependencies/"
             main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
             wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
-            main.scale = (main.params[ 'SCALE' ][ 'size' ]).split( "," )
+            main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
             main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
             # main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
             main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
@@ -76,8 +75,6 @@
             main.testSetUp.envSetupException( e )
         main.testSetUp.evnSetupConclusion( stepResult )
 
-
-
     @staticmethod
     def installOnos( main, vlanCfg=True ):
         """
@@ -119,7 +116,7 @@
         cliResult = main.TRUE
         main.step( "Checking if ONOS CLI is ready" )
         for ctrl in main.Cluster.runningNodes:
-            ctrl.CLI.startCellCli( )
+            ctrl.CLI.startCellCli()
             cliResult = cliResult and ctrl.CLI.startOnosCli( ctrl.ipAddress,
                                                              commandlineTimeout=60,
                                                              onosStartTimeout=100 )
@@ -139,10 +136,10 @@
                                  onfail="ONOS summary command failed" )
 
         with open( "%s/json/%s.json" % (
-                main.dependencyPath, main.cfgName) ) as cfg:
+                main.dependencyPath, main.cfgName ) ) as cfg:
             main.Cluster.active( 0 ).REST.setNetCfg( json.load( cfg ) )
         with open( "%s/json/%s.chart" % (
-                main.dependencyPath, main.cfgName) ) as chart:
+                main.dependencyPath, main.cfgName ) ) as chart:
             main.pingChart = json.load( chart )
         if not ready:
             main.log.error( "ONOS startup failed!" )
@@ -157,7 +154,7 @@
     @staticmethod
     def startMininet( main, topology, args="" ):
         main.step( "Starting Mininet Topology" )
-        arg = "--onos %d %s" % (main.Cluster.numCtrls, args)
+        arg = "--onos %d %s" % ( main.Cluster.numCtrls, args )
         main.topology = topology
         topoResult = main.Mininet1.startNet(
                 topoFile=main.Mininet1.home + main.topology, args=arg )
@@ -172,44 +169,44 @@
 
     @staticmethod
     def config( main, cfgName ):
-        main.spines     = []
+        main.spines = []
 
-        main.failures   = int(main.params[ 'failures' ])
-        main.cfgName    = cfgName
+        main.failures = int( main.params[ 'failures' ] )
+        main.cfgName = cfgName
 
-        if main.cfgName == '2x2' :
-            spine           = {}
-            spine[ 'name' ] = main.params['switches'][ 'spine1' ]
-            spine[ 'dpid' ] = main.params['switches'][ 'spinedpid1' ]
-            main.spines.append(spine)
+        if main.cfgName == '2x2':
+            spine = {}
+            spine[ 'name' ] = main.params[ 'switches' ][ 'spine1' ]
+            spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid1' ]
+            main.spines.append( spine )
 
-            spine           = {}
-            spine[ 'name' ] = main.params['switches'][ 'spine2' ]
-            spine[ 'dpid' ] = main.params['switches'][ 'spinedpid2' ]
-            main.spines.append(spine)
+            spine = {}
+            spine[ 'name' ] = main.params[ 'switches' ][ 'spine2' ]
+            spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid2' ]
+            main.spines.append( spine )
 
-        elif main.cfgName == '4x4' :
-            spine           = {}
-            spine[ 'name' ] = main.params['switches'][ 'spine1' ]
-            spine[ 'dpid' ] = main.params['switches'][ 'spinedpid1' ]
-            main.spines.append(spine)
+        elif main.cfgName == '4x4':
+            spine = {}
+            spine[ 'name' ] = main.params[ 'switches' ][ 'spine1' ]
+            spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid1' ]
+            main.spines.append( spine )
 
-            spine           = {}
-            spine[ 'name' ] = main.params['switches'][ 'spine2' ]
-            spine[ 'dpid' ] = main.params['switches'][ 'spinedpid2' ]
-            main.spines.append(spine)
+            spine = {}
+            spine[ 'name' ] = main.params[ 'switches' ][ 'spine2' ]
+            spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid2' ]
+            main.spines.append( spine )
 
-            spine           = {}
-            spine[ 'name' ] = main.params['switches'][ 'spine3' ]
-            spine[ 'dpid' ] = main.params['switches'][ 'spinedpid3' ]
-            main.spines.append(spine)
+            spine = {}
+            spine[ 'name' ] = main.params[ 'switches' ][ 'spine3' ]
+            spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid3' ]
+            main.spines.append( spine )
 
-            spine           = {}
-            spine[ 'name' ] = main.params['switches'][ 'spine4' ]
-            spine[ 'dpid' ] = main.params['switches'][ 'spinedpid4' ]
-            main.spines.append(spine)
+            spine = {}
+            spine[ 'name' ] = main.params[ 'switches' ][ 'spine4' ]
+            spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid4' ]
+            main.spines.append( spine )
 
-        else :
+        else:
             main.log.error( "Configuration failed!" )
             main.cleanAndExit()
 
@@ -222,9 +219,9 @@
                                  kwargs={ 'min': minFlowCount },
                                  attempts=10,
                                  sleep=10 )
-        utilities.assertEquals( \
+        utilities.assertEquals(
                 expect=True,
-                actual=(count > 0),
+                actual=( count > 0 ),
                 onpass="Flow count looks correct: " + str( count ),
                 onfail="Flow count looks wrong: " + str( count ) )
 
@@ -234,7 +231,7 @@
                                      kwargs={ 'isPENDING': False },
                                      attempts=2,
                                      sleep=10 )
-        utilities.assertEquals( \
+        utilities.assertEquals(
                 expect=main.TRUE,
                 actual=flowCheck,
                 onpass="Flow status is correct!",
@@ -253,11 +250,11 @@
     def pingAll( main, tag="", dumpflows=True ):
         main.log.report( "Check full connectivity" )
         print main.pingChart
-        for entry in main.pingChart.itervalues( ):
+        for entry in main.pingChart.itervalues():
             print entry
             hosts, expect = entry[ 'hosts' ], entry[ 'expect' ]
             expect = main.TRUE if expect else main.FALSE
-            main.step( "Connectivity for %s %s" % (str( hosts ), tag) )
+            main.step( "Connectivity for %s %s" % ( str( hosts ), tag ) )
             pa = main.Mininet1.pingallHosts( hosts )
             utilities.assert_equals( expect=expect, actual=pa,
                                      onpass="IP connectivity successfully tested",
@@ -280,7 +277,7 @@
         Kill a link and verify ONOS can see the proper link change
         """
         main.linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
-        main.step( "Kill link between %s and %s" % (end1, end2) )
+        main.step( "Kill link between %s and %s" % ( end1, end2 ) )
         LinkDown = main.Mininet1.link( END1=end1, END2=end2, OPTION="down" )
         LinkDown = main.Mininet1.link( END2=end1, END1=end2, OPTION="down" )
         main.log.info(
@@ -308,7 +305,7 @@
             switches, links: number of expected switches and links after linkDown, ex.: '4', '6'
         Kill a link and verify ONOS can see the proper link change
         """
-        main.step( "Restore link between %s and %s" % (end1, end2) )
+        main.step( "Restore link between %s and %s" % ( end1, end2 ) )
         result = False
         count = 0
         while True:
@@ -319,7 +316,7 @@
                     "Waiting %s seconds for link up to be discovered" % main.linkSleep )
             time.sleep( main.linkSleep )
 
-            for i in range(0, main.Cluster.numCtrls):
+            for i in range( 0, main.Cluster.numCtrls ):
                 ctrl = main.Cluster.runningNodes[ i ]
                 onosIsUp = main.ONOSbench.isup( ctrl.ipAddress )
                 if onosIsUp == main.TRUE:
@@ -347,7 +344,7 @@
         main.Mininet1.switch( SW=switch, OPTION="stop" )
         # todo make this repeatable
         main.log.info( "Waiting %s seconds for switch down to be discovered" % (
-            main.switchSleep) )
+            main.switchSleep ) )
         time.sleep( main.switchSleep )
         topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus,
                                     main.FALSE,
@@ -370,7 +367,7 @@
         main.log.info( "Starting" + switch )
         main.Mininet1.switch( SW=switch, OPTION="start" )
         main.log.info( "Waiting %s seconds for switch up to be discovered" % (
-            main.switchSleep) )
+            main.switchSleep ) )
         time.sleep( main.switchSleep )
         topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus,
                                     main.FALSE,
@@ -413,7 +410,6 @@
         switches, links, nodes: number of expected switches, links and nodes after KillOnos, ex.: '4', '6'
         Completely Kill an ONOS instance and verify the ONOS cluster can see the proper change
         """
-
         main.step( "Killing ONOS instance" )
 
         for i in nodes:
@@ -484,7 +480,7 @@
         main.step( "Checking ONOS nodes" )
         nodeResults = utilities.retry( Testcaselib.nodesCheck,
                                        False,
-                                       args=[nodes],
+                                       args=[ nodes ],
                                        attempts=5,
                                        sleep=10 )
         utilities.assert_equals( expect=True, actual=nodeResults,
@@ -527,15 +523,15 @@
     def addHostCfg( main ):
         """
         Adds Host Configuration to ONOS
-        Updates expected state of the network (pingChart)
+        Updates expected state of the network ( pingChart )
         """
         import json
-        hostCfg = { }
+        hostCfg = {}
         with open( main.dependencyPath + "/json/extra.json" ) as template:
             hostCfg = json.load( template )
         main.pingChart[ 'ip' ][ 'hosts' ] += [ 'in1' ]
         main.step( "Pushing new configuration" )
-        mac, cfg = hostCfg[ 'hosts' ].popitem( )
+        mac, cfg = hostCfg[ 'hosts' ].popitem()
         main.Cluster.active( 0 ).REST.setNetCfg( cfg[ 'basic' ],
                                                  subjectClass="hosts",
                                                  subjectKey=urllib.quote( mac,
@@ -543,17 +539,17 @@
                                                  configKey="basic" )
         main.pingChart[ 'ip' ][ 'hosts' ] += [ 'out1' ]
         main.step( "Pushing new configuration" )
-        mac, cfg = hostCfg[ 'hosts' ].popitem( )
+        mac, cfg = hostCfg[ 'hosts' ].popitem()
         main.Cluster.active( 0 ).REST.setNetCfg( cfg[ 'basic' ],
                                                  subjectClass="hosts",
                                                  subjectKey=urllib.quote( mac,
                                                                           safe='' ),
-                                             configKey="basic" )
+                                                 configKey="basic" )
         main.pingChart.update( { 'vlan1': { "expect": "True",
                                             "hosts": [ "olt1", "vsg1" ] } } )
         main.pingChart[ 'vlan5' ][ 'expect' ] = 0
         main.pingChart[ 'vlan10' ][ 'expect' ] = 0
-        ports = "[%s,%s]" % (5, 6)
+        ports = "[%s,%s]" % ( 5, 6 )
         cfg = '{"of:0000000000000001":[{"vlan":1,"ports":%s,"name":"OLT 1"}]}' % ports
         main.Cluster.active( 0 ).REST.setNetCfg( json.loads( cfg ),
                                                  subjectClass="apps",
@@ -564,15 +560,15 @@
     def delHostCfg( main ):
         """
         Removest Host Configuration from ONOS
-        Updates expected state of the network (pingChart)
+        Updates expected state of the network ( pingChart )
         """
         import json
-        hostCfg = { }
+        hostCfg = {}
         with open( main.dependencyPath + "/json/extra.json" ) as template:
             hostCfg = json.load( template )
         main.step( "Removing host configuration" )
         main.pingChart[ 'ip' ][ 'expect' ] = 0
-        mac, cfg = hostCfg[ 'hosts' ].popitem( )
+        mac, cfg = hostCfg[ 'hosts' ].popitem()
         main.Cluster.active( 0 ).REST.removeNetCfg( subjectClass="hosts",
                                                     subjectKey=urllib.quote(
                                                             mac,
@@ -580,7 +576,7 @@
                                                     configKey="basic" )
         main.step( "Removing configuration" )
         main.pingChart[ 'ip' ][ 'expect' ] = 0
-        mac, cfg = hostCfg[ 'hosts' ].popitem( )
+        mac, cfg = hostCfg[ 'hosts' ].popitem()
         main.Cluster.active( 0 ).REST.removeNetCfg( subjectClass="hosts",
                                                     subjectKey=urllib.quote(
                                                             mac,
@@ -591,20 +587,20 @@
         main.Cluster.active( 0 ).REST.removeNetCfg( subjectClass="apps",
                                                     subjectKey="org.onosproject.segmentrouting",
                                                     configKey="xconnect" )
+
     @staticmethod
     def nodesCheck( nodes ):
         results = True
         nodesOutput = main.Cluster.command( "nodes", specificDriver=2 )
-        ips = main.Cluster.getIps( activeOnly=True )
-        ips.sort()
+        ips = sorted( main.Cluster.getIps( activeOnly=True ) )
         for i in nodesOutput:
             try:
                 current = json.loads( i )
                 activeIps = []
                 currentResult = False
                 for node in current:
-                    if node['state'] == 'READY':
-                        activeIps.append( node['ip'] )
+                    if node[ 'state' ] == 'READY':
+                        activeIps.append( node[ 'ip' ] )
                 currentResult = True
                 for ip in ips:
                     if ip not in activeIps:
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/cord_fabric.py b/TestON/tests/USECASE/SegmentRouting/dependencies/cord_fabric.py
old mode 100755
new mode 100644
index 1c7e258..1012fef
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/cord_fabric.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/cord_fabric.py
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 
 """
-Copyright 2016 Open Networking Foundation (ONF)
+Copyright 2016 Open Networking Foundation ( ONF )
 
 Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
 the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -10,7 +10,7 @@
     TestON is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation, either version 2 of the License, or
-    (at your option) any later version.
+    ( at your option ) any later version.
 
     TestON is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,7 +20,6 @@
     You should have received a copy of the GNU General Public License
     along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 """
-
 import os
 import re
 import math
@@ -35,9 +34,9 @@
 
 
 # Parse command line options and dump results
-def parseOptions( ):
-    """Parse command line options"""
-    parser = OptionParser( )
+def parseOptions():
+    "Parse command line options"
+    parser = OptionParser()
     parser.add_option( '--spine', dest='spine', type='int', default=2,
                        help='number of spine switches, default=2' )
     parser.add_option( '--leaf', dest='leaf', type='int', default=2,
@@ -50,52 +49,54 @@
                        help='vid of cross connect, default=-1, -1 means utilize default value' )
     parser.add_option( '--ipv6', action="store_true", dest='ipv6',
                        help='hosts are capable to use also ipv6' )
-    (options, args) = parser.parse_args( )
+    ( options, args ) = parser.parse_args()
     return options, args
 
 
-opts, args = parseOptions( )
+opts, args = parseOptions()
 
 IP6_SUBNET_CLASS = 120
 IP4_SUBNET_CLASS = 24
 
+
 class LeafAndSpine6( Topo ):
+
     """
     Create Leaf and Spine Topology for IPv4/IPv6 tests.
     """
     def __init__( self, spine=2, leaf=2, fanout=2, **opts ):
         Topo.__init__( self, **opts )
-        spines          = {}
-        leafs           = {}
+        spines = {}
+        leafs = {}
         """
         We calculate the offset from /120 and from /24 in order to have
         a number of /120 and /24 subnets == leaf
         """
-        offset          = int(math.ceil(math.sqrt( leaf )))
+        offset = int( math.ceil( math.sqrt( leaf ) ) )
         """
         We calculate the subnets to use and set options
         """
-        ipv6SubnetClass = unicode('2000::/%s' % (IP6_SUBNET_CLASS - offset))
-        ipv6Subnets     = list(IPv6Network(ipv6SubnetClass).subnets( new_prefix = IP6_SUBNET_CLASS ))
-        ipv4SubnetClass = unicode('10.0.0.0/%s' % (IP4_SUBNET_CLASS - offset))
-        ipv4Subnets     = list(IPv4Network(ipv4SubnetClass).subnets( new_prefix = IP4_SUBNET_CLASS ))
-        linkopts        = dict( bw=100 )
+        ipv6SubnetClass = unicode( '2000::/%s' % ( IP6_SUBNET_CLASS - offset ) )
+        ipv6Subnets = list( IPv6Network( ipv6SubnetClass ).subnets( new_prefix=IP6_SUBNET_CLASS ) )
+        ipv4SubnetClass = unicode( '10.0.0.0/%s' % ( IP4_SUBNET_CLASS - offset ) )
+        ipv4Subnets = list( IPv4Network( ipv4SubnetClass ).subnets( new_prefix=IP4_SUBNET_CLASS ) )
+        linkopts = dict( bw=100 )
         """
         We create the spine switches
         """
         for s in range( spine ):
-            spines[ s ] = self.addSwitch( 'spine10%s' % (s + 1),
-                                          dpid="00000000010%s" % (s + 1) )
+            spines[ s ] = self.addSwitch( 'spine10%s' % ( s + 1 ),
+                                          dpid="00000000010%s" % ( s + 1 ) )
         """
         We create the leaf switches
         """
         for ls in range( leaf ):
-            leafs[ ls ] = self.addSwitch( 'leaf%s' % (ls + 1),
-                                          dpid="00000000000%s" % (1 + ls) )
-            ipv6Subnet  = ipv6Subnets[ ls ]
-            ipv6Hosts   = list(ipv6Subnet.hosts())
-            ipv4Subnet  = ipv4Subnets[ ls ]
-            ipv4Hosts   = list(ipv4Subnet.hosts())
+            leafs[ ls ] = self.addSwitch( 'leaf%s' % ( ls + 1 ),
+                                          dpid="00000000000%s" % ( 1 + ls ) )
+            ipv6Subnet = ipv6Subnets[ ls ]
+            ipv6Hosts = list( ipv6Subnet.hosts() )
+            ipv4Subnet = ipv4Subnets[ ls ]
+            ipv4Hosts = list( ipv4Subnet.hosts() )
             """
             We add the hosts
             """
@@ -105,13 +106,13 @@
                 ipv4 = ipv4Hosts[ f ]
                 ipv4Gateway = ipv4Hosts[ len( ipv4Hosts ) - 1 ]
                 host = self.addHost(
-                    name='h%s' % (ls * fanout + f + 1),
+                    name='h%s' % ( ls * fanout + f + 1 ),
                     cls=Ipv6Host,
-                    ip="%s/%s" %(ipv4, IP4_SUBNET_CLASS),
+                    ip="%s/%s" % ( ipv4, IP4_SUBNET_CLASS ),
                     gateway='%s' % ipv4Gateway,
-                    ipv6="%s/%s" %(ipv6, IP6_SUBNET_CLASS),
+                    ipv6="%s/%s" % ( ipv6, IP6_SUBNET_CLASS ),
                     ipv6Gateway="%s" % ipv6Gateway
-                    )
+                )
                 self.addLink( host, leafs[ ls ], **linkopts )
             """
             Connect leaf to all spines
@@ -120,45 +121,45 @@
                 switch = spines[ s ]
                 self.addLink( leafs[ ls ], switch, **linkopts )
 
+
 class LeafAndSpine( Topo ):
+
     def __init__( self, spine=2, leaf=2, fanout=2, **opts ):
         "Create Leaf and Spine Topo."
         Topo.__init__( self, **opts )
         # Add spine switches
-        spines = { }
-        leafs = { }
+        spines = {}
+        leafs = {}
         for s in range( spine ):
-            spines[ s ] = self.addSwitch( 'spine10%s' % (s + 1),
-                                          dpid="00000000010%s" % (s + 1) )
+            spines[ s ] = self.addSwitch( 'spine10%s' % ( s + 1 ),
+                                          dpid="00000000010%s" % ( s + 1 ) )
         # Set link speeds to 100Mb/s
         linkopts = dict( bw=100 )
         # Add Leaf switches
         for ls in range( leaf ):
-            leafs[ ls ] = self.addSwitch( 'leaf%s' % (ls + 1),
-                                          dpid="00000000000%s" % (1 + ls) )
+            leafs[ ls ] = self.addSwitch( 'leaf%s' % ( ls + 1 ),
+                                          dpid="00000000000%s" % ( 1 + ls ) )
             # Add hosts under a leaf, fanout hosts per leaf switch
             for f in range( fanout ):
-                host = self.addHost( 'h%s' % (ls * fanout + f + 1),
+                host = self.addHost( 'h%s' % ( ls * fanout + f + 1 ),
                                      cls=IpHost,
-                                     ip='10.0.%s.%s/24' % ((ls + 1), (f + 1)),
-                                     gateway='10.0.%s.254' % (ls + 1) )
+                                     ip='10.0.%s.%s/24' % ( ( ls + 1 ), ( f + 1 ) ),
+                                     gateway='10.0.%s.254' % ( ls + 1 ) )
                 self.addLink( host, leafs[ ls ], **linkopts )
                 # Add Xconnect simulation
             if ls is 0:
                 in1 = self.addHost( 'in1', cls=IpHost, ip='10.0.1.9/24', mac="00:00:00:00:00:09" )
-                self.addLink( in1, leafs[0], **linkopts )
+                self.addLink( in1, leafs[ 0 ], **linkopts )
                 out1 = self.addHost( 'out1', cls=IpHost, ip='10.0.9.1/24', mac="00:00:00:00:09:01" )
-                self.addLink( out1, leafs[0], **linkopts )
+                self.addLink( out1, leafs[ 0 ], **linkopts )
                 br1 = self.addSwitch( 'br1', cls=OVSBridge )
                 self.addLink( br1, leafs[ 0 ], **linkopts )
                 vlans = [ 1, 5, 10 ]
                 for vid in vlans:
                     olt = self.addHost( 'olt%s' % vid, cls=VLANHost, vlan=vid,
-                                        ip="10.%s.0.1/24" % vid
-                                        , mac="00:00:%02d:00:00:01" % vid )
+                                        ip="10.%s.0.1/24" % vid, mac="00:00:%02d:00:00:01" % vid )
                     vsg = self.addHost( 'vsg%s' % vid, cls=VLANHost, vlan=vid,
-                                        ip="10.%s.0.2/24" % vid
-                                        , mac="00:00:%02d:00:00:02" % vid )
+                                        ip="10.%s.0.2/24" % vid, mac="00:00:%02d:00:00:02" % vid )
                     self.addLink( olt, leafs[ 0 ], **linkopts )
                     self.addLink( vsg, br1, **linkopts )
             # Connect leaf to all spines
@@ -166,12 +167,14 @@
                 switch = spines[ s ]
                 self.addLink( leafs[ ls ], switch, **linkopts )
 
+
 class IpHost( Host ):
+
     def __init__( self, name, *args, **kwargs ):
         super( IpHost, self ).__init__( name, *args, **kwargs )
-        gateway = re.split('\.|/', kwargs['ip'])
-        gateway[3] = '254'
-        self.gateway = '.'.join(gateway[0:4])
+        gateway = re.split( '\.|/', kwargs[ 'ip' ] )
+        gateway[ 3 ] = '254'
+        self.gateway = '.'.join( gateway[ 0:4 ] )
 
     def config( self, **kwargs ):
         Host.config( self, **kwargs )
@@ -179,77 +182,84 @@
         self.cmd( mtu )
         self.cmd( 'ip route add default via %s' % self.gateway )
 
+
 class Ipv6Host( IpHost ):
+
     """
     Abstraction to model an augmented host with a ipv6
     functionalities as well
     """
     def __init__( self, name, *args, **kwargs ):
-        IpHost.__init__(self, name, *args, **kwargs)
+        IpHost.__init__( self, name, *args, **kwargs )
 
     def config( self, **kwargs ):
         IpHost.config( self, **kwargs )
-        ipv6Cmd         = 'ifconfig %s-eth0 inet6 add %s' % (self.name, kwargs['ipv6'])
-        ipv6GatewayCmd  = 'ip -6 route add default via %s' % kwargs['ipv6Gateway']
-        ipv6MtuCmd      = 'ifconfig %s-eth0 inet6 mtu 1490' % (self.name)
+        ipv6Cmd = 'ifconfig %s-eth0 inet6 add %s' % ( self.name, kwargs[ 'ipv6' ] )
+        ipv6GatewayCmd = 'ip -6 route add default via %s' % kwargs[ 'ipv6Gateway' ]
+        ipv6MtuCmd = 'ifconfig %s-eth0 inet6 mtu 1490' % ( self.name )
         self.cmd( ipv6Cmd )
         self.cmd( ipv6GatewayCmd )
         self.cmd( ipv6MtuCmd )
 
+
 class VLANHost( Host ):
+
     "Host connected to VLAN interface"
 
     def config( self, vlan=100, **params ):
-        """Configure VLANHost according to (optional) parameters:
+        """Configure VLANHost according to ( optional ) parameters:
            vlan: VLAN ID for default interface"""
         r = super( VLANHost, self ).config( **params )
-        intf = self.defaultIntf( )
+        intf = self.defaultIntf()
         # remove IP from default, "physical" interface
         self.cmd( 'ifconfig %s inet 0' % intf )
-        intf = self.defaultIntf( )
+        intf = self.defaultIntf()
         # create VLAN interface
-        self.cmd( 'vconfig add %s %d' % (intf, vlan) )
-        self.cmd( 'ifconfig %s.%d %s' % (intf, vlan, params[ 'ip' ]) )
+        self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
+        self.cmd( 'ifconfig %s.%d %s' % ( intf, vlan, params[ 'ip' ] ) )
         # update the intf name and host's intf map
-        self.cmd( 'ifconfig %s.%d mtu 1480' % (intf, vlan) )
-        newName = '%s.%d' % (intf, vlan)
-        # update the (Mininet) interface to refer to VLAN interface name
+        self.cmd( 'ifconfig %s.%d mtu 1480' % ( intf, vlan ) )
+        newName = '%s.%d' % ( intf, vlan )
+        # update the ( Mininet ) interface to refer to VLAN interface name
         intf.name = newName
         # add VLAN interface to host's name to intf map
         self.nameToIntf[ newName ] = intf
 
+
 class ExtendedCLI( CLI ):
+
     """
     Extends mininet CLI with the following commands:
     addvlanhost
     addiphost
     """
     def do_addhost( self, line ):
-        #Parsing args from CLI
-        args = line.split( )
-        if len( args ) < 3 or len( args ) :
+        # Parsing args from CLI
+        args = line.split()
+        if len( args ) < 3 or len( args ):
             "usage: addhost hostname switch **params"
-        hostname, switch = args[0],  args[1]
-        params = eval(line.split( ' ', 3 )[2])
+        hostname, switch = args[ 0 ], args[ 1 ]
+        params = eval( line.split( ' ', 3 )[ 2 ] )
         if 'cls' in params:
-            params['cls'] = eval( params[ 'cls' ] )
+            params[ 'cls' ] = eval( params[ 'cls' ] )
         if hostname in self.mn:
-            #error( '%s already exists!\n' % hostname )
+            # error( '%s already exists!\n' % hostname )
             return
         if switch not in self.mn:
-            #error( '%s does not exist!\n' % switch )
+            # error( '%s does not exist!\n' % switch )
             return
         print params
         host = self.mn.addHostCfg( hostname, **params )
-        #switch.attach( link.intf2 )
-        #host.config()
+        # switch.attach( link.intf2 )
+        # host.config()
         link = self.mn.addLink( host, switch )
-        host.config(**params)
+        host.config( **params )
 
     def do_pingall6( self, line ):
         "Ping6 between all hosts."
         self.mn.pingAll6( line )
 
+
 def config( opts ):
     spine = opts.spine
     leaf = opts.leaf
@@ -257,7 +267,7 @@
     vlan = opts.vlan
     ipv6 = opts.ipv6
     controllers = [ os.environ[ 'OC%s' % i ] for i in
-                    range( 1, opts.onos + 1 ) ] if (opts.onos) else [
+                    range( 1, opts.onos + 1 ) ] if ( opts.onos ) else [
         '127.0.0.1' ]
     if not ipv6:
         topo = LeafAndSpine(
@@ -265,7 +275,7 @@
             leaf=leaf,
             fanout=fanout,
             vlan=vlan,
-            )
+        )
     else:
         topo = LeafAndSpine6(
             spine=spine,
@@ -273,20 +283,20 @@
             fanout=fanout,
             vlan=vlan,
             ipv6=ipv6
-            )
+        )
     net = Mininet( topo=topo, link=TCLink, build=False,
                    switch=UserSwitch, controller=None, autoSetMacs=True )
     i = 0
     for ip in controllers:
-        net.addController( "c%s" % (i), controller=RemoteController, ip=ip )
-        i += 1;
-    net.build( )
-    net.start( )
+        net.addController( "c%s" % ( i ), controller=RemoteController, ip=ip )
+        i += 1
+    net.build()
+    net.start()
     if not ipv6:
         out1 = net.get( 'out1' )
-        out1.cmd( "arp -s 10.0.9.254 10:00:00:00:00:01 -i %s " % (out1.intf()) )
-    ExtendedCLI(net)
-    net.stop( )
+        out1.cmd( "arp -s 10.0.9.254 10:00:00:00:00:01 -i %s " % ( out1.intf() ) )
+    ExtendedCLI( net )
+    net.stop()
 
 if __name__ == '__main__':
     setLogLevel( 'info' )