diff --git a/TestON/drivers/common/api/controllerdriver.py b/TestON/drivers/common/api/controllerdriver.py
index f6b941f..5ac112f 100644
--- a/TestON/drivers/common/api/controllerdriver.py
+++ b/TestON/drivers/common/api/controllerdriver.py
@@ -1,14 +1,14 @@
 #!/usr/bin/env python
-'''
-Created on 29-Nov-2012 
+"""
+Created on 29-Nov-2012
 
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)      
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
 
 
     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
@@ -16,15 +16,17 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
-'''  
+"""
 import sys
-sys.path.append("../")
+sys.path.append( "../" )
 from drivers.common.apidriver import API
 
-class Controller(API):
+
+class Controller( API ):
     # The common functions for emulator included in emulatordriver
-    def __init__(self):
-        super(API, self).__init__()
-        
+
+    def __init__( self ):
+        super( API, self ).__init__()
+
diff --git a/TestON/drivers/common/api/fvtapidriver.py b/TestON/drivers/common/api/fvtapidriver.py
index 620b3e9..8203166 100644
--- a/TestON/drivers/common/api/fvtapidriver.py
+++ b/TestON/drivers/common/api/fvtapidriver.py
@@ -1,14 +1,14 @@
 #!/usr/bin/env python
-'''
+"""
 Created on 26-Oct-2012
 
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
 
 
     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
@@ -16,18 +16,18 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
 fvtapidriver is the basic driver which will handle the fvtapidriver functions
-'''
-'''
+"""
+"""
 There are two changes required in flowvisor-test framework :
 
 1. In ~/flowvisortests/tests/templatetest.py line : 15 comment 'basic_logger = None'
 2. In ~/flowvisortests/tests/testutils.py line : 50 specify config file path CONFIG_FILE = "~/flowvisor-test/tests/tests-base.json"
 
-'''
+"""
 import pexpect
 import struct
 import fcntl
@@ -35,12 +35,12 @@
 import signal
 import re
 import sys
-sys.path.append("../")
+sys.path.append( "../" )
 from common.apidriver import API
 import logging
 
-sys.path.append(path+"/lib/flowvisor-test/tests")
-sys.path.append(path+"/lib/flowvisor-test/src/python/")
+sys.path.append( path + "/lib/flowvisor-test/tests" )
+sys.path.append( path + "/lib/flowvisor-test/src/python/" )
 
 import templatetest
 import testutils
@@ -53,29 +53,30 @@
 import __builtin__
 
 config_default = {
-    "param"              : None,
-    "fv_cmd"             : "/home/openflow/flowvisor/scripts/flowvisor.sh",
-    "platform"           : "local",
-    "controller_host"    : "127.0.0.1",
-    "controller_port"    : 6633,
-    "timeout"            : 3,
-    "port_count"         : 4,
-    "base_of_port"       : 1,
-    "base_if_index"      : 1,
-    "test_spec"          : "all",
-    "test_dir"           : ".",
-    "log_file"           : "/home/openflow/fvt.log",
-    "list"               : False,
-    "debug"              : "debug",
-    "dbg_level"          : logging.DEBUG,
-    "port_map"           : {},
-    "test_params"        : "None"
+    "param": None,
+    "fv_cmd": "/home/openflow/flowvisor/scripts/flowvisor.sh",
+    "platform": "local",
+    "controller_host": "127.0.0.1",
+    "controller_port": 6633,
+    "timeout": 3,
+    "port_count": 4,
+    "base_of_port": 1,
+    "base_if_index": 1,
+    "test_spec": "all",
+    "test_dir": ".",
+    "log_file": "/home/openflow/fvt.log",
+    "list": False,
+    "debug": "debug",
+    "dbg_level": logging.DEBUG,
+    "port_map": {},
+    "test_params": "None"
 }
 
-def test_set_init(config):
+
+def test_set_init( config ):
     """
     Set up function for basic test classes
-    @param config The configuration dictionary; see fvt
+    config: The configuration dictionary; see fvt
     """
     global basic_port_map
     global basic_fv_cmd
@@ -84,88 +85,89 @@
     global basic_config
     global baisc_logger
 
-    basic_fv_cmd = config["fv_cmd"]
-    basic_timeout = config["timeout"]
-    basic_port_map = config["port_map"]
+    basic_fv_cmd = config[ "fv_cmd" ]
+    basic_timeout = config[ "timeout" ]
+    basic_port_map = config[ "port_map" ]
     basic_config = config
 
-class FvtApiDriver(API,templatetest.TemplateTest):
 
-    def __init__(self):
-        super(API, self).__init__()
+class FvtApiDriver( API, templatetest.TemplateTest ):
+
+    def __init__( self ):
+        super( API, self ).__init__()
         print 'init'
-                                                
 
-    def connect(self,**connectargs):
+    def connect( self, **connectargs ):
         for key in connectargs:
-            vars(self)[key] = connectargs[key]
-        
-        self.name = self.options['name']
-        connect_result = super(API,self).connect()
-        self.logFileName = main.logdir+"/"+self.name+".session"
-        config_default["log_file"] = self.logFileName
-        test_set_init(config_default)
-        __builtin__.basic_logger = vars(main)[self.name+'log']
-        __builtin__.basic_logger.info("Calling my test setup")
-        self.setUp(basic_logger)
+            vars( self )[ key ] = connectargs[ key ]
 
-        (self.fv, self.sv, sv_ret, ctl_ret, sw_ret) = testutils.setUpTestEnv(self, fv_cmd=basic_fv_cmd)
-        
-        self.chkSetUpCondition(self.fv, sv_ret, ctl_ret, sw_ret)
+        self.name = self.options[ 'name' ]
+        connect_result = super( API, self ).connect()
+        self.logFileName = main.logdir + "/" + self.name + ".session"
+        config_default[ "log_file" ] = self.logFileName
+        test_set_init( config_default )
+        __builtin__.basic_logger = vars( main )[ self.name + 'log' ]
+        __builtin__.basic_logger.info( "Calling my test setup" )
+        self.setUp( basic_logger )
+
+        ( self.fv, self.sv, sv_ret, ctl_ret, sw_ret ) = testutils.setUpTestEnv(
+            self, fv_cmd=basic_fv_cmd )
+
+        self.chkSetUpCondition( self.fv, sv_ret, ctl_ret, sw_ret )
         return main.TRUE
 
-    def simplePacket(self,dl_src):
-        dl_src = vars(testutils)[dl_src]
-        return testutils.simplePacket(dl_src = dl_src)
-   
-    def genPacketIn(self, in_port, pkt):
-        return testutils.genPacketIn(in_port=in_port, pkt=pkt)
-     
-    def ofmsgSndCmp(self, snd_list, exp_list, xid_ignore=True, hdr_only=True):
-        return testutils.ofmsgSndCmp(self, snd_list, exp_list, xid_ignore, hdr_only)
-    
-    def setRule(self,sv,rule,num_try) :
-        return testutils.setRule(self,sv,rule,num_try)
-    
-    def chkFlowdb(self,controller_number,switch_number,exp_count,exp_rewrites) :
-        return testutils.chkFlowdb(self,controller_number,switch_number,exp_count,exp_rewrites)
-    
-    def chkSwitchStats(self, switch_number, ofproto, exp_snd_count, exp_rcv_count):
-        return testutils.chkSwitchStats(self, switch_number, ofproto, exp_snd_count, exp_rcv_count)
-    
-    def chkSliceStats(self,controller_number,ofproto,exp_snd_count,exp_rcv_count) :
-        return testutils.chkSliceStats(self,controller_number,ofproto,exp_snd_count,exp_rcv_count)
-    
-    def recvStats(self,swId,typ) :
-        return testutils.recvStats(self,swId,typ)
-    
-    def ofmsgSndCmpWithXid(self,snd_list,exp_list,xid_ignore,hdr_only) :
-        return testutils.ofmsgSndCmpWithXid(self,snd_list,exp_list,xid_ignore,hdr_only)
-    
-    def genPacketOut(self,xid,buffer_id,in_port,action_ports,pkt) :
-        return testutils.genPacketOut(self,xid,buffer_id,in_port,action_ports,pkt)
-    
-    def genFlowModFlush(self) :
+    def simplePacket( self, dl_src ):
+        dl_src = vars( testutils )[ dl_src ]
+        return testutils.simplePacket( dl_src=dl_src )
+
+    def genPacketIn( self, in_port, pkt ):
+        return testutils.genPacketIn( in_port=in_port, pkt=pkt )
+
+    def ofmsgSndCmp( self, snd_list, exp_list, xid_ignore=True, hdr_only=True ):
+        return testutils.ofmsgSndCmp( self, snd_list, exp_list, xid_ignore, hdr_only )
+
+    def setRule( self, sv, rule, num_try ):
+        return testutils.setRule( self, sv, rule, num_try )
+
+    def chkFlowdb( self, controller_number, switch_number, exp_count, exp_rewrites ):
+        return testutils.chkFlowdb( self, controller_number, switch_number, exp_count, exp_rewrites )
+
+    def chkSwitchStats( self, switch_number, ofproto, exp_snd_count, exp_rcv_count ):
+        return testutils.chkSwitchStats( self, switch_number, ofproto, exp_snd_count, exp_rcv_count )
+
+    def chkSliceStats( self, controller_number, ofproto, exp_snd_count, exp_rcv_count ):
+        return testutils.chkSliceStats( self, controller_number, ofproto, exp_snd_count, exp_rcv_count )
+
+    def recvStats( self, swId, typ ):
+        return testutils.recvStats( self, swId, typ )
+
+    def ofmsgSndCmpWithXid( self, snd_list, exp_list, xid_ignore, hdr_only ):
+        return testutils.ofmsgSndCmpWithXid( self, snd_list, exp_list, xid_ignore, hdr_only )
+
+    def genPacketOut( self, xid, buffer_id, in_port, action_ports, pkt ):
+        return testutils.genPacketOut( self, xid, buffer_id, in_port, action_ports, pkt )
+
+    def genFlowModFlush( self ):
         return testutils.genFlowModFlush()
-    
-    def genPhyPort(self,name,addr,port_no) :
-        return testutils.genPhyPort(name,addr,port_no)
-    
-    def disconnect(self,handle):
+
+    def genPhyPort( self, name, addr, port_no ):
+        return testutils.genPhyPort( name, addr, port_no )
+
+    def disconnect( self, handle ):
         response = ''
-        '''
+        """
         if self.handle:
             self.handle = handle
-            response = self.execute(cmd="exit",prompt="(.*)",timeout=120)
+            response = self.execute( cmd="exit",prompt="(.*)",timeout=120 )
         else :
-            main.log.error("Connection failed to the host")
+            main.log.error( "Connection failed to the host" )
             response = main.FALSE
-        '''
-        return response  
-    
-    def setUp(self,basic_logger):
+        """
+        return response
+
+    def setUp( self, basic_logger ):
         self.logger = basic_logger
-        #basic_logger.info("** START TEST CASE " + str(self))
+        # basic_logger.info( "** START TEST CASE " + str( self ) )
         if basic_timeout == 0:
             self.timeout = None
         else:
@@ -174,13 +176,12 @@
         self.sv = None
         self.controllers = []
         self.switches = []
-    
-    def close_log_handles(self) :
-        self.tearDown() 
-        vars(main)[self.name+'log'].removeHandler(self.log_handler)
-        #if self.logfile_handler:
+
+    def close_log_handles( self ):
+        self.tearDown()
+        vars( main )[ self.name + 'log' ].removeHandler( self.log_handler )
+        # if self.logfile_handler:
         #    self.logfile_handler.close()
-        
+
         return main.TRUE
 
-    
diff --git a/TestON/drivers/common/apidriver.py b/TestON/drivers/common/apidriver.py
index 254ab1b..7de283c 100644
--- a/TestON/drivers/common/apidriver.py
+++ b/TestON/drivers/common/apidriver.py
@@ -1,14 +1,14 @@
 #!/usr/bin/env python
-'''
-Created on 22-Nov-2012 
+"""
+Created on 22-Nov-2012
 
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)      
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
 
 
     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
@@ -16,29 +16,37 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
-'''
-
-import struct, fcntl, os, sys, signal
-import sys, re
-sys.path.append("../")
+"""
+import struct
+import fcntl
+import os
+import sys
+import signal
+import sys
+import re
+sys.path.append( "../" )
 
 from drivers.component import Component
-class API(Component):
-    '''
+
+
+class API( Component ):
+
+    """
         This will define common functions for CLI included.
-    '''
-    def __init__(self):
-        super(Component, self).__init__()
-        
-    def connect(self):
-        '''
+    """
+    def __init__( self ):
+        super( Component, self ).__init__()
+
+    def connect( self ):
+        """
            Connection will establish to the remote host using ssh.
            It will take user_name ,ip_address and password as arguments<br>
-           and will return the handle. 
-        '''
-        super(API, self).connect()
-         
-        return main.TRUE       
+           and will return the handle.
+        """
+        super( API, self ).connect()
+
+        return main.TRUE
+
diff --git a/TestON/drivers/common/cli/dpclidriver.py b/TestON/drivers/common/cli/dpclidriver.py
index 1e7015c..057a3f1 100644
--- a/TestON/drivers/common/cli/dpclidriver.py
+++ b/TestON/drivers/common/cli/dpclidriver.py
@@ -1,147 +1,190 @@
-'''
-Driver for blank dataplane VMs. Created for SDNIP test. 
-'''
-
+"""
+Driver for blank dataplane VMs. Created for SDNIP test.
+"""
 import time
 import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
+import sys
+import signal
 import sys
 import re
 import json
-sys.path.append("../")
+sys.path.append( "../" )
 from drivers.common.clidriver import CLI
 
-class DPCliDriver(CLI):
 
-    def __init__(self):
-        super(CLI, self).__init__()
+class DPCliDriver( CLI ):
 
-    def connect(self,**connectargs):
+    def __init__( self ):
+        super( CLI, self ).__init__()
+
+    def connect( self, **connectargs ):
         for key in connectargs:
-           vars(self)[key] = connectargs[key]
+            vars( self )[ key ] = connectargs[ key ]
 
-
-        self.name = self.options['name']
-        self.handle = super(DPCliDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
+        self.name = self.options[ 'name' ]
+        self.handle = super( DPCliDriver, self ).connect( user_name=self.user_name,
+         		ip_address=self.ip_address,
+         		port=self.port,
+         		pwd=self.pwd )
 
         if self.handle:
             return self.handle
-        else :
-            main.log.info("NO HANDLE")
+        else:
+            main.log.info( "NO HANDLE" )
             return main.FALSE
 
-    def create_interfaces(self, net, number, start):
-        '''
+    def create_interfaces( self, net, number, start ):
+        """
         Creates a number,specified by 'number,' of subinterfaces on eth0. Ip addresses start at 'net'.'start'.1.1 with a 24 bit netmask. Addresses increment sequentially in the third quad,
         therefore all interfaces are in different subnets on the same machine. When the third quad reaches 255, it is reset to 1 and the second quad is incremented.
         Every single ip address is placed in a file in /tmp titled 'ip_table{net}.txt'
         The file is used by 'pingall_interfaces()' as a fping argument
         This method returns true if all interfaces are created without a hitch, and false if a single interface has issues
-        '''
+        """
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
 
-        self.handle.sendline("")
-        self.handle.expect("\$")
+        self.handle.sendline( "rm /tmp/local_ip.txt" )
+        self.handle.expect( "\$" )
+        self.handle.sendline( "touch /tmp/local_ip.txt" )
+        self.handle.expect( "\$" )
 
-        self.handle.sendline("rm /tmp/local_ip.txt")
-        self.handle.expect("\$")
-        self.handle.sendline("touch /tmp/local_ip.txt")
-        self.handle.expect("\$")
-
-        main.log.info("Creating interfaces")
+        main.log.info( "Creating interfaces" )
         k = 0
         intf = 0
         while number != 0:
-            k= k + 1
+            k = k + 1
             if k == 256:
                 k = 1
                 start = start + 1
             number = number - 1
             intf = intf + 1
-            ip = net+"."+str(start)+"."+str(k)+".1"
-            self.handle.sendline("sudo ifconfig eth0:"+str(intf)+" "+ip+" netmask 255.255.255.0")
+            ip = net + "." + str( start ) + "." + str( k ) + ".1"
+            self.handle.sendline(
+                "sudo ifconfig eth0:" + str(
+                    intf ) + " " + ip + " netmask 255.255.255.0" )
 
-            i = self.handle.expect(["\$","password",pexpect.TIMEOUT,pexpect.EOF], timeout = 120)
-                if i == 0:
-                    self.handle.sendline("echo "+str(ip)+" >> /tmp/local_ip.txt")
-                    self.handle.expect("\$")
-                elif i == 1:
-                    main.log.info("Sending sudo password")
-                    self.handle.sendline(self.pwd) 
-                    self.handle.expect("\$")
-                else:
-                    main.log.error("INTERFACES NOT CREATED")
-                    return main.FALSE
+            i = self.handle.expect( [
+				    "\$",
+                                    "password",
+                                    pexpect.TIMEOUT,
+                                    pexpect.EOF ],
+                		    timeout=120 )
 
+            if i == 0:
+                self.handle.sendline(
+                    "echo " + str( ip ) + " >> /tmp/local_ip.txt" )
+                self.handle.expect( "\$" )
+            elif i == 1:
+                main.log.info( "Sending sudo password" )
+                self.handle.sendline( self.pwd )
+                self.handle.expect( "\$" )
+            else:
+                main.log.error( "INTERFACES NOT CREATED" )
+                return main.FALSE
 
-    def pingall_interfaces(self, netsrc, netstrt, netdst, destlogin, destip):
-        '''
-        Copies the /tmp/ip_table{net}.txt file from the machine you wish to ping, then runs fping with a source address of {netsrc}.{netstrt}.1.1 on the copied file.
+    def pingall_interfaces( self, netsrc, netstrt, netdst, destlogin, destip ):
+        """
+        Copies the /tmp/ip_table{ net }.txt file from the machine you wish to ping, then runs fping with a source address of { netsrc }.{ netstrt }.1.1 on the copied file.
         Check every single response for reachable or unreachable. If all are reachable, function returns true. If a SINGLE host is unreachable, then the function stops and returns false
         If fping is not installed, this function will install fping then run the same command
-        '''
+        """
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
 
-        self.handle.sendline("")
-        self.handle.expect("\$")
-      
-        self.handle.sendline("scp "+str(destlogin)+"@"+str(destip)+":/tmp/local_ip.txt /tmp/ip_table"+str(net)+".txt")
-        i = self.handle.expect(["100%","password",pexpect.TIMEOUT], timeout = 30)
+        self.handle.sendline( "scp " + str( destlogin ) + "@" + 
+			      str( destip ) + ":/tmp/local_ip.txt /tmp/ip_table" +
+			      str( net ) + ".txt" )
+        
+	i = self.handle.expect( [
+				"100%",
+                                "password",
+                                pexpect.TIMEOUT ],
+		                timeout=30 )
+
         if i == 0:
-            main.log.info("Copied ping file successfully")
+            main.log.info( "Copied ping file successfully" )
         elif i == 1:
-            self.handle.sendline(self.pwd)
-            self.handle.expect("100%")
-            main.log.info("Copied ping file successfully")
+            self.handle.sendline( self.pwd )
+            self.handle.expect( "100%" )
+            main.log.info( "Copied ping file successfully" )
         elif i == 2:
-            main.log.error("COULD NOT COPY PING FILE FROM "+str(destip))
+            main.log.error( "COULD NOT COPY PING FILE FROM " + str( destip ) )
             result = main.FALSE
             return result
-       
-        self.handle.sendline("")
-        self.handle.expect("\$")
 
-        main.log.info("Pinging interfaces on the "+str(netdst)+" network from "+str(netsrc)+"."+str(netstrt)+".1.1") 
-        self.handle.sendline("sudo fping -S "+str(netsrc)+"."+str(netstrt)+".1.1 -f /tmp/ip_table"+str(netdst)+".txt")
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
+
+        main.log.info( "Pinging interfaces on the " + str( netdst ) +
+		       " network from " + str( netsrc ) + "." + 
+		       str( netstrt ) + ".1.1" )
+        self.handle.sendline( "sudo fping -S " + str( netsrc ) + "." +
+			      str( netstrt ) + ".1.1 -f /tmp/ip_table" + 
+			      str( netdst ) + ".txt" )
         while 1:
-            i = self.handle.expect(["reachable","unreachable","\$","password",pexpect.TIMEOUT,"not installed"], timeout=45)
+            i = self.handle.expect( [
+				    "reachable",
+                                    "unreachable",
+                                    "\$",
+                                    "password",
+                                    pexpect.TIMEOUT,
+                                    "not installed" ],
+				    timeout=45 )
             if i == 0:
                 result = main.TRUE
             elif i == 1:
-                main.log.error("An interface was unreachable")
+                main.log.error( "An interface was unreachable" )
                 result = main.FALSE
                 return result
             elif i == 2:
-                main.log.info("All interfaces reachable")
+                main.log.info( "All interfaces reachable" )
                 return result
             elif i == 3:
-                self.handle.sendline(self.pwd)
+                self.handle.sendline( self.pwd )
             elif i == 4:
-                main.log.error("Unable to fping")
+                main.log.error( "Unable to fping" )
                 result = main.FALSE
                 return result
             elif i == 5:
-                main.log.info("fping not installed, installing fping")
-                self.handle.sendline("sudo apt-get install fping")
-                i = self.handle.expect(["password","\$",pexpect.TIMEOUT], timeout = 60)
+                main.log.info( "fping not installed, installing fping" )
+                self.handle.sendline( "sudo apt-get install fping" )
+                i = self.handle.expect(
+                    [ "password",
+                                      "\$",
+                                      pexpect.TIMEOUT ],
+                    timeout=60 )
                 if i == 0:
-                    self.handle.sendline(self.pwd)
-                    self.handle.expect("\$", timeout = 30)
-                    main.log.info("fping installed, now pinging interfaces")
-                    self.handle.sendline("sudo fping -S "+str(netsrc)+"."+str(netstrt)+".1.1 -f /tmp/ip_table"+str(netdst)+".txt")
+                    self.handle.sendline( self.pwd )
+                    self.handle.expect( "\$", timeout=30 )
+                    main.log.info( "fping installed, now pinging interfaces" )
+                    self.handle.sendline(
+                        "sudo fping -S " + str(
+                            netsrc ) + "." + str(
+                                netstrt ) + ".1.1 -f /tmp/ip_table" + str(
+                                    netdst ) + ".txt" )
                 elif i == 1:
-                    main.log.info("fping installed, now pinging interfaces")
-                    self.handle.sendline("sudo fping -S "+str(netsrc)+"."+str(netstrt)+".1.1 -f /tmp/ip_table"+str(netdst)+".txt")
+                    main.log.info( "fping installed, now pinging interfaces" )
+                    self.handle.sendline(
+                        "sudo fping -S " + str(
+                            netsrc ) + "." + str(
+                                netstrt ) + ".1.1 -f /tmp/ip_table" + str(
+                                    netdst ) + ".txt" )
                 elif i == 2:
-                    main.log.error("Could not install fping")
+                    main.log.error( "Could not install fping" )
                     result = main.FALSE
                     return result
 
-    def disconnect(self):
+    def disconnect( self ):
         response = ''
         try:
-            self.handle.sendline("exit")
-            self.handle.expect("closed")
+            self.handle.sendline( "exit" )
+            self.handle.expect( "closed" )
         except:
-            main.log.error("Connection failed to the host")
+            main.log.error( "Connection failed to the host" )
             response = main.FALSE
         return response
 
diff --git a/TestON/drivers/common/cli/emulator/flowvisordriver.py b/TestON/drivers/common/cli/emulator/flowvisordriver.py
index 66946bd..d0e6ea5 100644
--- a/TestON/drivers/common/cli/emulator/flowvisordriver.py
+++ b/TestON/drivers/common/cli/emulator/flowvisordriver.py
@@ -1,14 +1,14 @@
 #!/usr/bin/env python
-'''
+"""
 Created on 26-Mar-2013
 
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
 
 
     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
@@ -16,12 +16,11 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
 FlowVisorDriver is the basic driver which will handle the Mininet functions
-'''
-
+"""
 import pexpect
 import struct
 import fcntl
@@ -30,150 +29,197 @@
 import re
 import sys
 import core.teston
-sys.path.append("../")
+sys.path.append( "../" )
 from drivers.common.cli.emulatordriver import Emulator
 from drivers.common.clidriver import CLI
 
-class FlowVisorDriver(Emulator):
-    '''
-        FlowVisorDriver is the basic driver which will handle the Mininet functions
-    '''
-    def __init__(self):
-        super(Emulator, self).__init__()
-        self.handle = self
-        self.wrapped = sys.modules[__name__]
 
-    def connect(self, **connectargs):
-        #,user_name, ip_address, pwd,options):
-        # Here the main is the TestON instance after creating all the log handles.
+class FlowVisorDriver( Emulator ):
+
+    """
+        FlowVisorDriver is the basic driver which will handle the Mininet functions
+    """
+    def __init__( self ):
+        super( Emulator, self ).__init__()
+        self.handle = self
+        self.wrapped = sys.modules[ __name__ ]
+
+    def connect( self, **connectargs ):
+        #,user_name, ip_address, pwd,options ):
+        # Here the main is the TestON instance after creating all the log
+        # handles.
         for key in connectargs:
-            vars(self)[key] = connectargs[key]       
-        
-        self.name = self.options['name']
-        self.handle = super(FlowVisorDriver, self).connect(user_name = self.user_name, ip_address = self.ip_address,port = None, pwd = self.pwd)
-        
+            vars( self )[ key ] = connectargs[ key ]
+
+        self.name = self.options[ 'name' ]
+        self.handle = super(
+            FlowVisorDriver,
+            self ).connect(
+            user_name=self.user_name,
+            ip_address=self.ip_address,
+            port=None,
+            pwd=self.pwd )
+
         self.ssh_handle = self.handle
-        
-        # Copying the readme file to process the 
-        if self.handle :
-            self.execute(cmd='\r',prompt='\$',timeout=10)
-            self.options['path'] = '/home/openflow/flowvisor/scripts/'
+
+        # Copying the readme file to process the
+        if self.handle:
+            self.execute( cmd='\r', prompt='\$', timeout=10 )
+            self.options[ 'path' ] = '/home/openflow/flowvisor/scripts/'
             #self.handle.logfile = sys.stdout
-            self.execute(cmd='cd '+self.options['path'],prompt='\$',timeout=10)
-            main.log.info("Starting FlowVisor ")
-            
-            response = self.execute(cmd='./flowvisor.sh &',prompt='---\sSetting\slogging\slevel\sto\sNOTE',timeout=10)
-           
+            self.execute(
+                cmd='cd ' +
+                self.options[ 'path' ],
+                prompt='\$',
+                timeout=10 )
+            main.log.info( "Starting FlowVisor " )
+
+            response = self.execute(
+                cmd='./flowvisor.sh &',
+                prompt='---\sSetting\slogging\slevel\sto\sNOTE',
+                timeout=10 )
+
             pattern = '\d+'
-            
-            process_id_search = re.search("\[\d+\]\s+(\d+)", str(response))
+
+            process_id_search = re.search( "\[\d+\]\s+(\d+)", str( response ) )
             self.fvprocess_id = "None"
             if process_id_search:
-                self.fvprocess_id = process_id_search.group(1)
-            
-            utilities.assert_matches(expect=pattern,actual=response,onpass="FlowVisor Started Successfully : Proceess Id :"+self.fvprocess_id,onfail="Failed to start FlowVisor")
-            main.log.info(response)
+                self.fvprocess_id = process_id_search.group( 1 )
+
+            utilities.assert_matches(
+                expect=pattern,
+                actual=response,
+                onpass="FlowVisor Started Successfully : Proceess Id :" +
+                self.fvprocess_id,
+                onfail="Failed to start FlowVisor" )
+            main.log.info( response )
             #import time
-            #time.sleep(10)
-            #response = self.execute(cmd='./start_visualizer.sh & \r',prompt='\$',timeout=10)
-            
+            # time.sleep( 10 )
+            #response = self.execute( cmd='./start_visualizer.sh & \r',prompt='\$',timeout=10 )
+
             return main.TRUE
-        else :
-            main.log.error("Connection failed to the host "+self.user_name+"@"+self.ip_address) 
-            main.log.error("Failed to connect to the FlowVisor")
+        else:
+            main.log.error(
+                "Connection failed to the host " +
+                self.user_name +
+                "@" +
+                self.ip_address )
+            main.log.error( "Failed to connect to the FlowVisor" )
             return main.FALSE
-    def removeFlowSpace(self,id):
+
+    def removeFlowSpace( self, id ):
         if id == "all":
             flow_space = self.listFlowSpace()
-            flow_ids = re.findall("\,id=\[(\d+)\]", flow_space)
-            for id in flow_ids :
-                self.removeFlowSpace(id)
-        else :
-            self.execute(cmd="clear",prompt="\$",timeout=10)
-            self.execute(cmd="./fvctl.sh removeFlowSpace "+id,prompt="passwd:",timeout=10)
-            self.execute(cmd="\n",prompt="\$",timeout=10)
-            main.log.info("Removed flowSpace which is having id :"+id)
-            
+            flow_ids = re.findall( "\,id=\[(\d+)\]", flow_space )
+            for id in flow_ids:
+                self.removeFlowSpace( id )
+        else:
+            self.execute( cmd="clear", prompt="\$", timeout=10 )
+            self.execute(
+                cmd="./fvctl.sh removeFlowSpace " +
+                id,
+                prompt="passwd:",
+                timeout=10 )
+            self.execute( cmd="\n", prompt="\$", timeout=10 )
+            main.log.info( "Removed flowSpace which is having id :" + id )
+
         return main.TRUE
-        
-    def addFlowSpace(self,**flowspace_args):
+
+    def addFlowSpace( self, **flowspace_args ):
         temp_string = None
         for key in flowspace_args:
-            if temp_string :
-                temp_string = temp_string +','+ key+'='+flowspace_args[key]
-            else :
+            if temp_string:
+                temp_string = temp_string + ',' + \
+                    key + '=' + flowspace_args[ key ]
+            else:
                 temp_string = ''
-                temp_string = temp_string + key+'='+flowspace_args[key]
-        
-        src_search = re.search('dl_src', temp_string)
-        if src_search :
-            flowspace = "any 100 dl_type=0x806,nw_proto=6,"+temp_string +" Slice:SSH=4"
-        else :
-            flowspace = "any 100 dl_type=0x800,nw_proto=6,"+temp_string +" Slice:SSH=4"
-            
-        '''
+                temp_string = temp_string + key + '=' + flowspace_args[ key ]
+
+        src_search = re.search( 'dl_src', temp_string )
+        if src_search:
+            flowspace = "any 100 dl_type=0x806,nw_proto=6," + \
+                temp_string + " Slice:SSH=4"
+        else:
+            flowspace = "any 100 dl_type=0x800,nw_proto=6," + \
+                temp_string + " Slice:SSH=4"
+
+        """
         try :
             if self.dl_src and self.nw_dst:
                 flowspace = "any 100 dl_type=0x806,dl_src="+self.dl_src+",nw_dst="+self.nw_dst+" Slice:"+self.Slice+"=4"
         except :
             try :
                 if self.nw_src and self.tp_dst:
-                    flowspace = "any 100 dl_type=0x800,nw_proto=6,nw_src="+self.nw_src+",tp_dst="+self.tp_dst+" Slice:"+self.Slice+"=4"         
+                    flowspace = "any 100 dl_type=0x800,nw_proto=6,nw_src="+self.nw_src+",tp_dst="+self.tp_dst+" Slice:"+self.Slice+"=4"
             except :
                 try :
                     if self.nw_src and self.tp_src:
                         flowspace = "any 100 dl_type=0x800,nw_proto=6,nw_src="+self.nw_src+",tp_src="+self.tp_dst+" Slice:"+self.Slice+"=4"
                 except :
-                    main.log.error("Please specify flowspace properly")
-        '''    
-
-        #self.execute(cmd="clear",prompt="\$",timeout=10)
-        self.execute(cmd="./fvctl.sh addFlowSpace "+flowspace,prompt="passwd:",timeout=10)
-        self.execute(cmd="\n",prompt="\$",timeout=10)
-        sucess_match = re.search("success\:\s+(\d+)", main.last_response)
-        if sucess_match :
-            main.log.info("Added flow Space and id is "+sucess_match.group(1))
+                    main.log.error( "Please specify flowspace properly" )
+        """
+        # self.execute( cmd="clear",prompt="\$",timeout=10 )
+        self.execute(
+            cmd="./fvctl.sh addFlowSpace " +
+            flowspace,
+            prompt="passwd:",
+            timeout=10 )
+        self.execute( cmd="\n", prompt="\$", timeout=10 )
+        sucess_match = re.search( "success\:\s+(\d+)", main.last_response )
+        if sucess_match:
+            main.log.info(
+                "Added flow Space and id is " +
+                sucess_match.group( 1 ) )
             return main.TRUE
-        else :
+        else:
             return main.FALSE
-        
-    
-    
-    def listFlowSpace(self):
-        self.execute(cmd="clear",prompt="\$",timeout=10)
-        self.execute(cmd="./fvctl.sh listFlowSpace ",prompt="passwd:",timeout=10)
-        self.execute(cmd="\n",prompt="\$",timeout=10)
+
+    def listFlowSpace( self ):
+        self.execute( cmd="clear", prompt="\$", timeout=10 )
+        self.execute(
+            cmd="./fvctl.sh listFlowSpace ",
+            prompt="passwd:",
+            timeout=10 )
+        self.execute( cmd="\n", prompt="\$", timeout=10 )
         flow_space = main.last_response
-        flow_space = self.remove_contol_chars( flow_space)
-        flow_space = re.sub("rule\s(\d+)\:", "\nrule "+r'\1'+":",flow_space)
-        main.log.info(flow_space)
-        
+        flow_space = self.remove_contol_chars( flow_space )
+        flow_space = re.sub(
+            "rule\s(\d+)\:",
+            "\nrule " +
+            r'\1' +
+            ":",
+            flow_space )
+        main.log.info( flow_space )
+
         return flow_space
-        
-    def listDevices(self):
-        #self.execute(cmd="clear",prompt="\$",timeout=10)
-        #self.execute(cmd="./fvctl.sh listDevices ",prompt="passwd:",timeout=10)
-        #self.execute(cmd="\n",prompt="\$",timeout=10)
+
+    def listDevices( self ):
+        # self.execute( cmd="clear",prompt="\$",timeout=10 )
+        #self.execute( cmd="./fvctl.sh listDevices ",prompt="passwd:",timeout=10 )
+        # self.execute( cmd="\n",prompt="\$",timeout=10 )
         devices_list = ''
-        last_response = re.findall("(Device\s\d+\:\s((\d|[a-z])(\d|[a-z])\:)+(\d|[a-z])(\d|[a-z]))", main.last_response)
-        
-        for resp in last_response :
-            devices_match = re.search("(Device\s\d+\:\s((\d|[a-z])(\d|[a-z])\:)+(\d|[a-z])(\d|[a-z]))", str(resp))
+        last_response = re.findall(
+            "(Device\s\d+\:\s((\d|[a-z])(\d|[a-z])\:)+(\d|[a-z])(\d|[a-z]))",
+            main.last_response )
+
+        for resp in last_response:
+            devices_match = re.search(
+                "(Device\s\d+\:\s((\d|[a-z])(\d|[a-z])\:)+(\d|[a-z])(\d|[a-z]))",
+                str( resp ) )
             if devices_match:
-                devices_list = devices_list+devices_match.group(0)+"\n"
+                devices_list = devices_list + devices_match.group( 0 ) + "\n"
         devices_list = "Device 0: 00:00:00:00:00:00:00:02 \n Device 1: 00:00:00:00:00:00:00:03"
-        main.log.info("List of Devices \n"+devices_list)
-        
+        main.log.info( "List of Devices \n" + devices_list )
+
         return main.TRUE
-    
- 
-    def disconnect(self):
-        
+
+    def disconnect( self ):
+
         response = ''
-        main.log.info("Stopping the FlowVisor")
+        main.log.info( "Stopping the FlowVisor" )
         if self.handle:
-            self.handle.sendline("kill -9 "+str(self.fvprocess_id))
-        else :
-            main.log.error("Connection failed to the host")
+            self.handle.sendline( "kill -9 " + str( self.fvprocess_id ) )
+        else:
+            main.log.error( "Connection failed to the host" )
             response = main.FALSE
-        return response 
+        return response
diff --git a/TestON/drivers/common/cli/emulator/lincoedriver.py b/TestON/drivers/common/cli/emulator/lincoedriver.py
index 2cb7c98..944eded 100644
--- a/TestON/drivers/common/cli/emulator/lincoedriver.py
+++ b/TestON/drivers/common/cli/emulator/lincoedriver.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-'''
+"""
 This driver handles the optical switch emulator linc-oe.
 
 Please follow the coding style demonstrated by existing
@@ -13,8 +13,7 @@
     shreya@onlab.us
 
 OCT 20 2014
-'''
-
+"""
 import traceback
 import pexpect
 import struct
@@ -25,117 +24,122 @@
 import sys
 import core.teston
 import time
-sys.path.append("../")
+sys.path.append( "../" )
 from math import pow
 from drivers.common.cli.emulatordriver import Emulator
 from drivers.common.clidriver import CLI
 
-class LincOEDriver(Emulator):
-    '''
-    LincOEDriver class will handle all emulator functions    
-    '''
-    def __init__(self):
-        super(Emulator, self).__init__()
+
+class LincOEDriver( Emulator ):
+
+    """
+    LincOEDriver class will handle all emulator functions
+    """
+    def __init__( self ):
+        super( Emulator, self ).__init__()
         self.handle = self
-        self.wrapped = sys.modules[__name__]
+        self.wrapped = sys.modules[ __name__ ]
         self.flag = 0
 
-    def connect(self, **connectargs):
-        '''
+    def connect( self, **connectargs ):
+        """
         Create ssh handle for Linc-OE cli
-        '''
+        """
         import time
 
         for key in connectargs:
-            vars(self)[key] = connectargs[key]       
-        
-        self.name = self.options['name']
+            vars( self )[ key ] = connectargs[ key ]
+
+        self.name = self.options[ 'name' ]
         self.handle = \
-                super(LincOEDriver, self).connect(\
-                user_name = self.user_name,
-                ip_address = self.ip_address,
-                port = None, 
-                pwd = self.pwd)
-        
+            super( LincOEDriver, self ).connect(
+                user_name=self.user_name,
+                ip_address=self.ip_address,
+                port=None,
+                pwd=self.pwd )
+
         self.ssh_handle = self.handle
-        
-        if self.handle :
-            main.log.info("Handle successfully created")
+
+        if self.handle:
+            main.log.info( "Handle successfully created" )
             self.home = "~/linc-oe"
-         
-            self.handle.sendline("cd "+self.home)
-            self.handle.expect("oe$")
-          
-            #self.handle.sendline("pgrep -g linc")
-            #self.handle.expect("\$")
-            print "handle = ", self.handle.before            
-            
-            return main.TRUE 
-            ''' 
-            main.log.info("Building Linc-OE")
-            self.handle.sendline("make rel")
-            i = self.handle.expect(["ERROR","linc-oe\$"],timeout=60)
+
+            self.handle.sendline( "cd " + self.home )
+            self.handle.expect( "oe$" )
+
+            #self.handle.sendline( "pgrep -g linc" )
+            # self.handle.expect( "\$" )
+            print "handle = ", self.handle.before
+
+            return main.TRUE
+            """
+            main.log.info( "Building Linc-OE" )
+            self.handle.sendline( "make rel" )
+            i = self.handle.expect( [ "ERROR","linc-oe\$" ],timeout=60 )
             if i == 0:
-                self.handle.sendline("sudo pkill -9 epmd")
-                self.handle.expect("\$")
-                self.handle.sendline("make rel")
-                x = self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
-                main.log.info("make rel returned: "+ str(x))
-            else: 
-            
-            main.log.info(self.name+": Starting Linc-OE CLI.. This may take a while")
-            time.sleep(30)
-            self.handle.sendline("sudo ./rel/linc/bin/linc console")
-            j = self.handle.expect(["linc@",pexpect.EOF,pexpect.TIMEOUT])
+                self.handle.sendline( "sudo pkill -9 epmd" )
+                self.handle.expect( "\$" )
+                self.handle.sendline( "make rel" )
+                x = self.handle.expect( [ "\$",pexpect.EOF,pexpect.TIMEOUT ] )
+                main.log.info( "make rel returned: "+ str( x ) )
+            else:
+
+            main.log.info( self.name+": Starting Linc-OE CLI.. This may take a while" )
+            time.sleep( 30 )
+            self.handle.sendline( "sudo ./rel/linc/bin/linc console" )
+            j = self.handle.expect( [ "linc@",pexpect.EOF,pexpect.TIMEOUT ] )
             if j == 0:
-                main.log.info("Linc-OE CLI started")
+                main.log.info( "Linc-OE CLI started" )
                 return main.TRUE
-            '''
+            """
         else:
-            main.log.error(self.name+
-                    ": Connection failed to the host "+
-                    self.user_name+"@"+self.ip_address) 
-            main.log.error(self.name+
-                    ": Failed to connect to Linc-OE")
+            main.log.error( self.name +
+                            ": Connection failed to the host " +
+                            self.user_name + "@" + self.ip_address )
+            main.log.error( self.name +
+                            ": Failed to connect to Linc-OE" )
             return main.FALSE
 
-
-    def start_console(self):
+    def start_console( self ):
         import time
-        main.log.info(self.name+": Starting Linc-OE CLI.. This may take a while")
-        time.sleep(30)
-        self.handle.sendline("sudo ./rel/linc/bin/linc console")
-        j = self.handle.expect(["linc@",pexpect.EOF,pexpect.TIMEOUT])
+        main.log.info(
+            self.name +
+            ": Starting Linc-OE CLI.. This may take a while" )
+        time.sleep( 30 )
+        self.handle.sendline( "sudo ./rel/linc/bin/linc console" )
+        j = self.handle.expect( [ "linc@", pexpect.EOF, pexpect.TIMEOUT ] )
         start_result = self.handle.before
         if j == 0:
-            main.log.info("Linc-OE CLI started")
+            main.log.info( "Linc-OE CLI started" )
             return main.TRUE
         else:
-            main.log.error(self.name+
-            ": Connection failed to the host "+self.user_name+"@"+self.ip_address)
-            main.log.error(self.name+
-            ": Failed to connect to Linc-OE")
+            main.log.error(
+                self.name +
+                ": Connection failed to the host " +
+                self.user_name +
+                "@" +
+                self.ip_address )
+            main.log.error( self.name +
+                            ": Failed to connect to Linc-OE" )
             return main.FALSE
 
-
-
-    def build(self):
-        '''
+    def build( self ):
+        """
         Build Linc-OE with the specified settings
-        '''
+        """
         try:
-            self.handle.sendline("make rel")
-            i = self.handle.expect([
+            self.handle.sendline( "make rel" )
+            i = self.handle.expect( [
                 "ERROR",
-                "\$"])
+                "\$" ] )
 
             if i == 0:
-                #If error, try to resolve the most common error
-                #(epmd running and cannot compile)
-                self.handle.sendline("sudo pkill -9 epmd")
-                self.handle.sendline("make rel")
-                self.handle.expect("\$")
-                    
+                # If error, try to resolve the most common error
+                #( epmd running and cannot compile )
+                self.handle.sendline( "sudo pkill -9 epmd" )
+                self.handle.sendline( "make rel" )
+                self.handle.expect( "\$" )
+
                 handle = self.handle.before
                 return handle
 
@@ -143,226 +147,225 @@
                 return main.TRUE
 
         except pexpect.EOF:
-            main.log.error(self.name+ ": EOF exception")
-            main.log.error(self.name+ ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" :::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" :::::::")
+            main.log.info( self.name + " :::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " :::::::" )
             main.cleanup()
             main.exit()
 
-    def set_interface_up(self, intfs):
-        '''
+    def set_interface_up( self, intfs ):
+        """
         Specify interface to bring up.
         When Linc-OE is started, tap interfaces should
         be created. They must be brought up manually
-        '''
+        """
         try:
-            self.handle.sendline("ifconfig "+str(intfs)+" up")
-            self.handle.expect("linc@")
-   
+            self.handle.sendline( "ifconfig " + str( intfs ) + " up" )
+            self.handle.expect( "linc@" )
+
             handle = self.handle.before
 
             return handle
 
         except pexpect.EOF:
-            main.log.error(self.name+ ": EOF exception")
-            main.log.error(self.name+ ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" :::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" :::::::")
+            main.log.info( self.name + " :::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " :::::::" )
             main.cleanup()
             main.exit()
 
-    def start_switch(self, sw_id):
-        '''
+    def start_switch( self, sw_id ):
+        """
         Start a logical switch using switch id
-        '''
+        """
         try:
-            self.handle.sendline("linc:start_switch("+str(sw_id)+").")
-            self.handle.expect("linc@")
+            self.handle.sendline( "linc:start_switch(" + str( sw_id ) + ")." )
+            self.handle.expect( "linc@" )
 
             handle = self.handle.before
 
         except pexpect.EOF:
-            main.log.error(self.name+ ": EOF exception")
-            main.log.error(self.name+ ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" :::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" :::::::")
+            main.log.info( self.name + " :::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " :::::::" )
             main.cleanup()
             main.exit()
 
-    def stop_switch(self, sw_id):
-        '''
+    def stop_switch( self, sw_id ):
+        """
         Stop a logical switch using switch id
-        '''
+        """
         try:
-            self.handle.sendline("linc:stop_switch("+str(sw_id)+").")
-            self.handle.expect("linc@")
+            self.handle.sendline( "linc:stop_switch(" + str( sw_id ) + ")." )
+            self.handle.expect( "linc@" )
 
             handle = self.handle.before
 
         except pexpect.EOF:
-            main.log.error(self.name+ ": EOF exception")
-            main.log.error(self.name+ ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" :::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" :::::::")
+            main.log.info( self.name + " :::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " :::::::" )
             main.cleanup()
             main.exit()
-     
-    def get_datapath_id(self, sw_id):
-        '''
+
+    def get_datapath_id( self, sw_id ):
+        """
         Get datapath id of a specific switch by switch id
-        '''
+        """
         try:
-            self.handle.sendline("linc_logic:get_datapath_id("+
-                    str(sw_id)+").")
-            self.handle.expect("linc@")
+            self.handle.sendline( "linc_logic:get_datapath_id(" +
+                                  str( sw_id ) + ")." )
+            self.handle.expect( "linc@" )
 
             handle = self.handle.before
-        
+
         except pexpect.EOF:
-            main.log.error(self.name+ ": EOF exception")
-            main.log.error(self.name+ ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" :::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" :::::::")
+            main.log.info( self.name + " :::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " :::::::" )
             main.cleanup()
             main.exit()
 
-    def list_ports(self, sw_id):
-        '''
+    def list_ports( self, sw_id ):
+        """
         List all ports of a switch by switch id
-        '''
+        """
         try:
-            self.handle.sendline("linc:ports("+str(sw_id)+").")
-            self.handle.expect("linc@")
+            self.handle.sendline( "linc:ports(" + str( sw_id ) + ")." )
+            self.handle.expect( "linc@" )
 
             handle = self.handle.before
 
         except pexpect.EOF:
-            main.log.error(self.name+ ": EOF exception")
-            main.log.error(self.name+ ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" :::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" :::::::")
+            main.log.info( self.name + " :::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " :::::::" )
             main.cleanup()
             main.exit()
 
-    def port_up(self, sw_id, pt_id):
-        '''
+    def port_up( self, sw_id, pt_id ):
+        """
         Bring port up using switch id and port id
-        '''
+        """
         try:
-            self.handle.sendline("linc:port_up("+
-                    str(sw_id)+", "+str(pt_id)+").")
-            self.handle.expect("linc@")
+            self.handle.sendline( "linc:port_up(" +
+                                  str( sw_id ) + ", " + str( pt_id ) + ")." )
+            self.handle.expect( "linc@" )
 
             handle = self.handle.before
 
         except pexpect.EOF:
-            main.log.error(self.name+ ": EOF exception")
-            main.log.error(self.name+ ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" :::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" :::::::")
+            main.log.info( self.name + " :::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " :::::::" )
             main.cleanup()
             main.exit()
-    
-    def port_down(self, sw_id, pt_id):
-        '''
+
+    def port_down( self, sw_id, pt_id ):
+        """
         Bring port down using switch id and port id
-        '''
+        """
         try:
-            self.handle.sendline("linc:port_down("+
-                    str(sw_id)+", "+str(pt_id)+").")
-            self.handle.expect("linc@")
+            self.handle.sendline( "linc:port_down(" +
+                                  str( sw_id ) + ", " + str( pt_id ) + ")." )
+            self.handle.expect( "linc@" )
 
             handle = self.handle.before
 
         except pexpect.EOF:
-            main.log.error(self.name+ ": EOF exception")
-            main.log.error(self.name+ ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" :::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" :::::::")
+            main.log.info( self.name + " :::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " :::::::" )
             main.cleanup()
             main.exit()
-    
-    def stopLincOEConsole(self):
-        '''
+
+    def stopLincOEConsole( self ):
+        """
         This function is only used for packet optical testing
         Send disconnect prompt to Linc-OE CLI
-        (CTRL+C) and kill the linc process
-        '''
+        ( CTRL+C ) and kill the linc process
+        """
         try:
             cmd = "pgrep -f linc"
-            self.handle.sendline("pgrep -f linc")
-            self.handle.expect("linc") 
+            self.handle.sendline( "pgrep -f linc" )
+            self.handle.expect( "linc" )
             print "stophandle = ", self.handle.before
         except pexpect.EOF:
-            main.log.error(self.name+ ": EOF exception")
-            main.log.error(self.name+ ":    " + self.handle.before) 
+            main.log.error( self.name + ": EOF exception" )
+            main.log.error( self.name + ":    " + self.handle.before )
 
-    def disconnect(self):
-        '''
+    def disconnect( self ):
+        """
         Send disconnect prompt to Linc-OE CLI
-        (CTRL+C) and kill the linc process
-        '''
+        ( CTRL+C ) and kill the linc process
+        """
         try:
-            #Send CTRL+C twice to exit CLI
-            self.handle.send("\x03")
-            self.handle.send("\x03")
-            self.handle.expect("\$")
+            # Send CTRL+C twice to exit CLI
+            self.handle.send( "\x03" )
+            self.handle.send( "\x03" )
+            self.handle.expect( "\$" )
             handle1 = self.handle.before
             cmd = "pgrep -f linc"
-            self.handle.sendline(cmd)
-            self.handle.expect("\$")
+            self.handle.sendline( cmd )
+            self.handle.expect( "\$" )
             handle2 = self.handle.before
-            main.log.info("pid's = "+handle2)
+            main.log.info( "pid's = " + handle2 )
             cmd = "sudo kill -9 `pgrep -f linc`"
-            self.handle.sendline(cmd)
-            self.handle.expect("\$")
-            
+            self.handle.sendline( cmd )
+            self.handle.expect( "\$" )
+
         except pexpect.EOF:
-            main.log.error(self.name+ ": EOF exception")
-            main.log.error(self.name+ ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" :::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" :::::::")
+            main.log.info( self.name + " :::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " :::::::" )
             main.cleanup()
             main.exit()
 
 if __name__ != "__main__":
     import sys
-    sys.modules[__name__] = LincOEDriver()
-
+    sys.modules[ __name__ ] = LincOEDriver()
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 10e46a7..d82a58e 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -103,10 +103,10 @@
             main.log.info( self.name + ": building fresh mininet" )
             # for reactive/PARP enabled tests
             cmdString = "sudo mn " + self.options[ 'arg1' ] +\
-                    " " + self.options[ 'arg2' ] +\
-                    " --mac --controller " +\
-                    self.options[ 'controller' ] + " " +\
-                    self.options[ 'arg3' ]
+                " " + self.options[ 'arg2' ] +\
+                " --mac --controller " +\
+                self.options[ 'controller' ] + " " +\
+                self.options[ 'arg3' ]
 
             argList = self.options[ 'arg1' ].split( "," )
             global topoArgList
@@ -185,7 +185,7 @@
             total_num_hosts = num_switches * num_hosts_per_sw
             num_links = total_num_hosts + ( num_switches - 1 )
             print "num_switches for %s(%d,%d) = %d and links=%d" %\
-                    ( topoType, depth, fanout, num_switches, num_links )
+                ( topoType, depth, fanout, num_switches, num_links )
         topoDict = {}
         topoDict = {
             "num_switches": int( num_switches ),
@@ -227,7 +227,7 @@
             # NOTE: mininet's pingall rounds, so we will check the number of
             # passed and number of failed
             pattern = "Results\:\s0\%\sdropped\s\(" +\
-                    "(?P<passed>[\d]+)/(?P=passed)"
+                "(?P<passed>[\d]+)/(?P=passed)"
             if re.search( pattern, response ):
                 main.log.info( self.name + ": All hosts are reachable" )
                 return main.TRUE
@@ -323,11 +323,11 @@
                 main.exit()
 
             pattern = "inet\s(addr|Mask):([0-1]{1}[0-9]{1,2}|" +\
-                    "2[0-4][0-9]|25[0-5]|[0-9]{1,2}).([0-1]{1}" +\
-                    "[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2})." +\
-                    "([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|" +\
-                    "[0-9]{1,2}).([0-1]{1}[0-9]{1,2}|2[0-4]" +\
-                    "[0-9]|25[0-5]|[0-9]{1,2})"
+                "2[0-4][0-9]|25[0-5]|[0-9]{1,2}).([0-1]{1}" +\
+                "[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2})." +\
+                "([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|" +\
+                "[0-9]{1,2}).([0-1]{1}[0-9]{1,2}|2[0-4]" +\
+                "[0-9]|25[0-5]|[0-9]{1,2})"
             # pattern = "inet addr:10.0.0.6"
             if re.search( pattern, response ):
                 main.log.info( self.name + ": Host Ip configured properly" )
@@ -588,7 +588,7 @@
            return information dict about interfaces connected to the node"""
         if self.handle:
             cmd = 'py "\\n".join(["name=%s,mac=%s,ip=%s,enabled=%s"' +\
-                    ' % (i.name, i.MAC(), i.IP(), i.isUp())'
+                ' % (i.name, i.MAC(), i.IP(), i.isUp())'
             cmd += ' for i in %s.intfs.values()])' % node
             try:
                 response = self.execute(
@@ -851,7 +851,7 @@
 
         sw = args[ "SW" ] if args[ "SW" ] is not None else ""
         ptcpA = int( args[ "PORT1" ] ) + \
-                    int( sw ) if args[ "PORT1" ] is not None else ""
+            int( sw ) if args[ "PORT1" ] is not None else ""
         ptcpB = "ptcp:" + str( ptcpA ) if ptcpA != "" else ""
 
         command = "sh ovs-vsctl set-controller s" + \
@@ -871,7 +871,7 @@
                 "PORT" +
                 str( i ) ] is not None else ""
             tcp = "tcp:" + str( ip ) + ":" + str( port ) + \
-                               " " if ip != "" else ""
+                " " if ip != "" else ""
             command = command + tcp
         try:
             self.execute( cmd=command, prompt="mininet>", timeout=5 )
@@ -883,7 +883,7 @@
         except:
             main.log.info( self.name + ":" * 50 )
             main.log.error( traceback.print_exc() )
-            main.log.info(":" * 50 )
+            main.log.info( ":" * 50 )
             main.cleanup()
             main.exit()
 
@@ -1251,7 +1251,7 @@
         except:
             main.log.info( self.name + ":" * 50 )
             main.log.error( traceback.print_exc() )
-            main.log.info(":" * 50 )
+            main.log.info( ":" * 50 )
             main.cleanup()
             main.exit()
 
@@ -1270,7 +1270,7 @@
         except:
             main.log.info( self.name + ":" * 50 )
             main.log.error( traceback.print_exc() )
-            main.log.info(":" * 50 )
+            main.log.info( ":" * 50 )
             main.cleanup()
             main.exit()
 
@@ -1290,7 +1290,7 @@
             for port in switch.ports.values():
                 ports.append( { 'of_port': port.port_no,
                                 'mac': str( port.hw_addr ).replace( '\'',
-                                                                    ''),
+                                                                    '' ),
                                 'name': port.name } )
             output[ 'switches' ].append( {
                 "name": switch.name,
@@ -1344,7 +1344,7 @@
             main.log.report( str( list1 ) )
             main.log.report( "Switches in ONOS but not in MN:" )
             list2 = [ switch for switch in onosDPIDs if switch not in mnDPIDs ]
-            main.log.report(str( list2 ) )
+            main.log.report( str( list2 ) )
         else:  # list of dpid's match in onos and mn
             switch_results = main.TRUE
         return switch_results
@@ -1476,7 +1476,7 @@
                 # print port.hw_addr.toStr( separator='' )
                 ports.append( { 'of_port': port.port_no,
                                 'mac': str( port.hw_addr ).replace( '\'',
-                                                                    ''),
+                                                                    '' ),
                                 'name': port.name } )
             output[ 'switches' ].append( {
                 "name": switch.name,
@@ -1568,7 +1568,7 @@
                 elif ( str( onos_node1 ) == str( node2 ) and
                         str( onos_node2 ) == str( node1 ) ):
                     if ( int( onos_port1 ) == int( port2 )
-                         and int( onos_port2 ) == int( port1 ) ):
+                            and int( onos_port2 ) == int( port1 ) ):
                         second_dir = main.TRUE
                     else:
                         main.log.warn(
diff --git a/TestON/drivers/common/cli/emulator/poxclidriver.py b/TestON/drivers/common/cli/emulator/poxclidriver.py
index a562274..291e916 100644
--- a/TestON/drivers/common/cli/emulator/poxclidriver.py
+++ b/TestON/drivers/common/cli/emulator/poxclidriver.py
@@ -1,14 +1,14 @@
 #!/usr/bin/env python
-'''
+"""
 Created on 26-Oct-2012
-       
-@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
+
+author:: Raghav Kashyap( raghavkashyap@paxterrasolutions.com )
 
 
     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
@@ -16,112 +16,141 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
 pox driver provides the basic functions of POX controller
-'''
+"""
 import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
+import sys
+import signal
 import sys
 from drivers.common.cli.emulatordriver import Emulator
 
-class PoxCliDriver(Emulator):
-    '''
-        PoxCliDriver driver provides the basic functions of POX controller
-    '''
-    def __init__(self):
-        super(Emulator, self).__init__()
-        self.handle = self
-        self.wrapped = sys.modules[__name__]
 
-    def connect(self, **connectargs):
-        #,user_name, ip_address, pwd,options):
-        '''
-          this subroutine is to launch pox controller . It must have arguments as : 
+class PoxCliDriver( Emulator ):
+
+    """
+        PoxCliDriver driver provides the basic functions of POX controller
+    """
+    def __init__( self ):
+        super( Emulator, self ).__init__()
+        self.handle = self
+        self.wrapped = sys.modules[ __name__ ]
+
+    def connect( self, **connectargs ):
+        #,user_name, ip_address, pwd,options ):
+        """
+          this subroutine is to launch pox controller . It must have arguments as :
           user_name  = host name ,
           ip_address = ip address of the host ,
           pwd = password of host ,
           options = it is a topology hash which will consists the component's details for the test run
 
           *** host is here a virtual mahine or system where pox framework hierarchy exists
-        '''
-        
+        """
         for key in connectargs:
-            vars(self)[key] = connectargs[key]       
-        
-        self.name = self.options['name']
-        
+            vars( self )[ key ] = connectargs[ key ]
+
+        self.name = self.options[ 'name' ]
+
         poxLibPath = 'default'
-        copy = super(PoxCliDriver, self).secureCopy(self.user_name, self.ip_address,'/home/openflow/pox/pox/core.py', self.pwd,path+'/lib/pox/')
-        self.handle = super(PoxCliDriver, self).connect(user_name = self.user_name, ip_address = self.ip_address,port = None, pwd = self.pwd)
-        
+        copy = super(
+            PoxCliDriver,
+            self ).secureCopy(
+            self.user_name,
+            self.ip_address,
+            '/home/openflow/pox/pox/core.py',
+            self.pwd,
+            path +
+            '/lib/pox/' )
+        self.handle = super(
+            PoxCliDriver,
+            self ).connect(
+            user_name=self.user_name,
+            ip_address=self.ip_address,
+            port=None,
+            pwd=self.pwd )
+
         if self.handle:
-            self.handle.expect("openflow")
-            command = self.getcmd(self.options)
-            #print command       
-            main.log.info("Entering into POX hierarchy")
-            if self.options['pox_lib_location'] != 'default':
-                self.execute(cmd="cd "+self.options['pox_lib_location'],prompt="/pox\$",timeout=120)
-            else:    
-                self.execute(cmd="cd ~/TestON/lib/pox/",prompt="/pox\$",timeout=120)
-            ### launching pox with components    
-            main.log.info("launching POX controller with given components")
-            self.execute(cmd=command,prompt="DEBUG:",timeout=120)
+            self.handle.expect( "openflow" )
+            command = self.getcmd( self.options )
+            # print command
+            main.log.info( "Entering into POX hierarchy" )
+            if self.options[ 'pox_lib_location' ] != 'default':
+                self.execute(
+                    cmd="cd " +
+                    self.options[ 'pox_lib_location' ],
+                    prompt="/pox\$",
+                    timeout=120 )
+            else:
+                self.execute(
+                    cmd="cd ~/TestON/lib/pox/",
+                    prompt="/pox\$",
+                    timeout=120 )
+            # launching pox with components
+            main.log.info( "launching POX controller with given components" )
+            self.execute( cmd=command, prompt="DEBUG:", timeout=120 )
             return main.TRUE
-        else :
-            main.log.error("Connection failed to the host "+self.user_name+"@"+self.ip_address)
-            main.log.error("Failed to connect to the POX controller")
+        else:
+            main.log.error(
+                "Connection failed to the host " +
+                self.user_name +
+                "@" +
+                self.ip_address )
+            main.log.error( "Failed to connect to the POX controller" )
             return main.FALSE
-    
-        
-    def disconnect(self,handle):
+
+    def disconnect( self, handle ):
         if self.handle:
-            self.execute(cmd="exit()",prompt="/pox\$",timeout=120)
-        else :
-            main.log.error("Connection failed to the host") 
+            self.execute( cmd="exit()", prompt="/pox\$", timeout=120 )
+        else:
+            main.log.error( "Connection failed to the host" )
 
-
-    def get_version(self):
-        file_input = path+'/lib/pox/core.py'
-        version = super(PoxCliDriver, self).get_version()
+    def get_version( self ):
+        file_input = path + '/lib/pox/core.py'
+        version = super( PoxCliDriver, self ).get_version()
         pattern = '\s*self\.version(.*)'
         import re
-        for line in open(file_input,'r').readlines():
-            result = re.match(pattern, line)
+        for line in open( file_input, 'r' ).readlines():
+            result = re.match( pattern, line )
             if result:
-                version = result.group(0)
-                version = re.sub("\s*self\.version\s*=\s*|\(|\)",'',version)
-                version = re.sub(",",'.',version)
-                version = "POX "+version
-            
-            
-        return version
-            
+                version = result.group( 0 )
+                version = re.sub(
+                    "\s*self\.version\s*=\s*|\(|\)",
+                    '',
+                    version )
+                version = re.sub( ",", '.', version )
+                version = "POX " + version
 
-    def getcmd(self,options):
-        command = "./pox.py " 
+        return version
+
+    def getcmd( self, options ):
+        command = "./pox.py "
         for item in options.keys():
-            if isinstance(options[item],dict):
+            if isinstance( options[ item ], dict ):
                 command = command + item
-                for items in options[item].keys():
-                    if options[item][items] == "None":
+                for items in options[ item ].keys():
+                    if options[ item ][ items ] == "None":
                         command = command + " --" + items + " "
-                    else :
-                        command = command + " --" + items + "=" + options[item][items] + " "
+                    else:
+                        command = command + " --" + items + \
+                            "=" + options[ item ][ items ] + " "
             else:
                 if item == 'pox_lib_location':
-                    poxLibPath = options[item]
+                    poxLibPath = options[ item ]
                 elif item == 'type' or item == 'name':
                     pass
-                else :
+                else:
                     command = command + item
 
+        return command
 
-        return command 
-            
 
 if __name__ != "__main__":
     import sys
 
-    sys.modules[__name__] = PoxCliDriver()    
+    sys.modules[ __name__ ] = PoxCliDriver()
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index 48d3389..a8aedea 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -1,14 +1,14 @@
 #!/usr/bin/env python
-'''
+"""
 Created on 26-Oct-2012
 
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
 
 
     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,449 +20,536 @@
 
 
 MininetCliDriver is the basic driver which will handle the Mininet functions
-'''
+"""
 import traceback
 import pexpect
 import re
 import sys
-sys.path.append("../")
+sys.path.append( "../" )
 from drivers.common.cli.emulatordriver import Emulator
 
-class RemoteMininetDriver(Emulator):
-    '''
+
+class RemoteMininetDriver( Emulator ):
+
+    """
     RemoteMininetCliDriver is the basic driver which will handle the Mininet functions
     The main different between this and the MininetCliDriver is that this one does not build the mininet.
     It assumes that there is already a mininet running on the target.
-    '''
-    def __init__(self):
-        super(Emulator, self).__init__()
+    """
+    def __init__( self ):
+        super( Emulator, self ).__init__()
         self.handle = self
-        self.wrapped = sys.modules[__name__]
+        self.wrapped = sys.modules[ __name__ ]
         self.flag = 0
 
-    def connect(self, **connectargs):
-        #,user_name, ip_address, pwd,options):
-        # Here the main is the TestON instance after creating all the log handles.
+    def connect( self, **connectargs ):
+        #,user_name, ip_address, pwd,options ):
+        # Here the main is the TestON instance after creating all the log
+        # handles.
         for key in connectargs:
-            vars(self)[key] = connectargs[key]
+            vars( self )[ key ] = connectargs[ key ]
 
-        self.name = self.options['name']
-        self.handle = super(RemoteMininetDriver, self).connect(user_name = self.user_name, ip_address = self.ip_address,port = None, pwd = self.pwd)
+        self.name = self.options[ 'name' ]
+        self.handle = super(
+            RemoteMininetDriver,
+            self ).connect(
+            user_name=self.user_name,
+            ip_address=self.ip_address,
+            port=None,
+            pwd=self.pwd )
 
         self.ssh_handle = self.handle
 
         # Copying the readme file to process the
-        if self.handle :
+        if self.handle:
             return main.TRUE
 
-        else :
-            main.log.error("Connection failed to the host "+self.user_name+"@"+self.ip_address)
-            main.log.error("Failed to connect to the Mininet")
+        else:
+            main.log.error(
+                "Connection failed to the host " +
+                self.user_name +
+                "@" +
+                self.ip_address )
+            main.log.error( "Failed to connect to the Mininet" )
             return main.FALSE
 
-#*********************************************************************************************
-#*********************************************************************************************
+#*************************************************************************
+#*************************************************************************
 # checkForLoss will determine if any of the pings had any packets lost during the course of
 # the pingLong.
-#*********************************************************************************************
-#*********************************************************************************************
+#*************************************************************************
+#*************************************************************************
 
-    def checkForLoss(self, pingList):
-        '''
+    def checkForLoss( self, pingList ):
+        """
         Returns main.FALSE for 0% packet loss and
         Returns main.ERROR if "found multiple mininet" is found and
         Returns main.TRUE else
-        '''
-        #TODO: maybe we want to return the % loss instead? This way we can set an acceptible loss %.
-        #EX: 393 packets transmitted, 380 received, 3% packet loss, time 78519ms
+        """
+        # TODO: maybe we want to return the % loss instead? This way we can set an acceptible loss %.
+        # EX: 393 packets transmitted, 380 received, 3% packet loss, time 78519ms
         # we may need to return a float to get around rounding errors
 
-        self.handle.sendline("")
-        self.handle.expect("\$")
-        #Clear any output waiting in the bg from killing pings
-        self.handle.sendline("")
-        self.handle.expect("\$")
-        self.handle.sendline("cat " + pingList)
-        self.handle.expect(pingList)
-        self.handle.expect("\$")
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
+        # Clear any output waiting in the bg from killing pings
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
+        self.handle.sendline( "cat " + pingList )
+        self.handle.expect( pingList )
+        self.handle.expect( "\$" )
         outputs = self.handle.before + self.handle.after
-        if re.search(" 0% packet loss",outputs):
+        if re.search( " 0% packet loss", outputs ):
             return main.FALSE
-        elif re.search("found multiple mininet",outputs):
+        elif re.search( "found multiple mininet", outputs ):
             return main.ERROR
         else:
-            main.log.error("Error, unexpected output in the ping file")
+            main.log.error( "Error, unexpected output in the ping file" )
             main.log.warn( outputs )
             return main.TRUE
 
-
-
-    def pingLong(self,**pingParams):
-        '''
+    def pingLong( self, **pingParams ):
+        """
         Starts a continuous ping on the mininet host outputing to a file in the /tmp dir.
-        '''
-        self.handle.sendline("")
-        self.handle.expect("\$")
-        args = utilities.parse_args(["SRC","TARGET","PINGTIME"],**pingParams)
-        precmd = "sudo rm /tmp/ping." + args["SRC"]
-        self.execute(cmd=precmd,prompt="(.*)",timeout=10)
-        command = "sudo mininet/util/m " + args["SRC"] + " ping "+args ["TARGET"]+" -i .2 -w " + str(args['PINGTIME']) + " -D > /tmp/ping." + args["SRC"] + " &"
+        """
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
+        args = utilities.parse_args(
+            [ "SRC", "TARGET", "PINGTIME" ], **pingParams )
+        precmd = "sudo rm /tmp/ping." + args[ "SRC" ]
+        self.execute( cmd=precmd, prompt="(.*)", timeout=10 )
+        command = "sudo mininet/util/m " + args[ "SRC" ] + " ping " + args[
+            "TARGET" ] + " -i .2 -w " + str( args[ 'PINGTIME' ] ) + " -D > /tmp/ping." + args[ "SRC" ] + " &"
         main.log.info( command )
-        self.execute(cmd=command,prompt="(.*)",timeout=10)
-        self.handle.sendline("")
-        self.handle.expect("\$")
+        self.execute( cmd=command, prompt="(.*)", timeout=10 )
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
         return main.TRUE
 
-    def pingstatus(self,**pingParams):
-        '''
+    def pingstatus( self, **pingParams ):
+        """
         Tails the respective ping output file and check that there is a moving "64 bytes"
-        '''
-        self.handle.sendline("")
-        self.handle.expect("\$")
-        args = utilities.parse_args(["SRC"],**pingParams)
-        self.handle.sendline("tail /tmp/ping." + args["SRC"])
-        self.handle.expect("tail")
-        self.handle.expect("\$")
+        """
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
+        args = utilities.parse_args( [ "SRC" ], **pingParams )
+        self.handle.sendline( "tail /tmp/ping." + args[ "SRC" ] )
+        self.handle.expect( "tail" )
+        self.handle.expect( "\$" )
         result = self.handle.before + self.handle.after
-        self.handle.sendline("")
-        self.handle.expect("\$")
-        if re.search('Unreachable', result ):
-            main.log.info("Unreachable found in ping logs...")
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
+        if re.search( 'Unreachable', result ):
+            main.log.info( "Unreachable found in ping logs..." )
             return main.FALSE
-        elif re.search('64\sbytes', result):
-            main.log.info("Pings look good")
+        elif re.search( '64\sbytes', result ):
+            main.log.info( "Pings look good" )
             return main.TRUE
         else:
-            main.log.info("No, or faulty ping data...")
+            main.log.info( "No, or faulty ping data..." )
             return main.FALSE
 
-    def pingKill(self, testONUser, testONIP):
-        '''
+    def pingKill( self, testONUser, testONIP ):
+        """
         Kills all continuous ping processes.
         Then copies all the ping files to the TestStation.
-        '''
-        self.handle.sendline("")
-        self.handle.expect("\$")
+        """
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
         command = "sudo kill -SIGINT `pgrep ping`"
         main.log.info( command )
-        self.execute(cmd=command,prompt="(.*)",timeout=10)
+        self.execute( cmd=command, prompt="(.*)", timeout=10 )
 
         main.log.info( "Transferring ping files to TestStation" )
-        command = "scp /tmp/ping.* "+ str(testONUser) + "@" + str(testONIP) + ":/tmp/"
-        self.execute(cmd=command,prompt="100%",timeout=20)
-        #Make sure the output is cleared
-        self.handle.sendline("")
-        self.handle.expect("\$")
-        self.handle.sendline("")
-        self.handle.expect("\$")
-        self.handle.sendline("")
-        i=self.handle.expect(["password","\$"])
+        command = "scp /tmp/ping.* " + \
+            str( testONUser ) + "@" + str( testONIP ) + ":/tmp/"
+        self.execute( cmd=command, prompt="100%", timeout=20 )
+        # Make sure the output is cleared
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
+        self.handle.sendline( "" )
+        i = self.handle.expect( [ "password", "\$" ] )
         if i == 0:
-            main.log.error("Error, sudo asking for password")
-            main.log.error(self.handle.before)
+            main.log.error( "Error, sudo asking for password" )
+            main.log.error( self.handle.before )
             return main.FALSE
         else:
             return main.TRUE
 
-    def pingLongKill(self):
-        self.handle.sendline("")
-        self.handle.expect("\$")
+    def pingLongKill( self ):
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
         command = "sudo kill -SIGING `pgrep ping`"
-        main.log.info(command)
-        self.execute(cmd=command,prompt="(.*)",timeout=10)
-        self.handle.sendline("")
-        self.handle.expect("\$")
+        main.log.info( command )
+        self.execute( cmd=command, prompt="(.*)", timeout=10 )
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
         return main.TRUE
 
-    def pingHostOptical(self,**pingParams):
-        '''
+    def pingHostOptical( self, **pingParams ):
+        """
         This function is only for Packey Optical related ping
-        Use the next pingHost() function for all normal scenarios)
+        Use the next pingHost() function for all normal scenarios )
         Ping from one mininet host to another
         Currently the only supported Params: SRC and TARGET
-        '''
-        args = utilities.parse_args(["SRC","TARGET"],**pingParams)
-        #command = args["SRC"] + " ping -" + args["CONTROLLER"] + " " +args ["TARGET"]
-        command = args["SRC"] + " ping "+args ["TARGET"]+" -c 1 -i 1 -W 8"
+        """
+        args = utilities.parse_args( [ "SRC", "TARGET" ], **pingParams )
+        #command = args[ "SRC" ] + " ping -" + args[ "CONTROLLER" ] + " " +args [ "TARGET" ]
+        command = args[ "SRC" ] + " ping " + \
+            args[ "TARGET" ] + " -c 1 -i 1 -W 8"
         try:
-            main.log.warn("Sending: " + command)
-            #response = self.execute(cmd=command,prompt="mininet",timeout=10 )
-            self.handle.sendline(command)
-            i = self.handle.expect([command,pexpect.TIMEOUT])
+            main.log.warn( "Sending: " + command )
+            #response = self.execute( cmd=command,prompt="mininet",timeout=10 )
+            self.handle.sendline( command )
+            i = self.handle.expect( [ command, pexpect.TIMEOUT ] )
             if i == 1:
-                main.log.error(self.name + ": timeout when waiting for response from mininet")
-                main.log.error("response: " + str(self.handle.before))
-            i = self.handle.expect(["mininet>",pexpect.TIMEOUT])
+                main.log.error(
+                    self.name +
+                    ": timeout when waiting for response from mininet" )
+                main.log.error( "response: " + str( self.handle.before ) )
+            i = self.handle.expect( [ "mininet>", pexpect.TIMEOUT ] )
             if i == 1:
-                main.log.error(self.name + ": timeout when waiting for response from mininet")
-                main.log.error("response: " + str(self.handle.before))
+                main.log.error(
+                    self.name +
+                    ": timeout when waiting for response from mininet" )
+                main.log.error( "response: " + str( self.handle.before ) )
             response = self.handle.before
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanup()
             main.exit()
-        main.log.info(self.name+": Ping Response: "+ response )
-        #if utilities.assert_matches(expect=',\s0\%\spacket\sloss',actual=response,onpass="No Packet loss",onfail="Host is not reachable"):
-        if re.search(',\s0\%\spacket\sloss',response):
-            main.log.info(self.name+": no packets lost, host is reachable")
+        main.log.info( self.name + ": Ping Response: " + response )
+        # if utilities.assert_matches(
+        # expect=',\s0\%\spacket\sloss',actual=response,onpass="No Packet
+        # loss",onfail="Host is not reachable" ):
+        if re.search( ',\s0\%\spacket\sloss', response ):
+            main.log.info( self.name + ": no packets lost, host is reachable" )
             main.last_result = main.TRUE
             return main.TRUE
-        else :
-            main.log.error(self.name+": PACKET LOST, HOST IS NOT REACHABLE")
+        else:
+            main.log.error(
+                self.name +
+                ": PACKET LOST, HOST IS NOT REACHABLE" )
             main.last_result = main.FALSE
             return main.FALSE
 
-    def pingHost(self,**pingParams):
-        '''
+    def pingHost( self, **pingParams ):
+        """
         Pings between two hosts on remote mininet
-        '''
-        self.handle.sendline("")
-        self.handle.expect("\$")
-        args = utilities.parse_args(["SRC","TARGET"],**pingParams)
-        #command = "mininet/util/m " + args["SRC"] + " ping "+args ["TARGET"]+" -c 4 -W 1 -i .2"
-        command = "mininet/util/m " + args["SRC"] + " ping "+args ["TARGET"]+" -c 4 -W 1 -i .2"
-        main.log.info ( command )
-        response = self.execute(cmd=command,prompt="rtt",timeout=10 )
-        #self.handle.sendline("")
-        #self.handle.expect("\$")
-        if utilities.assert_matches(expect=',\s0\%\spacket\sloss',actual=response,onpass="No Packet loss",onfail="Host is not reachable"):
-            main.log.info("NO PACKET LOSS, HOST IS REACHABLE")
+        """
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
+        args = utilities.parse_args( [ "SRC", "TARGET" ], **pingParams )
+        #command = "mininet/util/m " + args[ "SRC" ] + " ping "+args [ "TARGET" ]+" -c 4 -W 1 -i .2"
+        command = "mininet/util/m " + \
+            args[ "SRC" ] + " ping " + args[ "TARGET" ] + " -c 4 -W 1 -i .2"
+        main.log.info( command )
+        response = self.execute( cmd=command, prompt="rtt", timeout=10 )
+        # self.handle.sendline( "" )
+        # self.handle.expect( "\$" )
+        if utilities.assert_matches(
+                expect=',\s0\%\spacket\sloss',
+                actual=response,
+                onpass="No Packet loss",
+                onfail="Host is not reachable" ):
+            main.log.info( "NO PACKET LOSS, HOST IS REACHABLE" )
             main.last_result = main.TRUE
             return main.TRUE
-        else :
-            main.log.error("PACKET LOST, HOST IS NOT REACHABLE")
+        else:
+            main.log.error( "PACKET LOST, HOST IS NOT REACHABLE" )
             main.last_result = main.FALSE
             return main.FALSE
 
-
-    def checknum(self,num):
-        '''
+    def checknum( self, num ):
+        """
         Verifies the correct number of switches are running
-        '''
-        if self.handle :
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline('ifconfig -a | grep "sw.. " | wc -l')
-            self.handle.expect("wc")
-            self.handle.expect("\$")
+        """
+        if self.handle:
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( 'ifconfig -a | grep "sw.. " | wc -l' )
+            self.handle.expect( "wc" )
+            self.handle.expect( "\$" )
             response = self.handle.before
-            self.handle.sendline('ps -ef | grep "bash -ms mininet:sw" | grep -v color | wc -l')
-            self.handle.expect("color")
-            self.handle.expect("\$")
+            self.handle.sendline(
+                'ps -ef | grep "bash -ms mininet:sw" | grep -v color | wc -l' )
+            self.handle.expect( "color" )
+            self.handle.expect( "\$" )
             response2 = self.handle.before
 
-            if re.search(num, response):
-                if re.search(num, response2):
+            if re.search( num, response ):
+                if re.search( num, response2 ):
                     return main.TRUE
                 else:
                     return main.FALSE
             else:
                 return main.FALSE
-        else :
-            main.log.error("Connection failed to the host")
+        else:
+            main.log.error( "Connection failed to the host" )
 
-    def start_tcpdump(self, filename, intf = "eth0", port = "port 6633", user="admin"):
-        '''
+    def start_tcpdump(
+            self,
+            filename,
+            intf="eth0",
+            port="port 6633",
+            user="admin" ):
+        """
         Runs tpdump on an intferface and saves the file
         intf can be specified, or the default eth0 is used
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.sendline("sudo tcpdump -n -i "+ intf + " " + port + " -w " + filename.strip() + " -Z " + user + "  &")
-            self.handle.sendline("")
-            self.handle.sendline("")
-            i=self.handle.expect(['No\ssuch\device','listening\son',pexpect.TIMEOUT,"\$"],timeout=10)
-            main.log.warn(self.handle.before + self.handle.after)
+            self.handle.sendline( "" )
+            self.handle.sendline(
+                "sudo tcpdump -n -i " +
+                intf +
+                " " +
+                port +
+                " -w " +
+                filename.strip() +
+                " -Z " +
+                user +
+                "  &" )
+            self.handle.sendline( "" )
+            self.handle.sendline( "" )
+            i = self.handle.expect(
+                [ 'No\ssuch\device', 'listening\son', pexpect.TIMEOUT, "\$" ], timeout=10 )
+            main.log.warn( self.handle.before + self.handle.after )
             if i == 0:
-                main.log.error(self.name + ": tcpdump - No such device exists. tcpdump attempted on: " + intf)
+                main.log.error(
+                    self.name +
+                    ": tcpdump - No such device exists. tcpdump attempted on: " +
+                    intf )
                 return main.FALSE
             elif i == 1:
-                main.log.info(self.name + ": tcpdump started on " + intf)
+                main.log.info( self.name + ": tcpdump started on " + intf )
                 return main.TRUE
             elif i == 2:
-                main.log.error(self.name + ": tcpdump command timed out! Check interface name, given interface was: " + intf)
+                main.log.error(
+                    self.name +
+                    ": tcpdump command timed out! Check interface name, given interface was: " +
+                    intf )
                 return main.FALSE
-            elif i ==3:
-                main.log.info(self.name +": " +  self.handle.before)
+            elif i == 3:
+                main.log.info( self.name + ": " + self.handle.before )
                 return main.TRUE
             else:
-                main.log.error(self.name + ": tcpdump - unexpected response")
+                main.log.error( self.name + ": tcpdump - unexpected response" )
             return main.FALSE
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                self.name +
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.log.error( traceback.print_exc() )
-            main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.cleanup()
             main.exit()
 
-    def stop_tcpdump(self):
+    def stop_tcpdump( self ):
         "pkills tcpdump"
         try:
-            self.handle.sendline("sudo pkill tcpdump")
-            self.handle.sendline("")
-            self.handle.sendline("")
-            self.handle.expect("\$")
+            self.handle.sendline( "sudo pkill tcpdump" )
+            self.handle.sendline( "" )
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                self.name +
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.log.error( traceback.print_exc() )
-            main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.cleanup()
             main.exit()
 
-    def run_optical_mn_script(self):
-        '''
+    def run_optical_mn_script( self ):
+        """
             This function is only meant for Packet Optical.
-            It runs the python script "optical.py" to create the packet layer(mn)
+            It runs the python script "optical.py" to create the packet layer( mn )
             topology
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline("cd ~")
-            self.handle.expect("\$")
-            self.handle.sendline("sudo python optical.py")
-            self.handle.expect(">")
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "cd ~" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "sudo python optical.py" )
+            self.handle.expect( ">" )
             return main.TRUE
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             return main.FALSE
 
-    def disconnect(self):
-        '''
+    def disconnect( self ):
+        """
         Called at the end of the test to disconnect the handle.
-        '''
+        """
         response = ''
-        #print "Disconnecting Mininet"
+        # print "Disconnecting Mininet"
         if self.handle:
-            self.handle.sendline("exit")
-            self.handle.expect("exit")
-            self.handle.expect("(.*)")
+            self.handle.sendline( "exit" )
+            self.handle.expect( "exit" )
+            self.handle.expect( "(.*)" )
             response = self.handle.before
 
-        else :
-            main.log.error("Connection failed to the host")
+        else:
+            main.log.error( "Connection failed to the host" )
             response = main.FALSE
         return response
 
-    def get_flowTable(self, protoVersion, sw):
-        #TODO document usage
-        #TODO add option to look at cookies. ignoreing them for now
-        self.handle.sendline("cd")
-        self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
-        #print "get_flowTable(" + str(protoVersion) +" " + str(sw) +")"
-        #NOTE: Use format to force consistent flow table output across versions
-        if protoVersion==1.0:
-            command = "sudo ovs-ofctl dump-flows " + sw + " -F OpenFlow10-table_id | awk '{OFS=\",\" ; print $1  $3  $6  $7  $8}' | cut -d ',' -f 2- | sort -n -k1 -r"
-            self.handle.sendline(command)
-            self.handle.expect(["k1 -r",pexpect.EOF,pexpect.TIMEOUT])
-            self.handle.expect(["OFPST_FLOW",pexpect.EOF,pexpect.TIMEOUT])
+    def get_flowTable( self, protoVersion, sw ):
+        # TODO document usage
+        # TODO add option to look at cookies. ignoreing them for now
+        self.handle.sendline( "cd" )
+        self.handle.expect( [ "\$", pexpect.EOF, pexpect.TIMEOUT ] )
+        # print "get_flowTable(" + str( protoVersion ) +" " + str( sw ) +")"
+        # NOTE: Use format to force consistent flow table output across
+        # versions
+        if protoVersion == 1.0:
+            command = "sudo ovs-ofctl dump-flows " + sw + \
+                " -F OpenFlow10-table_id | awk '{OFS=\",\" ; print $1  $3  $6  $7  $8}' | cut -d ',' -f 2- | sort -n -k1 -r"
+            self.handle.sendline( command )
+            self.handle.expect( [ "k1 -r", pexpect.EOF, pexpect.TIMEOUT ] )
+            self.handle.expect(
+                [ "OFPST_FLOW", pexpect.EOF, pexpect.TIMEOUT ] )
             response = self.handle.before
-            #print "response=", response
+            # print "response=", response
             return response
-        elif protoVersion==1.3:
-            command = "sudo ovs-ofctl dump-flows " + sw + " -O OpenFlow13  | awk '{OFS=\",\" ; print $1  $3  $6  $7}' | cut -d ',' -f 2- | sort -n -k1 -r"
-            self.handle.sendline(command)
-            self.handle.expect(["k1 -r",pexpect.EOF,pexpect.TIMEOUT])
-            self.handle.expect(["OFPST_FLOW",pexpect.EOF,pexpect.TIMEOUT])
+        elif protoVersion == 1.3:
+            command = "sudo ovs-ofctl dump-flows " + sw + \
+                " -O OpenFlow13  | awk '{OFS=\",\" ; print $1  $3  $6  $7}' | cut -d ',' -f 2- | sort -n -k1 -r"
+            self.handle.sendline( command )
+            self.handle.expect( [ "k1 -r", pexpect.EOF, pexpect.TIMEOUT ] )
+            self.handle.expect(
+                [ "OFPST_FLOW", pexpect.EOF, pexpect.TIMEOUT ] )
             response = self.handle.before
-            #print "response=", response
+            # print "response=", response
             return response
         else:
-            main.log.error("Unknown  protoVersion in get_flowTable(). given: ("+str(type(protoVersion))+") '"+str(protoVersion)+"'")
+            main.log.error(
+                "Unknown  protoVersion in get_flowTable(). given: (" +
+                str(
+                    type( protoVersion ) ) +
+                ") '" +
+                str(protoVersion) +
+                "'" )
 
-
-    def flow_comp(self,flow1,flow2):
-        if flow1==flow2:
+    def flow_comp( self, flow1, flow2 ):
+        if flow1 == flow2:
             return main.TRUE
         else:
-            main.log.info("Flow tables do not match, printing tables:")
-            main.log.info("Flow Table 1:")
-            main.log.info(flow1)
-            main.log.info("Flow Table 2:")
-            main.log.info(flow2)
+            main.log.info( "Flow tables do not match, printing tables:" )
+            main.log.info( "Flow Table 1:" )
+            main.log.info( flow1 )
+            main.log.info( "Flow Table 2:" )
+            main.log.info( flow2 )
             return main.FALSE
 
-    def setIpTablesOUTPUT(self, dst_ip, dst_port, action='add', packet_type='tcp',rule='DROP'):
-        '''
+    def setIpTablesOUTPUT(
+            self,
+            dst_ip,
+            dst_port,
+            action='add',
+            packet_type='tcp',
+            rule='DROP' ):
+        """
         Description:
-            add or remove iptables rule to DROP (default)  packets from specific IP and PORT
+            add or remove iptables rule to DROP ( default )  packets from specific IP and PORT
         Usage:
-        * specify action ('add' or 'remove')
+        * specify action ( 'add' or 'remove' )
           when removing, pass in the same argument as you would add. It will
           delete that specific rule.
         * specify the destination ip to block with dst_ip
         * specify destination port to block to dst_port
-        * optional packet type to block (default tcp)
-        * optional iptables rule (default DROP)
+        * optional packet type to block ( default tcp )
+        * optional iptables rule ( default DROP )
         WARNING:
         * This function uses root privilege iptables command which may result in
           unwanted network errors. USE WITH CAUTION
-        '''
+        """
         import re
         import time
 
-        #NOTE*********
+        # NOTE*********
         #   The strict checking methods of this driver function is intentional
         #   to discourage any misuse or error of iptables, which can cause
         #   severe network errors
         #*************
 
-        #NOTE: Sleep needed to give some time for rule to be added and registered
+        # NOTE: Sleep needed to give some time for rule to be added and registered
         #      to the instance
-        time.sleep(5)
+        time.sleep( 5 )
 
         action_type = action.lower()
-        if action_type != 'add' and action_type !='remove':
-            main.log.error("Invalid action type. 'add' or 'remove' table rule")
+        if action_type != 'add' and action_type != 'remove':
+            main.log.error(
+                "Invalid action type. 'add' or 'remove' table rule" )
             if rule != 'DROP' and rule != 'ACCEPT' and rule != 'LOG':
-                #NOTE: Currently only supports rules DROP, ACCEPT, and LOG
-                main.log.error("Invalid rule. 'DROP' or 'ACCEPT' or 'LOG' only.")
+                # NOTE: Currently only supports rules DROP, ACCEPT, and LOG
+                main.log.error(
+                    "Invalid rule. 'DROP' or 'ACCEPT' or 'LOG' only." )
                 return
             return
         else:
 
-            #If there is no existing rule in the iptables, we will see an
+            # If there is no existing rule in the iptables, we will see an
             #'iptables:'... message. We expect to see this message.
-            #Otherwise, if there IS an existing rule, we will get the prompt
+            # Otherwise, if there IS an existing rule, we will get the prompt
             # back, hence why we expect $ for remove type. We want to remove
             # an already existing rule
 
             if action_type == 'add':
-                #NOTE: "iptables:" expect is a result of return from the command
+                # NOTE: "iptables:" expect is a result of return from the command
                 #      iptables -C ...
                 #      Any changes by the iptables command return string
-                #      will result in failure of the function. (deemed unlikely
-                #      at the time of writing this function)
-                #Check for existing rules on current input
-                self.handle.sendline("")
-                self.handle.expect("\$")
-                self.handle.sendline("sudo iptables -C OUTPUT -p "+str(packet_type)+
-                        " -d "+ str(dst_ip)+" --dport "+str(dst_port)+" -j "+str(rule))
-                i = self.handle.expect(["iptables:", "\$"])
+                #      will result in failure of the function. ( deemed unlikely
+                #      at the time of writing this function )
+                # Check for existing rules on current input
+                self.handle.sendline( "" )
+                self.handle.expect( "\$" )
+                self.handle.sendline(
+                    "sudo iptables -C OUTPUT -p " +
+                    str( packet_type ) +
+                    " -d " +
+                    str( dst_ip ) +
+                    " --dport " +
+                    str( dst_port ) +
+                    " -j " +
+                    str( rule ) )
+                i = self.handle.expect( [ "iptables:", "\$" ] )
                 print i
                 print self.handle.before
                 print "after: "
                 print self.handle.after
 
             elif action_type == 'remove':
-                #Check for existing rules on current input
-                self.handle.sendline("")
-                self.handle.expect("\$")
-                self.handle.sendline("sudo iptables -C OUTPUT -p "+str(packet_type)+
-                        " -d "+ str(dst_ip)+" --dport "+str(dst_port)+" -j "+str(rule))
-                self.handle.expect("\$")
+                # Check for existing rules on current input
+                self.handle.sendline( "" )
+                self.handle.expect( "\$" )
+                self.handle.sendline(
+                    "sudo iptables -C OUTPUT -p " +
+                    str( packet_type ) +
+                    " -d " +
+                    str( dst_ip ) +
+                    " --dport " +
+                    str( dst_port ) +
+                    " -j " +
+                    str( rule ) )
+                self.handle.expect( "\$" )
             print "before: "
             print self.handle.before
             actual_string = self.handle.after
@@ -470,73 +557,104 @@
             print "Actual String:"
             print actual_string
 
-            if re.search(expect_string, actual_string):
+            if re.search( expect_string, actual_string ):
                 match_result = main.TRUE
             else:
                 match_result = main.FALSE
-            #If match_result is main.TRUE, it means there is no matching rule.
+            # If match_result is main.TRUE, it means there is no matching rule.
 
-            #If tables does not exist and expected prompt is returned, go ahead and
-            #add iptables rule
+            # If tables does not exist and expected prompt is returned, go ahead and
+            # add iptables rule
             if match_result == main.TRUE:
-                #Ensure action type is add
+                # Ensure action type is add
                 if action_type == 'add':
                     #-A is the 'append' action of iptables
                     action_add = '-A'
                     try:
-                        self.handle.sendline("")
-                        self.handle.sendline("sudo iptables "+action_add+" OUTPUT -p "+str(packet_type)+
-                            " -d "+ str(dst_ip)+" --dport "+str(dst_port)+" -j "+str(rule))
+                        self.handle.sendline( "" )
+                        self.handle.sendline(
+                            "sudo iptables " +
+                            action_add +
+                            " OUTPUT -p " +
+                            str( packet_type ) +
+                            " -d " +
+                            str( dst_ip ) +
+                            " --dport " +
+                            str( dst_port ) +
+                            " -j " +
+                            str( rule ) )
 
-                        info_string = "Rules added to "+str(self.name)
-                        info_string += "iptable rule added to block IP: "+str(dst_ip)
-                        info_string += "Port: "+str(dst_port)+" Rule: "+str(rule)
+                        info_string = "Rules added to " + str( self.name )
+                        info_string += "iptable rule added to block IP: " + \
+                            str( dst_ip )
+                        info_string += "Port: " + \
+                            str( dst_port ) + " Rule: " + str( rule )
 
-                        main.log.info(info_string)
+                        main.log.info( info_string )
 
-                        self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
+                        self.handle.expect(
+                            [ "\$", pexpect.EOF, pexpect.TIMEOUT ] )
                     except pexpect.TIMEOUT:
-                        main.log.error(self.name + ": Timeout exception in setIpTables function")
+                        main.log.error(
+                            self.name +
+                            ": Timeout exception in setIpTables function" )
                     except:
-                        main.log.error( traceback.print_exc())
+                        main.log.error( traceback.print_exc() )
                         main.cleanup()
                         main.exit()
                 else:
-                    main.log.error("Given rule already exists, but attempted to add it")
-            #If match_result is 0, it means there IS a matching rule provided
+                    main.log.error(
+                        "Given rule already exists, but attempted to add it" )
+            # If match_result is 0, it means there IS a matching rule provided
             elif match_result == main.FALSE:
-                #Ensure action type is remove
+                # Ensure action type is remove
                 if action_type == 'remove':
                     #-D is the 'delete' rule of iptables
                     action_remove = '-D'
                     try:
-                        self.handle.sendline("")
-                        #Delete a specific rule specified into the function
-                        self.handle.sendline("sudo iptables "+action_remove+" OUTPUT -p "+str(packet_type)+
-                            " -d "+ str(dst_ip)+" --dport "+str(dst_port)+" -j "+str(rule))
+                        self.handle.sendline( "" )
+                        # Delete a specific rule specified into the function
+                        self.handle.sendline(
+                            "sudo iptables " +
+                            action_remove +
+                            " OUTPUT -p " +
+                            str( packet_type ) +
+                            " -d " +
+                            str( dst_ip ) +
+                            " --dport " +
+                            str( dst_port ) +
+                            " -j " +
+                            str( rule ) )
 
-                        info_string = "Rules removed from "+str(self.name)
-                        info_string += " iptables rule removed from blocking IP: "+str(dst_ip)
-                        info_string += " Port: "+str(dst_port)+" Rule: "+str(rule)
+                        info_string = "Rules removed from " + str( self.name )
+                        info_string += " iptables rule removed from blocking IP: " + \
+                            str( dst_ip )
+                        info_string += " Port: " + \
+                            str( dst_port ) + " Rule: " + str( rule )
 
-                        main.log.info(info_string)
+                        main.log.info( info_string )
 
-                        self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
+                        self.handle.expect(
+                            [ "\$", pexpect.EOF, pexpect.TIMEOUT ] )
                     except pexpect.TIMEOUT:
-                        main.log.error(self.name + ": Timeout exception in setIpTables function")
+                        main.log.error(
+                            self.name +
+                            ": Timeout exception in setIpTables function" )
                     except:
-                        main.log.error( traceback.print_exc())
+                        main.log.error( traceback.print_exc() )
                         main.cleanup()
                         main.exit()
                 else:
-                    main.log.error("Given rule does not exist, but attempted to remove it")
+                    main.log.error(
+                        "Given rule does not exist, but attempted to remove it" )
             else:
-                #NOTE: If a bad usage of this function occurs, exit the entire test
-                main.log.error("Bad rule given for iptables. Exiting...")
+                # NOTE: If a bad usage of this function occurs, exit the entire
+                # test
+                main.log.error( "Bad rule given for iptables. Exiting..." )
                 main.cleanup()
                 main.exit()
 
 
 if __name__ != "__main__":
     import sys
-    sys.modules[__name__] = RemoteMininetDriver()
+    sys.modules[ __name__ ] = RemoteMininetDriver()
diff --git a/TestON/drivers/common/cli/emulatordriver.py b/TestON/drivers/common/cli/emulatordriver.py
index b561e9c..bb8da7c 100644
--- a/TestON/drivers/common/cli/emulatordriver.py
+++ b/TestON/drivers/common/cli/emulatordriver.py
@@ -1,13 +1,13 @@
 #!/usr/bin/env python
-'''
-Created on 26-Oct-2012 
+"""
+Created on 26-Oct-2012
 
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)      
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
 
     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
@@ -15,18 +15,24 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
-''' 
+"""
 import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
 import sys
-sys.path.append("../")
+import signal
+import sys
+sys.path.append( "../" )
 from drivers.common.clidriver import CLI
 
-class Emulator(CLI):
+
+class Emulator( CLI ):
     # The common functions for emulator included in emulatordriver
-    def __init__(self):
-        super(CLI, self).__init__()
-        
+
+    def __init__( self ):
+        super( CLI, self ).__init__()
+
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 838e6f4..b8a2bd5 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1,9 +1,9 @@
 #!/usr/bin/env python
 
-'''
+"""
 This driver enters the onos> prompt to issue commands.
 
-Please follow the coding style demonstrated by existing 
+Please follow the coding style demonstrated by existing
 functions and document properly.
 
 If you are a contributor to the driver, please
@@ -15,1131 +15,1055 @@
 
 OCT 13 2014
 
-'''
-
+"""
 import sys
 import pexpect
 import re
 import traceback
 #import os.path
-sys.path.append("../")
+sys.path.append( "../" )
 from drivers.common.clidriver import CLI
 
-class OnosCliDriver(CLI):
 
-    def __init__(self):
-        '''
-        Initialize client 
-        '''
-        super(CLI, self).__init__()
+class OnosCliDriver( CLI ):
 
-    def connect(self,**connectargs):
-        '''
+    def __init__( self ):
+        """
+        Initialize client
+        """
+        super( CLI, self ).__init__()
+
+    def connect( self, **connectargs ):
+        """
         Creates ssh handle for ONOS cli.
-        '''
+        """
         try:
             for key in connectargs:
-                vars(self)[key] = connectargs[key]
+                vars( self )[ key ] = connectargs[ key ]
             self.home = "~/ONOS"
             for key in self.options:
                 if key == "home":
-                    self.home = self.options['home']
+                    self.home = self.options[ 'home' ]
                     break
 
+            self.name = self.options[ 'name' ]
+            self.handle = super( OnosCliDriver, self ).connect(
+                user_name=self.user_name,
+                ip_address=self.ip_address,
+                port=self.port,
+                pwd=self.pwd,
+                home=self.home )
 
-            self.name = self.options['name']
-            self.handle = super(OnosCliDriver,self).connect(
-                    user_name = self.user_name, 
-                    ip_address = self.ip_address,
-                    port = self.port, 
-                    pwd = self.pwd, 
-                    home = self.home)
-           
-            self.handle.sendline("cd "+ self.home)
-            self.handle.expect("\$")
+            self.handle.sendline( "cd " + self.home )
+            self.handle.expect( "\$" )
             if self.handle:
                 return self.handle
-            else :
-                main.log.info("NO ONOS HANDLE")
+            else:
+                main.log.info( "NO ONOS HANDLE" )
                 return main.FALSE
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name + ":::::::::::::::::::::::")
+            main.log.info( self.name + ":::::::::::::::::::::::" )
             main.log.error( traceback.print_exc() )
-            main.log.info(":::::::::::::::::::::::")
+            main.log.info( ":::::::::::::::::::::::" )
             main.cleanup()
             main.exit()
 
-    def disconnect(self):
-        '''
+    def disconnect( self ):
+        """
         Called when Test is complete to disconnect the ONOS handle.
-        '''
+        """
         response = ''
         try:
-            self.handle.sendline("")
-            i = self.handle.expect(["onos>","\$"])
+            self.handle.sendline( "" )
+            i = self.handle.expect( [ "onos>", "\$" ] )
             if i == 0:
-                self.handle.sendline("system:shutdown")
-                self.handle.expect("Confirm")
-                self.handle.sendline("yes")
-                self.handle.expect("\$")
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline("exit")
-            self.handle.expect("closed")
+                self.handle.sendline( "system:shutdown" )
+                self.handle.expect( "Confirm" )
+                self.handle.sendline( "yes" )
+                self.handle.expect( "\$" )
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "exit" )
+            self.handle.expect( "closed" )
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
         except:
-            main.log.error(self.name + ": Connection failed to the host")
+            main.log.error( self.name + ": Connection failed to the host" )
             response = main.FALSE
         return response
 
-    def logout(self):
-        '''
+    def logout( self ):
+        """
         Sends 'logout' command to ONOS cli
-        '''
+        """
         try:
-            self.handle.sendline("")
-            i = self.handle.expect([
+            self.handle.sendline( "" )
+            i = self.handle.expect( [
                 "onos>",
-                "\$"], timeout=10)
+                "\$" ], timeout=10 )
             if i == 0:
-                self.handle.sendline("logout")
-                self.handle.expect("\$")
+                self.handle.sendline( "logout" )
+                self.handle.expect( "\$" )
             elif i == 1:
                 return main.TRUE
-                    
+
         except pexpect.EOF:
-            main.log.error(self.name + ": eof exception found")
-            main.log.error(self.name + ":    " +
-                    self.handle.before)
+            main.log.error( self.name + ": eof exception found" )
+            main.log.error( self.name + ":    " +
+                            self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def set_cell(self, cellname):
-        '''
+    def set_cell( self, cellname ):
+        """
         Calls 'cell <name>' to set the environment variables on ONOSbench
-        
+
         Before issuing any cli commands, set the environment variable first.
-        '''
+        """
         try:
             if not cellname:
-                main.log.error("Must define cellname")
+                main.log.error( "Must define cellname" )
                 main.cleanup()
                 main.exit()
             else:
-                self.handle.sendline("cell "+str(cellname))
-                #Expect the cellname in the ONOS_CELL variable.
-                #Note that this variable name is subject to change
+                self.handle.sendline( "cell " + str( cellname ) )
+                # Expect the cellname in the ONOS_CELL variable.
+                # Note that this variable name is subject to change
                 #   and that this driver will have to change accordingly
-                self.handle.expect("ONOS_CELL="+str(cellname))
+                self.handle.expect( "ONOS_CELL=" + str( cellname ) )
                 handle_before = self.handle.before
                 handle_after = self.handle.after
-                #Get the rest of the handle
-                self.handle.sendline("")
-                self.handle.expect("\$")
+                # Get the rest of the handle
+                self.handle.sendline( "" )
+                self.handle.expect( "\$" )
                 handle_more = self.handle.before
 
-                main.log.info("Cell call returned: "+handle_before+
-                        handle_after + handle_more)
+                main.log.info( "Cell call returned: " + handle_before +
+                               handle_after + handle_more )
 
                 return main.TRUE
 
         except pexpect.EOF:
-            main.log.error(self.name + ": eof exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": eof exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
-        
-    def start_onos_cli(self, ONOS_ip, karafTimeout=""):
-        '''
-        karafTimeout is an optional arugument. karafTimeout value passed by user would be used to set the 
+
+    def start_onos_cli( self, ONOS_ip, karafTimeout="" ):
+        """
+        karafTimeout is an optional arugument. karafTimeout value passed by user would be used to set the
         current karaf shell idle timeout. Note that when ever this property is modified the shell will exit and
         the subsequent login would reflect new idle timeout.
-        Below is an example to start a session with 60 seconds idle timeout (input value is in milliseconds):
-          
+        Below is an example to start a session with 60 seconds idle timeout ( input value is in milliseconds ):
+
         tValue = "60000"
-        main.ONOScli1.start_onos_cli(ONOS_ip, karafTimeout=tValue)
-        
+        main.ONOScli1.start_onos_cli( ONOS_ip, karafTimeout=tValue )
+
         Note: karafTimeout is left as str so that this could be read and passed to start_onos_cli from PARAMS file as str.
-        '''
+        """
         try:
-            self.handle.sendline("")
-            x = self.handle.expect([
-                "\$", "onos>"], timeout=10)
+            self.handle.sendline( "" )
+            x = self.handle.expect( [
+                "\$", "onos>" ], timeout=10 )
 
             if x == 1:
-                main.log.info("ONOS cli is already running")
+                main.log.info( "ONOS cli is already running" )
                 return main.TRUE
 
-            #Wait for onos start (-w) and enter onos cli
-            self.handle.sendline("onos -w "+str(ONOS_ip))
-            i = self.handle.expect([
-                    "onos>",
-                    pexpect.TIMEOUT],timeout=60)
+            # Wait for onos start ( -w ) and enter onos cli
+            self.handle.sendline( "onos -w " + str( ONOS_ip ) )
+            i = self.handle.expect( [
+                "onos>",
+                pexpect.TIMEOUT ], timeout=60 )
 
             if i == 0:
-                main.log.info(str(ONOS_ip)+" CLI Started successfully")
+                main.log.info( str( ONOS_ip ) + " CLI Started successfully" )
                 if karafTimeout:
-                    self.handle.sendline("config:property-set -p org.apache.karaf.shell sshIdleTimeout "+karafTimeout)
-                    self.handle.expect("\$")
-                    self.handle.sendline("onos -w "+str(ONOS_ip))
-                    self.handle.expect("onos>")
+                    self.handle.sendline(
+                        "config:property-set -p org.apache.karaf.shell sshIdleTimeout " +
+                        karafTimeout )
+                    self.handle.expect( "\$" )
+                    self.handle.sendline( "onos -w " + str( ONOS_ip ) )
+                    self.handle.expect( "onos>" )
                 return main.TRUE
             else:
-                #If failed, send ctrl+c to process and try again
-                main.log.info("Starting CLI failed. Retrying...")
-                self.handle.send("\x03")
-                self.handle.sendline("onos -w "+str(ONOS_ip))
-                i = self.handle.expect(["onos>",pexpect.TIMEOUT],
-                        timeout=30)
+                # If failed, send ctrl+c to process and try again
+                main.log.info( "Starting CLI failed. Retrying..." )
+                self.handle.send( "\x03" )
+                self.handle.sendline( "onos -w " + str( ONOS_ip ) )
+                i = self.handle.expect( [ "onos>", pexpect.TIMEOUT ],
+                                        timeout=30 )
                 if i == 0:
-                    main.log.info(str(ONOS_ip)+" CLI Started "+
-                        "successfully after retry attempt")
+                    main.log.info( str( ONOS_ip ) + " CLI Started " +
+                                   "successfully after retry attempt" )
                     if karafTimeout:
-                        self.handle.sendline("config:property-set -p org.apache.karaf.shell sshIdleTimeout "+karafTimeout)
-                        self.handle.expect("\$")
-                        self.handle.sendline("onos -w "+str(ONOS_ip))
-			self.handle.expect("onos>")
+                        self.handle.sendline(
+                            "config:property-set -p org.apache.karaf.shell sshIdleTimeout " +
+                            karafTimeout )
+                        self.handle.expect( "\$" )
+                        self.handle.sendline( "onos -w " + str( ONOS_ip ) )
+                        self.handle.expect( "onos>" )
                     return main.TRUE
                 else:
-                    main.log.error("Connection to CLI "+\
-                        str(ONOS_ip)+" timeout")
+                    main.log.error( "Connection to CLI " +
+                                    str( ONOS_ip ) + " timeout" )
                     return main.FALSE
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def sendline(self, cmd_str):
-        '''
-        Send a completely user specified string to 
-        the onos> prompt. Use this function if you have 
+    def sendline( self, cmd_str ):
+        """
+        Send a completely user specified string to
+        the onos> prompt. Use this function if you have
         a very specific command to send.
-        
+
         Warning: There are no sanity checking to commands
         sent using this method.
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
+            self.handle.sendline( "" )
+            self.handle.expect( "onos>" )
 
-            self.handle.sendline(cmd_str)
-            self.handle.expect("onos>")
+            self.handle.sendline( "log:log \"Sending CLI command: '"
+                                  + cmd_str + "'\"" )
+            self.handle.expect( "onos>" )
+            self.handle.sendline( cmd_str )
+            self.handle.expect( cmd_str )
+            self.handle.expect( "onos>" )
 
             handle = self.handle.before
-            
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-            
-            handle += self.handle.before
-            handle += self.handle.after
 
-            main.log.info("Command sent.")
-            ansi_escape = re.compile(r'\x1b[^m]*m')
-            handle = ansi_escape.sub('', handle)
+            self.handle.sendline( "" )
+            self.handle.expect( "onos>" )
+
+            #handle += self.handle.before
+            #handle += self.handle.after
+
+            main.log.info( "Command '" + str(cmd_str) + "' sent to "
+                           + self.name + "." )
+            ansi_escape = re.compile( r'\x1b[^m]*m' )
+            handle = ansi_escape.sub( '', handle )
 
             return handle
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    #IMPORTANT NOTE:
-    #For all cli commands, naming convention should match
-    #the cli command replacing ':' with '_'.
-    #Ex) onos:topology > onos_topology
+    # IMPORTANT NOTE:
+    # For all cli commands, naming convention should match
+    # the cli command replacing ':' with '_'.
+    # Ex ) onos:topology > onos_topology
     #    onos:links    > onos_links
     #    feature:list  > feature_list
-   
-    def add_node(self, node_id, ONOS_ip, tcp_port=""):
-        '''
+
+    def add_node( self, node_id, ONOS_ip, tcp_port="" ):
+        """
         Adds a new cluster node by ID and address information.
         Required:
             * node_id
             * ONOS_ip
         Optional:
             * tcp_port
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            self.handle.sendline("add-node "+
-                    str(node_id)+" "+
-                    str(ONOS_ip)+" "+
-                    str(tcp_port))
-            
-            i = self.handle.expect([
-                "Error",
-                "onos>" ])
-            
-            #Clear handle to get previous output
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            handle = self.handle.before
-
-            if i == 0:
-                main.log.error("Error in adding node")
-                main.log.error(handle)
-                return main.FALSE 
+            cmd_str = "add-node " + str( node_id ) + " " +\
+                str( ONOS_ip ) + " " + str( tcp_port )
+            handle = self.sendline( cmd_str )
+            if re.search( "Error", handle ):
+                main.log.error( "Error in adding node" )
+                main.log.error( handle )
+                return main.FALSE
             else:
-                main.log.info("Node "+str(ONOS_ip)+" added")
+                main.log.info( "Node " + str( ONOS_ip ) + " added" )
                 return main.TRUE
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def remove_node(self, node_id):
-        '''
+    def remove_node( self, node_id ):
+        """
         Removes a cluster by ID
         Issues command: 'remove-node [<node-id>]'
         Required:
             * node_id
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
 
-            self.handle.sendline("remove-node "+str(node_id))
-            self.handle.expect("onos>")
+            cmd_str = "remove-node " + str( node_id )
+            self.sendline( cmd_str )
+            # TODO: add error checking. Does ONOS give any errors?
 
             return main.TRUE
-        
+
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def nodes(self):
-        '''
+    def nodes( self ):
+        """
         List the nodes currently visible
         Issues command: 'nodes'
         Returns: entire handle of list of nodes
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            self.handle.sendline("nodes")
-            self.handle.expect("onos>")
-
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            handle = self.handle.before
-
+            cmd_str = "nodes"
+            handle = self.sendline( cmd_str )
             return handle
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def topology(self):
-        '''
+    def topology( self ):
+        """
         Shows the current state of the topology
         by issusing command: 'onos> onos:topology'
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-            #either onos:topology or 'topology' will work in CLI
-            self.handle.sendline("onos:topology")
-            self.handle.expect("onos>")
-
-            handle = self.handle.before
-
-            main.log.info("onos:topology returned: " +
-                    str(handle))
-            
+            # either onos:topology or 'topology' will work in CLI
+            cmd_str = "onos:topology"
+            handle = self.sendline( cmd_str )
+            main.log.info( "onos:topology returned: " + str( handle ) )
             return handle
-        
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
-       
-    def feature_install(self, feature_str):
-        '''
-        Installs a specified feature 
+
+    def feature_install( self, feature_str ):
+        """
+        Installs a specified feature
         by issuing command: 'onos> feature:install <feature_str>'
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            self.handle.sendline("feature:install "+str(feature_str))
-            self.handle.expect("onos>")
-
+            cmd_str = "feature:install " + str( feature_str )
+            self.sendline( cmd_str )
+            # TODO: Check for possible error responses from karaf
             return main.TRUE
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
-            main.log.report("Failed to install feature")
-            main.log.report("Exiting test")
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.log.report( "Failed to install feature" )
+            main.log.report( "Exiting test" )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.report("Failed to install feature")
-            main.log.report("Exiting test")
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.report( "Failed to install feature" )
+            main.log.report( "Exiting test" )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
-       
-    def feature_uninstall(self, feature_str):
-        '''
+
+    def feature_uninstall( self, feature_str ):
+        """
         Uninstalls a specified feature
         by issuing command: 'onos> feature:uninstall <feature_str>'
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            self.handle.sendline("feature:uninstall "+str(feature_str))
-            self.handle.expect("onos>")
-
+            cmd_str = "feature:uninstall " + str( feature_str )
+            self.sendline( cmd_str )
+            # TODO: Check for possible error responses from karaf
             return main.TRUE
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def devices(self, json_format=True):
-        '''
+    def devices( self, json_format=True ):
+        """
         Lists all infrastructure devices or switches
         Optional argument:
             * json_format - boolean indicating if you want output in json
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
             if json_format:
-                self.handle.sendline("devices -j")
-                self.handle.expect("devices -j")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                '''
-                handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
-                To make that escape sequence visible, use repr() function. The repr(handle) output when printed shows the ANSI escape sequences.
-                In json.loads(somestring), this somestring variable is actually repr(somestring) and json.loads would fail with the escape sequence.
-                So we take off that escape sequence using
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle)
-                '''
-                #print "repr(handle) =", repr(handle)
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle)
-                #print "repr(handle1) = ", repr(handle1)
+                cmd_str = "devices -j"
+                handle = self.sendline( cmd_str )
+                """
+                handle variable here contains some ANSI escape color code
+                sequences at the end which are invisible in the print command
+                output. To make that escape sequence visible, use repr()
+                function. The repr( handle ) output when printed shows the
+                ANSI escape sequences. In json.loads( somestring ), this
+                somestring variable is actually repr( somestring ) and
+                json.loads would fail with the escape sequence. So we take off
+                that escape sequence using:
+
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle1 = ansi_escape.sub( '', handle )
+                """
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle1 = ansi_escape.sub( '', handle )
                 return handle1
             else:
-                self.handle.sendline("devices")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                #print "handle =",handle
+                cmd_str = "devices"
+                handle = self.sendline( cmd_str )
                 return handle
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-       
-    def balance_masters(self):
-        '''
+    def balance_masters( self ):
+        """
         This balances the devices across all controllers
         by issuing command: 'onos> onos:balance-masters'
         If required this could be extended to return devices balanced output.
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            self.handle.sendline("onos:balance-masters")
-            self.handle.expect("onos>")
+            cmd_str = "onos:balance-masters"
+            self.sendline( cmd_str )
+            # TODO: Check for error responses from ONOS
             return main.TRUE
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def links(self, json_format=True):
-        '''
+    def links( self, json_format=True ):
+        """
         Lists all core links
         Optional argument:
             * json_format - boolean indicating if you want output in json
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
             if json_format:
-                self.handle.sendline("links -j")
-                self.handle.expect("links -j")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                '''
-                handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
-                To make that escape sequence visible, use repr() function. The repr(handle) output when printed shows the ANSI escape sequences.
-                In json.loads(somestring), this somestring variable is actually repr(somestring) and json.loads would fail with the escape sequence.
-                So we take off that escape sequence using
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle)
-                '''
-                #print "repr(handle) =", repr(handle)
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle)
-                #print "repr(handle1) = ", repr(handle1)
+                cmd_str = "links -j"
+                handle = self.sendline( cmd_str )
+                """
+                handle variable here contains some ANSI escape color code
+                sequences at the end which are invisible in the print command
+                output. To make that escape sequence visible, use repr()
+                function. The repr( handle ) output when printed shows the ANSI
+                escape sequences. In json.loads( somestring ), this somestring
+                variable is actually repr( somestring ) and json.loads would
+                fail with the escape sequence. So we take off that escape
+                sequence using:
+
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle1 = ansi_escape.sub( '', handle )
+                """
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle1 = ansi_escape.sub( '', handle )
                 return handle1
             else:
-                self.handle.sendline("links")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                #print "handle =",handle
+                cmd_str = "links"
+                handle = self.sendline( cmd_str )
                 return handle
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-
-    def ports(self, json_format=True):
-        '''
+    def ports( self, json_format=True ):
+        """
         Lists all ports
         Optional argument:
             * json_format - boolean indicating if you want output in json
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
             if json_format:
-                self.handle.sendline("ports -j")
-                self.handle.expect("ports -j")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                '''
-                handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
-                To make that escape sequence visible, use repr() function. The repr(handle) output when printed shows the ANSI escape sequences.
-                In json.loads(somestring), this somestring variable is actually repr(somestring) and json.loads would fail with the escape sequence.
-                So we take off that escape sequence using the following commads:
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle)
-                '''
-                #print "repr(handle) =", repr(handle)
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle)
-                #print "repr(handle1) = ", repr(handle1)
+                cmd_str = "ports -j"
+                handle = self.sendline( cmd_str )
+                """
+                handle variable here contains some ANSI escape color code
+                sequences at the end which are invisible in the print command
+                output. To make that escape sequence visible, use repr()
+                function. The repr( handle ) output when printed shows the ANSI
+                escape sequences. In json.loads( somestring ), this somestring
+                variable is actually repr( somestring ) and json.loads would
+                fail with the escape sequence. So we take off that escape
+                sequence using the following commads:
+
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle1 = ansi_escape.sub( '', handle )
+                """
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle1 = ansi_escape.sub( '', handle )
                 return handle1
 
             else:
-                self.handle.sendline("ports")
-                self.handle.expect("onos>")
-                self.handle.sendline("")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                #print "handle =",handle
+                cmd_str = "ports"
+                handle = self.sendline( cmd_str )
                 return handle
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-
-    def roles(self, json_format=True):
-        '''
+    def roles( self, json_format=True ):
+        """
         Lists all devices and the controllers with roles assigned to them
         Optional argument:
             * json_format - boolean indicating if you want output in json
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
             if json_format:
-                self.handle.sendline("roles -j")
-                self.handle.expect("roles -j")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                '''
-                handle variable here contains some ANSI escape color code sequences at the
-                end which are invisible in the print command output. To make that escape
-                sequence visible, use repr() function. The repr(handle) output when printed
-                shows the ANSI escape sequences. In json.loads(somestring), this somestring
-                variable is actually repr(somestring) and json.loads would fail with the escape
-                sequence.
+                cmd_str = "roles -j"
+                handle = self.sendline( cmd_str )
+                """
+                handle variable here contains some ANSI escape color code
+                sequences at the end which are invisible in the print command
+                output. To make that escape sequence visible, use repr()
+                function. The repr( handle ) output when printed shows the ANSI
+                escape sequences. In json.loads( somestring ), this somestring
+                variable is actually repr( somestring ) and json.loads would
+                fail with the escape sequence.
 
-                So we take off that escape sequence using the following commads:
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle)
-                '''
-                #print "repr(handle) =", repr(handle)
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle)
-                #print "repr(handle1) = ", repr(handle1)
+                So we take off that escape sequence using the following
+                commads:
+
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle1 = ansi_escape.sub( '', handle )
+                """
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle1 = ansi_escape.sub( '', handle )
                 return handle1
 
             else:
-                self.handle.sendline("roles")
-                self.handle.expect("onos>")
-                self.handle.sendline("")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                #print "handle =",handle
+                cmd_str = "roles"
+                handle = self.sendline( cmd_str )
                 return handle
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def get_role(self, device_id):
-        '''
-        Given the a string containing the json representation of the "roles" cli command and a 
-        partial or whole device id, returns a json object containing the
-        roles output for the first device whose id contains "device_id"
+    def get_role( self, device_id ):
+        """
+        Given the a string containing the json representation of the "roles"
+        cli command and a partial or whole device id, returns a json object
+        containing the roles output for the first device whose id contains
+        "device_id"
 
         Returns:
-        Dict of the role assignments for the given device or
-        None if not match
-        '''
+        A dict of the role assignments for the given device or
+        None if no match
+        """
         try:
             import json
-            if device_id == None:
+            if device_id is None:
                 return None
             else:
                 raw_roles = self.roles()
-                roles_json = json.loads(raw_roles)
-                #search json for the device with id then return the device
+                roles_json = json.loads( raw_roles )
+                # search json for the device with id then return the device
                 for device in roles_json:
-                    #print device
-                    if str(device_id) in device['id']:
+                    # print device
+                    if str( device_id ) in device[ 'id' ]:
                         return device
             return None
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def roles_not_null(self):
-        '''
+    def roles_not_null( self ):
+        """
         Iterates through each device and checks if there is a master assigned
         Returns: main.TRUE if each device has a master
                  main.FALSE any device has no master
-        '''
+        """
         try:
             import json
             raw_roles = self.roles()
-            roles_json = json.loads(raw_roles)
-            #search json for the device with id then return the device
+            roles_json = json.loads( raw_roles )
+            # search json for the device with id then return the device
             for device in roles_json:
-                #print device
-                if device['master'] == "none":
-                    main.log.warn("Device has no master: " + str(device) )
+                # print device
+                if device[ 'master' ] == "none":
+                    main.log.warn( "Device has no master: " + str( device ) )
                     return main.FALSE
             return main.TRUE
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-
-    def paths(self, src_id, dst_id):
-        '''
+    def paths( self, src_id, dst_id ):
+        """
         Returns string of paths, and the cost.
         Issues command: onos:paths <src> <dst>
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            self.handle.sendline("onos:paths "+
-                    str(src_id) + " " + str(dst_id))
-            i = self.handle.expect([
-                "Error",
-                "onos>"])
-            
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            handle = self.handle.before
-
-            if i == 0:
-                main.log.error("Error in getting paths")
-                return (handle, "Error")
+            cmd_str = "onos:paths " + str( src_id ) + " " + str( dst_id )
+            handle = self.sendline( cmd_str )
+            if re.search( "Error", handle ):
+                main.log.error( "Error in getting paths" )
+                return ( handle, "Error" )
             else:
-                path = handle.split(";")[0]
-                cost = handle.split(";")[1]
-                return (path, cost)
-        
+                path = handle.split( ";" )[ 0 ]
+                cost = handle.split( ";" )[ 1 ]
+                return ( path, cost )
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def hosts(self, json_format=True):
-        '''
+    def hosts( self, json_format=True ):
+        """
         Lists all discovered hosts
         Optional argument:
             * json_format - boolean indicating if you want output in json
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
             if json_format:
-                self.handle.sendline("hosts -j")
-                self.handle.expect("hosts -j")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                '''
-                handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
-                To make that escape sequence visible, use repr() function. The repr(handle) output when printed shows the ANSI escape sequences.
-                In json.loads(somestring), this somestring variable is actually repr(somestring) and json.loads would fail with the escape sequence.
-                So we take off that escape sequence using
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle)
-                '''
-                #print "repr(handle) =", repr(handle)
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle)
-                #print "repr(handle1) = ", repr(handle1)
+                cmd_str = "hosts -j"
+                handle = self.sendline( cmd_str )
+                """
+                handle variable here contains some ANSI escape color code
+                sequences at the end which are invisible in the print command
+                output. To make that escape sequence visible, use repr()
+                function. The repr( handle ) output when printed shows the ANSI
+                escape sequences. In json.loads( somestring ), this somestring
+                variable is actually repr( somestring ) and json.loads would
+                fail with the escape sequence. So we take off that escape
+                sequence using:
+
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle1 = ansi_escape.sub( '', handle )
+                """
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle1 = ansi_escape.sub( '', handle )
                 return handle1
             else:
-                self.handle.sendline("hosts")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                #print "handle =",handle
+                cmd_str = "hosts"
+                handle = self.sendline( cmd_str )
                 return handle
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def get_host(self, mac):
-        '''
+    def get_host( self, mac ):
+        """
         Return the first host from the hosts api whose 'id' contains 'mac'
-        Note: mac must be a colon seperated mac address, but could be a partial mac address
+
+        Note: mac must be a colon seperated mac address, but could be a
+              partial mac address
+
         Return None if there is no match
-        '''
+        """
         import json
         try:
-            if mac == None:
+            if mac is None:
                 return None
             else:
                 mac = mac
                 raw_hosts = self.hosts()
-                hosts_json = json.loads(raw_hosts)
-                #search json for the host with mac then return the device
+                hosts_json = json.loads( raw_hosts )
+                # search json for the host with mac then return the device
                 for host in hosts_json:
-                    #print "%s in  %s?" % (mac, host['id'])
-                    if mac in host['id']:
+                    # print "%s in  %s?" % ( mac, host[ 'id' ] )
+                    if mac in host[ 'id' ]:
                         return host
             return None
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-
-    def get_hosts_id(self, host_list):
-        '''
-        Obtain list of hosts 
+    def get_hosts_id( self, host_list ):
+        """
+        Obtain list of hosts
         Issues command: 'onos> hosts'
-        
+
         Required:
             * host_list: List of hosts obtained by Mininet
         IMPORTANT:
             This function assumes that you started your
-            topology with the option '--mac'. 
+            topology with the option '--mac'.
             Furthermore, it assumes that value of VLAN is '-1'
         Description:
-            Converts mininet hosts (h1, h2, h3...) into 
-            ONOS format (00:00:00:00:00:01/-1 , ...)
-        '''
-        
+            Converts mininet hosts ( h1, h2, h3... ) into
+            ONOS format ( 00:00:00:00:00:01/-1 , ... )
+        """
         try:
             onos_host_list = []
 
             for host in host_list:
-                host = host.replace("h", "")
-                host_hex = hex(int(host)).zfill(12)
-                host_hex = str(host_hex).replace('x','0')
-                i = iter(str(host_hex))
-                host_hex = ":".join(a+b for a,b in zip(i,i))
+                host = host.replace( "h", "" )
+                host_hex = hex( int( host ) ).zfill( 12 )
+                host_hex = str( host_hex ).replace( 'x', '0' )
+                i = iter( str( host_hex ) )
+                host_hex = ":".join( a + b for a, b in zip( i, i ) )
                 host_hex = host_hex + "/-1"
-                onos_host_list.append(host_hex) 
+                onos_host_list.append( host_hex )
 
-            return onos_host_list 
+            return onos_host_list
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def add_host_intent(self, host_id_one, host_id_two):
-        '''
+    def add_host_intent( self, host_id_one, host_id_two ):
+        """
         Required:
             * host_id_one: ONOS host id for host1
             * host_id_two: ONOS host id for host2
         Description:
-            Adds a host-to-host intent (bidrectional) by
+            Adds a host-to-host intent ( bidrectional ) by
             specifying the two hosts.
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            self.handle.sendline("add-host-intent "+
-                    str(host_id_one) + " " + str(host_id_two))
-            self.handle.expect("onos>")
-
-            handle = self.handle.before
-            #print "handle =", handle
-
-            main.log.info("Host intent installed between "+
-                    str(host_id_one) + " and " + str(host_id_two))
-
+            cmd_str = "add-host-intent " + str( host_id_one ) +\
+                " " + str( host_id_two )
+            handle = self.sendline( cmd_str )
+            main.log.info( "Host intent installed between " +
+                           str( host_id_one ) + " and " + str( host_id_two ) )
             return handle
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def add_optical_intent(self, ingress_device, egress_device):
-        '''
+    def add_optical_intent( self, ingress_device, egress_device ):
+        """
         Required:
             * ingress_device: device id of ingress device
             * egress_device: device id of egress device
         Optional:
             TODO: Still needs to be implemented via dev side
-        ''' 
+        """
         try:
-            self.handle.sendline("add-optical-intent "+
-                    str(ingress_device) + " " + str(egress_device))
-            self.handle.expect("add-optical-intent")
-            i = self.handle.expect([
-                "Error",
-                "onos>"])
-
-            handle = self.handle.before
-
-            #If error, return error message
-            if i == 0:
+            cmd_str = "add-optical-intent " + str( ingress_device ) +\
+                " " + str( egress_device )
+            handle = self.sendline( cmd_str )
+            # If error, return error message
+            if re.search( "Error", handle ):
                 return handle
             else:
                 return main.TRUE
-        
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def add_point_intent(self, ingress_device, egress_device,
-            port_ingress="", port_egress="", ethType="", ethSrc="",
-            ethDst="", bandwidth="", lambda_alloc=False, 
-            ipProto="", ipSrc="", ipDst="", tcpSrc="", tcpDst=""):
-        '''
+    def add_point_intent(
+            self,
+            ingress_device,
+            egress_device,
+            port_ingress="",
+            port_egress="",
+            ethType="",
+            ethSrc="",
+            ethDst="",
+            bandwidth="",
+            lambda_alloc=False,
+            ipProto="",
+            ipSrc="",
+            ipDst="",
+            tcpSrc="",
+            tcpDst="" ):
+        """
         Required:
             * ingress_device: device id of ingress device
             * egress_device: device id of egress device
         Optional:
             * ethType: specify ethType
-            * ethSrc: specify ethSrc (i.e. src mac addr)
-            * ethDst: specify ethDst (i.e. dst mac addr)
+            * ethSrc: specify ethSrc ( i.e. src mac addr )
+            * ethDst: specify ethDst ( i.e. dst mac addr )
             * bandwidth: specify bandwidth capacity of link
-            * lambda_alloc: if True, intent will allocate lambda 
+            * lambda_alloc: if True, intent will allocate lambda
               for the specified intent
-            * ipProto: specify ip protocol 
+            * ipProto: specify ip protocol
             * ipSrc: specify ip source address
             * ipDst: specify ip destination address
             * tcpSrc: specify tcp source port
             * tcpDst: specify tcp destination port
         Description:
-            Adds a point-to-point intent (uni-directional) by
+            Adds a point-to-point intent ( uni-directional ) by
             specifying device id's and optional fields
 
-        NOTE: This function may change depending on the 
+        NOTE: This function may change depending on the
               options developers provide for point-to-point
               intent via cli
-        '''
+        """
         try:
             cmd = ""
 
-            #If there are no optional arguments
+            # If there are no optional arguments
             if not ethType and not ethSrc and not ethDst\
                     and not bandwidth and not lambda_alloc \
                     and not ipProto and not ipSrc and not ipDst \
                     and not tcpSrc and not tcpDst:
                 cmd = "add-point-intent"
-      
 
             else:
                 cmd = "add-point-intent"
-                
+
                 if ethType:
-                    cmd += " --ethType " + str(ethType)
+                    cmd += " --ethType " + str( ethType )
                 if ethSrc:
-                    cmd += " --ethSrc " + str(ethSrc) 
-                if ethDst:    
-                    cmd += " --ethDst " + str(ethDst) 
+                    cmd += " --ethSrc " + str( ethSrc )
+                if ethDst:
+                    cmd += " --ethDst " + str( ethDst )
                 if bandwidth:
-                    cmd += " --bandwidth " + str(bandwidth)
+                    cmd += " --bandwidth " + str( bandwidth )
                 if lambda_alloc:
                     cmd += " --lambda "
                 if ipProto:
-                    cmd += " --ipProto " + str(ipProto)
+                    cmd += " --ipProto " + str( ipProto )
                 if ipSrc:
-                    cmd += " --ipSrc " + str(ipSrc)
+                    cmd += " --ipSrc " + str( ipSrc )
                 if ipDst:
-                    cmd += " --ipDst " + str(ipDst)
+                    cmd += " --ipDst " + str( ipDst )
                 if tcpSrc:
-                    cmd += " --tcpSrc " + str(tcpSrc)
+                    cmd += " --tcpSrc " + str( tcpSrc )
                 if tcpDst:
-                    cmd += " --tcpDst " + str(tcpDst)
+                    cmd += " --tcpDst " + str( tcpDst )
 
-            #Check whether the user appended the port 
-            #or provided it as an input
+            # Check whether the user appended the port
+            # or provided it as an input
             if "/" in ingress_device:
-                cmd += " "+str(ingress_device) 
+                cmd += " " + str( ingress_device )
             else:
                 if not port_ingress:
-                    main.log.error("You must specify "+
-                        "the ingress port")
-                    #TODO: perhaps more meaningful return
+                    main.log.error( "You must specify " +
+                                    "the ingress port" )
+                    # TODO: perhaps more meaningful return
                     return main.FALSE
 
-                cmd += " "+ \
-                    str(ingress_device) + "/" +\
-                    str(port_ingress) + " " 
+                cmd += " " + \
+                    str( ingress_device ) + "/" +\
+                    str( port_ingress ) + " "
 
             if "/" in egress_device:
-                cmd += " "+str(egress_device)
+                cmd += " " + str( egress_device )
             else:
                 if not port_egress:
-                    main.log.error("You must specify "+
-                        "the egress port")
+                    main.log.error( "You must specify " +
+                                    "the egress port" )
                     return main.FALSE
-                
-                cmd += " "+\
-                    str(egress_device) + "/" +\
-                    str(port_egress)  
 
-            self.handle.sendline(cmd)
-            
-            main.log.info(cmd + " sent")
-            i = self.handle.expect([
-                "Error",
-                "onos>"])
+                cmd += " " +\
+                    str( egress_device ) + "/" +\
+                    str( port_egress )
 
-            if i == 0:
-                main.log.error("Error in adding point-to-point intent")
+            handle = self.sendline( cmd )
+            if re.search( "Error", handle ):
+                main.log.error( "Error in adding point-to-point intent" )
                 return main.FALSE
             else:
                 return main.TRUE
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-
-    def add_multipoint_to_singlepoint_intent(self, ingress_device1, ingress_device2,egress_device,
-            port_ingress="", port_egress="", ethType="", ethSrc="",
-            ethDst="", bandwidth="", lambda_alloc=False, 
-            ipProto="", ipSrc="", ipDst="", tcpSrc="", tcpDst="", setEthSrc="", setEthDst=""):
-        '''
+    def add_multipoint_to_singlepoint_intent(
+            self,
+            ingress_device1,
+            ingress_device2,
+            egress_device,
+            port_ingress="",
+            port_egress="",
+            ethType="",
+            ethSrc="",
+            ethDst="",
+            bandwidth="",
+            lambda_alloc=False,
+            ipProto="",
+            ipSrc="",
+            ipDst="",
+            tcpSrc="",
+            tcpDst="",
+            setEthSrc="",
+            setEthDst="" ):
+        """
         Note:
-            This function assumes that there would be 2 ingress devices and one egress device
-            For more number of ingress devices, this function needs to be modified
+            This function assumes that there would be 2 ingress devices and
+            one egress device. For more number of ingress devices, this
+            function needs to be modified
         Required:
             * ingress_device1: device id of ingress device1
             * ingress_device2: device id of ingress device2
             * egress_device: device id of egress device
         Optional:
             * ethType: specify ethType
-            * ethSrc: specify ethSrc (i.e. src mac addr)
-            * ethDst: specify ethDst (i.e. dst mac addr)
+            * ethSrc: specify ethSrc ( i.e. src mac addr )
+            * ethDst: specify ethDst ( i.e. dst mac addr )
             * bandwidth: specify bandwidth capacity of link
-            * lambda_alloc: if True, intent will allocate lambda 
+            * lambda_alloc: if True, intent will allocate lambda
               for the specified intent
-            * ipProto: specify ip protocol 
+            * ipProto: specify ip protocol
             * ipSrc: specify ip source address
             * ipDst: specify ip destination address
             * tcpSrc: specify tcp source port
@@ -1147,273 +1071,236 @@
             * setEthSrc: action to Rewrite Source MAC Address
             * setEthDst: action to Rewrite Destination MAC Address
         Description:
-            Adds a multipoint-to-singlepoint intent (uni-directional) by
+            Adds a multipoint-to-singlepoint intent ( uni-directional ) by
             specifying device id's and optional fields
 
-        NOTE: This function may change depending on the 
+        NOTE: This function may change depending on the
               options developers provide for multipointpoint-to-singlepoint
               intent via cli
-        '''
+        """
         try:
             cmd = ""
 
-            #If there are no optional arguments
+            # If there are no optional arguments
             if not ethType and not ethSrc and not ethDst\
-                    and not bandwidth and not lambda_alloc \
-                    and not ipProto and not ipSrc and not ipDst \
-                    and not tcpSrc and not tcpDst and not setEthSrc and not setEthDst:
+                    and not bandwidth and not lambda_alloc\
+                    and not ipProto and not ipSrc and not ipDst\
+                    and not tcpSrc and not tcpDst and not setEthSrc\
+                    and not setEthDst:
                 cmd = "add-multi-to-single-intent"
-      
 
             else:
                 cmd = "add-multi-to-single-intent"
-                
+
                 if ethType:
-                    cmd += " --ethType " + str(ethType)
+                    cmd += " --ethType " + str( ethType )
                 if ethSrc:
-                    cmd += " --ethSrc " + str(ethSrc) 
-                if ethDst:    
-                    cmd += " --ethDst " + str(ethDst) 
+                    cmd += " --ethSrc " + str( ethSrc )
+                if ethDst:
+                    cmd += " --ethDst " + str( ethDst )
                 if bandwidth:
-                    cmd += " --bandwidth " + str(bandwidth)
+                    cmd += " --bandwidth " + str( bandwidth )
                 if lambda_alloc:
                     cmd += " --lambda "
                 if ipProto:
-                    cmd += " --ipProto " + str(ipProto)
+                    cmd += " --ipProto " + str( ipProto )
                 if ipSrc:
-                    cmd += " --ipSrc " + str(ipSrc)
+                    cmd += " --ipSrc " + str( ipSrc )
                 if ipDst:
-                    cmd += " --ipDst " + str(ipDst)
+                    cmd += " --ipDst " + str( ipDst )
                 if tcpSrc:
-                    cmd += " --tcpSrc " + str(tcpSrc)
+                    cmd += " --tcpSrc " + str( tcpSrc )
                 if tcpDst:
-                    cmd += " --tcpDst " + str(tcpDst)
+                    cmd += " --tcpDst " + str( tcpDst )
                 if setEthSrc:
-                    cmd += " --setEthSrc "+ str(setEthSrc)
+                    cmd += " --setEthSrc " + str( setEthSrc )
                 if setEthDst:
-                    cmd += " --setEthDst "+ str(setEthDst)
+                    cmd += " --setEthDst " + str( setEthDst )
 
-            #Check whether the user appended the port 
-            #or provided it as an input
+            # Check whether the user appended the port
+            # or provided it as an input
             if "/" in ingress_device1:
-                cmd += " "+str(ingress_device1) 
+                cmd += " " + str( ingress_device1 )
             else:
                 if not port_ingress1:
-                    main.log.error("You must specify "+
-                        "the ingress port1")
-                    #TODO: perhaps more meaningful return
+                    main.log.error( "You must specify " +
+                                    "the ingress port1" )
+                    # TODO: perhaps more meaningful return
                     return main.FALSE
 
-                cmd += " "+ \
-                    str(ingress_device1) + "/" +\
-                    str(port_ingress1) + " " 
+                cmd += " " + \
+                    str( ingress_device1 ) + "/" +\
+                    str( port_ingress1 ) + " "
 
             if "/" in ingress_device2:
-                cmd += " "+str(ingress_device2)
+                cmd += " " + str( ingress_device2 )
             else:
                 if not port_ingress2:
-                    main.log.error("You must specify "+
-                        "the ingress port2")
-                    #TODO: perhaps more meaningful return
+                    main.log.error( "You must specify " +
+                                    "the ingress port2" )
+                    # TODO: perhaps more meaningful return
                     return main.FALSE
 
-                cmd += " "+ \
-                    str(ingress_device2) + "/" +\
-                    str(port_ingress2) + " "
+                cmd += " " + \
+                    str( ingress_device2 ) + "/" +\
+                    str( port_ingress2 ) + " "
 
             if "/" in egress_device:
-                cmd += " "+str(egress_device)
+                cmd += " " + str( egress_device )
             else:
                 if not port_egress:
-                    main.log.error("You must specify "+
-                        "the egress port")
+                    main.log.error( "You must specify " +
+                                    "the egress port" )
                     return main.FALSE
-                
-                cmd += " "+\
-                    str(egress_device) + "/" +\
-                    str(port_egress)  
-            print "cmd= ",cmd
-            self.handle.sendline(cmd)
-            
-            main.log.info(cmd + " sent")
-            i = self.handle.expect([
-                "Error",
-                "onos>"])
 
-            if i == 0:
-                main.log.error("Error in adding point-to-point intent")
+                cmd += " " +\
+                    str( egress_device ) + "/" +\
+                    str( port_egress )
+            print "cmd= ", cmd
+            handle = self.sendline( cmd )
+            if re.search( "Error", handle ):
+                main.log.error( "Error in adding point-to-point intent" )
                 return self.handle
             else:
                 return main.TRUE
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-
-    def remove_intent(self, intent_id):
-        '''
+    def remove_intent( self, intent_id ):
+        """
         Remove intent for specified intent id
-        '''
+
+        Returns:
+            main.False on error and
+            cli output otherwise
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            self.handle.sendline("remove-intent "+str(intent_id))
-            i = self.handle.expect([
-                "Error",
-                "onos>"])
-           
-            handle = self.handle.before
-
-            if i == 0:
-                main.log.error("Error in removing intent")
-                return handle
+            cmd_str = "remove-intent " + str( intent_id )
+            handle = self.sendline( cmd_str )
+            if re.search( "Error", handle ):
+                main.log.error( "Error in removing intent" )
+                return main.FALSE
             else:
-                return handle 
-        
+                # TODO: Should this be main.TRUE
+                return handle
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    # This method should be used after installing application: onos-app-sdnip
-    def routes(self, json_format=False):
-        '''
+    def routes( self, json_format=False ):
+        """
+        NOTE: This method should be used after installing application:
+              onos-app-sdnip
         Optional:
             * json_format: enable output formatting in json
         Description:
             Obtain all routes in the system
-        '''
+        """
         try:
             if json_format:
-                self.handle.sendline("routes -j")
-                self.handle.expect("routes -j")
-                self.handle.expect("onos>")
-                handle_tmp = self.handle.before
-                
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle = ansi_escape.sub('', handle_tmp)
-
+                cmd_str = "routes -j"
+                handle_tmp = self.sendline( cmd_str )
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle = ansi_escape.sub( '', handle_tmp )
             else:
-                self.handle.sendline("")
-                self.handle.expect("onos>")
-
-                self.handle.sendline("routes")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-
+                cmd_str = "routes"
+                handle = self.sendline( cmd_str )
             return handle
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name + " ::::::")
-            main.log.error(traceback.print_exc())
-            main.log.info(self.name + " ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def intents(self, json_format = True):
-        '''
+    def intents( self, json_format=True ):
+        """
         Optional:
             * json_format: enable output formatting in json
         Description:
-            Obtain intents currently installed 
-        '''
+            Obtain intents currently installed
+        """
         try:
             if json_format:
-                self.handle.sendline("intents -j")
-                self.handle.expect("intents -j")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle = ansi_escape.sub('', handle)
+                cmd_str = "intents -j"
+                handle = self.sendline( cmd_str )
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle = ansi_escape.sub( '', handle )
             else:
-                self.handle.sendline("")
-                self.handle.expect("onos>")
-
-                self.handle.sendline("intents")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-
+                cmd_str = "intents"
+                handle = self.sendline( cmd_str )
             return handle
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def flows(self, json_format = True):
-        '''
+    def flows( self, json_format=True ):
+        """
         Optional:
             * json_format: enable output formatting in json
         Description:
-            Obtain flows currently installed 
-        '''
+            Obtain flows currently installed
+        """
         try:
             if json_format:
-                self.handle.sendline("flows -j")
-                self.handle.expect("flows -j")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle = ansi_escape.sub('', handle)
-
+                cmd_str = "flows -j"
+                handle = self.sendline( cmd_str )
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle = ansi_escape.sub( '', handle )
             else:
-                self.handle.sendline("")
-                self.handle.expect("onos>")
-                self.handle.sendline("flows")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-            if re.search("Error\sexecuting\scommand:", handle):
-                main.log.error(self.name + ".flows() response: " + str(handle))
-
+                cmd_str = "flows"
+                handle = self.sendline( cmd_str )
+            if re.search( "Error\sexecuting\scommand:", handle ):
+                main.log.error( self.name + ".flows() response: " +
+                                str( handle ) )
             return handle
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def push_test_intents(self, dpid_src, dpid_dst, num_intents, 
-            num_mult="", app_id="", report=True):
-        '''
+    def push_test_intents( self, dpid_src, dpid_dst, num_intents,
+                           num_mult="", app_id="", report=True ):
+        """
         Description:
-            Push a number of intents in a batch format to 
+            Push a number of intents in a batch format to
             a specific point-to-point intent definition
         Required:
             * dpid_src: specify source dpid
@@ -1425,310 +1312,280 @@
             * app_id: specify the application id init to further
               modularize the intents
             * report: default True, returns latency information
-        '''
+        """
         try:
-            cmd = "push-test-intents "+\
-                  str(dpid_src)+" "+str(dpid_dst)+" "+\
-                  str(num_intents)
-            
+            cmd = "push-test-intents " +\
+                  str( dpid_src ) + " " + str( dpid_dst ) + " " +\
+                  str( num_intents )
             if num_mult:
-                cmd += " " + str(num_mult)
-                #If app id is specified, then num_mult 
-                #must exist because of the way this command
+                cmd += " " + str( num_mult )
+                # If app id is specified, then num_mult
+                # must exist because of the way this command
                 #takes in arguments
                 if app_id:
-                    cmd += " " + str(app_id)
-            
-            self.handle.sendline(cmd)
-            self.handle.expect(cmd)
-            self.handle.expect("onos>")
-                
-            handle = self.handle.before
-              
-            #Some color thing that we want to escape
-            ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-            handle = ansi_escape.sub('', handle)
-    
+                    cmd += " " + str( app_id )
+            handle = self.sendline( cmd )
+            # Some color thing that we want to escape
+            ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+            handle = ansi_escape.sub( '', handle )
             if report:
                 lat_result = []
-                main.log.info(handle)
-                #Split result by newline
-                newline = handle.split("\r\r\n")
-                #Ignore the first object of list, which is empty
-                newline = newline[1:]
-                #Some sloppy parsing method to get the latency
+                main.log.info( handle )
+                # Split result by newline
+                newline = handle.split( "\r\r\n" )
+                # Ignore the first object of list, which is empty
+                newline = newline[ 1: ]
+                # Some sloppy parsing method to get the latency
                 for result in newline:
-                    result = result.split(": ")
-                    #Append the first result of second parse
-                    lat_result.append(result[1].split(" ")[0])
-
-                main.log.info(lat_result) 
-                return lat_result 
+                    result = result.split( ": " )
+                    # Append the first result of second parse
+                    lat_result.append( result[ 1 ].split( " " )[ 0 ] )
+                main.log.info( lat_result )
+                return lat_result
             else:
                 return main.TRUE
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def intents_events_metrics(self, json_format=True):
-        '''
-        Description:Returns topology metrics 
+    def intents_events_metrics( self, json_format=True ):
+        """
+        Description:Returns topology metrics
         Optional:
             * json_format: enable json formatting of output
-        '''
+        """
         try:
             if json_format:
-                self.handle.sendline("intents-events-metrics -j")
-                self.handle.expect("intents-events-metrics -j")
-                self.handle.expect("onos>")
-                
-                handle = self.handle.before
-              
-                #Some color thing that we want to escape
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle = ansi_escape.sub('', handle)
-            
+                cmd_str = "intents-events-metrics -j"
+                handle = self.sendline( cmd_str )
+                # Some color thing that we want to escape
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle = ansi_escape.sub( '', handle )
             else:
-                self.handle.sendline("intents-events-metrics")
-                self.handle.expect("intents-events-metrics")
-                self.handle.expect("onos>")
-                
-                handle = self.handle.before
-
+                cmd_str = "intents-events-metrics"
+                handle = self.sendline( cmd_str )
             return handle
-        
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def topology_events_metrics(self, json_format=True):
-        '''
-        Description:Returns topology metrics 
+    def topology_events_metrics( self, json_format=True ):
+        """
+        Description:Returns topology metrics
         Optional:
             * json_format: enable json formatting of output
-        '''
+        """
         try:
             if json_format:
-                self.handle.sendline("topology-events-metrics -j")
-                self.handle.expect("topology-events-metrics -j")
-                self.handle.expect("onos>")
-                
-                handle = self.handle.before
-              
-                #Some color thing that we want to escape
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle = ansi_escape.sub('', handle)
-            
+                cmd_str = "topology-events-metrics -j"
+                handle = self.sendline( cmd_str )
+                # Some color thing that we want to escape
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle = ansi_escape.sub( '', handle )
             else:
-                self.handle.sendline("topology-events-metrics")
-                self.handle.expect("topology-events-metrics")
-                self.handle.expect("onos>")
-                
-                handle = self.handle.before
-
+                cmd_str = "topology-events-metrics"
+                handle = self.sendline( cmd_str )
             return handle
-        
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    #Wrapper functions ****************
-    #Wrapper functions use existing driver
-    #functions and extends their use case.
-    #For example, we may use the output of
-    #a normal driver function, and parse it
-    #using a wrapper function
+    # Wrapper functions ****************
+    # Wrapper functions use existing driver
+    # functions and extends their use case.
+    # For example, we may use the output of
+    # a normal driver function, and parse it
+    # using a wrapper function
 
-    def get_all_intents_id(self):
-        '''
+    def get_all_intents_id( self ):
+        """
         Description:
             Obtain all intent id's in a list
-        '''
+        """
         try:
-            #Obtain output of intents function
+            # Obtain output of intents function
             intents_str = self.intents()
             all_intent_list = []
             intent_id_list = []
 
-            #Parse the intents output for ID's
-            intents_list = [s.strip() for s in intents_str.splitlines()]
+            # Parse the intents output for ID's
+            intents_list = [ s.strip() for s in intents_str.splitlines() ]
             for intents in intents_list:
                 if "onos>" in intents:
                     continue
                 elif "intents" in intents:
                     continue
                 else:
-                    line_list = intents.split(" ")
-                    all_intent_list.append(line_list[0])
-            
-            all_intent_list = all_intent_list[1:-2]
+                    line_list = intents.split( " " )
+                    all_intent_list.append( line_list[ 0 ] )
+
+            all_intent_list = all_intent_list[ 1:-2 ]
 
             for intents in all_intent_list:
                 if not intents:
                     continue
                 else:
-                    intent_id_list.append(intents) 
+                    intent_id_list.append( intents )
 
             return intent_id_list
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def get_all_devices_id(self):
-        '''
+    def get_all_devices_id( self ):
+        """
         Use 'devices' function to obtain list of all devices
         and parse the result to obtain a list of all device
         id's. Returns this list. Returns empty list if no
         devices exist
-        List is ordered sequentially 
-        
+        List is ordered sequentially
+
         This function may be useful if you are not sure of the
-        device id, and wish to execute other commands using 
+        device id, and wish to execute other commands using
         the ids. By obtaining the list of device ids on the fly,
         you can iterate through the list to get mastership, etc.
-        '''
+        """
         try:
-            #Call devices and store result string
-            devices_str = self.devices(json_format=False)
+            # Call devices and store result string
+            devices_str = self.devices( json_format=False )
             id_list = []
-            
+
             if not devices_str:
-                main.log.info("There are no devices to get id from")
+                main.log.info( "There are no devices to get id from" )
                 return id_list
-           
-            #Split the string into list by comma
-            device_list = devices_str.split(",")
-            #Get temporary list of all arguments with string 'id='
-            temp_list = [dev for dev in device_list if "id=" in dev]
-            #Split list further into arguments before and after string
-            # 'id='. Get the latter portion (the actual device id) and
+
+            # Split the string into list by comma
+            device_list = devices_str.split( "," )
+            # Get temporary list of all arguments with string 'id='
+            temp_list = [ dev for dev in device_list if "id=" in dev ]
+            # Split list further into arguments before and after string
+            # 'id='. Get the latter portion ( the actual device id ) and
             # append to id_list
             for arg in temp_list:
-                id_list.append(arg.split("id=")[1])
+                id_list.append( arg.split( "id=" )[ 1 ] )
             return id_list
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def get_all_nodes_id(self):
-        '''
+    def get_all_nodes_id( self ):
+        """
         Uses 'nodes' function to obtain list of all nodes
         and parse the result of nodes to obtain just the
-        node id's. 
+        node id's.
         Returns:
             list of node id's
-        '''
+        """
         try:
             nodes_str = self.nodes()
             id_list = []
 
             if not nodes_str:
-                main.log.info("There are no nodes to get id from")
+                main.log.info( "There are no nodes to get id from" )
                 return id_list
 
-            #Sample nodes_str output
-            #id=local, address=127.0.0.1:9876, state=ACTIVE *
+            # Sample nodes_str output
+            # id=local, address=127.0.0.1:9876, state=ACTIVE *
 
-            #Split the string into list by comma
-            nodes_list = nodes_str.split(",")
-            temp_list = [node for node in nodes_list if "id=" in node]
+            # Split the string into list by comma
+            nodes_list = nodes_str.split( "," )
+            temp_list = [ node for node in nodes_list if "id=" in node ]
             for arg in temp_list:
-                id_list.append(arg.split("id=")[1])
+                id_list.append( arg.split( "id=" )[ 1 ] )
 
             return id_list
-        
+
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def get_device(self, dpid=None):
-        '''
+    def get_device( self, dpid=None ):
+        """
         Return the first device from the devices api whose 'id' contains 'dpid'
         Return None if there is no match
-        '''
+        """
         import json
         try:
-            if dpid == None:
+            if dpid is None:
                 return None
             else:
-                dpid = dpid.replace(':', '')
+                dpid = dpid.replace( ':', '' )
                 raw_devices = self.devices()
-                devices_json = json.loads(raw_devices)
-                #search json for the device with dpid then return the device
+                devices_json = json.loads( raw_devices )
+                # search json for the device with dpid then return the device
                 for device in devices_json:
-                    #print "%s in  %s?" % (dpid, device['id'])
-                    if dpid in device['id']:
+                    # print "%s in  %s?" % ( dpid, device[ 'id' ] )
+                    if dpid in device[ 'id' ]:
                         return device
             return None
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def check_status(self, ip, numoswitch, numolink, log_level="info"):
-        '''
-        Checks the number of swithes & links that ONOS sees against the 
-        supplied values. By default this will report to main.log, but the 
+    def check_status( self, ip, numoswitch, numolink, log_level="info" ):
+        """
+        Checks the number of swithes & links that ONOS sees against the
+        supplied values. By default this will report to main.log, but the
         log level can be specifid.
-        
+
         Params: ip = ip used for the onos cli
                 numoswitch = expected number of switches
                 numlink = expected number of links
@@ -1737,380 +1594,339 @@
 
         log_level can
 
-        Returns: main.TRUE if the number of switchs and links are correct, 
+        Returns: main.TRUE if the number of switchs and links are correct,
                  main.FALSE if the numer of switches and links is incorrect,
                  and main.ERROR otherwise
-        '''
-
+        """
         try:
-            topology = self.get_topology(ip)
+            topology = self.get_topology( ip )
             if topology == {}:
                 return main.ERROR
             output = ""
-            #Is the number of switches is what we expected
-            devices = topology.get('devices',False)
-            links = topology.get('links',False)
+            # Is the number of switches is what we expected
+            devices = topology.get( 'devices', False )
+            links = topology.get( 'links', False )
             if devices == False or links == False:
                 return main.ERROR
-            switch_check = ( int(devices) == int(numoswitch) )
-            #Is the number of links is what we expected
-            link_check = ( int(links) == int(numolink) )
-            if (switch_check and link_check):
-                #We expected the correct numbers
+            switch_check = ( int( devices ) == int( numoswitch ) )
+            # Is the number of links is what we expected
+            link_check = ( int( links ) == int( numolink ) )
+            if ( switch_check and link_check ):
+                # We expected the correct numbers
                 output = output + "The number of links and switches match "\
-                        + "what was expected"
+                    + "what was expected"
                 result = main.TRUE
             else:
                 output = output + \
-                        "The number of links and switches does not match what was expected"
+                    "The number of links and switches does not match what was expected"
                 result = main.FALSE
-            output = output + "\n ONOS sees %i devices (%i expected) and %i links (%i expected)"\
-                    % ( int(devices), int(numoswitch), int(links), int(numolink) )
+            output = output + "\n ONOS sees %i devices (%i expected) and %i links (%i expected)" % (
+                int( devices ), int( numoswitch ), int( links ), int( numolink ) )
             if log_level == "report":
-                main.log.report(output)
+                main.log.report( output )
             elif log_level == "warn":
-                main.log.warn(output)
+                main.log.warn( output )
             else:
-                main.log.info(output)
-            return result 
+                main.log.info( output )
+            return result
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def device_role(self, device_id, onos_node, role="master"):
-        '''
+    def device_role( self, device_id, onos_node, role="master" ):
+        """
         Calls the device-role cli command.
         device_id must be the id of a device as seen in the onos devices command
         onos_node is the ip of one of the onos nodes in the cluster
         role must be either master, standby, or none
 
-        Returns main.TRUE or main.FALSE based on argument verification.
-            When device-role supports errors this should be extended to
-            support that output
-        '''
+        Returns:
+            main.TRUE or main.FALSE based on argument verification and
+            main.ERROR if command returns and error
+        """
         try:
-            #print "beginning device_role... \n\tdevice_id:" + device_id
-            #print "\tonos_node: " + onos_node
-            #print "\trole: "+ role
-            if role.lower() == "master" or \
-                    role.lower() == "standby" or \
+            if role.lower() == "master" or role.lower() == "standby" or\
                     role.lower() == "none":
-                        self.handle.sendline("")
-                        self.handle.expect("onos>")
-                        self.handle.sendline("device-role " +
-                                str(device_id) + " " +
-                                str(onos_node) +  " " +
-                                str(role))
-                        i= self.handle.expect(["Error","onos>"])
-                        if i == 0:
-                            output = str(self.handle.before)
-                            self.handle.expect("onos>")
-                            output = output + str(self.handle.before)
-                            main.log.error(self.name + ": " +
-                                    output + '\033[0m')#end color output to escape any colours from the cli
-                            return main.ERROR
-                        self.handle.sendline("")
-                        self.handle.expect("onos>")
-                        return main.TRUE
+                cmd_str = "device-role " +\
+                    str( device_id ) + " " +\
+                    str( onos_node ) +  " " +\
+                    str( role )
+                handle = self.sendline( cmd_str )
+                if re.search( "Error", handle ):
+                    # end color output to escape any colours
+                    # from the cli
+                    main.log.error( self.name + ": " +
+                                    handle + '\033[0m' )
+                    return main.ERROR
+                return main.TRUE
             else:
+                main.log.error( "Invalid 'role' given to device_role(). " +
+                                "Value was '" + str(role) + "'." )
                 return main.FALSE
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def clusters(self, json_format=True):
-        '''
+    def clusters( self, json_format=True ):
+        """
         Lists all clusters
         Optional argument:
             * json_format - boolean indicating if you want output in json
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
             if json_format:
-                self.handle.sendline("clusters -j")
-                self.handle.expect("clusters -j")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                '''
+                cmd_str = "clusters -j"
+                handle = self.sendline( cmd_str )
+                """
                 handle variable here contains some ANSI escape color code
                 sequences at the end which are invisible in the print command
-                output. To make that escape sequence visible, use repr() function.
-                The repr(handle) output when printed shows the ANSI escape sequences.
-                In json.loads(somestring), this somestring variable is actually
-                repr(somestring) and json.loads would fail with the escape sequence.
-                So we take off that escape sequence using
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle)
-                '''
-                #print "repr(handle) =", repr(handle)
-                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle)
-                #print "repr(handle1) = ", repr(handle1)
+                output. To make that escape sequence visible, use repr()
+                function. The repr( handle ) output when printed shows the ANSI
+                escape sequences. In json.loads( somestring ), this somestring
+                variable is actually repr( somestring ) and json.loads would fail
+                with the escape sequence. So we take off that escape sequence
+                using:
+
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle1 = ansi_escape.sub( '', handle )
+                """
+                ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
+                handle1 = ansi_escape.sub( '', handle )
                 return handle1
             else:
-                self.handle.sendline("clusters")
-                self.handle.expect("onos>")
-                handle = self.handle.before
-                #print "handle =",handle
+                cmd_str = "clusters"
+                handle = self.sendline( cmd_str )
                 return handle
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def election_test_leader(self):
-        '''
-         * CLI command to get the current leader for the Election test application.
-         #NOTE: Requires installation of the onos-app-election feature
-         Returns: Node IP of the leader if one exists
-                  None if none exists
-                  Main.FALSE on error
-        '''
+    def election_test_leader( self ):
+        """
+        CLI command to get the current leader for the Election test application
+        NOTE: Requires installation of the onos-app-election feature
+        Returns: Node IP of the leader if one exists
+                 None if none exists
+                 Main.FALSE on error
+        """
         try:
-            self.handle.sendline("election-test-leader")
-            self.handle.expect("election-test-leader")
-            self.handle.expect("onos>")
-            response = self.handle.before
-            #Leader
-            node_search = re.search("The\scurrent\sleader\sfor\sthe\sElection\sapp\sis\s(?P<node>.+)\.", response)
+            cmd_str = "election-test-leader"
+            response = self.sendline( cmd_str )
+            # Leader
+            leaderPattern = "The\scurrent\sleader\sfor\sthe\sElection\s" +\
+                "app\sis\s(?P<node>.+)\."
+            node_search = re.search( leaderPattern, response )
             if node_search:
-                node = node_search.group('node')
-                main.log.info("Election-test-leader on "+str(self.name)+" found " + node + " as the leader")
+                node = node_search.group( 'node' )
+                main.log.info( "Election-test-leader on " + str( self.name ) +
+                               " found " + node + " as the leader" )
                 return node
-            #no leader
-            null_search = re.search("There\sis\scurrently\sno\sleader\selected\sfor\sthe\sElection\sapp", response)
+            # no leader
+            nullPattern = "There\sis\scurrently\sno\sleader\selected\sfor\s" +\
+                "the\sElection\sapp"
+            null_search = re.search( nullPattern, response )
             if null_search:
-                main.log.info("Election-test-leader found no leader on " + self.name )
+                main.log.info( "Election-test-leader found no leader on " +
+                               self.name )
                 return None
-            #error
-            if re.search("Command\snot\sfound", response):
-                main.log.error("Election app is not loaded on " + self.name)
+            # error
+            errorPattern = "Command\snot\sfound"
+            if re.search( errorPattern, response ):
+                main.log.error( "Election app is not loaded on " + self.name )
+                # TODO: Should this be main.ERROR?
                 return main.FALSE
             else:
-                main.log.error("Error in election_test_leader: unexpected response")
-                main.log.error( repr(response) )
+                main.log.error( "Error in election_test_leader: " +
+                                "unexpected response" )
+                main.log.error( repr( response ) )
                 return main.FALSE
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def election_test_run(self):
-        '''
-         * CLI command to run for leadership of the Election test application.
-         #NOTE: Requires installation of the onos-app-election feature
-         Returns: Main.TRUE on success
-                  Main.FALSE on error
-        '''
+    def election_test_run( self ):
+        """
+        CLI command to run for leadership of the Election test application.
+        NOTE: Requires installation of the onos-app-election feature
+        Returns: Main.TRUE on success
+                 Main.FALSE on error
+        """
         try:
-            self.handle.sendline("election-test-run")
-            self.handle.expect("election-test-run")
-            self.handle.expect("onos>")
-            response = self.handle.before
-            #success
-            search = re.search("Entering\sleadership\selections\sfor\sthe\sElection\sapp.", response)
+            cmd_str = "election-test-run"
+            response = self.sendline( cmd_str )
+            # success
+            successPattern = "Entering\sleadership\selections\sfor\sthe\s" +\
+                "Election\sapp."
+            search = re.search( successPattern, response )
             if search:
-                main.log.info(self.name + " entering leadership elections for the Election app.")
+                main.log.info( self.name + " entering leadership elections " +
+                               "for the Election app." )
                 return main.TRUE
-            #error
-            if re.search("Command\snot\sfound", response):
-                main.log.error("Election app is not loaded on " + self.name)
+            # error
+            errorPattern = "Command\snot\sfound"
+            if re.search( errorPattern, response ):
+                main.log.error( "Election app is not loaded on " + self.name )
                 return main.FALSE
             else:
-                main.log.error("Error in election_test_run: unexpected response")
-                main.log.error( repr(response) )
+                main.log.error( "Error in election_test_run: " +
+                                "unexpected response" )
+                main.log.error( repr( response ) )
                 return main.FALSE
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def election_test_withdraw(self):
-        '''
+    def election_test_withdraw( self ):
+        """
          * CLI command to withdraw the local node from leadership election for
          * the Election test application.
          #NOTE: Requires installation of the onos-app-election feature
          Returns: Main.TRUE on success
                   Main.FALSE on error
-        '''
+        """
         try:
-            self.handle.sendline("election-test-withdraw")
-            self.handle.expect("election-test-withdraw")
-            self.handle.expect("onos>")
-            response = self.handle.before
-            #success
-            search = re.search("Withdrawing\sfrom\sleadership\selections\sfor\sthe\sElection\sapp.", response)
-            if search:
-                main.log.info(self.name + " withdrawing from leadership elections for the Election app.")
+            cmd_str = "election-test-withdraw"
+            response = self.sendline( cmd_str )
+            # success
+            successPattern = "Withdrawing\sfrom\sleadership\selections\sfor" +\
+                "\sthe\sElection\sapp."
+            if re.search( successPattern, response ):
+                main.log.info( self.name + " withdrawing from leadership " +
+                               "elections for the Election app." )
                 return main.TRUE
-            #error
-            if re.search("Command\snot\sfound", response):
-                main.log.error("Election app is not loaded on " + self.name)
+            # error
+            errorPattern = "Command\snot\sfound"
+            if re.search( errorPattern, response ):
+                main.log.error( "Election app is not loaded on " + self.name )
                 return main.FALSE
             else:
-                main.log.error("Error in election_test_withdraw: unexpected response")
-                main.log.error( repr(response) )
+                main.log.error( "Error in election_test_withdraw: " +
+                                "unexpected response" )
+                main.log.error( repr( response ) )
                 return main.FALSE
-
-
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
     #***********************************
-    def getDevicePortsEnabledCount(self,dpid):
-        '''
+    def getDevicePortsEnabledCount( self, dpid ):
+        """
         Get the count of all enabled ports on a particular device/switch
-        '''
+        """
         try:
-            dpid = str(dpid)
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            self.handle.sendline("onos:ports -e "+dpid+" | wc -l")
-            i = self.handle.expect([
-                "No such device",
-                "onos>"])
-            
-            #self.handle.sendline("")
-            #self.handle.expect("onos>")
-
-            output = self.handle.before
-
-            if i == 0:
-                main.log.error("Error in getting ports")
-                return (output, "Error")
+            dpid = str( dpid )
+            cmd_str = "onos:ports -e " + dpid + " | wc -l"
+            output = self.sendline( cmd_str )
+            if re.search( "No such device", output ):
+                main.log.error( "Error in getting ports" )
+                return ( output, "Error" )
             else:
-                result = output
-                return result
-        
+                return output
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def getDeviceLinksActiveCount(self,dpid):
-        '''
+    def getDeviceLinksActiveCount( self, dpid ):
+        """
         Get the count of all enabled ports on a particular device/switch
-        '''
+        """
         try:
-            dpid = str(dpid)
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            self.handle.sendline("onos:links "+dpid+" | grep ACTIVE | wc -l")
-            i = self.handle.expect([
-                "No such device",
-                "onos>"])
-
-            output = self.handle.before
-
-            if i == 0:
-                main.log.error("Error in getting ports")
-                return (output, "Error")
+            dpid = str( dpid )
+            cmd_str = "onos:links " + dpid + " | grep ACTIVE | wc -l"
+            output = self.sendline( cmd_str )
+            if re.search( "No such device", output ):
+                main.log.error( "Error in getting ports " )
+                return ( output, "Error " )
             else:
-                result = output
-                return result
-        
+                return output
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def getAllIntentIds(self):
-        '''
+    def getAllIntentIds( self ):
+        """
         Return a list of all Intent IDs
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("onos>")
-
-            self.handle.sendline("onos:intents | grep id=")
-            i = self.handle.expect([
-                "Error",
-                "onos>"])
-
-            output = self.handle.before
-
-            if i == 0:
-                main.log.error("Error in getting ports")
-                return (output, "Error")
+            cmd_str = "onos:intents | grep id="
+            output = self.sendline( cmd_str )
+            if re.search( "Error", output ):
+                main.log.error( "Error in getting ports" )
+                return ( output, "Error" )
             else:
-                result = output
-                return result
-        
+                return output
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index c8713e5..d671f48 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -1,10 +1,10 @@
 #!/usr/bin/env python
 
-'''
-This driver interacts with ONOS bench, the OSGi platform 
-that configures the ONOS nodes. (aka ONOS-next) 
+"""
+This driver interacts with ONOS bench, the OSGi platform
+that configures the ONOS nodes. ( aka ONOS-next )
 
-Please follow the coding style demonstrated by existing 
+Please follow the coding style demonstrated by existing
 functions and document properly.
 
 If you are a contributor to the driver, please
@@ -15,125 +15,126 @@
 
 OCT 9 2014
 
-'''
-
+"""
 import sys
 import time
 import pexpect
 import traceback
 import os.path
-sys.path.append("../")
+sys.path.append( "../" )
 from drivers.common.clidriver import CLI
 
-class OnosDriver(CLI):
 
-    def __init__(self):
-        '''
-        Initialize client 
-        '''
-        super(CLI, self).__init__()
+class OnosDriver( CLI ):
 
-    def connect(self,**connectargs):
-        '''
+    def __init__( self ):
+        """
+        Initialize client
+        """
+        super( CLI, self ).__init__()
+
+    def connect( self, **connectargs ):
+        """
         Creates ssh handle for ONOS "bench".
-        '''
+        """
         try:
             for key in connectargs:
-                vars(self)[key] = connectargs[key]
+                vars( self )[ key ] = connectargs[ key ]
             self.home = "~/ONOS"
             for key in self.options:
                 if key == "home":
-                    self.home = self.options['home']
+                    self.home = self.options[ 'home' ]
                     break
 
+            self.name = self.options[ 'name' ]
+            self.handle = super( OnosDriver, self ).connect(
+                user_name=self.user_name,
+                    ip_address=self.ip_address,
+                    port=self.port,
+                    pwd=self.pwd,
+                    home=self.home )
 
-            self.name = self.options['name']
-            self.handle = super(OnosDriver,self).connect(
-                    user_name = self.user_name, 
-                    ip_address = self.ip_address,
-                    port = self.port, 
-                    pwd = self.pwd, 
-                    home = self.home)
-           
-            self.handle.sendline("cd "+ self.home)
-            self.handle.expect("\$")
+            self.handle.sendline( "cd " + self.home )
+            self.handle.expect( "\$" )
             if self.handle:
                 return self.handle
-            else :
-                main.log.info("NO ONOS HANDLE")
+            else:
+                main.log.info( "NO ONOS HANDLE" )
                 return main.FALSE
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                self.name +
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.log.error( traceback.print_exc() )
-            main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.cleanup()
             main.exit()
 
-    def disconnect(self):
-        '''
+    def disconnect( self ):
+        """
         Called when Test is complete to disconnect the ONOS handle.
-        '''
+        """
         response = ''
         try:
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline("exit")
-            self.handle.expect("closed")
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "exit" )
+            self.handle.expect( "closed" )
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
         except:
-            main.log.error(self.name + ": Connection failed to the host")
+            main.log.error( self.name + ": Connection failed to the host" )
             response = main.FALSE
         return response
 
-    def onos_package(self):
-        '''
+    def onos_package( self ):
+        """
         Produce a self-contained tar.gz file that can be deployed
-        and executed on any platform with Java 7 JRE. 
-        '''
-        
+        and executed on any platform with Java 7 JRE.
+        """
         try:
-            self.handle.sendline("onos-package")
-            self.handle.expect("onos-package")
-            self.handle.expect("tar.gz",timeout=30)
-            handle = str(self.handle.before)
-            main.log.info("onos-package command returned: "+
-                    handle)
-            #As long as the sendline does not time out, 
-            #return true. However, be careful to interpret
-            #the results of the onos-package command return
+            self.handle.sendline( "onos-package" )
+            self.handle.expect( "onos-package" )
+            self.handle.expect( "tar.gz", timeout=30 )
+            handle = str( self.handle.before )
+            main.log.info( "onos-package command returned: " +
+                           handle )
+            # As long as the sendline does not time out,
+            # return true. However, be careful to interpret
+            # the results of the onos-package command return
             return main.TRUE
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
         except:
-            main.log.error("Failed to package ONOS")
+            main.log.error( "Failed to package ONOS" )
             main.cleanup()
             main.exit()
 
-    def onos_build(self):
-        '''
+    def onos_build( self ):
+        """
         Use the pre defined script to build onos via mvn
-        '''
-        
+        """
         try:
-            self.handle.sendline("onos-build")
-            self.handle.expect("onos-build")
-            i = self.handle.expect([
-                "BUILD SUCCESS",
-                "ERROR",
-                "BUILD FAILED"], timeout=120)
-            handle = str(self.handle.before)
+            self.handle.sendline( "onos-build" )
+            self.handle.expect( "onos-build" )
+            i = self.handle.expect( [
+                                    "BUILD SUCCESS",
+                                    "ERROR",
+                                    "BUILD FAILED" ],
+                                    timeout=120 )
+            handle = str( self.handle.before )
 
-            main.log.info("onos-build command returned: "+
-                    handle)
+            main.log.info( "onos-build command returned: " +
+                           handle )
 
             if i == 0:
                 return main.TRUE
@@ -141,862 +142,920 @@
                 return handle
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
         except:
-            main.log.error("Failed to build ONOS")
+            main.log.error( "Failed to build ONOS" )
             main.cleanup()
             main.exit()
 
-    def clean_install(self):
-        '''
-        Runs mvn clean install in the root of the ONOS directory. 
-        This will clean all ONOS artifacts then compile each module 
+    def clean_install( self ):
+        """
+        Runs mvn clean install in the root of the ONOS directory.
+        This will clean all ONOS artifacts then compile each module
 
-        Returns: main.TRUE on success 
+        Returns: main.TRUE on success
         On Failure, exits the test
-        '''
+        """
         try:
-            main.log.info("Running 'mvn clean install' on " + str(self.name) + 
-                    ". This may take some time.") 
-            self.handle.sendline("cd "+ self.home)
-            self.handle.expect("\$")
+            main.log.info( "Running 'mvn clean install' on " + str( self.name ) +
+                           ". This may take some time." )
+            self.handle.sendline( "cd " + self.home )
+            self.handle.expect( "\$" )
 
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline("mvn clean install")
-            self.handle.expect("mvn clean install")
-            while 1:
-                i=self.handle.expect([
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "mvn clean install" )
+            self.handle.expect( "mvn clean install" )
+            while True:
+                i = self.handle.expect( [
                     'There\sis\sinsufficient\smemory\sfor\sthe\sJava\s\
                             Runtime\sEnvironment\sto\scontinue',
                     'BUILD\sFAILURE',
                     'BUILD\sSUCCESS',
                     'ONOS\$',
-                    pexpect.TIMEOUT],timeout=600)
+                    pexpect.TIMEOUT ], timeout=600 )
                 if i == 0:
-                    main.log.error(self.name + ":There is insufficient memory \
-                            for the Java Runtime Environment to continue.")
-                    #return main.FALSE
+                    main.log.error( self.name + ":There is insufficient memory \
+                            for the Java Runtime Environment to continue." )
+                    # return main.FALSE
                     main.cleanup()
                     main.exit()
                 if i == 1:
-                    main.log.error(self.name + ": Build failure!")
-                    #return main.FALSE
+                    main.log.error( self.name + ": Build failure!" )
+                    # return main.FALSE
                     main.cleanup()
                     main.exit()
                 elif i == 2:
-                    main.log.info(self.name + ": Build success!")
+                    main.log.info( self.name + ": Build success!" )
                 elif i == 3:
-                    main.log.info(self.name + ": Build complete")
-                    #Print the build time
+                    main.log.info( self.name + ": Build complete" )
+                    # Print the build time
                     for line in self.handle.before.splitlines():
                         if "Total time:" in line:
-                            main.log.info(line)
-                    self.handle.sendline("")
-                    self.handle.expect("\$", timeout=60)
+                            main.log.info( line )
+                    self.handle.sendline( "" )
+                    self.handle.expect( "\$", timeout=60 )
                     return main.TRUE
                 elif i == 4:
-                    main.log.error(self.name + ": mvn clean install TIMEOUT!")
-                    #return main.FALSE
+                    main.log.error(
+                        self.name +
+                        ": mvn clean install TIMEOUT!" )
+                    # return main.FALSE
                     main.cleanup()
                     main.exit()
                 else:
-                    main.log.error(self.name + ": unexpected response from \
-                            mvn clean install")
-                    #return main.FALSE
+                    main.log.error( self.name + ": unexpected response from \
+                            mvn clean install" )
+                    # return main.FALSE
                     main.cleanup()
                     main.exit()
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                self.name +
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.log.error( traceback.print_exc() )
-            main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.cleanup()
             main.exit()
 
-    def git_pull(self, comp1=""):
-        '''
+    def git_pull( self, comp1="" ):
+        """
         Assumes that "git pull" works without login
 
         This function will perform a git pull on the ONOS instance.
-        If used as git_pull("NODE") it will do git pull + NODE. This is
+        If used as git_pull( "NODE" ) it will do git pull + NODE. This is
         for the purpose of pulling from other nodes if necessary.
 
         Otherwise, this function will perform a git pull in the
         ONOS repository. If it has any problems, it will return main.ERROR
-        If it successfully does a git_pull, it will return a 1 (main.TRUE)
+        If it successfully does a git_pull, it will return a 1 ( main.TRUE )
         If it has no updates, it will return 3.
 
-        '''
+        """
         try:
-            # main.log.info(self.name + ": Stopping ONOS")
-            #self.stop()
-            self.handle.sendline("cd " + self.home)
-            self.handle.expect("ONOS\$")
-            if comp1=="":
-                self.handle.sendline("git pull")
+            # main.log.info( self.name + ": Stopping ONOS" )
+            # self.stop()
+            self.handle.sendline( "cd " + self.home )
+            self.handle.expect( "ONOS\$" )
+            if comp1 == "":
+                self.handle.sendline( "git pull" )
             else:
-                self.handle.sendline("git pull " + comp1)
+                self.handle.sendline( "git pull " + comp1 )
 
-            i=self.handle.expect(['fatal',
-                'Username\sfor\s(.*):\s',
-                '\sfile(s*) changed,\s',
-                'Already up-to-date',
-                'Aborting',
-                'You\sare\snot\scurrently\son\sa\sbranch',
-                'You\sasked\sme\sto\spull\swithout\stelling\sme\swhich\sbranch\syou',
-                'Pull\sis\snot\spossible\sbecause\syou\shave\sunmerged\sfiles',
-                pexpect.TIMEOUT],
-                timeout=300)
-            #debug
-           #main.log.report(self.name +": DEBUG:  \n"+"git pull response: " + str(self.handle.before) + str(self.handle.after))
-            if i==0:
-                main.log.error(self.name + ": Git pull had some issue...")
+            i = self.handle.expect( [ 'fatal',
+                                    'Username\sfor\s(.*):\s',
+                                      '\sfile(s*) changed,\s',
+                                      'Already up-to-date',
+                                      'Aborting',
+                                      'You\sare\snot\scurrently\son\sa\sbranch',
+                                      'You\sasked\sme\sto\spull\swithout\stelling\sme\swhich\sbranch\syou',
+                                      'Pull\sis\snot\spossible\sbecause\syou\shave\sunmerged\sfiles',
+                                      pexpect.TIMEOUT ],
+                                    timeout=300 )
+            # debug
+           # main.log.report( self.name +": DEBUG:  \n"+"git pull response: " +
+           # str( self.handle.before ) + str( self.handle.after ) )
+            if i == 0:
+                main.log.error( self.name + ": Git pull had some issue..." )
                 return main.ERROR
-            elif i==1:
-                main.log.error(self.name + ": Git Pull Asking for username. ")
+            elif i == 1:
+                main.log.error(
+                    self.name +
+                    ": Git Pull Asking for username. " )
                 return main.ERROR
-            elif i==2:
-                main.log.info(self.name + ": Git Pull - pulling repository now")
-                self.handle.expect("ONOS\$", 120)
-                return main.TRUE # So that only when git pull is done, we do mvn clean compile
-            elif i==3:
-                main.log.info(self.name + ": Git Pull - Already up to date")
+            elif i == 2:
+                main.log.info(
+                    self.name +
+                    ": Git Pull - pulling repository now" )
+                self.handle.expect( "ONOS\$", 120 )
+                return main.TRUE  # So that only when git pull is done, we do mvn clean compile
+            elif i == 3:
+                main.log.info( self.name + ": Git Pull - Already up to date" )
                 return i
-            elif i==4:
-                main.log.info(self.name + ": Git Pull - Aborting... Are there conflicting git files?")
+            elif i == 4:
+                main.log.info(
+                    self.name +
+                    ": Git Pull - Aborting... Are there conflicting git files?" )
                 return main.ERROR
-            elif i==5:
-                main.log.info(self.name + ": Git Pull - You are not currently on a branch so git pull failed!")
+            elif i == 5:
+                main.log.info(
+                    self.name +
+                    ": Git Pull - You are not currently on a branch so git pull failed!" )
                 return main.ERROR
-            elif i==6:
-                main.log.info(self.name + ": Git Pull - You have not configured an upstream branch to pull from. Git pull failed!")
+            elif i == 6:
+                main.log.info(
+                    self.name +
+                    ": Git Pull - You have not configured an upstream branch to pull from. Git pull failed!" )
                 return main.ERROR
-            elif i==7:
-                main.log.info(self.name + ": Git Pull - Pull is not possible because you have unmerged files.")
+            elif i == 7:
+                main.log.info(
+                    self.name +
+                    ": Git Pull - Pull is not possible because you have unmerged files." )
                 return main.ERROR
-            elif i==8:
-                main.log.error(self.name + ": Git Pull - TIMEOUT")
-                main.log.error(self.name + " Response was: " + str(self.handle.before))
+            elif i == 8:
+                main.log.error( self.name + ": Git Pull - TIMEOUT" )
+                main.log.error(
+                    self.name + " Response was: " + str(
+                        self.handle.before ) )
                 return main.ERROR
             else:
-                main.log.error(self.name + ": Git Pull - Unexpected response, check for pull errors")
+                main.log.error(
+                    self.name +
+                    ": Git Pull - Unexpected response, check for pull errors" )
                 return main.ERROR
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                self.name +
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.log.error( traceback.print_exc() )
-            main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.cleanup()
             main.exit()
 
-    def git_checkout(self, branch="master"):
-        '''
+    def git_checkout( self, branch="master" ):
+        """
         Assumes that "git pull" works without login
-        
+
         This function will perform a git git checkout on the ONOS instance.
-        If used as git_checkout("branch") it will do git checkout of the "branch".
+        If used as git_checkout( "branch" ) it will do git checkout of the "branch".
 
         Otherwise, this function will perform a git checkout of the master
-        branch of the ONOS repository. If it has any problems, it will return 
-        main.ERROR. 
-        If the branch was already the specified branch, or the git checkout was 
+        branch of the ONOS repository. If it has any problems, it will return
+        main.ERROR.
+        If the branch was already the specified branch, or the git checkout was
         successful then the function will return main.TRUE.
 
-        '''
+        """
         try:
-            self.handle.sendline("cd " + self.home)
-            self.handle.expect("ONOS\$")
-            main.log.info(self.name + ": Checking out git branch: " + branch + "...")
-            cmd = "git checkout "+branch
-            self.handle.sendline(cmd)
-            self.handle.expect(cmd)
-            i=self.handle.expect(['fatal',
-                'Username\sfor\s(.*):\s',
-                'Already\son\s\'',
-                'Switched\sto\sbranch\s\'' + str(branch), 
-                pexpect.TIMEOUT,
-                'error: Your local changes to the following files would be overwritten by checkout:',
-                'error: you need to resolve your current index first'],timeout=60)
+            self.handle.sendline( "cd " + self.home )
+            self.handle.expect( "ONOS\$" )
+            main.log.info(
+                self.name +
+                ": Checking out git branch: " +
+                branch +
+                "..." )
+            cmd = "git checkout " + branch
+            self.handle.sendline( cmd )
+            self.handle.expect( cmd )
+            i = self.handle.expect( [ 'fatal',
+                                    'Username\sfor\s(.*):\s',
+                                      'Already\son\s\'',
+                                      'Switched\sto\sbranch\s\'' +
+                                          str( branch ),
+                                      pexpect.TIMEOUT,
+                                      'error: Your local changes to the following files would be overwritten by checkout:',
+                                      'error: you need to resolve your current index first' ], timeout=60 )
 
-            if i==0:
-                main.log.error(self.name + ": Git checkout had some issue...")
-                main.log.error(self.name + ":     " + self.handle.before)
+            if i == 0:
+                main.log.error(
+                    self.name +
+                    ": Git checkout had some issue..." )
+                main.log.error( self.name + ":     " + self.handle.before )
                 return main.ERROR
-            elif i==1:
-                main.log.error(self.name + ": Git checkout asking for username."\
-                        +" Please configure your local git repository to be able "\
-                        +"to access your remote repository passwordlessly")
+            elif i == 1:
+                main.log.error( self.name + ": Git checkout asking for username."
+                                + " Please configure your local git repository to be able "
+                                + "to access your remote repository passwordlessly" )
                 return main.ERROR
-            elif i==2:
-                main.log.info(self.name + ": Git Checkout %s : Already on this branch" %branch)
-                self.handle.expect("ONOS\$")
-                #main.log.info("DEBUG: after checkout cmd = "+ self.handle.before)
+            elif i == 2:
+                main.log.info(
+                    self.name +
+                    ": Git Checkout %s : Already on this branch" %
+                    branch )
+                self.handle.expect( "ONOS\$" )
+                # main.log.info( "DEBUG: after checkout cmd = "+
+                # self.handle.before )
                 return main.TRUE
-            elif i==3:
-                main.log.info(self.name + ": Git checkout %s - Switched to this branch" %branch)
-                self.handle.expect("ONOS\$")
-                #main.log.info("DEBUG: after checkout cmd = "+ self.handle.before)
+            elif i == 3:
+                main.log.info(
+                    self.name +
+                    ": Git checkout %s - Switched to this branch" %
+                    branch )
+                self.handle.expect( "ONOS\$" )
+                # main.log.info( "DEBUG: after checkout cmd = "+
+                # self.handle.before )
                 return main.TRUE
-            elif i==4:
-                main.log.error(self.name + ": Git Checkout- TIMEOUT")
-                main.log.error(self.name + " Response was: " + str(self.handle.before))
+            elif i == 4:
+                main.log.error( self.name + ": Git Checkout- TIMEOUT" )
+                main.log.error(
+                    self.name + " Response was: " + str(
+                        self.handle.before ) )
                 return main.ERROR
-            elif i==5:
-                self.handle.expect("Aborting")
-                main.log.error(self.name + ": Git checkout error: \n" + \
-                        "Your local changes to the following files would be overwritten by checkout:" + \
-                        str(self.handle.before))
-                self.handle.expect("ONOS\$")
+            elif i == 5:
+                self.handle.expect( "Aborting" )
+                main.log.error( self.name + ": Git checkout error: \n" +
+                                "Your local changes to the following files would be overwritten by checkout:" +
+                                str( self.handle.before ) )
+                self.handle.expect( "ONOS\$" )
                 return main.ERROR
-            elif i==6:
-                main.log.error(self.name + ": Git checkout error: \n" + \
-                        "You need to resolve your current index first:" + \
-                        str(self.handle.before))
-                self.handle.expect("ONOS\$")
+            elif i == 6:
+                main.log.error( self.name + ": Git checkout error: \n" +
+                                "You need to resolve your current index first:" +
+                                str( self.handle.before ) )
+                self.handle.expect( "ONOS\$" )
                 return main.ERROR
             else:
-                main.log.error(self.name + ": Git Checkout - Unexpected response, check for pull errors")
-                main.log.error(self.name + ":     " + self.handle.before)
+                main.log.error(
+                    self.name +
+                    ": Git Checkout - Unexpected response, check for pull errors" )
+                main.log.error( self.name + ":     " + self.handle.before )
                 return main.ERROR
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                self.name +
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.log.error( traceback.print_exc() )
-            main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.cleanup()
             main.exit()
 
-    def get_version(self, report=False):
-        '''
+    def get_version( self, report=False ):
+        """
         Writes the COMMIT number to the report to be parsed by Jenkins data collecter.
-        '''
+        """
         try:
-            self.handle.sendline("export TERM=xterm-256color")
-            self.handle.expect("xterm-256color")
-            self.handle.expect("\$")
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline("cd " + self.home + "; git log -1 --pretty=fuller --decorate=short | grep -A 6 \"commit\" --color=never")
-            #NOTE: for some reason there are backspaces inserted in this phrase when run from Jenkins on some tests
-            self.handle.expect("never")
-            self.handle.expect("\$")
-            response=(self.name +": \n"+ str(self.handle.before + self.handle.after))
-            self.handle.sendline("cd " + self.home)
-            self.handle.expect("\$")
-            lines=response.splitlines()
+            self.handle.sendline( "export TERM=xterm-256color" )
+            self.handle.expect( "xterm-256color" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline(
+                "cd " +
+                self.home +
+                "; git log -1 --pretty=fuller --decorate=short | grep -A 6 \"commit\" --color=never" )
+            # NOTE: for some reason there are backspaces inserted in this
+            # phrase when run from Jenkins on some tests
+            self.handle.expect( "never" )
+            self.handle.expect( "\$" )
+            response = ( self.name + ": \n" + str(
+                self.handle.before + self.handle.after ) )
+            self.handle.sendline( "cd " + self.home )
+            self.handle.expect( "\$" )
+            lines = response.splitlines()
             for line in lines:
                 print line
             if report:
-                for line in lines[2:-1]:
-                    #Bracket replacement is for Wiki-compliant
-                    #formatting. '<' or '>' are interpreted 
-                    #as xml specific tags that cause errors
-                    line = line.replace("<","[")
-                    line = line.replace(">","]")
-                    main.log.report("\t" + line)
-            return lines[2]
+                for line in lines[ 2:-1 ]:
+                    # Bracket replacement is for Wiki-compliant
+                    # formatting. '<' or '>' are interpreted
+                    # as xml specific tags that cause errors
+                    line = line.replace( "<", "[" )
+                    line = line.replace( ">", "]" )
+                    main.log.report( "\t" + line )
+            return lines[ 2 ]
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanup()
             main.exit()
         except pexpect.TIMEOUT:
-            main.log.error(self.name + ": TIMEOUT exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": TIMEOUT exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                self.name +
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.log.error( traceback.print_exc() )
-            main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
+            main.log.info(
+                ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" )
             main.cleanup()
             main.exit()
 
-    def create_cell_file(self, bench_ip, file_name, mn_ip_addrs,
-            extra_feature_string, *onos_ip_addrs):
-        '''
+    def create_cell_file( self, bench_ip, file_name, mn_ip_addrs,
+                          extra_feature_string, *onos_ip_addrs ):
+        """
         Creates a cell file based on arguments
         Required:
-            * Bench IP address (bench_ip)
+            * Bench IP address ( bench_ip )
                 - Needed to copy the cell file over
-            * File name of the cell file (file_name)
-            * Mininet IP address (mn_ip_addrs)
-                - Note that only 1 ip address is 
+            * File name of the cell file ( file_name )
+            * Mininet IP address ( mn_ip_addrs )
+                - Note that only 1 ip address is
                   supported currently
-            * ONOS IP addresses (onos_ip_addrs) 
+            * ONOS IP addresses ( onos_ip_addrs )
                 - Must be passed in as last arguments
-        
+
         NOTE: Assumes cells are located at:
             ~/<self.home>/tools/test/cells/
-        '''
-        
-        #Variable initialization
+        """
+        # Variable initialization
         cell_directory = self.home + "/tools/test/cells/"
-        #We want to create the cell file in the dependencies directory
-        #of TestON first, then copy over to ONOS bench
+        # We want to create the cell file in the dependencies directory
+        # of TestON first, then copy over to ONOS bench
         temp_directory = "/tmp/"
-        #Create the cell file in the directory for writing (w+)
-        cell_file = open(temp_directory+file_name , 'w+')
-       
-        #Feature string is hardcoded environment variables
-        #That you may wish to use by default on startup.
-        #Note that you  may not want certain features listed
-        #on here.
-        core_feature_string = "export ONOS_FEATURES=webconsole,onos-api,"+\
-                "onos-cli,onos-openflow,"+extra_feature_string
+        # Create the cell file in the directory for writing ( w+ )
+        cell_file = open( temp_directory + file_name, 'w+' )
+
+        # Feature string is hardcoded environment variables
+        # That you may wish to use by default on startup.
+        # Note that you  may not want certain features listed
+        # on here.
+        core_feature_string = "export ONOS_FEATURES=webconsole,onos-api," +\
+            "onos-cli,onos-openflow," + extra_feature_string
         mn_string = "export OCN="
         onos_string = "export OC"
         temp_count = 1
-   
-        #Create ONOS_NIC ip address prefix
-        temp_onos_ip = onos_ip_addrs[0] 
+
+        # Create ONOS_NIC ip address prefix
+        temp_onos_ip = onos_ip_addrs[ 0 ]
         temp_list = []
-        temp_list = temp_onos_ip.split(".")
-        #Omit last element of list to format for NIC
-        temp_list = temp_list[:-1]
-        #Structure the nic string ip
-        nic_addr = ".".join(temp_list) + ".*"
-        onos_nic_string = "export ONOS_NIC="+nic_addr
+        temp_list = temp_onos_ip.split( "." )
+        # Omit last element of list to format for NIC
+        temp_list = temp_list[ :-1 ]
+        # Structure the nic string ip
+        nic_addr = ".".join( temp_list ) + ".*"
+        onos_nic_string = "export ONOS_NIC=" + nic_addr
 
         try:
-            #Start writing to file
-            cell_file.write(onos_nic_string + "\n") 
+            # Start writing to file
+            cell_file.write( onos_nic_string + "\n" )
 
             for arg in onos_ip_addrs:
-                #For each argument in onos_ip_addrs, write to file
-                #Output should look like the following:
+                # For each argument in onos_ip_addrs, write to file
+                # Output should look like the following:
                 #   export OC1="10.128.20.11"
                 #   export OC2="10.128.20.12"
-                cell_file.write(onos_string + str(temp_count) +
-                        "=" + "\"" + arg + "\"" + "\n" )
+                cell_file.write( onos_string + str( temp_count ) +
+                                 "=" + "\"" + arg + "\"" + "\n" )
                 temp_count = temp_count + 1
-            
-            cell_file.write(mn_string +"\""+ mn_ip_addrs +"\""+ "\n") 
-            cell_file.write(core_feature_string + "\n")
+
+            cell_file.write( mn_string + "\"" + mn_ip_addrs + "\"" + "\n" )
+            cell_file.write( core_feature_string + "\n" )
             cell_file.close()
 
-            #We use os.system to send the command to TestON cluster
-            #to account for the case in which TestON is not located
-            #on the same cluster as the ONOS bench
-            #Note that even if TestON is located on the same cluster
-            #as ONOS bench, you must setup passwordless ssh
-            #between TestON and ONOS bench in order to automate the test.
-            os.system("scp "+temp_directory+file_name+
-                    " admin@"+bench_ip+":"+cell_directory)
+            # We use os.system to send the command to TestON cluster
+            # to account for the case in which TestON is not located
+            # on the same cluster as the ONOS bench
+            # Note that even if TestON is located on the same cluster
+            # as ONOS bench, you must setup passwordless ssh
+            # between TestON and ONOS bench in order to automate the test.
+            os.system( "scp " + temp_directory + file_name +
+                       " admin@" + bench_ip + ":" + cell_directory )
 
             return main.TRUE
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name + ":::::::::")
+            main.log.info( self.name + ":::::::::" )
             main.log.error( traceback.print_exc() )
-            main.log.info(":::::::")
+            main.log.info( ":::::::" )
             main.cleanup()
             main.exit()
 
-    def set_cell(self, cellname):
-        '''
+    def set_cell( self, cellname ):
+        """
         Calls 'cell <name>' to set the environment variables on ONOSbench
-        '''
+        """
         try:
             if not cellname:
-                main.log.error("Must define cellname")
+                main.log.error( "Must define cellname" )
                 main.cleanup()
                 main.exit()
             else:
-                self.handle.sendline("cell "+str(cellname))
-                #Expect the cellname in the ONOS_CELL variable.
-                #Note that this variable name is subject to change
+                self.handle.sendline( "cell " + str( cellname ) )
+                # Expect the cellname in the ONOS_CELL variable.
+                # Note that this variable name is subject to change
                 #   and that this driver will have to change accordingly
-                self.handle.expect("ONOS_CELL="+str(cellname))
+                self.handle.expect( "ONOS_CELL=" + str( cellname ) )
                 handle_before = self.handle.before
                 handle_after = self.handle.after
-                #Get the rest of the handle
-                self.handle.sendline("")
-                self.handle.expect("\$")
+                # Get the rest of the handle
+                self.handle.sendline( "" )
+                self.handle.expect( "\$" )
                 handle_more = self.handle.before
 
-                main.log.info("Cell call returned: "+handle_before+
-                        handle_after + handle_more)
+                main.log.info( "Cell call returned: " + handle_before +
+                               handle_after + handle_more )
 
                 return main.TRUE
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def verify_cell(self):
-        '''
+    def verify_cell( self ):
+        """
         Calls 'onos-verify-cell' to check for cell installation
-        '''
-        #TODO: Add meaningful expect value
+        """
+        # TODO: Add meaningful expect value
 
         try:
-            #Clean handle by sending empty and expecting $
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline("onos-verify-cell")
-            self.handle.expect("\$")
+            # Clean handle by sending empty and expecting $
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "onos-verify-cell" )
+            self.handle.expect( "\$" )
             handle_before = self.handle.before
             handle_after = self.handle.after
-            #Get the rest of the handle
-            self.handle.sendline("")
-            self.handle.expect("\$")
+            # Get the rest of the handle
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
             handle_more = self.handle.before
 
-            main.log.info("Verify cell returned: "+handle_before+
-                    handle_after + handle_more)
+            main.log.info( "Verify cell returned: " + handle_before +
+                           handle_after + handle_more )
 
             return main.TRUE
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def onos_cli(self, ONOS_ip, cmdstr):
-        '''
+    def onos_cli( self, ONOS_ip, cmdstr ):
+        """
         Uses 'onos' command to send various ONOS CLI arguments.
         Required:
             * ONOS_ip: specify the ip of the cell machine
             * cmdstr: specify the command string to send
-        
-        This function is intended to expose the entire karaf 
+
+        This function is intended to expose the entire karaf
         CLI commands for ONOS. Try to use this function first
         before attempting to write a ONOS CLI specific driver
-        function. 
-        You can see a list of available 'cmdstr' arguments 
+        function.
+        You can see a list of available 'cmdstr' arguments
         by starting onos, and typing in 'onos' to enter the
         onos> CLI. Then, type 'help' to see the list of
-        available commands. 
-        '''
+        available commands.
+        """
         try:
             if not ONOS_ip:
-                main.log.error("You must specify the IP address")
+                main.log.error( "You must specify the IP address" )
                 return main.FALSE
             if not cmdstr:
-                main.log.error("You must specify the command string")
+                main.log.error( "You must specify the command string" )
                 return main.FALSE
 
-            cmdstr = str(cmdstr)
-            self.handle.sendline("")
-            self.handle.expect("\$")
+            cmdstr = str( cmdstr )
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
 
-            self.handle.sendline("onos -w " + ONOS_ip + " " + cmdstr)
-            self.handle.expect("\$")
+            self.handle.sendline( "onos -w " + ONOS_ip + " " + cmdstr )
+            self.handle.expect( "\$" )
 
             handle_before = self.handle.before
             print "handle_before = ", self.handle.before
-            #handle_after = str(self.handle.after)
+            # handle_after = str( self.handle.after )
 
-            #self.handle.sendline("")
-            #self.handle.expect("\$")
-            #handle_more = str(self.handle.before)
+            # self.handle.sendline( "" )
+            # self.handle.expect( "\$" )
+            # handle_more = str( self.handle.before )
 
-            main.log.info("Command sent successfully")
+            main.log.info( "Command sent successfully" )
 
-            #Obtain return handle that consists of result from 
-            #the onos command. The string may need to be 
-            #configured further. 
-            #return_string = handle_before + handle_after
+            # Obtain return handle that consists of result from
+            # the onos command. The string may need to be
+            # configured further.
+            # return_string = handle_before + handle_after
             return_string = handle_before
             print "return_string = ", return_string
             return return_string
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def onos_install(self, options="-f", node = ""):
-        '''
+    def onos_install( self, options="-f", node="" ):
+        """
         Installs ONOS bits on the designated cell machine.
-        If -f option is provided, it also forces an uninstall. 
-        Presently, install also includes onos-push-bits and 
+        If -f option is provided, it also forces an uninstall.
+        Presently, install also includes onos-push-bits and
         onos-config within.
-        The node option allows you to selectively only push the jar 
+        The node option allows you to selectively only push the jar
         files to certain onos nodes
 
         Returns: main.TRUE on success and main.FALSE on failure
-        '''
+        """
         try:
             if options:
-                self.handle.sendline("onos-install " + options + " " + node)
+                self.handle.sendline( "onos-install " + options + " " + node )
             else:
-                self.handle.sendline("onos-install "+node)
-            self.handle.expect("onos-install ")
-            #NOTE: this timeout may need to change depending on the network and size of ONOS
-            i=self.handle.expect(["Network\sis\sunreachable",
-                "onos\sstart/running,\sprocess",
-                "ONOS\sis\salready\sinstalled",
-                pexpect.TIMEOUT],timeout=60)
+                self.handle.sendline( "onos-install " + node )
+            self.handle.expect( "onos-install " )
+            # NOTE: this timeout may need to change depending on the network
+            # and size of ONOS
+            i = self.handle.expect( [ "Network\sis\sunreachable",
+                                    "onos\sstart/running,\sprocess",
+                                      "ONOS\sis\salready\sinstalled",
+                                      pexpect.TIMEOUT ], timeout=60 )
 
             if i == 0:
-                main.log.warn("Network is unreachable")
+                main.log.warn( "Network is unreachable" )
                 return main.FALSE
             elif i == 1:
-                main.log.info("ONOS was installed on " + node + " and started")
+                main.log.info(
+                    "ONOS was installed on " +
+                    node +
+                    " and started" )
                 return main.TRUE
             elif i == 2:
-                main.log.info("ONOS is already installed on "+node)
+                main.log.info( "ONOS is already installed on " + node )
                 return main.TRUE
-            elif i == 3: 
-                main.log.info("Installation of ONOS on " + node + " timed out")
+            elif i == 3:
+                main.log.info(
+                    "Installation of ONOS on " +
+                    node +
+                    " timed out" )
                 return main.FALSE
 
-    
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def onos_start(self, node_ip):
-        '''
+    def onos_start( self, node_ip ):
+        """
         Calls onos command: 'onos-service [<node-ip>] start'
         This command is a remote management of the ONOS upstart daemon
-        '''
-
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline("onos-service "+str(node_ip)+
-                " start")
-            i = self.handle.expect([
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "onos-service " + str( node_ip ) +
+                                  " start" )
+            i = self.handle.expect( [
                 "Job\sis\salready\srunning",
                 "start/running",
                 "Unknown\sinstance",
-                pexpect.TIMEOUT],timeout=120)
+                pexpect.TIMEOUT ], timeout=120 )
 
             if i == 0:
-                main.log.info("Service is already running")
+                main.log.info( "Service is already running" )
                 return main.TRUE
             elif i == 1:
-                main.log.info("ONOS service started")
+                main.log.info( "ONOS service started" )
                 return main.TRUE
             else:
-                main.log.error("ONOS service failed to start")
+                main.log.error( "ONOS service failed to start" )
                 main.cleanup()
                 main.exit()
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def onos_stop(self, node_ip):
-        '''
+    def onos_stop( self, node_ip ):
+        """
         Calls onos command: 'onos-service [<node-ip>] stop'
         This command is a remote management of the ONOS upstart daemon
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline("onos-service "+str(node_ip)+
-                " stop")
-            i = self.handle.expect([
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "onos-service " + str( node_ip ) +
+                                  " stop" )
+            i = self.handle.expect( [
                 "stop/waiting",
                 "Unknown\sinstance",
-                pexpect.TIMEOUT],timeout=60)
+                pexpect.TIMEOUT ], timeout=60 )
 
             if i == 0:
-                main.log.info("ONOS service stopped")
+                main.log.info( "ONOS service stopped" )
                 return main.TRUE
             elif i == 1:
-                main.log.info("Unknown ONOS instance specified: "+
-                        str(node_ip))
+                main.log.info( "Unknown ONOS instance specified: " +
+                               str( node_ip ) )
                 return main.FALSE
             else:
-                main.log.error("ONOS service failed to stop")
+                main.log.error( "ONOS service failed to stop" )
                 return main.FALSE
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
-    
-    def onos_uninstall(self, node_ip=""):
-        '''
+
+    def onos_uninstall( self, node_ip="" ):
+        """
         Calls the command: 'onos-uninstall'
-        Uninstalls ONOS from the designated cell machine, stopping 
+        Uninstalls ONOS from the designated cell machine, stopping
         if needed
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline( "onos-uninstall "+str(node_ip) )
-            self.handle.expect("\$")
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "onos-uninstall " + str( node_ip ) )
+            self.handle.expect( "\$" )
 
-            main.log.info("ONOS "+node_ip+" was uninstalled")
+            main.log.info( "ONOS " + node_ip + " was uninstalled" )
 
-            #onos-uninstall command does not return any text
+            # onos-uninstall command does not return any text
             return main.TRUE
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def onos_die(self, node_ip):
-        '''
+    def onos_die( self, node_ip ):
+        """
         Issues the command 'onos-die <node-ip>'
         This command calls onos-kill and also stops the node
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            cmd_str = "onos-kill "+str(node_ip)
-            self.handle.sendline(cmd_str)
-            i = self.handle.expect([
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            cmd_str = "onos-kill " + str( node_ip )
+            self.handle.sendline( cmd_str )
+            i = self.handle.expect( [
                 "Killing\sONOS",
                 "ONOS\sprocess\sis\snot\srunning",
-                pexpect.TIMEOUT], timeout=20)
+                pexpect.TIMEOUT ], timeout=20 )
             if i == 0:
-                main.log.info("ONOS instance "+str(node_ip)+
-                    " was killed and stopped")
+                main.log.info( "ONOS instance " + str( node_ip ) +
+                               " was killed and stopped" )
                 return main.TRUE
             elif i == 1:
-                main.log.info("ONOS process was not running")
+                main.log.info( "ONOS process was not running" )
                 return main.FALSE
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-
-    def onos_kill(self, node_ip):
-        '''
+    def onos_kill( self, node_ip ):
+        """
         Calls the command: 'onos-kill [<node-ip>]'
         "Remotely, and unceremoniously kills the ONOS instance running on
         the specified cell machine" - Tom V
-        '''
-        
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline("onos-kill " + str(node_ip))
-            i = self.handle.expect([
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "onos-kill " + str( node_ip ) )
+            i = self.handle.expect( [
                 "\$",
                 "No\sroute\sto\shost",
                 "password:",
-                pexpect.TIMEOUT], timeout=20)
-            
+                pexpect.TIMEOUT ], timeout=20 )
+
             if i == 0:
-                main.log.info("ONOS instance "+str(node_ip)+" was killed")
+                main.log.info(
+                    "ONOS instance " + str(
+                        node_ip ) + " was killed" )
                 return main.TRUE
             elif i == 1:
-                main.log.info("No route to host")
+                main.log.info( "No route to host" )
                 return main.FALSE
             elif i == 2:
-                main.log.info("Passwordless login for host: "+str(node_ip)+
-                        " not configured")
+                main.log.info( "Passwordless login for host: " + str( node_ip ) +
+                               " not configured" )
                 return main.FALSE
             else:
-                main.log.info("ONOS instasnce was not killed")
+                main.log.info( "ONOS instasnce was not killed" )
                 return main.FALSE
-        
+
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def onos_remove_raft_logs(self):
-        '''
+    def onos_remove_raft_logs( self ):
+        """
         Removes Raft / Copy cat files from ONOS to ensure
         a cleaner environment.
 
         Description:
             Stops all ONOS defined in the cell,
             wipes the raft / copycat log files
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline("onos-remove-raft-logs")
-            #Sometimes this command hangs
-            i = self.handle.expect(["\$", pexpect.TIMEOUT],
-                    timeout=120)
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "onos-remove-raft-logs" )
+            # Sometimes this command hangs
+            i = self.handle.expect( [ "\$", pexpect.TIMEOUT ],
+                                    timeout=120 )
             if i == 1:
-                i = self.handle.expect(["\$", pexpect.TIMEOUT],
-                        timeout=120)
+                i = self.handle.expect( [ "\$", pexpect.TIMEOUT ],
+                                        timeout=120 )
                 if i == 1:
                     return main.FALSE
-            self.handle.sendline("")
-            self.handle.expect("\$")
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
             return main.TRUE
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def onos_start_network(self, mntopo):
-        '''
-        Calls the command 'onos-start-network [<mininet-topo>]
-        "remotely starts the specified topology on the cell's 
+    def onos_start_network( self, mntopo ):
+        """
+        Calls the command 'onos-start-network [ <mininet-topo> ]
+        "remotely starts the specified topology on the cell's
         mininet machine against all controllers configured in the
-        cell." 
+        cell."
         * Specify mininet topology file name for mntopo
         * Topo files should be placed at:
           ~/<your-onos-directory>/tools/test/topos
-        
+
         NOTE: This function will take you to the mininet prompt
-        '''
+        """
         try:
             if not mntopo:
-                main.log.error("You must specify a topo file to execute")
+                main.log.error( "You must specify a topo file to execute" )
                 return main.FALSE
-            
-            mntopo = str(mntopo)
-            self.handle.sendline("")
-            self.handle.expect("\$")
 
-            self.handle.sendline("onos-start-network " + mntopo)
-            self.handle.expect("mininet>")
-            main.log.info("Network started, entered mininet prompt")
+            mntopo = str( mntopo )
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
 
-            #TODO: Think about whether return is necessary or not
+            self.handle.sendline( "onos-start-network " + mntopo )
+            self.handle.expect( "mininet>" )
+            main.log.info( "Network started, entered mininet prompt" )
+
+            # TODO: Think about whether return is necessary or not
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-
-    def isup(self, node = ""):
-        '''
-        Run's onos-wait-for-start which only returns once ONOS is at run 
-        level 100(ready for use)
+    def isup( self, node="" ):
+        """
+        Run's onos-wait-for-start which only returns once ONOS is at run
+        level 100( ready for use )
 
         Returns: main.TRUE if ONOS is running and main.FALSE on timeout
-        '''
+        """
         try:
-            self.handle.sendline("onos-wait-for-start " + node )
-            self.handle.expect("onos-wait-for-start")
-            #NOTE: this timeout is arbitrary"
-            i = self.handle.expect(["\$", pexpect.TIMEOUT], timeout = 120)
+            self.handle.sendline( "onos-wait-for-start " + node )
+            self.handle.expect( "onos-wait-for-start" )
+            # NOTE: this timeout is arbitrary"
+            i = self.handle.expect( [ "\$", pexpect.TIMEOUT ], timeout=120 )
             if i == 0:
-                main.log.info(self.name + ": " + node + " is up")
+                main.log.info( self.name + ": " + node + " is up" )
                 return main.TRUE
             elif i == 1:
-                #NOTE: since this function won't return until ONOS is ready,
+                # NOTE: since this function won't return until ONOS is ready,
                 #   we will kill it on timeout
-                main.log.error("ONOS has not started yet")
-                self.handle.send("\x03")    #Control-C
-                self.handle.expect("\$")
+                main.log.error( "ONOS has not started yet" )
+                self.handle.send( "\x03" )  # Control-C
+                self.handle.expect( "\$" )
                 return main.FALSE
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def push_test_intents_shell(self, dpid_src, dpid_dst, num_intents,
-            dir_file, onos_ip, num_mult="", app_id="", report=True,
-            options=""):    
-        '''  
+    def push_test_intents_shell( self, dpid_src, dpid_dst, num_intents,
+                                 dir_file, onos_ip, num_mult="", app_id="", report=True,
+                                 options="" ):
+        """
         Description:
-            Use the linux prompt to push test intents to 
+            Use the linux prompt to push test intents to
             better parallelize the results than the CLI
         Required:
             * dpid_src: specify source dpid
@@ -1005,105 +1064,107 @@
             * dir_file: specify directory and file name to save
               results
             * onos_ip: specify the IP of ONOS to install on
-        NOTE: 
+        NOTE:
             You must invoke this command at linux shell prompt
-        '''
-        try: 
-            #Create the string to sendline 
+        """
+        try:
+            # Create the string to sendline
             if options:
-                base_cmd = "onos "+str(onos_ip)+" push-test-intents "+\
-                options+" "
+                base_cmd = "onos " + str( onos_ip ) + " push-test-intents " +\
+                    options + " "
             else:
-                base_cmd = "onos "+str(onos_ip)+" push-test-intents "
-            
-            add_dpid = base_cmd + str(dpid_src) + " " + str(dpid_dst)  
+                base_cmd = "onos " + str( onos_ip ) + " push-test-intents "
+
+            add_dpid = base_cmd + str( dpid_src ) + " " + str( dpid_dst )
             if not num_mult:
-                add_intents = add_dpid + " " + str(num_intents)
+                add_intents = add_dpid + " " + str( num_intents )
             elif num_mult:
-                add_intents = add_dpid + " " + str(num_intents) + " " +\
-                              str(num_mult)
+                add_intents = add_dpid + " " + str( num_intents ) + " " +\
+                    str( num_mult )
                 if app_id:
-                    add_app = add_intents + " " + str(app_id) 
+                    add_app = add_intents + " " + str( app_id )
                 else:
                     add_app = add_intents
 
             if report:
-                send_cmd = add_app + " > " + str(dir_file) + " &" 
+                send_cmd = add_app + " > " + str( dir_file ) + " &"
             else:
                 send_cmd = add_app + " &"
-            main.log.info("Send cmd: "+send_cmd)
+            main.log.info( "Send cmd: " + send_cmd )
 
-            self.handle.sendline(send_cmd)
+            self.handle.sendline( send_cmd )
 
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
-            main.exit() 
+            main.exit()
 
-    def get_topology(self,topology_output):
-        '''
+    def get_topology( self, topology_output ):
+        """
         parses the onos:topology output
-        Returns: a topology dict populated by the key values found in 
+        Returns: a topology dict populated by the key values found in
                  the cli command.
-        '''
-
+        """
         try:
-            #call the cli to get the topology summary
-            #cmdstr = "onos:topology"
-            #cli_result = self.onos_cli(ip, cmdstr)
-            #print "cli_result = ", cli_result
+            # call the cli to get the topology summary
+            # cmdstr = "onos:topology"
+            # cli_result = self.onos_cli( ip, cmdstr )
+            # print "cli_result = ", cli_result
 
-            #Parse the output
+            # Parse the output
             topology = {}
-            #for line in cli_result.split("\n"):
+            # for line in cli_result.split( "\n" ):
             for line in topology_output.splitlines():
-                if not line.startswith("time="):
+                if not line.startswith( "time=" ):
                     continue
-                #else
-                #print line
-                for var in line.split(","):
-                    #print "'"+var+"'"
-                    #print "'"+var.strip()+"'"
-                    key, value = var.strip().split("=")
-                    topology[key] = value
-            #print "topology = ", topology
-            #devices = topology.get('devices', False)
-            #print "devices = ", devices
-            #links = topology.get('links', False)
-            #print "links = ", links
-            #SCCs = topology.get('SCC(s)', False)
-            #print "SCCs = ", SCCs
-            #paths = topology.get('paths', False)
-            #print "paths = ", paths
+                # else
+                # print line
+                for var in line.split( "," ):
+                    # print "'"+var+"'"
+                    # print "'"+var.strip()+"'"
+                    key, value = var.strip().split( "=" )
+                    topology[ key ] = value
+            # print "topology = ", topology
+            # devices = topology.get( 'devices', False )
+            # print "devices = ", devices
+            # links = topology.get( 'links', False )
+            # print "links = ", links
+            # SCCs = topology.get( 'SCC(s)', False )
+            # print "SCCs = ", SCCs
+            # paths = topology.get( 'paths', False )
+            # print "paths = ", paths
 
             return topology
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
-    
-   
 
-    def check_status(self, topology_result, numoswitch, numolink, log_level="info"):
-        '''
-        Checks the number of swithes & links that ONOS sees against the 
-        supplied values. By default this will report to main.log, but the 
+    def check_status(
+        self,
+        topology_result,
+        numoswitch,
+        numolink,
+        log_level="info" ):
+        """
+        Checks the number of swithes & links that ONOS sees against the
+        supplied values. By default this will report to main.log, but the
         log level can be specifid.
-        
+
         Params: ip = ip used for the onos cli
                 numoswitch = expected number of switches
                 numlink = expected number of links
@@ -1112,283 +1173,280 @@
 
         log_level can
 
-        Returns: main.TRUE if the number of switchs and links are correct, 
+        Returns: main.TRUE if the number of switchs and links are correct,
                  main.FALSE if the numer of switches and links is incorrect,
                  and main.ERROR otherwise
-        '''
-
+        """
         try:
-            topology = self.get_topology(topology_result)
+            topology = self.get_topology( topology_result )
             if topology == {}:
                 return main.ERROR
             output = ""
-            #Is the number of switches is what we expected
-            devices = topology.get('devices',False)
-            links = topology.get('links',False)
+            # Is the number of switches is what we expected
+            devices = topology.get( 'devices', False )
+            links = topology.get( 'links', False )
             if devices == False or links == False:
                 return main.ERROR
-            switch_check = ( int(devices) == int(numoswitch) )
-            #Is the number of links is what we expected
-            link_check = ( int(links) == int(numolink) )
-            if (switch_check and link_check):
-                #We expected the correct numbers
+            switch_check = ( int( devices ) == int( numoswitch ) )
+            # Is the number of links is what we expected
+            link_check = ( int( links ) == int( numolink ) )
+            if ( switch_check and link_check ):
+                # We expected the correct numbers
                 output = output + "The number of links and switches match "\
-                        + "what was expected"
+                    + "what was expected"
                 result = main.TRUE
             else:
                 output = output + \
-                        "The number of links and switches does not match what was expected"
+                    "The number of links and switches does not match what was expected"
                 result = main.FALSE
             output = output + "\n ONOS sees %i devices (%i expected) and %i links (%i expected)"\
-                    % ( int(devices), int(numoswitch), int(links), int(numolink) )
+                % ( int( devices ), int( numoswitch ), int( links ), int( numolink ) )
             if log_level == "report":
-                main.log.report(output)
+                main.log.report( output )
             elif log_level == "warn":
-                main.log.warn(output)
+                main.log.warn( output )
             else:
-                main.log.info(output)
-            return result 
+                main.log.info( output )
+            return result
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def tshark_pcap(self, interface, dir_file):
-        '''
+    def tshark_pcap( self, interface, dir_file ):
+        """
         Capture all packet activity and store in specified
         directory/file
 
         Required:
             * interface: interface to capture
             * dir: directory/filename to store pcap
-        '''
-        self.handle.sendline("")
-        self.handle.expect("\$")
+        """
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
 
-        self.handle.sendline("tshark -i "+str(interface)+
-                " -t e -w "+str(dir_file)+ " &")
-        self.handle.sendline("\r")
-        self.handle.expect("Capturing on")
-        self.handle.sendline("\r")
-        self.handle.expect("\$")
+        self.handle.sendline( "tshark -i " + str( interface ) +
+                              " -t e -w " + str( dir_file ) + " &" )
+        self.handle.sendline( "\r" )
+        self.handle.expect( "Capturing on" )
+        self.handle.sendline( "\r" )
+        self.handle.expect( "\$" )
 
-        main.log.info("Tshark started capturing files on "+
-                str(interface)+ " and saving to directory: "+
-                str(dir_file))
+        main.log.info( "Tshark started capturing files on " +
+                       str( interface ) + " and saving to directory: " +
+                       str( dir_file ) )
 
-
-    def run_onos_topo_cfg(self, instance_name, json_file):
-        '''
+    def run_onos_topo_cfg( self, instance_name, json_file ):
+        """
          On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg $OC1 filename
             which starts the rest and copies the json file to the onos instance
-        '''
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline("cd ~/ONOS/tools/test/bin")
-            self.handle.expect("/bin$")
-            cmd = "./onos-topo-cfg " +instance_name +" " +json_file
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "cd ~/ONOS/tools/test/bin" )
+            self.handle.expect( "/bin$" )
+            cmd = "./onos-topo-cfg " + instance_name + " " + json_file
             print "cmd = ", cmd
-            self.handle.sendline(cmd)
-            self.handle.expect("\$")
-            self.handle.sendline("cd ~")
-            self.handle.expect("\$")
+            self.handle.sendline( cmd )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "cd ~" )
+            self.handle.expect( "\$" )
             return main.TRUE
         except:
             return main.FALSE
-            
-    def tshark_grep(self, grep, directory, interface='eth0'):
-        '''
+
+    def tshark_grep( self, grep, directory, interface='eth0' ):
+        """
         Required:
-            * grep string 
+            * grep string
             * directory to store results
         Optional:
             * interface - default: eth0
         Description:
             Uses tshark command to grep specific group of packets
             and stores the results to specified directory.
-            The timestamp is hardcoded to be in epoch 
-        '''
-        self.handle.sendline("")
-        self.handle.expect("\$")
-        self.handle.sendline("")
-        self.handle.sendline("tshark -i "+str(interface)+
-                " -t e | grep --line-buffered \""+str(grep)+"\" >"+directory+" &")
-        self.handle.sendline("\r")
-        self.handle.expect("Capturing on")
-        self.handle.sendline("\r")
-        self.handle.expect("\$")
+            The timestamp is hardcoded to be in epoch
+        """
+        self.handle.sendline( "" )
+        self.handle.expect( "\$" )
+        self.handle.sendline( "" )
+        self.handle.sendline( "tshark -i " + str( interface ) +
+                              " -t e | grep --line-buffered \"" + str(grep) + "\" >" + directory + " &" )
+        self.handle.sendline( "\r" )
+        self.handle.expect( "Capturing on" )
+        self.handle.sendline( "\r" )
+        self.handle.expect( "\$" )
 
-    def tshark_stop(self):
-        '''
+    def tshark_stop( self ):
+        """
         Removes wireshark files from /tmp and kills all tshark processes
-        '''
-        #Remove all pcap from previous captures
-        self.execute(cmd="sudo rm /tmp/wireshark*")
-        self.handle.sendline("")
-        self.handle.sendline("sudo kill -9 `ps -ef | grep \"tshark -i\" |"+
-                " grep -v grep | awk '{print $2}'`")
-        self.handle.sendline("")
-        main.log.info("Tshark stopped")
+        """
+        # Remove all pcap from previous captures
+        self.execute( cmd="sudo rm /tmp/wireshark*" )
+        self.handle.sendline( "" )
+        self.handle.sendline( "sudo kill -9 `ps -ef | grep \"tshark -i\" |" +
+                              " grep -v grep | awk '{print $2}'`" )
+        self.handle.sendline( "" )
+        main.log.info( "Tshark stopped" )
 
-    def ptpd(self, args):
-        '''
+    def ptpd( self, args ):
+        """
         Initiate ptp with user-specified args.
         Required:
             * args: specify string of args after command
               'sudo ptpd'
-        '''
+        """
         try:
-            self.handle.sendline("sudo ptpd "+str(args))
-            i = self.handle.expect([
+            self.handle.sendline( "sudo ptpd " + str( args ) )
+            i = self.handle.expect( [
                 "Multiple",
                 "Error",
-                "\$"])
-            self.handle.expect("\$")
+                "\$" ] )
+            self.handle.expect( "\$" )
 
             if i == 0:
                 handle = self.handle.before
-                main.log.info("ptpd returned an error: "+
-                    str(handle))
+                main.log.info( "ptpd returned an error: " +
+                               str( handle ) )
                 return handle
             elif i == 1:
                 handle = self.handle.before
-                main.log.error("ptpd returned an error: "+
-                    str(handle))
+                main.log.error( "ptpd returned an error: " +
+                                str( handle ) )
                 return handle
             else:
                 return main.TRUE
-        
+
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
 
-    def cp_logs_to_dir(self, log_to_copy, 
-            dest_dir, copy_file_name=""):
-        '''
-        Copies logs to a desired directory. 
+    def cp_logs_to_dir( self, log_to_copy,
+                        dest_dir, copy_file_name="" ):
+        """
+        Copies logs to a desired directory.
         Current implementation of ONOS deletes its karaf
         logs on every iteration. For debugging purposes,
-        you may want to use this function to capture 
-        certain karaf logs. (or any other logs if needed)
+        you may want to use this function to capture
+        certain karaf logs. ( or any other logs if needed )
         Localtime will be attached to the filename
 
         Required:
             * log_to_copy: specify directory and log name to
               copy.
-              ex) /opt/onos/log/karaf.log.1
+              ex ) /opt/onos/log/karaf.log.1
               For copying multiple files, leave copy_file_name
-              empty and only specify dest_dir - 
-              ex) /opt/onos/log/karaf*
+              empty and only specify dest_dir -
+              ex ) /opt/onos/log/karaf*
             * dest_dir: specify directory to copy to.
-              ex) /tmp/
-        Optional:   
+              ex ) /tmp/
+        Optional:
             * copy_file_name: If you want to rename the log
               file, specify copy_file_name. This will not work
               with multiple file copying
-        '''
+        """
         try:
-            localtime = time.strftime('%x %X')
-            localtime = localtime.replace("/","")
-            localtime = localtime.replace(" ","_")
-            localtime = localtime.replace(":","")
-            if dest_dir[-1:] != "/":
+            localtime = time.strftime( '%x %X' )
+            localtime = localtime.replace( "/", "" )
+            localtime = localtime.replace( " ", "_" )
+            localtime = localtime.replace( ":", "" )
+            if dest_dir[ -1: ] != "/":
                 dest_dir += "/"
 
             if copy_file_name:
-                self.handle.sendline("cp "+str(log_to_copy)+
-                        " "+str(dest_dir)+str(copy_file_name)+
-                        localtime)
-                self.handle.expect("cp")
-                self.handle.expect("\$")
+                self.handle.sendline( "cp " + str( log_to_copy ) +
+                                      " " + str( dest_dir ) + str( copy_file_name ) +
+                                      localtime )
+                self.handle.expect( "cp" )
+                self.handle.expect( "\$" )
             else:
-                self.handle.sendline("cp "+str(log_to_copy)+
-                        " "+str(dest_dir))
-                self.handle.expect("cp")
-                self.handle.expect("\$")
-                
-            return self.handle.before
-        
-        except pexpect.EOF:
-            main.log.error("Copying files failed")
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
-        except:
-            main.log.error("Copying files failed")
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+                self.handle.sendline( "cp " + str( log_to_copy ) +
+                                      " " + str( dest_dir ) )
+                self.handle.expect( "cp" )
+                self.handle.expect( "\$" )
 
-    def check_logs(self, onos_ip):
-        '''
+            return self.handle.before
+
+        except pexpect.EOF:
+            main.log.error( "Copying files failed" )
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+        except:
+            main.log.error( "Copying files failed" )
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
+
+    def check_logs( self, onos_ip ):
+        """
         runs onos-check-logs on the given onos node
         returns the response
-        '''
+        """
         try:
-            cmd = "onos-check-logs " + str(onos_ip)
-            self.handle.sendline(cmd)
-            self.handle.expect(cmd)
-            self.handle.expect("\$")
+            cmd = "onos-check-logs " + str( onos_ip )
+            self.handle.sendline( cmd )
+            self.handle.expect( cmd )
+            self.handle.expect( "\$" )
             response = self.handle.before
             return response
         except pexpect.EOF:
-            main.log.error("Lost ssh connection")
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( "Lost ssh connection" )
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
         except:
-            main.log.error("Some error in check_logs:")
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.error( "Some error in check_logs:" )
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
 
-    def onos_status(self, node=""):
-        '''
+    def onos_status( self, node="" ):
+        """
         Calls onos command: 'onos-service [<node-ip>] status'
-        '''
-
+        """
         try:
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            self.handle.sendline("onos-service "+str(node)+
-                " status")
-            i = self.handle.expect([
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "onos-service " + str( node ) +
+                                  " status" )
+            i = self.handle.expect( [
                 "start/running",
                 "stop/waiting",
-                pexpect.TIMEOUT],timeout=120)
+                pexpect.TIMEOUT ], timeout=120 )
 
             if i == 0:
-                main.log.info("ONOS is running")
+                main.log.info( "ONOS is running" )
                 return main.TRUE
             elif i == 1:
-                main.log.info("ONOS is stopped")
+                main.log.info( "ONOS is stopped" )
                 return main.FALSE
             else:
-                main.log.error("ONOS service failed to check the status")
+                main.log.error( "ONOS service failed to check the status" )
                 main.cleanup()
                 main.exit()
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
             main.cleanup()
             main.exit()
         except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
             main.cleanup()
             main.exit()
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py b/TestON/drivers/common/cli/quaggaclidriver.py
index 8314941..28f95af 100644
--- a/TestON/drivers/common/cli/quaggaclidriver.py
+++ b/TestON/drivers/common/cli/quaggaclidriver.py
@@ -2,93 +2,111 @@
 
 import time
 import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
+import sys
+import signal
 import sys
 import re
 import json
-sys.path.append("../")
+sys.path.append( "../" )
 from drivers.common.clidriver import CLI
 
-class QuaggaCliDriver(CLI):
 
-    def __init__(self):
-        super(CLI, self).__init__()
+class QuaggaCliDriver( CLI ):
+
+    def __init__( self ):
+        super( CLI, self ).__init__()
 
     # TODO: simplify this method
-    def connect(self, **connectargs):
+    def connect( self, **connectargs ):
         for key in connectargs:
-            vars(self)[key] = connectargs[key]
+            vars( self )[ key ] = connectargs[ key ]
 
-        self.name = self.options['name']
-        # self.handle = super(QuaggaCliDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
-        self.handle = super(QuaggaCliDriver, self).connect(user_name=self.user_name, ip_address="1.1.1.1", port=self.port, pwd=self.pwd)
-        main.log.info("connect parameters:" + str(self.user_name) + ";" + str(self.ip_address) + ";" + str(self.port) + ";" + str(self.pwd))
+        self.name = self.options[ 'name' ]
+        # self.handle = super( QuaggaCliDriver,self ).connect(
+        # user_name=self.user_name, ip_address=self.ip_address,port=self.port,
+        # pwd=self.pwd )
+        self.handle = super(
+            QuaggaCliDriver,
+            self ).connect(
+                user_name=self.user_name,
+         ip_address="1.1.1.1",
+         port=self.port,
+         pwd=self.pwd )
+        main.log.info(
+            "connect parameters:" + str(
+                self.user_name ) + ";" + str(
+                    self.ip_address ) + ";" + str(
+                 self.port ) + ";" + str(
+                     self.pwd ) )
 
         if self.handle:
-            #self.handle.expect("",timeout=10)
-            #self.handle.expect("\$",timeout=10)
-            self.handle.sendline("telnet localhost 2605")
-            #self.handle.expect("Password:", timeout=5)
-            self.handle.expect("Password:")
-            self.handle.sendline("hello")
-            #self.handle.expect("bgpd", timeout=5)
-            self.handle.expect("bgpd")
-            self.handle.sendline("enable")
-            #self.handle.expect("bgpd#", timeout=5)
-            self.handle.expect("bgpd#")
+            # self.handle.expect( "",timeout=10 )
+            # self.handle.expect( "\$",timeout=10 )
+            self.handle.sendline( "telnet localhost 2605" )
+            # self.handle.expect( "Password:", timeout=5 )
+            self.handle.expect( "Password:" )
+            self.handle.sendline( "hello" )
+            # self.handle.expect( "bgpd", timeout=5 )
+            self.handle.expect( "bgpd" )
+            self.handle.sendline( "enable" )
+            # self.handle.expect( "bgpd#", timeout=5 )
+            self.handle.expect( "bgpd#" )
             return self.handle
-        else :
-            main.log.info("NO HANDLE")
+        else:
+            main.log.info( "NO HANDLE" )
             return main.FALSE
 
-    def loginQuagga(self, ip_address):
-        self.name = self.options['name']
-        self.handle = super(QuaggaCliDriver, self).connect(
+    def loginQuagga( self, ip_address ):
+        self.name = self.options[ 'name' ]
+        self.handle = super( QuaggaCliDriver, self ).connect(
             user_name=self.user_name, ip_address=ip_address,
-            port=self.port, pwd=self.pwd)
-        main.log.info("connect parameters:" + str(self.user_name) + ";"
-        + str(self.ip_address) + ";" + str(self.port) + ";" + str(self.pwd))
+            port=self.port, pwd=self.pwd )
+        main.log.info( "connect parameters:" + str( self.user_name ) + ";"
+                       + str( self.ip_address ) + ";" + str( self.port ) + ";" + str( self.pwd ) )
 
         if self.handle:
-            #self.handle.expect("")
-            #self.handle.expect("\$")
-            self.handle.sendline("telnet localhost 2605")
-            #self.handle.expect("Password:", timeout=5)
-            self.handle.expect("Password:")
-            self.handle.sendline("hello")
-            #self.handle.expect("bgpd", timeout=5)
-            self.handle.expect("bgpd")
-            self.handle.sendline("enable")
-            #self.handle.expect("bgpd#", timeout=5)
-            self.handle.expect("bgpd#")
-            main.log.info("I in quagga on host " + str(ip_address))
+            # self.handle.expect( "" )
+            # self.handle.expect( "\$" )
+            self.handle.sendline( "telnet localhost 2605" )
+            # self.handle.expect( "Password:", timeout=5 )
+            self.handle.expect( "Password:" )
+            self.handle.sendline( "hello" )
+            # self.handle.expect( "bgpd", timeout=5 )
+            self.handle.expect( "bgpd" )
+            self.handle.sendline( "enable" )
+            # self.handle.expect( "bgpd#", timeout=5 )
+            self.handle.expect( "bgpd#" )
+            main.log.info( "I in quagga on host " + str( ip_address ) )
 
             return self.handle
         else:
-            main.log.info("NO HANDLE")
+            main.log.info( "NO HANDLE" )
             return main.FALSE
 
-    def enter_config(self, asn):
-        main.log.info("I am in enter_config method!")
+    def enter_config( self, asn ):
+        main.log.info( "I am in enter_config method!" )
         try:
-            self.handle.sendline("")
-            self.handle.expect("bgpd#")
+            self.handle.sendline( "" )
+            self.handle.expect( "bgpd#" )
         except:
-            main.log.warn("Probably not currently in enable mode!")
+            main.log.warn( "Probably not currently in enable mode!" )
             self.disconnect()
             return main.FALSE
-        self.handle.sendline("configure terminal")
-        self.handle.expect("config", timeout=5)
-        routerAS = "router bgp " + str(asn)
+        self.handle.sendline( "configure terminal" )
+        self.handle.expect( "config", timeout=5 )
+        routerAS = "router bgp " + str( asn )
         try:
-            self.handle.sendline(routerAS)
-            self.handle.expect("config-router", timeout=5)
+            self.handle.sendline( routerAS )
+            self.handle.expect( "config-router", timeout=5 )
             return main.TRUE
         except:
             return main.FALSE
 
-    def generate_prefixes(self, net, numRoutes):
-        main.log.info("I am in generate_prefixes method!")
+    def generate_prefixes( self, net, numRoutes ):
+        main.log.info( "I am in generate_prefixes method!" )
 
         # each IP prefix will be composed by "net" + "." + m + "." + n + "." + x
         # the length of each IP prefix is 24
@@ -97,248 +115,298 @@
         m = numRoutes / 256
         n = numRoutes % 256
 
-        for i in range(0, m):
-            for j in range(0, 256):
-                network = str(net) + "." + str(i) + "." + str(j) + ".0/24"
-                routes.append(network)
+        for i in range( 0, m ):
+            for j in range( 0, 256 ):
+                network = str(
+                    net ) + "." + str(
+                        i ) + "." + str(
+                            j ) + ".0/24"
+                routes.append( network )
                 routes_gen = routes_gen + 1
 
-        for j in range(0, n):
-            network = str(net) + "." + str(m) + "." + str(j) + ".0/24"
-            routes.append(network)
+        for j in range( 0, n ):
+            network = str( net ) + "." + str( m ) + "." + str( j ) + ".0/24"
+            routes.append( network )
             routes_gen = routes_gen + 1
 
         if routes_gen == numRoutes:
-            main.log.info("Successfully generated " + str(numRoutes)
-            + " prefixes!")
+            main.log.info( "Successfully generated " + str( numRoutes )
+                           + " prefixes!" )
             return routes
         return main.FALSE
 
-    # This method generates a multiple to single point intent(MultiPointToSinglePointIntent) for a given route
-    def generate_expected_singleRouteIntent(self, prefix, nextHop, nextHopMac, sdnip_data):
+    # This method generates a multiple to single point intent(
+    # MultiPointToSinglePointIntent ) for a given route
+    def generate_expected_singleRouteIntent( self, prefix, nextHop, nextHopMac, sdnip_data ):
 
         ingress = []
         egress = ""
-        for peer in sdnip_data['bgpPeers']:
-            if peer['ipAddress'] == nextHop:
-                egress = "of:" + str(peer['attachmentDpid']).replace(":", "") + ":" + str(peer['attachmentPort'])
+        for peer in sdnip_data[ 'bgpPeers' ]:
+            if peer[ 'ipAddress' ] == nextHop:
+                egress = "of:" + str( peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" + str( peer[ 'attachmentPort' ] )
             else:
-                ingress.append("of:" + str(peer['attachmentDpid']).replace(":", "") + ":" + str(peer['attachmentPort']))
+                ingress.append( "of:" +  \
+                         str( peer[ 'attachmentDpid' ] ).replace( ":",
+                         "" ) + ":" + str( peer[ 'attachmentPort' ] ) )
 
         selector = "ETH_TYPE{ethType=800},IPV4_DST{ip=" + prefix + "}"
-        treatment = "[ETH_DST{mac=" + str(nextHopMac) + "}]"
+        treatment = "[ETH_DST{mac=" + str( nextHopMac ) + "}]"
 
-        intent = egress + "/" + str(sorted(ingress)) + "/" + selector + "/" + treatment
+        intent = egress + "/" + \
+            str( sorted( ingress ) ) + "/" + selector + "/" + treatment
         return intent
 
-    def generate_expected_onePeerRouteIntents(self, prefixes, nextHop, nextHopMac, sdnip_json_file_path):
+    def generate_expected_onePeerRouteIntents( self, prefixes, nextHop, nextHopMac, sdnip_json_file_path ):
         intents = []
-        sdnip_json_file = open(sdnip_json_file_path).read()
+        sdnip_json_file = open( sdnip_json_file_path ).read()
 
-        sdnip_data = json.loads(sdnip_json_file)
+        sdnip_data = json.loads( sdnip_json_file )
 
         for prefix in prefixes:
-            intents.append(self.generate_expected_singleRouteIntent(prefix, nextHop, nextHopMac, sdnip_data))
-        return sorted(intents)
+            intents.append(
+                self.generate_expected_singleRouteIntent(
+                    prefix,
+                    nextHop,
+                    nextHopMac,
+                    sdnip_data ) )
+        return sorted( intents )
 
     # TODO
     # This method generates all expected route intents for all BGP peers
-    def generate_expected_routeIntents(self):
+    def generate_expected_routeIntents( self ):
         intents = []
         return intents
 
     # This method extracts all actual routes from ONOS CLI
-    def extract_actual_routes(self, get_routes_result):
-        routes_json_obj = json.loads(get_routes_result)
+    def extract_actual_routes( self, get_routes_result ):
+        routes_json_obj = json.loads( get_routes_result )
 
         allRoutes_actual = []
         for route in routes_json_obj:
-            if route['prefix'] == '172.16.10.0/24':
+            if route[ 'prefix' ] == '172.16.10.0/24':
                 continue
-            allRoutes_actual.append(route['prefix'] + "/" + route['nextHop'])
+            allRoutes_actual.append(
+                route[ 'prefix' ] + "/" + route[ 'nextHop' ] )
 
-        return sorted(allRoutes_actual)
+        return sorted( allRoutes_actual )
 
     # This method extracts all actual route intents from ONOS CLI
-    def extract_actual_routeIntents(self, get_intents_result):
+    def extract_actual_routeIntents( self, get_intents_result ):
         intents = []
         # TODO: delete the line below when change to Mininet demo script
-        # get_intents_result=open("../tests/SdnIpTest/intents.json").read()
-        intents_json_obj = json.loads(get_intents_result)
+        # get_intents_result=open( "../tests/SdnIpTest/intents.json" ).read()
+        intents_json_obj = json.loads( get_intents_result )
 
         for intent in intents_json_obj:
-            if intent['appId'] != "org.onosproject.sdnip" :
+            if intent[ 'appId' ] != "org.onosproject.sdnip":
                 continue
-            if intent['type'] == "MultiPointToSinglePointIntent" and intent['state'] == 'INSTALLED':
-                egress = str(intent['egress']['device']) + ":" + str(intent['egress']['port'])
+            if intent[ 'type' ] == "MultiPointToSinglePointIntent" and intent[ 'state' ] == 'INSTALLED':
+                egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + str(
+                    intent[ 'egress' ][ 'port' ] )
                 ingress = []
-                for attachmentPoint in intent['ingress']:
-                    ingress.append(str(attachmentPoint['device']) + ":" + str(attachmentPoint['port']))
+                for attachmentPoint in intent[ 'ingress' ]:
+                    ingress.append(
+                        str( attachmentPoint[ 'device' ] ) + ":" + str( attachmentPoint[ 'port' ] ) )
 
-                selector = intent['selector'].replace("[" , "").replace("]" , "").replace(" ", "")
-                if str(selector).startswith("IPV4"):
-                    str1, str2 = str(selector).split(",")
+                selector = intent[ 'selector' ].replace(
+                    "[", "" ).replace( "]", "" ).replace( " ", "" )
+                if str( selector ).startswith( "IPV4" ):
+                    str1, str2 = str( selector ).split( "," )
                     selector = str2 + "," + str1
 
-                intent = egress + "/" + str(sorted(ingress)) + "/" + selector + "/" + intent['treatment']
-                intents.append(intent)
-        return sorted(intents)
+                intent = egress + "/" + \
+                    str( sorted( ingress ) ) + "/" + \
+                        selector + "/" + intent[ 'treatment' ]
+                intents.append( intent )
+        return sorted( intents )
 
     # This method extracts all actual BGP intents from ONOS CLI
-    def extract_actual_bgpIntents(self, get_intents_result):
+    def extract_actual_bgpIntents( self, get_intents_result ):
         intents = []
         # TODO: delete the line below when change to Mininet demo script
-        # get_intents_result=open("../tests/SdnIpTest/intents.json").read()
-        intents_json_obj = json.loads(get_intents_result)
+        # get_intents_result=open( "../tests/SdnIpTest/intents.json" ).read()
+        intents_json_obj = json.loads( get_intents_result )
 
         for intent in intents_json_obj:
-            if intent['appId'] != "org.onosproject.sdnip":
+            if intent[ 'appId' ] != "org.onosproject.sdnip":
                 continue
-            if intent['type'] == "PointToPointIntent" and "protocol=6" in str(intent['selector']):
-                ingress = str(intent['ingress']['device']) + ":" + str(intent['ingress']['port'])
-                egress = str(intent['egress']['device']) + ":" + str(intent['egress']['port'])
-                selector = str(intent['selector']).replace(" ", "").replace("[", "").replace("]", "").split(",")
-                intent = ingress + "/" + egress + "/" + str(sorted(selector))
-                intents.append(intent)
+            if intent[ 'type' ] == "PointToPointIntent" and "protocol=6" in str( intent[ 'selector' ] ):
+                ingress = str( intent[ 'ingress' ][ 'device' ] ) + ":" + str(
+                    intent[ 'ingress' ][ 'port' ] )
+                egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + str(
+                    intent[ 'egress' ][ 'port' ] )
+                selector = str(
+                    intent[ 'selector' ] ).replace( " ", "" ).replace( "[", "" ).replace( "]", "" ).split( "," )
+                intent = ingress + "/" + egress + \
+                    "/" + str( sorted( selector ) )
+                intents.append( intent )
 
-        return sorted(intents)
+        return sorted( intents )
 
-    # This method generates a single point to single point intent(PointToPointIntent) for BGP path
-    def generate_expected_bgpIntents(self, sdnip_json_file_path):
+    # This method generates a single point to single point intent(
+    # PointToPointIntent ) for BGP path
+    def generate_expected_bgpIntents( self, sdnip_json_file_path ):
         from operator import eq
 
-        sdnip_json_file = open(sdnip_json_file_path).read()
-        sdnip_data = json.loads(sdnip_json_file)
+        sdnip_json_file = open( sdnip_json_file_path ).read()
+        sdnip_data = json.loads( sdnip_json_file )
 
         intents = []
         bgpPeerAttachmentPoint = ""
-        bgpSpeakerAttachmentPoint = "of:" + str(sdnip_data['bgpSpeakers'][0]['attachmentDpid']).replace(":", "") + ":" + str(sdnip_data['bgpSpeakers'][0]['attachmentPort'])
-        for peer in sdnip_data['bgpPeers']:
-            bgpPeerAttachmentPoint = "of:" + str(peer['attachmentDpid']).replace(":", "") + ":" + str(peer['attachmentPort'])
+        bgpSpeakerAttachmentPoint = "of:" + str(
+            sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ).replace( ":",
+                                                                            "" ) + ":" + str( sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] )
+        for peer in sdnip_data[ 'bgpPeers' ]:
+            bgpPeerAttachmentPoint = "of:" + str(
+                peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" + str( peer[ 'attachmentPort' ] )
             # find out the BGP speaker IP address for this BGP peer
             bgpSpeakerIpAddress = ""
-            for interfaceAddress in sdnip_data['bgpSpeakers'][0]['interfaceAddresses']:
-                # if eq(interfaceAddress['interfaceDpid'],sdnip_data['bgpSpeakers'][0]['attachmentDpid']) and eq(interfaceAddress['interfacePort'], sdnip_data['bgpSpeakers'][0]['attachmentPort']):
-                if eq(interfaceAddress['interfaceDpid'], peer['attachmentDpid']) and eq(interfaceAddress['interfacePort'], peer['attachmentPort']):
-                    bgpSpeakerIpAddress = interfaceAddress['ipAddress']
+            for interfaceAddress in sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'interfaceAddresses' ]:
+                # if eq( interfaceAddress[ 'interfaceDpid' ],sdnip_data[
+                # 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ) and eq(
+                # interfaceAddress[ 'interfacePort' ], sdnip_data[
+                # 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] ):
+                if eq( interfaceAddress[ 'interfaceDpid' ], peer[ 'attachmentDpid' ] ) and eq( interfaceAddress[ 'interfacePort' ], peer[ 'attachmentPort' ] ):
+                    bgpSpeakerIpAddress = interfaceAddress[ 'ipAddress' ]
                     break
                 else:
                     continue
 
-            # from bgpSpeakerAttachmentPoint to bgpPeerAttachmentPoint direction
-            selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer['ipAddress'] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
-            selector = selector_str.replace(" ", "").replace("[", "").replace("]", "").split(",")
-            intent = bgpSpeakerAttachmentPoint + "/" + bgpPeerAttachmentPoint + "/" + str(sorted(selector))
-            intents.append(intent)
+            # from bgpSpeakerAttachmentPoint to bgpPeerAttachmentPoint
+            # direction
+            selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer[
+                'ipAddress' ] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
+            selector = selector_str.replace( " ", "" ).replace(
+                "[", "" ).replace( "]", "" ).split( "," )
+            intent = bgpSpeakerAttachmentPoint + "/" + \
+                bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
+            intents.append( intent )
 
-            selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer['ipAddress'] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
-            selector = selector_str.replace(" ", "").replace("[", "").replace("]", "").split(",")
-            intent = bgpSpeakerAttachmentPoint + "/" + bgpPeerAttachmentPoint + "/" + str(sorted(selector))
-            intents.append(intent)
+            selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer[
+                'ipAddress' ] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
+            selector = selector_str.replace( " ", "" ).replace(
+                "[", "" ).replace( "]", "" ).split( "," )
+            intent = bgpSpeakerAttachmentPoint + "/" + \
+                bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
+            intents.append( intent )
 
-            # from bgpPeerAttachmentPoint to bgpSpeakerAttachmentPoint direction
-            selector_str = "IPV4_SRC{ip=" + peer['ipAddress'] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
-            selector = selector_str.replace(" ", "").replace("[", "").replace("]", "").split(",")
-            intent = bgpPeerAttachmentPoint + "/" + bgpSpeakerAttachmentPoint + "/" + str(sorted(selector))
-            intents.append(intent)
+            # from bgpPeerAttachmentPoint to bgpSpeakerAttachmentPoint
+            # direction
+            selector_str = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
+                "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
+            selector = selector_str.replace( " ", "" ).replace(
+                "[", "" ).replace( "]", "" ).split( "," )
+            intent = bgpPeerAttachmentPoint + "/" + \
+                bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
+            intents.append( intent )
 
-            selector_str = "IPV4_SRC{ip=" + peer['ipAddress'] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
-            selector = selector_str.replace(" ", "").replace("[", "").replace("]", "").split(",")
-            intent = bgpPeerAttachmentPoint + "/" + bgpSpeakerAttachmentPoint + "/" + str(sorted(selector))
-            intents.append(intent)
+            selector_str = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
+                "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
+            selector = selector_str.replace( " ", "" ).replace(
+                "[", "" ).replace( "]", "" ).split( "," )
+            intent = bgpPeerAttachmentPoint + "/" + \
+                bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
+            intents.append( intent )
 
-        return sorted(intents)
+        return sorted( intents )
 
-    def add_routes(self, routes, routeRate):
-        main.log.info("I am in add_routes method!")
+    def add_routes( self, routes, routeRate ):
+        main.log.info( "I am in add_routes method!" )
 
         routes_added = 0
         try:
-            self.handle.sendline("")
-            # self.handle.expect("config-router")
-            self.handle.expect("config-router", timeout=5)
+            self.handle.sendline( "" )
+            # self.handle.expect( "config-router" )
+            self.handle.expect( "config-router", timeout=5 )
         except:
-            main.log.warn("Probably not in config-router mode!")
+            main.log.warn( "Probably not in config-router mode!" )
             self.disconnect()
-        main.log.info("Start to add routes")
+        main.log.info( "Start to add routes" )
 
-        for i in range(0, len(routes)):
-            routeCmd = "network " + routes[i]
+        for i in range( 0, len( routes ) ):
+            routeCmd = "network " + routes[ i ]
             try:
-                self.handle.sendline(routeCmd)
-                self.handle.expect("bgpd", timeout=5)
+                self.handle.sendline( routeCmd )
+                self.handle.expect( "bgpd", timeout=5 )
             except:
-                main.log.warn("Failed to add route")
+                main.log.warn( "Failed to add route" )
                 self.disconnect()
             waitTimer = 1.00 / routeRate
-            time.sleep(waitTimer)
-        if routes_added == len(routes):
-            main.log.info("Finished adding routes")
+            time.sleep( waitTimer )
+        if routes_added == len( routes ):
+            main.log.info( "Finished adding routes" )
             return main.TRUE
         return main.FALSE
 
-    def delete_routes(self, routes, routeRate):
-        main.log.info("I am in delete_routes method!")
+    def delete_routes( self, routes, routeRate ):
+        main.log.info( "I am in delete_routes method!" )
 
         routes_added = 0
         try:
-            self.handle.sendline("")
-            # self.handle.expect("config-router")
-            self.handle.expect("config-router", timeout=5)
+            self.handle.sendline( "" )
+            # self.handle.expect( "config-router" )
+            self.handle.expect( "config-router", timeout=5 )
         except:
-            main.log.warn("Probably not in config-router mode!")
+            main.log.warn( "Probably not in config-router mode!" )
             self.disconnect()
-        main.log.info("Start to delete routes")
+        main.log.info( "Start to delete routes" )
 
-        for i in range(0, len(routes)):
-            routeCmd = "no network " + routes[i]
+        for i in range( 0, len( routes ) ):
+            routeCmd = "no network " + routes[ i ]
             try:
-                self.handle.sendline(routeCmd)
-                self.handle.expect("bgpd", timeout=5)
+                self.handle.sendline( routeCmd )
+                self.handle.expect( "bgpd", timeout=5 )
             except:
-                main.log.warn("Failed to add route")
+                main.log.warn( "Failed to add route" )
                 self.disconnect()
             waitTimer = 1.00 / routeRate
-            time.sleep(waitTimer)
-        if routes_added == len(routes):
-            main.log.info("Finished deleting routes")
+            time.sleep( waitTimer )
+        if routes_added == len( routes ):
+            main.log.info( "Finished deleting routes" )
             return main.TRUE
         return main.FALSE
 
-    def ping_test(self, ip_address, ping_test_file, ping_test_result_file):
-        main.log.info("Start the ping test on host:" + str(ip_address))
+    def ping_test( self, ip_address, ping_test_file, ping_test_result_file ):
+        main.log.info( "Start the ping test on host:" + str( ip_address ) )
 
-        self.name = self.options['name']
-        self.handle = super(QuaggaCliDriver, self).connect(
+        self.name = self.options[ 'name' ]
+        self.handle = super( QuaggaCliDriver, self ).connect(
             user_name=self.user_name, ip_address=ip_address,
-            port=self.port, pwd=self.pwd)
-        main.log.info("connect parameters:" + str(self.user_name) + ";"
-        + str(self.ip_address) + ";" + str(self.port) + ";" + str(self.pwd))
+            port=self.port, pwd=self.pwd )
+        main.log.info( "connect parameters:" + str( self.user_name ) + ";"
+                       + str( self.ip_address ) + ";" + str( self.port ) + ";" + str( self.pwd ) )
 
         if self.handle:
-            #self.handle.expect("")
-            #self.handle.expect("\$")
-            main.log.info("I in host " + str(ip_address))
-            main.log.info(ping_test_file + " > " + ping_test_result_file + " &")
-            self.handle.sendline(ping_test_file + " > " + ping_test_result_file + " &")
-            self.handle.expect("\$", timeout=60)
+            # self.handle.expect( "" )
+            # self.handle.expect( "\$" )
+            main.log.info( "I in host " + str( ip_address ) )
+            main.log.info(
+                ping_test_file +
+                " > " +
+                ping_test_result_file +
+                " &" )
+            self.handle.sendline(
+                ping_test_file +
+                " > " +
+                ping_test_result_file +
+                " &" )
+            self.handle.expect( "\$", timeout=60 )
             handle = self.handle.before
 
             return handle
         else:
-            main.log.info("NO HANDLE")
+            main.log.info( "NO HANDLE" )
             return main.FALSE
 
-
     # Please use the generate_routes plus add_routes instead of this one
-    def add_route(self, net, numRoutes, routeRate):
+    def add_route( self, net, numRoutes, routeRate ):
         try:
-            self.handle.sendline("")
-            self.handle.expect("config-router")
+            self.handle.sendline( "" )
+            self.handle.expect( "config-router" )
         except:
-            main.log.warn("Probably not in config-router mode!")
+            main.log.warn( "Probably not in config-router mode!" )
             self.disconnect()
-        main.log.info("Adding Routes")
+        main.log.info( "Adding Routes" )
         j = 0
         k = 0
         while numRoutes > 255:
@@ -348,44 +416,47 @@
         routes_added = 0
         if numRoutes > 255:
             numRoutes = 255
-        for m in range(1, j + 1):
-            for n in range(1, numRoutes + 1):
-                network = str(net) + "." + str(m) + "." + str(n) + ".0/24"
+        for m in range( 1, j + 1 ):
+            for n in range( 1, numRoutes + 1 ):
+                network = str( net ) + "." + str( m ) + "." + str( n ) + ".0/24"
                 routeCmd = "network " + network
                 try:
-                    self.handle.sendline(routeCmd)
-                    self.handle.expect("bgpd")
+                    self.handle.sendline( routeCmd )
+                    self.handle.expect( "bgpd" )
                 except:
-                    main.log.warn("failed to add route")
+                    main.log.warn( "failed to add route" )
                     self.disconnect()
                 waitTimer = 1.00 / routeRate
-                time.sleep(waitTimer)
+                time.sleep( waitTimer )
                 routes_added = routes_added + 1
-        for d in range(j + 1, j + 2):
-            for e in range(1, k + 1):
-                network = str(net) + "." + str(d) + "." + str(e) + ".0/24"
+        for d in range( j + 1, j + 2 ):
+            for e in range( 1, k + 1 ):
+                network = str(
+                    net ) + "." + str(
+                        d ) + "." + str(
+                            e ) + ".0/24"
                 routeCmd = "network " + network
                 try:
-                    self.handle.sendline(routeCmd)
-                    self.handle.expect("bgpd")
+                    self.handle.sendline( routeCmd )
+                    self.handle.expect( "bgpd" )
                 except:
-                    main.log.warn("failed to add route")
+                    main.log.warn( "failed to add route" )
                     self.disconnect
                 waitTimer = 1.00 / routeRate
-                time.sleep(waitTimer)
+                time.sleep( waitTimer )
                 routes_added = routes_added + 1
         if routes_added == numRoutes:
             return main.TRUE
         return main.FALSE
 
-    def del_route(self, net, numRoutes, routeRate):
+    def del_route( self, net, numRoutes, routeRate ):
         try:
-            self.handle.sendline("")
-            self.handle.expect("config-router")
+            self.handle.sendline( "" )
+            self.handle.expect( "config-router" )
         except:
-            main.log.warn("Probably not in config-router mode!")
+            main.log.warn( "Probably not in config-router mode!" )
             self.disconnect()
-        main.log.info("Deleting Routes")
+        main.log.info( "Deleting Routes" )
         j = 0
         k = 0
         while numRoutes > 255:
@@ -395,100 +466,106 @@
         routes_deleted = 0
         if numRoutes > 255:
             numRoutes = 255
-        for m in range(1, j + 1):
-            for n in range(1, numRoutes + 1):
-                network = str(net) + "." + str(m) + "." + str(n) + ".0/24"
+        for m in range( 1, j + 1 ):
+            for n in range( 1, numRoutes + 1 ):
+                network = str( net ) + "." + str( m ) + "." + str( n ) + ".0/24"
                 routeCmd = "no network " + network
                 try:
-                    self.handle.sendline(routeCmd)
-                    self.handle.expect("bgpd")
+                    self.handle.sendline( routeCmd )
+                    self.handle.expect( "bgpd" )
                 except:
-                    main.log.warn("Failed to delete route")
+                    main.log.warn( "Failed to delete route" )
                     self.disconnect()
                 waitTimer = 1.00 / routeRate
-                time.sleep(waitTimer)
+                time.sleep( waitTimer )
                 routes_deleted = routes_deleted + 1
-        for d in range(j + 1, j + 2):
-            for e in range(1, k + 1):
-                network = str(net) + "." + str(d) + "." + str(e) + ".0/24"
+        for d in range( j + 1, j + 2 ):
+            for e in range( 1, k + 1 ):
+                network = str( net ) + "." + str( d ) + "." + str( e ) + ".0/24"
                 routeCmd = "no network " + network
                 try:
-                    self.handle.sendline(routeCmd)
-                    self.handle.expect("bgpd")
+                    self.handle.sendline( routeCmd )
+                    self.handle.expect( "bgpd" )
                 except:
-                    main.log.warn("Failed to delete route")
+                    main.log.warn( "Failed to delete route" )
                     self.disconnect()
                 waitTimer = 1.00 / routeRate
-                time.sleep(waitTimer)
+                time.sleep( waitTimer )
                 routes_deleted = routes_deleted + 1
         if routes_deleted == numRoutes:
             return main.TRUE
         return main.FALSE
 
-    def check_routes(self, brand, ip, user, pw):
-        def pronto(ip, user, passwd):
+    def check_routes( self, brand, ip, user, pw ):
+        def pronto( ip, user, passwd ):
             print "Connecting to Pronto switch"
-            child = pexpect.spawn("telnet " + ip)
-            i = child.expect(["login:", "CLI#", pexpect.TIMEOUT])
+            child = pexpect.spawn( "telnet " + ip )
+            i = child.expect( [ "login:", "CLI#", pexpect.TIMEOUT ] )
             if i == 0:
                 print "Username and password required. Passing login info."
-                child.sendline(user)
-                child.expect("Password:")
-                child.sendline(passwd)
-                child.expect("CLI#")
+                child.sendline( user )
+                child.expect( "Password:" )
+                child.sendline( passwd )
+                child.expect( "CLI#" )
             print "Logged in, getting flowtable."
-            child.sendline("flowtable brief")
-            for t in range (9):
+            child.sendline( "flowtable brief" )
+            for t in range( 9 ):
                 t2 = 9 - t
-                print "\r" + str(t2)
-                sys.stdout.write("\033[F")
-                time.sleep(1)
+                print "\r" + str( t2 )
+                sys.stdout.write( "\033[F" )
+                time.sleep( 1 )
             print "Scanning flowtable"
-            child.expect("Flow table show")
+            child.expect( "Flow table show" )
             count = 0
-            while 1:
-                i = child.expect(['17\d\.\d{1,3}\.\d{1,3}\.\d{1,3}', 'CLI#', pexpect.TIMEOUT])
+            while True:
+                i = child.expect(
+                    [ '17\d\.\d{1,3}\.\d{1,3}\.\d{1,3}',
+                                'CLI#',
+                                pexpect.TIMEOUT ] )
                 if i == 0:
                     count = count + 1
                 elif i == 1:
-                    print "Pronto flows: " + str(count) + "\nDone\n"
+                    print "Pronto flows: " + str( count ) + "\nDone\n"
                     break
                 else:
                     break
-        def cisco(ip, user, passwd):
+
+        def cisco( ip, user, passwd ):
             print "Establishing Cisco switch connection"
-            child = pexpect.spawn("ssh " + user + "@" + ip)
-            i = child.expect(["Password:", "CLI#", pexpect.TIMEOUT])
+            child = pexpect.spawn( "ssh " + user + "@" + ip )
+            i = child.expect( [ "Password:", "CLI#", pexpect.TIMEOUT ] )
             if i == 0:
                 print "Password required. Passing now."
-                child.sendline(passwd)
-                child.expect("#")
+                child.sendline( passwd )
+                child.expect( "#" )
             print "Logged in. Retrieving flow table then counting flows."
-            child.sendline("show openflow switch all flows all")
-            child.expect("Logical Openflow Switch")
+            child.sendline( "show openflow switch all flows all" )
+            child.expect( "Logical Openflow Switch" )
             print "Flow table retrieved. Counting flows"
             count = 0
-            while 1:
-                i = child.expect(["nw_src=17", "#", pexpect.TIMEOUT])
+            while True:
+                i = child.expect( [ "nw_src=17", "#", pexpect.TIMEOUT ] )
                 if i == 0:
                     count = count + 1
                 elif i == 1:
-                    print "Cisco flows: " + str(count) + "\nDone\n"
+                    print "Cisco flows: " + str( count ) + "\nDone\n"
                     break
                 else:
                     break
             if brand == "pronto" or brand == "PRONTO":
-                pronto(ip, user, passwd)
+                pronto( ip, user, passwd )
             # elif brand  == "cisco" or brand == "CISCO":
-            #    cisco(ip,user,passwd)
-    def disconnect(self):
-        '''
-        Called when Test is complete to disconnect the Quagga handle.  
-        '''
+            #    cisco( ip,user,passwd )
+
+    def disconnect( self ):
+        """
+        Called when Test is complete to disconnect the Quagga handle.
+        """
         response = ''
         try:
             self.handle.close()
         except:
-            main.log.error("Connection failed to the host")
+            main.log.error( "Connection failed to the host" )
             response = main.FALSE
         return response
+
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py.fixed b/TestON/drivers/common/cli/quaggaclidriver.py.fixed
new file mode 100644
index 0000000..09b7614
--- /dev/null
+++ b/TestON/drivers/common/cli/quaggaclidriver.py.fixed
@@ -0,0 +1,596 @@
+#!/usr/bin/env python
+
+import time
+import pexpect
+import struct
+import fcntl
+import os
+import sys
+import signal
+import sys
+import re
+import json
+sys.path.append( "../" )
+from drivers.common.clidriver import CLI
+
+
+class QuaggaCliDriver( CLI ):
+
+    def __init__( self ):
+        super( CLI, self ).__init__()
+
+    # TODO: simplify this method
+    def connect( self, **connectargs ):
+        for key in connectargs:
+            vars( self )[ key ] = connectargs[ key ]
+
+        self.name = self.options[ 'name' ]
+        # self.handle = super( QuaggaCliDriver,self ).connect(
+        # user_name=self.user_name, ip_address=self.ip_address,port=self.port,
+        # pwd=self.pwd )
+        self.handle = super(
+            QuaggaCliDriver,
+            self ).connect(
+                user_name=self.user_name,
+         ip_address="1.1.1.1",
+         port=self.port,
+         pwd=self.pwd )
+        main.log.info(
+            "connect parameters:" + str(
+                self.user_name ) + ";" + str(
+                    self.ip_address ) + ";" + str(
+                 self.port ) + ";" + str(
+                     self.pwd ) )
+
+        if self.handle:
+            # self.handle.expect( "",timeout=10 )
+            # self.handle.expect( "\$",timeout=10 )
+            self.handle.sendline( "telnet localhost 2605" )
+            # self.handle.expect( "Password:", timeout=5 )
+            self.handle.expect( "Password:" )
+            self.handle.sendline( "hello" )
+            # self.handle.expect( "bgpd", timeout=5 )
+            self.handle.expect( "bgpd" )
+            self.handle.sendline( "enable" )
+            # self.handle.expect( "bgpd#", timeout=5 )
+            self.handle.expect( "bgpd#" )
+            return self.handle
+        else:
+            main.log.info( "NO HANDLE" )
+            return main.FALSE
+
+    def loginQuagga( self, ip_address ):
+        self.name = self.options[ 'name' ]
+        self.handle = super( QuaggaCliDriver, self ).connect(
+            user_name=self.user_name, ip_address=ip_address,
+            port=self.port, pwd=self.pwd )
+        main.log.info( "connect parameters:" + str( self.user_name ) + ";"
+                       + str( self.ip_address ) + ";" + str( self.port ) + ";" + str( self.pwd ) )
+
+        if self.handle:
+            # self.handle.expect( "" )
+            # self.handle.expect( "\$" )
+            self.handle.sendline( "telnet localhost 2605" )
+            # self.handle.expect( "Password:", timeout=5 )
+            self.handle.expect( "Password:" )
+            self.handle.sendline( "hello" )
+            # self.handle.expect( "bgpd", timeout=5 )
+            self.handle.expect( "bgpd" )
+            self.handle.sendline( "enable" )
+            # self.handle.expect( "bgpd#", timeout=5 )
+            self.handle.expect( "bgpd#" )
+            main.log.info( "I in quagga on host " + str( ip_address ) )
+
+            return self.handle
+        else:
+            main.log.info( "NO HANDLE" )
+            return main.FALSE
+
+    def enter_config( self, asn ):
+        main.log.info( "I am in enter_config method!" )
+        try:
+            self.handle.sendline( "" )
+            self.handle.expect( "bgpd#" )
+        except:
+            main.log.warn( "Probably not currently in enable mode!" )
+            self.disconnect()
+            return main.FALSE
+        self.handle.sendline( "configure terminal" )
+        self.handle.expect( "config", timeout=5 )
+        routerAS = "router bgp " + str( asn )
+        try:
+            self.handle.sendline( routerAS )
+            self.handle.expect( "config-router", timeout=5 )
+            return main.TRUE
+        except:
+            return main.FALSE
+
+    def generate_prefixes( self, net, numRoutes ):
+        main.log.info( "I am in generate_prefixes method!" )
+
+        # each IP prefix will be composed by "net" + "." + m + "." + n + "." + x
+        # the length of each IP prefix is 24
+        routes = []
+        routes_gen = 0
+        m = numRoutes / 256
+        n = numRoutes % 256
+
+        for i in range( 0, m ):
+            for j in range( 0, 256 ):
+                network = str(
+                    net ) + "." + str(
+                        i ) + "." + str(
+                            j ) + ".0/24"
+                routes.append( network )
+                routes_gen = routes_gen + 1
+
+        for j in range( 0, n ):
+            network = str( net ) + "." + str( m ) + "." + str( j ) + ".0/24"
+            routes.append( network )
+            routes_gen = routes_gen + 1
+
+        if routes_gen == numRoutes:
+            main.log.info( "Successfully generated " + str( numRoutes )
+                           + " prefixes!" )
+            return routes
+        return main.FALSE
+
+    # This method generates a multiple to single point intent(
+    # MultiPointToSinglePointIntent ) for a given route
+    def generate_expected_singleRouteIntent(
+        self,
+     prefix,
+     nextHop,
+     nextHopMac,
+     sdnip_data ):
+
+        ingress = []
+        egress = ""
+        for peer in sdnip_data[ 'bgpPeers' ]:
+            if peer[ 'ipAddress' ] == nextHop:
+                egress = "of:" + str(
+                    peer[ 'attachmentDpid' ] ).replace( ":",
+                                                        "" ) + ":" + str( peer[ 'attachmentPort' ] )
+            else:
+                ingress.append(
+                    "of:" + str( peer[ 'attachmentDpid' ] ).replace( ":",
+                                                                     "" ) + ":" + str( peer[ 'attachmentPort' ] ) )
+
+        selector = "ETH_TYPE{ethType=800},IPV4_DST{ip=" + prefix + "}"
+        treatment = "[ETH_DST{mac=" + str( nextHopMac ) + "}]"
+
+        intent = egress + "/" + \
+            str( sorted( ingress ) ) + "/" + selector + "/" + treatment
+        return intent
+
+    def generate_expected_onePeerRouteIntents(
+        self,
+     prefixes,
+     nextHop,
+     nextHopMac,
+     sdnip_json_file_path ):
+        intents = []
+        sdnip_json_file = open( sdnip_json_file_path ).read()
+
+        sdnip_data = json.loads( sdnip_json_file )
+
+        for prefix in prefixes:
+            intents.append(
+                self.generate_expected_singleRouteIntent(
+                    prefix,
+                    nextHop,
+                    nextHopMac,
+                    sdnip_data ) )
+        return sorted( intents )
+
+    # TODO
+    # This method generates all expected route intents for all BGP peers
+    def generate_expected_routeIntents( self ):
+        intents = []
+        return intents
+
+    # This method extracts all actual routes from ONOS CLI
+    def extract_actual_routes( self, get_routes_result ):
+        routes_json_obj = json.loads( get_routes_result )
+
+        allRoutes_actual = []
+        for route in routes_json_obj:
+            if route[ 'prefix' ] == '172.16.10.0/24':
+                continue
+            allRoutes_actual.append(
+                route[ 'prefix' ] + "/" + route[ 'nextHop' ] )
+
+        return sorted( allRoutes_actual )
+
+    # This method extracts all actual route intents from ONOS CLI
+    def extract_actual_routeIntents( self, get_intents_result ):
+        intents = []
+        # TODO: delete the line below when change to Mininet demo script
+        # get_intents_result=open( "../tests/SdnIpTest/intents.json" ).read()
+        intents_json_obj = json.loads( get_intents_result )
+
+        for intent in intents_json_obj:
+            if intent[ 'appId' ] != "org.onosproject.sdnip":
+                continue
+            if intent[ 'type' ] == "MultiPointToSinglePointIntent" and intent[ 'state' ] == 'INSTALLED':
+                egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + str(
+                    intent[ 'egress' ][ 'port' ] )
+                ingress = []
+                for attachmentPoint in intent[ 'ingress' ]:
+                    ingress.append(
+                        str( attachmentPoint[ 'device' ] ) + ":" + str( attachmentPoint[ 'port' ] ) )
+
+                selector = intent[ 'selector' ].replace(
+                    "[", "" ).replace( "]", "" ).replace( " ", "" )
+                if str( selector ).startswith( "IPV4" ):
+                    str1, str2 = str( selector ).split( "," )
+                    selector = str2 + "," + str1
+
+                intent = egress + "/" + \
+                    str( sorted( ingress ) ) + "/" + \
+                        selector + "/" + intent[ 'treatment' ]
+                intents.append( intent )
+        return sorted( intents )
+
+    # This method extracts all actual BGP intents from ONOS CLI
+    def extract_actual_bgpIntents( self, get_intents_result ):
+        intents = []
+        # TODO: delete the line below when change to Mininet demo script
+        # get_intents_result=open( "../tests/SdnIpTest/intents.json" ).read()
+        intents_json_obj = json.loads( get_intents_result )
+
+        for intent in intents_json_obj:
+            if intent[ 'appId' ] != "org.onosproject.sdnip":
+                continue
+            if intent[ 'type' ] == "PointToPointIntent" and "protocol=6" in str( intent[ 'selector' ] ):
+                ingress = str( intent[ 'ingress' ][ 'device' ] ) + ":" + str(
+                    intent[ 'ingress' ][ 'port' ] )
+                egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + str(
+                    intent[ 'egress' ][ 'port' ] )
+                selector = str(
+                    intent[ 'selector' ] ).replace( " ",
+                                                    "" ).replace( "[",
+                                                                  "" ).replace( "]",
+                                                                                "" ).split( "," )
+                intent = ingress + "/" + egress + \
+                    "/" + str( sorted( selector ) )
+                intents.append( intent )
+
+        return sorted( intents )
+
+    # This method generates a single point to single point intent(
+    # PointToPointIntent ) for BGP path
+    def generate_expected_bgpIntents( self, sdnip_json_file_path ):
+        from operator import eq
+
+        sdnip_json_file = open( sdnip_json_file_path ).read()
+        sdnip_data = json.loads( sdnip_json_file )
+
+        intents = []
+        bgpPeerAttachmentPoint = ""
+        bgpSpeakerAttachmentPoint = "of:" + str(
+            sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ).replace( ":",
+                                                                            "" ) + ":" + str( sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] )
+        for peer in sdnip_data[ 'bgpPeers' ]:
+            bgpPeerAttachmentPoint = "of:" + str(
+                peer[ 'attachmentDpid' ] ).replace( ":",
+                                                    "" ) + ":" + str( peer[ 'attachmentPort' ] )
+            # find out the BGP speaker IP address for this BGP peer
+            bgpSpeakerIpAddress = ""
+            for interfaceAddress in sdnip_data[ 'bgpSpeakers' ][ 0 ][ 'interfaceAddresses' ]:
+                # if eq( interfaceAddress[ 'interfaceDpid' ],sdnip_data[
+                # 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ) and eq(
+                # interfaceAddress[ 'interfacePort' ], sdnip_data[
+                # 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] ):
+                if eq( interfaceAddress[ 'interfaceDpid' ], peer[ 'attachmentDpid' ] ) and eq( interfaceAddress[ 'interfacePort' ], peer[ 'attachmentPort' ] ):
+                    bgpSpeakerIpAddress = interfaceAddress[ 'ipAddress' ]
+                    break
+                else:
+                    continue
+
+            # from bgpSpeakerAttachmentPoint to bgpPeerAttachmentPoint
+            # direction
+            selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer[
+                'ipAddress' ] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
+            selector = selector_str.replace( " ", "" ).replace(
+                "[", "" ).replace( "]", "" ).split( "," )
+            intent = bgpSpeakerAttachmentPoint + "/" + \
+                bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
+            intents.append( intent )
+
+            selector_str = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," + "IPV4_DST{ip=" + peer[
+                'ipAddress' ] + "/32}," + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
+            selector = selector_str.replace( " ", "" ).replace(
+                "[", "" ).replace( "]", "" ).split( "," )
+            intent = bgpSpeakerAttachmentPoint + "/" + \
+                bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
+            intents.append( intent )
+
+            # from bgpPeerAttachmentPoint to bgpSpeakerAttachmentPoint
+            # direction
+            selector_str = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
+                "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_DST{tcpPort=179}"
+            selector = selector_str.replace( " ", "" ).replace(
+                "[", "" ).replace( "]", "" ).split( "," )
+            intent = bgpPeerAttachmentPoint + "/" + \
+                bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
+            intents.append( intent )
+
+            selector_str = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
+                "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, TCP_SRC{tcpPort=179}"
+            selector = selector_str.replace( " ", "" ).replace(
+                "[", "" ).replace( "]", "" ).split( "," )
+            intent = bgpPeerAttachmentPoint + "/" + \
+                bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
+            intents.append( intent )
+
+        return sorted( intents )
+
+    def add_routes( self, routes, routeRate ):
+        main.log.info( "I am in add_routes method!" )
+
+        routes_added = 0
+        try:
+            self.handle.sendline( "" )
+            # self.handle.expect( "config-router" )
+            self.handle.expect( "config-router", timeout=5 )
+        except:
+            main.log.warn( "Probably not in config-router mode!" )
+            self.disconnect()
+        main.log.info( "Start to add routes" )
+
+        for i in range( 0, len( routes ) ):
+            routeCmd = "network " + routes[ i ]
+            try:
+                self.handle.sendline( routeCmd )
+                self.handle.expect( "bgpd", timeout=5 )
+            except:
+                main.log.warn( "Failed to add route" )
+                self.disconnect()
+            waitTimer = 1.00 / routeRate
+            time.sleep( waitTimer )
+        if routes_added == len( routes ):
+            main.log.info( "Finished adding routes" )
+            return main.TRUE
+        return main.FALSE
+
+    def delete_routes( self, routes, routeRate ):
+        main.log.info( "I am in delete_routes method!" )
+
+        routes_added = 0
+        try:
+            self.handle.sendline( "" )
+            # self.handle.expect( "config-router" )
+            self.handle.expect( "config-router", timeout=5 )
+        except:
+            main.log.warn( "Probably not in config-router mode!" )
+            self.disconnect()
+        main.log.info( "Start to delete routes" )
+
+        for i in range( 0, len( routes ) ):
+            routeCmd = "no network " + routes[ i ]
+            try:
+                self.handle.sendline( routeCmd )
+                self.handle.expect( "bgpd", timeout=5 )
+            except:
+                main.log.warn( "Failed to add route" )
+                self.disconnect()
+            waitTimer = 1.00 / routeRate
+            time.sleep( waitTimer )
+        if routes_added == len( routes ):
+            main.log.info( "Finished deleting routes" )
+            return main.TRUE
+        return main.FALSE
+
+    def ping_test( self, ip_address, ping_test_file, ping_test_result_file ):
+        main.log.info( "Start the ping test on host:" + str( ip_address ) )
+
+        self.name = self.options[ 'name' ]
+        self.handle = super( QuaggaCliDriver, self ).connect(
+            user_name=self.user_name, ip_address=ip_address,
+            port=self.port, pwd=self.pwd )
+        main.log.info( "connect parameters:" + str( self.user_name ) + ";"
+                       + str( self.ip_address ) + ";" + str( self.port ) + ";" + str( self.pwd ) )
+
+        if self.handle:
+            # self.handle.expect( "" )
+            # self.handle.expect( "\$" )
+            main.log.info( "I in host " + str( ip_address ) )
+            main.log.info(
+                ping_test_file +
+                " > " +
+                ping_test_result_file +
+                " &" )
+            self.handle.sendline(
+                ping_test_file +
+                " > " +
+                ping_test_result_file +
+                " &" )
+            self.handle.expect( "\$", timeout=60 )
+            handle = self.handle.before
+
+            return handle
+        else:
+            main.log.info( "NO HANDLE" )
+            return main.FALSE
+
+    # Please use the generate_routes plus add_routes instead of this one
+    def add_route( self, net, numRoutes, routeRate ):
+        try:
+            self.handle.sendline( "" )
+            self.handle.expect( "config-router" )
+        except:
+            main.log.warn( "Probably not in config-router mode!" )
+            self.disconnect()
+        main.log.info( "Adding Routes" )
+        j = 0
+        k = 0
+        while numRoutes > 255:
+            numRoutes = numRoutes - 255
+            j = j + 1
+        k = numRoutes % 254
+        routes_added = 0
+        if numRoutes > 255:
+            numRoutes = 255
+        for m in range( 1, j + 1 ):
+            for n in range( 1, numRoutes + 1 ):
+                network = str(
+                    net ) + "." + str(
+                        m ) + "." + str(
+                            n ) + ".0/24"
+                routeCmd = "network " + network
+                try:
+                    self.handle.sendline( routeCmd )
+                    self.handle.expect( "bgpd" )
+                except:
+                    main.log.warn( "failed to add route" )
+                    self.disconnect()
+                waitTimer = 1.00 / routeRate
+                time.sleep( waitTimer )
+                routes_added = routes_added + 1
+        for d in range( j + 1, j + 2 ):
+            for e in range( 1, k + 1 ):
+                network = str(
+                    net ) + "." + str(
+                        d ) + "." + str(
+                            e ) + ".0/24"
+                routeCmd = "network " + network
+                try:
+                    self.handle.sendline( routeCmd )
+                    self.handle.expect( "bgpd" )
+                except:
+                    main.log.warn( "failed to add route" )
+                    self.disconnect
+                waitTimer = 1.00 / routeRate
+                time.sleep( waitTimer )
+                routes_added = routes_added + 1
+        if routes_added == numRoutes:
+            return main.TRUE
+        return main.FALSE
+
+    def del_route( self, net, numRoutes, routeRate ):
+        try:
+            self.handle.sendline( "" )
+            self.handle.expect( "config-router" )
+        except:
+            main.log.warn( "Probably not in config-router mode!" )
+            self.disconnect()
+        main.log.info( "Deleting Routes" )
+        j = 0
+        k = 0
+        while numRoutes > 255:
+            numRoutes = numRoutes - 255
+            j = j + 1
+        k = numRoutes % 254
+        routes_deleted = 0
+        if numRoutes > 255:
+            numRoutes = 255
+        for m in range( 1, j + 1 ):
+            for n in range( 1, numRoutes + 1 ):
+                network = str(
+                    net ) + "." + str(
+                        m ) + "." + str(
+                            n ) + ".0/24"
+                routeCmd = "no network " + network
+                try:
+                    self.handle.sendline( routeCmd )
+                    self.handle.expect( "bgpd" )
+                except:
+                    main.log.warn( "Failed to delete route" )
+                    self.disconnect()
+                waitTimer = 1.00 / routeRate
+                time.sleep( waitTimer )
+                routes_deleted = routes_deleted + 1
+        for d in range( j + 1, j + 2 ):
+            for e in range( 1, k + 1 ):
+                network = str(
+                    net ) + "." + str(
+                        d ) + "." + str(
+                            e ) + ".0/24"
+                routeCmd = "no network " + network
+                try:
+                    self.handle.sendline( routeCmd )
+                    self.handle.expect( "bgpd" )
+                except:
+                    main.log.warn( "Failed to delete route" )
+                    self.disconnect()
+                waitTimer = 1.00 / routeRate
+                time.sleep( waitTimer )
+                routes_deleted = routes_deleted + 1
+        if routes_deleted == numRoutes:
+            return main.TRUE
+        return main.FALSE
+
+    def check_routes( self, brand, ip, user, pw ):
+        def pronto( ip, user, passwd ):
+            print "Connecting to Pronto switch"
+            child = pexpect.spawn( "telnet " + ip )
+            i = child.expect( [ "login:", "CLI#", pexpect.TIMEOUT ] )
+            if i == 0:
+                print "Username and password required. Passing login info."
+                child.sendline( user )
+                child.expect( "Password:" )
+                child.sendline( passwd )
+                child.expect( "CLI#" )
+            print "Logged in, getting flowtable."
+            child.sendline( "flowtable brief" )
+            for t in range( 9 ):
+                t2 = 9 - t
+                print "\r" + str( t2 )
+                sys.stdout.write( "\033[F" )
+                time.sleep( 1 )
+            print "Scanning flowtable"
+            child.expect( "Flow table show" )
+            count = 0
+            while True:
+                i = child.expect(
+                    [ '17\d\.\d{1,3}\.\d{1,3}\.\d{1,3}',
+                                'CLI#',
+                                pexpect.TIMEOUT ] )
+                if i == 0:
+                    count = count + 1
+                elif i == 1:
+                    print "Pronto flows: " + str( count ) + "\nDone\n"
+                    break
+                else:
+                    break
+
+        def cisco( ip, user, passwd ):
+            print "Establishing Cisco switch connection"
+            child = pexpect.spawn( "ssh " + user + "@" + ip )
+            i = child.expect( [ "Password:", "CLI#", pexpect.TIMEOUT ] )
+            if i == 0:
+                print "Password required. Passing now."
+                child.sendline( passwd )
+                child.expect( "#" )
+            print "Logged in. Retrieving flow table then counting flows."
+            child.sendline( "show openflow switch all flows all" )
+            child.expect( "Logical Openflow Switch" )
+            print "Flow table retrieved. Counting flows"
+            count = 0
+            while True:
+                i = child.expect( [ "nw_src=17", "#", pexpect.TIMEOUT ] )
+                if i == 0:
+                    count = count + 1
+                elif i == 1:
+                    print "Cisco flows: " + str( count ) + "\nDone\n"
+                    break
+                else:
+                    break
+            if brand == "pronto" or brand == "PRONTO":
+                pronto( ip, user, passwd )
+            # elif brand  == "cisco" or brand == "CISCO":
+            #    cisco( ip,user,passwd )
+
+    def disconnect( self ):
+        """
+        Called when Test is complete to disconnect the Quagga handle.
+        """
+        response = ''
+        try:
+            self.handle.close()
+        except:
+            main.log.error( "Connection failed to the host" )
+            response = main.FALSE
+        return response
+
diff --git a/TestON/drivers/common/cli/remotesysdriver.py b/TestON/drivers/common/cli/remotesysdriver.py
index 374e502..a536e02 100644
--- a/TestON/drivers/common/cli/remotesysdriver.py
+++ b/TestON/drivers/common/cli/remotesysdriver.py
@@ -1,13 +1,13 @@
 #!/usr/bin/env python
-'''
-Created on 26-Oct-2012 
+"""
+Created on 26-Oct-2012
 
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)      
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
 
     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
@@ -15,41 +15,52 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
-''' 
+"""
 import time
 import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
 import sys
-sys.path.append("../")
+import signal
+import sys
+sys.path.append( "../" )
 from drivers.common.clidriver import CLI
 
-class RemoteSysDriver(CLI):
+
+class RemoteSysDriver( CLI ):
     # The common functions for emulator included in emulatordriver
-    def __init__(self):
-        super(CLI, self).__init__()
-        
-    def connect(self,**connectargs):
+
+    def __init__( self ):
+        super( CLI, self ).__init__()
+
+    def connect( self, **connectargs ):
         for key in connectargs:
-            vars(self)[key] = connectargs[key]
-        
-        self.name = self.options['name']
+            vars( self )[ key ] = connectargs[ key ]
 
-        self.handle = super(RemoteSysDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
-        '''
+        self.name = self.options[ 'name' ]
+
+        self.handle = super(
+            RemoteSysDriver,
+            self ).connect(
+            user_name=self.user_name,
+            ip_address=self.ip_address,
+            port=self.port,
+            pwd=self.pwd )
+        """
         if self.handle:
-            self.execute(cmd= "\n",prompt= "\$|>|#",timeout= 10)
-            self.execute(cmd= "ssh -l paxterra 10.128.4.1",prompt= "paxterra@10.128.4.1's password:",timeout= 10)
-            self.execute(cmd= "\n",prompt= "paxterra@10.128.4.1's password:",timeout= 10)
-            self.execute(cmd = "0nLab_gu3st",prompt = "\$",timeout = 10)
-            self.execute(cmd = "cd TestON/bin/",prompt = "\$",timeout = 10)
-            self.execute(cmd = "./cli.py run Assert example 1",prompt = "\$",timeout = 10)
-            self.execute(cmd= "\n",prompt= "$",timeout= 10)
-            #self.execute(cmd = "help",prompt = ">",timeout = 10)
-            
-            #self.execute(cmd = "~.",prompt= ".*",timeout= 10)
-        return main.TRUE
-        '''
+            self.execute( cmd= "\n",prompt= "\$|>|#",timeout= 10 )
+            self.execute( cmd= "ssh -l paxterra 10.128.4.1",prompt= "paxterra@10.128.4.1's password:",timeout= 10 )
+            self.execute( cmd= "\n",prompt= "paxterra@10.128.4.1's password:",timeout= 10 )
+            self.execute( cmd="0nLab_gu3st",prompt="\$",timeout=10 )
+            self.execute( cmd="cd TestON/bin/",prompt="\$",timeout=10 )
+            self.execute( cmd="./cli.py run Assert example 1",prompt="\$",timeout=10 )
+            self.execute( cmd= "\n",prompt= "$",timeout= 10 )
+            #self.execute( cmd="help",prompt=">",timeout=10 )
 
+            #self.execute( cmd="~.",prompt= ".*",timeout= 10 )
+        return main.TRUE
+        """
diff --git a/TestON/drivers/common/cli/remotetestbed/floodlightclidriver.py b/TestON/drivers/common/cli/remotetestbed/floodlightclidriver.py
index 8b25b2f..10e7a85 100644
--- a/TestON/drivers/common/cli/remotetestbed/floodlightclidriver.py
+++ b/TestON/drivers/common/cli/remotetestbed/floodlightclidriver.py
@@ -1,14 +1,14 @@
 #!/usr/bin/env python
-'''
+"""
 Created on 12-Feb-2013
 
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
 
 
     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
@@ -16,12 +16,11 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
 FloodLightCliDriver is the basic driver which will handle the Mininet functions
-'''
-
+"""
 import pexpect
 import struct
 import fcntl
@@ -31,30 +30,44 @@
 import sys
 import time
 
-sys.path.append("../")
+sys.path.append( "../" )
 
 from drivers.common.cli.remotetestbeddriver import RemoteTestBedDriver
 
-class FloodLightCliDriver(RemoteTestBedDriver):
-    '''
-        FloodLightCliDriver is the basic driver which will handle the Mininet functions
-    '''
-    def __init__(self):
-        super(RemoteTestBedDriver, self).__init__()
-        
-    def connect(self,**connectargs):
-        for key in connectargs:
-            vars(self)[key] = connectargs[key]
-        
-        self.name = self.options['name']
 
-        self.handle = super(FloodLightCliDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
-        if self.handle :
-            main.log.info("Connected "+self.name)
-            self.execute(cmd="\r",prompt="\$",timeout=10)
-            self.execute(cmd="cd /home/openflow/floodlight/",prompt="floodlight\$",timeout=3)
-            self.execute(cmd="java -jar target/floodlight.jar &",prompt="\$",timeout=3)
-            self.execute(cmd="\r",prompt="\$",timeout=10)
+class FloodLightCliDriver( RemoteTestBedDriver ):
+
+    """
+        FloodLightCliDriver is the basic driver which will handle the Mininet functions
+    """
+    def __init__( self ):
+        super( RemoteTestBedDriver, self ).__init__()
+
+    def connect( self, **connectargs ):
+        for key in connectargs:
+            vars( self )[ key ] = connectargs[ key ]
+
+        self.name = self.options[ 'name' ]
+
+        self.handle = super(
+            FloodLightCliDriver,
+            self ).connect(
+            user_name=self.user_name,
+            ip_address=self.ip_address,
+            port=self.port,
+            pwd=self.pwd )
+        if self.handle:
+            main.log.info( "Connected " + self.name )
+            self.execute( cmd="\r", prompt="\$", timeout=10 )
+            self.execute(
+                cmd="cd /home/openflow/floodlight/",
+                prompt="floodlight\$",
+                timeout=3 )
+            self.execute(
+                cmd="java -jar target/floodlight.jar &",
+                prompt="\$",
+                timeout=3 )
+            self.execute( cmd="\r", prompt="\$", timeout=10 )
             return self.handle
-        else :
+        else:
             return main.FALSE
diff --git a/TestON/drivers/common/cli/remotetestbed/necswitchdriver.py b/TestON/drivers/common/cli/remotetestbed/necswitchdriver.py
index f5e652a..07fb668 100644
--- a/TestON/drivers/common/cli/remotetestbed/necswitchdriver.py
+++ b/TestON/drivers/common/cli/remotetestbed/necswitchdriver.py
@@ -1,545 +1,757 @@
 class NEC:
+
     def __init__( self ):
         self.prompt = '(.*)'
-        self.timeout = 60 
+        self.timeout = 60
 
-    def show(self, *options, **def_args ):
-        '''Possible Options :['  access-filter  ', '  accounting  ', '  acknowledgments  ', '  auto-config  ', '  axrp  ', '  cfm  ', '  channel-group  ', '  clock  ', '  config-lock-status  ', '  cpu  ', '  dhcp  ', '  dot1x  ', '  dumpfile  ', '  efmoam  ', '  environment  ', '  file  ', '  flash  ', '  gsrp  ', '  history  ', '  igmp-snooping  ', '  interfaces  ', '  ip  ', '  ip-dual  ', '  ipv6-dhcp  ', '  license  ', '  lldp  ', '  logging  ', '  loop-detection  ', '  mac-address-table  ', '  mc  ', '  memory  ', '  mld-snooping  ', '  netconf  ', '  netstat  ', '  ntp  ', '  oadp  ', '  openflow  ', '  port  ', '  power  ', '  processes  ', '  qos  ', '  qos-flow  ', '  sessions  ', '  sflow  ', '  spanning-tree  ', '  ssh  ', '  system  ', '  tcpdump  ', '  tech-support  ', '  track  ', '  version  ', '  vlan  ', '  vrrpstatus  ', '  whoami  ']'''
-        arguments= ''
+    def show( self, *options, **def_args ):
+        "Possible Options :['  access-filter  ', '  accounting  ', '  acknowledgments  ', '  auto-config  ', '  axrp  ', '  cfm  ', '  channel-group  ', '  clock  ', '  config-lock-status  ', '  cpu  ', '  dhcp  ', '  dot1x  ', '  dumpfile  ', '  efmoam  ', '  environment  ', '  file  ', '  flash  ', '  gsrp  ', '  history  ', '  igmp-snooping  ', '  interfaces  ', '  ip  ', '  ip-dual  ', '  ipv6-dhcp  ', '  license  ', '  lldp  ', '  logging  ', '  loop-detection  ', '  mac-address-table  ', '  mc  ', '  memory  ', '  mld-snooping  ', '  netconf  ', '  netstat  ', '  ntp  ', '  oadp  ', '  openflow  ', '  port  ', '  power  ', '  processes  ', '  qos  ', '  qos-flow  ', '  sessions  ', '  sflow  ', '  spanning-tree  ', '  ssh  ', '  system  ', '  tcpdump  ', '  tech-support  ', '  track  ', '  version  ', '  vlan  ', '  vrrpstatus  ', '  whoami  ']"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute( cmd="show " + arguments, prompt=prompt, timeout=timeout )
         return main.TRUE
 
-    def show_ip(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_ip( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   ip   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   ip   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_mc(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_mc( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   mc   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   mc   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_cfm(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_cfm( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   cfm   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   cfm   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_ntp(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_ntp( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   ntp   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   ntp   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_ssh(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_ssh( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   ssh   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   ssh   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_qos(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_qos( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   qos   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   qos   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_cpu(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_cpu( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   cpu   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   cpu   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_vlan(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_vlan( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   vlan   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   vlan   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_lldp(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_lldp( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   lldp   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   lldp   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_dhcp(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_dhcp( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   dhcp   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   dhcp   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_axrp(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_axrp( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   axrp   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   axrp   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_oadp(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_oadp( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   oadp   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   oadp   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_gsrp(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_gsrp( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   gsrp   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   gsrp   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_port(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_port( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   port   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   port   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_file(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_file( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   file   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   file   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_power(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_power( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   power   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   power   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_clock(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_clock( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   clock   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   clock   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_dot1x(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_dot1x( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   dot1x   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   dot1x   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_sflow(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_sflow( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   sflow   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   sflow   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_track(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_track( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   track   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   track   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_flash(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_flash( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   flash   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   flash   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_system(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_system( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   system   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   system   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_whoami(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_whoami( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   whoami   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   whoami   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_efmoam(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_efmoam( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   efmoam   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   efmoam   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_memory(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_memory( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   memory   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   memory   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_tcpdump(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_tcpdump( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   tcpdump   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   tcpdump   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_history(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_history( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   history   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   history   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_logging(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_logging( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   logging   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   logging   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_license(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_license( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   license   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   license   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_netstat(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_netstat( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   netstat   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   netstat   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_version(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_version( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   version   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   version   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_netconf(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_netconf( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   netconf   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   netconf   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_ipdual(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_ipdual( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   ip-dual   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   ip-dual   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_sessions(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_sessions( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   sessions   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   sessions   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_qosflow(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_qosflow( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   qos-flow   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   qos-flow   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_openflow(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_openflow( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   openflow   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   openflow   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_dumpfile(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_dumpfile( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   dumpfile   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   dumpfile   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_ipv6dhcp(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_ipv6dhcp( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   ipv6-dhcp   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   ipv6-dhcp   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_processes(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_processes( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   processes   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   processes   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_vrrpstatus(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_vrrpstatus( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   vrrpstatus   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   vrrpstatus   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_interfaces(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_interfaces( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   interfaces   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   interfaces   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_environment(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_environment( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   environment   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   environment   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_autoconfig(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_autoconfig( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   auto-config   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   auto-config   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_techsupport(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_techsupport( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   tech-support   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   tech-support   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_mldsnooping(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_mldsnooping( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   mld-snooping   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   mld-snooping   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_igmpsnooping(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_igmpsnooping( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   igmp-snooping   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   igmp-snooping   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_channelgroup(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_channelgroup( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   channel-group   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   channel-group   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_spanningtree(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_spanningtree( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   spanning-tree   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   spanning-tree   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_loopdetection(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_loopdetection( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   loop-detection   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   loop-detection   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_acknowledgments(self, *options, **def_args ):
-        '''Possible Options :['  interface  ']'''
-        arguments= ''
+    def show_acknowledgments( self, *options, **def_args ):
+        "Possible Options :['  interface  ']"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   acknowledgments   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   acknowledgments   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_macaddresstable(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_macaddresstable( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   mac-address-table   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   mac-address-table   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_configlockstatus(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_configlockstatus( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   config-lock-status   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   config-lock-status   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
 
-    def show_acknowledgments_interface(self, *options, **def_args ):
-        '''Possible Options :[]'''
-        arguments= ''
+    def show_acknowledgments_interface( self, *options, **def_args ):
+        "Possible Options :[]"
+        arguments = ''
         for option in options:
-            arguments = arguments + option +' ' 
-        prompt = def_args.setdefault('prompt',self.prompt)
-        timeout = def_args.setdefault('timeout',self.timeout)
-        self.execute( cmd= "show   acknowledgments     interface   "+ arguments, prompt = prompt, timeout = timeout ) 
+            arguments = arguments + option + ' '
+        prompt = def_args.setdefault( 'prompt', self.prompt )
+        timeout = def_args.setdefault( 'timeout', self.timeout )
+        self.execute(
+            cmd="show   acknowledgments     interface   " +
+            arguments,
+            prompt=prompt,
+            timeout=timeout )
         return main.TRUE
-
diff --git a/TestON/drivers/common/cli/remotetestbed/remotepoxdriver.py b/TestON/drivers/common/cli/remotetestbed/remotepoxdriver.py
index f0d2a16..44951aa 100644
--- a/TestON/drivers/common/cli/remotetestbed/remotepoxdriver.py
+++ b/TestON/drivers/common/cli/remotetestbed/remotepoxdriver.py
@@ -1,14 +1,14 @@
 #!/usr/bin/env python
-'''
+"""
 Created on 12-Feb-2013
 
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
 
 
     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
@@ -16,12 +16,11 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
 RemoteVMDriver is the basic driver which will handle the Mininet functions
-'''
-
+"""
 import pexpect
 import struct
 import fcntl
@@ -31,34 +30,49 @@
 import sys
 import time
 
-sys.path.append("../")
+sys.path.append( "../" )
 
 from drivers.common.cli.remotetestbeddriver import RemoteTestBedDriver
 
-class RemotePoxDriver(RemoteTestBedDriver):
-    '''
-        RemoteVMDriver is the basic driver which will handle the Mininet functions
-    '''
-    def __init__(self):
-        super(RemoteTestBedDriver, self).__init__()
-        
-    def connect(self,**connectargs):
-        for key in connectargs:
-            vars(self)[key] = connectargs[key]
-        
-        self.name = self.options['name']
 
-        self.handle = super(RemotePoxDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
-        if self.handle :
-            main.log.info(self.name+" connected successfully ")  
-            
-            self.execute(cmd="cd "+self.options['pox_lib_location'],prompt="/pox\$",timeout=120)
-            self.execute(cmd='./pox.py samples.of_tutorial',prompt="DEBUG:",timeout=120)
+class RemotePoxDriver( RemoteTestBedDriver ):
+
+    """
+        RemoteVMDriver is the basic driver which will handle the Mininet functions
+    """
+    def __init__( self ):
+        super( RemoteTestBedDriver, self ).__init__()
+
+    def connect( self, **connectargs ):
+        for key in connectargs:
+            vars( self )[ key ] = connectargs[ key ]
+
+        self.name = self.options[ 'name' ]
+
+        self.handle = super(
+            RemotePoxDriver,
+            self ).connect(
+            user_name=self.user_name,
+            ip_address=self.ip_address,
+            port=self.port,
+            pwd=self.pwd )
+        if self.handle:
+            main.log.info( self.name + " connected successfully " )
+
+            self.execute(
+                cmd="cd " +
+                self.options[ 'pox_lib_location' ],
+                prompt="/pox\$",
+                timeout=120 )
+            self.execute(
+                cmd='./pox.py samples.of_tutorial',
+                prompt="DEBUG:",
+                timeout=120 )
             return self.handle
         return main.TRUE
-        
-    def disconnect(self,handle):
+
+    def disconnect( self, handle ):
         if self.handle:
-            self.execute(cmd="exit()",prompt="/pox\$",timeout=120)
-        else :
-            main.log.error("Connection failed to the host") 
+            self.execute( cmd="exit()", prompt="/pox\$", timeout=120 )
+        else:
+            main.log.error( "Connection failed to the host" )
diff --git a/TestON/drivers/common/cli/remotetestbed/remotevmdriver.py b/TestON/drivers/common/cli/remotetestbed/remotevmdriver.py
index 4592e71..4f97854 100644
--- a/TestON/drivers/common/cli/remotetestbed/remotevmdriver.py
+++ b/TestON/drivers/common/cli/remotetestbed/remotevmdriver.py
@@ -1,14 +1,14 @@
 #!/usr/bin/env python
-'''
+"""
 Created on 12-Feb-2013
 
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
 
 
     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
@@ -16,12 +16,11 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
 RemoteVMDriver is the basic driver which will handle the Mininet functions
-'''
-
+"""
 import pexpect
 import struct
 import fcntl
@@ -31,68 +30,100 @@
 import sys
 import time
 
-sys.path.append("../")
+sys.path.append( "../" )
 
 from drivers.common.cli.remotetestbeddriver import RemoteTestBedDriver
 
-class RemoteVMDriver(RemoteTestBedDriver):
-    '''
-        RemoteVMDriver is the basic driver which will handle the Mininet functions
-    '''
-    def __init__(self):
-        super(RemoteTestBedDriver, self).__init__()
-        
-    def connect(self,**connectargs):
-        for key in connectargs:
-            vars(self)[key] = connectargs[key]
-        
-        self.name = self.options['name']
 
-        self.handle = super(RemoteVMDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
-        if self.handle :
-            main.log.info(self.name+" connected successfully ")  
+class RemoteVMDriver( RemoteTestBedDriver ):
+
+    """
+        RemoteVMDriver is the basic driver which will handle the Mininet functions
+    """
+    def __init__( self ):
+        super( RemoteTestBedDriver, self ).__init__()
+
+    def connect( self, **connectargs ):
+        for key in connectargs:
+            vars( self )[ key ] = connectargs[ key ]
+
+        self.name = self.options[ 'name' ]
+
+        self.handle = super(
+            RemoteVMDriver,
+            self ).connect(
+            user_name=self.user_name,
+            ip_address=self.ip_address,
+            port=self.port,
+            pwd=self.pwd )
+        if self.handle:
+            main.log.info( self.name + " connected successfully " )
             return self.handle
         return main.TRUE
-    def SSH(self,**connectargs):
+
+    def SSH( self, **connectargs ):
         for key in connectargs:
-            vars(self)[key] = connectargs[key]
-        
-        '''
+            vars( self )[ key ] = connectargs[ key ]
+
+        """
            Connection will establish to the remote host using ssh.
            It will take user_name ,ip_address and password as arguments<br>
-           and will return the handle. 
-        '''
+           and will return the handle.
+        """
         for key in connectargs:
-            vars(self)[key] = connectargs[key]
-            
+            vars( self )[ key ] = connectargs[ key ]
+
         ssh_newkey = 'Are you sure you want to continue connecting'
-        refused = "ssh: connect to host "+self.ip_address+" port 22: Connection refused"
+        refused = "ssh: connect to host " + \
+            self.ip_address + " port 22: Connection refused"
         if self.port:
-            self.handle.sendline('ssh -p '+self.port+' '+self.user_name+'@'+self.ip_address)
-        else :
-            self.handle.sendline('ssh '+self.user_name+'@'+self.ip_address)
-            self.handle.sendline("\r")
-            
-        i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF,pexpect.TIMEOUT,refused],120)
-        
-        if i==0:    
-            main.log.info("ssh key confirmation received, send yes")
-            self.handle.sendline('yes')
-            i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF])
-        if i==1:
-            main.log.info("ssh connection asked for password, gave password")
-            self.handle.sendline(self.pwd)
-            self.handle.expect('>|#|$')
-            
-        elif i==2:
-            main.log.error("Connection timeout")
+            self.handle.sendline(
+                'ssh -p ' +
+                self.port +
+                ' ' +
+                self.user_name +
+                '@' +
+                self.ip_address )
+        else:
+            self.handle.sendline(
+                'ssh ' +
+                self.user_name +
+                '@' +
+                self.ip_address )
+            self.handle.sendline( "\r" )
+
+        i = self.handle.expect( [ ssh_newkey,
+                                  'password:',
+                                  pexpect.EOF,
+                                  pexpect.TIMEOUT,
+                                  refused ],
+                                120 )
+
+        if i == 0:
+            main.log.info( "ssh key confirmation received, send yes" )
+            self.handle.sendline( 'yes' )
+            i = self.handle.expect( [ ssh_newkey, 'password:', pexpect.EOF ] )
+        if i == 1:
+            main.log.info( "ssh connection asked for password, gave password" )
+            self.handle.sendline( self.pwd )
+            self.handle.expect( '>|#|$' )
+
+        elif i == 2:
+            main.log.error( "Connection timeout" )
             return main.FALSE
-        elif i==3: #timeout
-            main.log.error("No route to the Host "+self.user_name+"@"+self.ip_address)
+        elif i == 3:  # timeout
+            main.log.error(
+                "No route to the Host " +
+                self.user_name +
+                "@" +
+                self.ip_address )
             return main.FALSE
-        elif i==4:
-            main.log.error("ssh: connect to host "+self.ip_address+" port 22: Connection refused")
+        elif i == 4:
+            main.log.error(
+                "ssh: connect to host " +
+                self.ip_address +
+                " port 22: Connection refused" )
             return main.FALSE
 
-        self.handle.sendline("\r")        
+        self.handle.sendline( "\r" )
         return main.TRUE
diff --git a/TestON/drivers/common/cli/remotetestbeddriver.py b/TestON/drivers/common/cli/remotetestbeddriver.py
index 79fbf1c..eaeacd9 100644
--- a/TestON/drivers/common/cli/remotetestbeddriver.py
+++ b/TestON/drivers/common/cli/remotetestbeddriver.py
@@ -1,13 +1,13 @@
 #!/usr/bin/env python
-'''
-Created on 26-Oct-2012 
+"""
+Created on 26-Oct-2012
 
-@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)      
+author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
 
     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
@@ -15,44 +15,66 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
-''' 
+"""
 import time
 import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
 import sys
-sys.path.append("../")
+import signal
+import sys
+sys.path.append( "../" )
 from drivers.common.clidriver import CLI
 
-class RemoteTestBedDriver(CLI):
-    # The common functions for emulator included in RemoteTestBedDriver
-    def __init__(self):
-        super(CLI, self).__init__()
-        
-    def connect(self,**connectargs):
-        for key in connectargs:
-           vars(self)['vm_'+key] = connectargs[key]
 
-        remote_user_name = main.componentDictionary[self.name]['remote_user_name']
-        remote_ip_address = main.componentDictionary[self.name]['remote_ip_address']
-        remote_port = main.componentDictionary[self.name]['remote_port'] 
-        remote_pwd = main.componentDictionary[self.name]['remote_pwd']
-        
-        self.handle = super(RemoteTestBedDriver,self).connect(user_name = remote_user_name, 
-                                                              ip_address = remote_ip_address,
-                                                              port = remote_port, pwd = remote_pwd)
-        
+class RemoteTestBedDriver( CLI ):
+    # The common functions for emulator included in RemoteTestBedDriver
+
+    def __init__( self ):
+        super( CLI, self ).__init__()
+
+    def connect( self, **connectargs ):
+        for key in connectargs:
+            vars( self )[ 'vm_' + key ] = connectargs[ key ]
+
+        remote_user_name = main.componentDictionary[
+            self.name ][ 'remote_user_name' ]
+        remote_ip_address = main.componentDictionary[
+            self.name ][ 'remote_ip_address' ]
+        remote_port = main.componentDictionary[ self.name ][ 'remote_port' ]
+        remote_pwd = main.componentDictionary[ self.name ][ 'remote_pwd' ]
+
+        self.handle = super(
+            RemoteTestBedDriver,
+            self ).connect(
+            user_name=remote_user_name,
+            ip_address=remote_ip_address,
+            port=remote_port,
+            pwd=remote_pwd )
+
         if self.handle:
-            self.execute(cmd= "\n",prompt= "\$|>|#",timeout= 10)
-            self.execute(cmd= "SET CYGWIN=notty",prompt= "\$|>|#",timeout= 10)
-            self.execute(cmd= "\n",prompt= "\$|>|#",timeout= 10)
-            main.log.info("ssh "+self.vm_user_name+'@'+self.vm_ip_address)
-            self.execute(cmd= "ssh "+self.vm_user_name+'@'+self.vm_ip_address,prompt= "(.*)",timeout= 10)
-            self.execute(cmd= "\n",prompt= "assword:",timeout= 10)
-            self.execute(cmd = self.vm_pwd,prompt = "\$",timeout = 10)
-            
+            self.execute( cmd="\n", prompt="\$|>|#", timeout=10 )
+            self.execute( cmd="SET CYGWIN=notty", prompt="\$|>|#", timeout=10 )
+            self.execute( cmd="\n", prompt="\$|>|#", timeout=10 )
+            main.log.info(
+                "ssh " +
+                self.vm_user_name +
+                '@' +
+                self.vm_ip_address )
+            self.execute(
+                cmd="ssh " +
+                self.vm_user_name +
+                '@' +
+                self.vm_ip_address,
+                prompt="(.*)",
+                timeout=10 )
+            self.execute( cmd="\n", prompt="assword:", timeout=10 )
+            self.execute( cmd=self.vm_pwd, prompt="\$", timeout=10 )
+
             return self.handle
-        else :
+        else:
             return main.FALSE
diff --git a/TestON/drivers/common/cli/tool/dpctlclidriver.py b/TestON/drivers/common/cli/tool/dpctlclidriver.py
index 3ad5bba..252fb8c 100644
--- a/TestON/drivers/common/cli/tool/dpctlclidriver.py
+++ b/TestON/drivers/common/cli/tool/dpctlclidriver.py
@@ -1,14 +1,14 @@
 #/usr/bin/env python
-'''
+"""
 Created on 26-Nov-2012
-       
-@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
+
+author:: Raghav Kashyap( raghavkashyap@paxterrasolutions.com )
 
 
     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
@@ -16,14 +16,18 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
 
 DPCTL driver class provides the basic functions of DPCTL controller
-'''
+"""
 import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
+import sys
+import signal
 import sys
 from drivers.common.cli.toolsdriver import Tools
 import pydoc
@@ -32,214 +36,280 @@
 import os
 import sys
 
-class DpctlCliDriver(Tools):
-    '''
+
+class DpctlCliDriver( Tools ):
+
+    """
      DpctlCliDriver driver class provides the basic functions of DPCTL controller
-    '''
-    def __init__(self):
-        super(DpctlCliDriver, self).__init__()
+    """
+    def __init__( self ):
+        super( DpctlCliDriver, self ).__init__()
         self.handle = self
-        self.wrapped = sys.modules[__name__]
-    
-    def connect(self,**connectargs):
-        
+        self.wrapped = sys.modules[ __name__ ]
+
+    def connect( self, **connectargs ):
+
         for key in connectargs:
-            vars(self)[key] = connectargs[key]       
-        
-        self.name = self.options['name']
-        
-        self.handle = super(DpctlCliDriver, self).connect(user_name = self.user_name, ip_address = self.ip_address,port = None, pwd = self.pwd)
-        if self.handle :
-            main.log.info("Connected to the host")
-            return main.TRUE
-        else :
-            main.log.error("Connection failed to the host "+self.user_name+"@"+self.ip_address)
-            return main.FALSE 
+            vars( self )[ key ] = connectargs[ key ]
 
-    def addFlow(self,**flowParameters):
-        '''
+        self.name = self.options[ 'name' ]
+
+        self.handle = super( 
+		      DpctlCliDriver, self ).connect( user_name=self.user_name,
+         	      ip_address=self.ip_address,
+         	      port=None,
+         	      pwd=self.pwd )
+        if self.handle:
+            main.log.info( "Connected to the host" )
+            return main.TRUE
+        else:
+            main.log.error(
+                "Connection failed to the host " +
+                self.user_name +
+                "@" +
+                self.ip_address )
+            return main.FALSE
+
+    def addFlow( self, **flowParameters ):
+        """
          addFlow create a new flow entry into flow table using "dpctl"
-        '''
-        args = utilities.parse_args(["TCPIP","TCPPORT","INPORT","ACTION","TIMEOUT"],**flowParameters)
+        """
+        args = utilities.parse_args( [
+				     "TCPIP",
+                                     "TCPPORT",
+                                     "INPORT",
+                                     "ACTION",
+                                     "TIMEOUT" ],
+            			     **flowParameters )
+
         cmd = "dpctl add-flow tcp:"
-        tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
-        tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
-        timeOut = args["TIMEOUT"] if args["TIMEOUT"] != None else 120
-        cmd = cmd + tcpIP + ":" + tcpPort + " in_port=" + str(args["INPORT"]) + ",idle_timeout=" + str(args["TIMEOUT"]) +",actions=" + args["ACTION"]   
-        response = self.execute(cmd=cmd,prompt="\~\$",timeout=60 )
-        if utilities.assert_matches(expect="openflow",actual=response,onpass="Flow Added Successfully",onfail="Adding Flow Failed!!!"):
+        tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+        tcpPort = args[ "TCPPORT" ] if args[
+            "TCPPORT" ] is not None else "6634"
+        timeOut = args[ "TIMEOUT" ] if args[ "TIMEOUT" ] is not None else 120
+        cmd = cmd + tcpIP + ":" + tcpPort + " in_port=" + \
+            str( args[ "INPORT" ] ) + ",idle_timeout=" + str(
+                args[ "TIMEOUT" ] ) + ",actions=" + args[ "ACTION" ]
+        response = self.execute( cmd=cmd, prompt="\~\$", timeout=60 )
+        if utilities.assert_matches( expect="openflow", actual=response, onpass="Flow Added Successfully", onfail="Adding Flow Failed!!!" ):
             return main.TRUE
-        else :
+        else:
             return main.FALSE
 
-    def showFlow(self,**flowParameters):
-        '''
+    def showFlow( self, **flowParameters ):
+        """
          showFlow dumps the flow entries of flow table using "dpctl"
-        '''
-        args = utilities.parse_args(["TCPIP","TCPPORT"],**flowParameters)
-        tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
-        tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
-        command = "dpctl show tcp:" + str(tcpIP) + ":" + str(tcpPort)
-        response = self.execute(cmd=command,prompt="get_config_reply",timeout=240)
-        if utilities.assert_matches(expect='features_reply',actual=response,onpass="Show flow executed",onfail="Show flow execution Failed"):
+        """
+        args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters )
+        tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+        tcpPort = args[ "TCPPORT" ] if args[
+            "TCPPORT" ] is not None else "6634"
+        command = "dpctl show tcp:" + str( tcpIP ) + ":" + str( tcpPort )
+        response = self.execute(
+            cmd=command,
+            prompt="get_config_reply",
+            timeout=240 )
+        if utilities.assert_matches( expect='features_reply', actual=response, onpass="Show flow executed", onfail="Show flow execution Failed" ):
             main.last_result = main.TRUE
             return main.TRUE
-        else :
+        else:
             main.last_result = main.FALSE
             return main.FALSE
 
-    def dumpFlow(self,**flowParameters):
-        '''
+    def dumpFlow( self, **flowParameters ):
+        """
          dumpFlow  gives installed flow information
-        '''
-        args = utilities.parse_args(["TCPIP","TCPPORT"],**flowParameters)
-        tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
-        tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
-        command = "dpctl dump-flows tcp:" + str(tcpIP) + ":" + str(tcpPort)
-        response = self.execute(cmd=command,prompt="type=",timeout=240)
-        if utilities.assert_matches(expect='stats_reply',actual=response,onpass="Dump flow executed",onfail="Dump flow execution Failed"):
+        """
+        args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters )
+        tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+        tcpPort = args[ "TCPPORT" ] if args[
+            "TCPPORT" ] is not None else "6634"
+        command = "dpctl dump-flows tcp:" + str( tcpIP ) + ":" + str( tcpPort )
+        response = self.execute( cmd=command, prompt="type=", timeout=240 )
+        if utilities.assert_matches( expect='stats_reply', actual=response, onpass="Dump flow executed", onfail="Dump flow execution Failed" ):
             main.last_result = main.TRUE
             return main.TRUE
-        else :
+        else:
             main.last_result = main.FALSE
             return main.FALSE
 
-    
-    def dumpTables(self,**flowParameters):
-        '''
+    def dumpTables( self, **flowParameters ):
+        """
          dumpTables gives statistics for each of the flow tables used by datapath switch.
-        '''
-        args = utilities.parse_args(["TCPIP","TCPPORT"],**flowParameters)
-        tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
-        tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
-        command = "dpctl dump-tables tcp:" + str(tcpIP) + ":" + str(tcpPort)
-        response = self.execute(cmd=command,prompt="matched",timeout=240)
-        if utilities.assert_matches(expect='lookup=3',actual=response,onpass="Dump Tables executed",onfail="Dump Tables execution Failed"):
+        """
+        args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters )
+        tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+        tcpPort = args[ "TCPPORT" ] if args[
+            "TCPPORT" ] is not None else "6634"
+        command = "dpctl dump-tables tcp:" + \
+            str( tcpIP ) + ":" + str( tcpPort )
+        response = self.execute( cmd=command, prompt="matched", timeout=240 )
+        if utilities.assert_matches( expect='lookup=3', actual=response, onpass="Dump Tables executed", onfail="Dump Tables execution Failed" ):
             main.last_result = main.TRUE
             return main.TRUE
-        else :
+        else:
             main.last_result = main.FALSE
             return main.FALSE
-         
-    def dumpPorts(self,**flowParameters):
-        '''
+
+    def dumpPorts( self, **flowParameters ):
+        """
          dumpPorts gives ports information
-        '''
-        args = utilities.parse_args(["TCPIP","TCPPORT"],**flowParameters)
-        tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
-        tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
-        command = "dpctl dump-ports tcp:" + str(tcpIP) + ":" + str(tcpPort)
-        response = self.execute(cmd=command,prompt="rx pkts",timeout=240)
-        if utilities.assert_matches(expect='ports',actual=response,onpass="Dump Ports executed",onfail="Dump Ports execution Failed"):
+        """
+        args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters )
+        tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+        tcpPort = args[ "TCPPORT" ] if args[
+            "TCPPORT" ] is not None else "6634"
+        command = "dpctl dump-ports tcp:" + str( tcpIP ) + ":" + str( tcpPort )
+        response = self.execute( cmd=command, prompt="rx pkts", timeout=240 )
+        if utilities.assert_matches( expect='ports', actual=response, onpass="Dump Ports executed", onfail="Dump Ports execution Failed" ):
             main.last_result = main.TRUE
             return main.TRUE
-        else :
+        else:
             main.last_result = main.FALSE
             return main.FALSE
 
-
-    def dumpAggregate(self,**flowParameters):
-        '''
+    def dumpAggregate( self, **flowParameters ):
+        """
          dumpAggregate  gives installed flow information.ggregate statistics for flows in datapath WITCH's tables that match flows.
          If flows is omitted, the statistics are aggregated across all flows in the datapath's flow tables
-        '''
-        args = utilities.parse_args(["TCPIP","TCPPORT","FLOW"],**flowParameters)
-        tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
-        tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
-        flow = args["FLOW"] if args["FLOW"] != None else ""
-        command = "dpctl dump-aggregate tcp:" + str(tcpIP) + ":" + str(tcpPort) + " " + str (flow)
-        response = self.execute(cmd=command,prompt="flow_count=",timeout=240)
-        if utilities.assert_matches(expect='stats_reply',actual=response,onpass="Dump Aggregate executed",onfail="Dump Aggregate execution Failed"):
+        """
+        args = utilities.parse_args(
+            [ "TCPIP", "TCPPORT", "FLOW" ], **flowParameters )
+        tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+        tcpPort = args[ "TCPPORT" ] if args[
+            "TCPPORT" ] is not None else "6634"
+        flow = args[ "FLOW" ] if args[ "FLOW" ] is not None else ""
+        command = "dpctl dump-aggregate tcp:" + \
+            str( tcpIP ) + ":" + str( tcpPort ) + " " + str( flow )
+        response = self.execute(
+            cmd=command,
+            prompt="flow_count=",
+            timeout=240 )
+        if utilities.assert_matches( expect='stats_reply', actual=response, onpass="Dump Aggregate executed", onfail="Dump Aggregate execution Failed" ):
             main.last_result = main.TRUE
             return main.TRUE
-        else :
+        else:
             main.last_result = main.FALSE
             return main.FALSE
 
-    def delFlow(self,**flowParameters):
-        '''
+    def delFlow( self, **flowParameters ):
+        """
          delFlow Deletes entries from the datapath switch's tables that match flow
-        '''
-        args = utilities.parse_args(["TCPIP","TCPPORT","FLOW"],**flowParameters)
-        tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
-        tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
-        flow = args["FLOW"] if args["FLOW"] != None else ""
-        command = "dpctl del-flows tcp:" + str(tcpIP) + ":" + str(tcpPort) + " " +str(flow)
-        response = self.execute(cmd=command,prompt="ETH-Tutorial",timeout=240)
-        if utilities.assert_matches(expect='@',actual=response,onpass="Delete flow executed",onfail="Delete flow execution Failed"):
+        """
+        args = utilities.parse_args(
+            [ "TCPIP", "TCPPORT", "FLOW" ], **flowParameters )
+        tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+        tcpPort = args[ "TCPPORT" ] if args[
+            "TCPPORT" ] is not None else "6634"
+        flow = args[ "FLOW" ] if args[ "FLOW" ] is not None else ""
+        command = "dpctl del-flows tcp:" + \
+            str( tcpIP ) + ":" + str( tcpPort ) + " " + str( flow )
+        response = self.execute(
+            cmd=command,
+            prompt="ETH-Tutorial",
+            timeout=240 )
+        if utilities.assert_matches( expect='@', actual=response, onpass="Delete flow executed", onfail="Delete flow execution Failed" ):
             main.last_result = main.TRUE
             return main.TRUE
-        else :
+        else:
             main.last_result = main.FALSE
             return main.FALSE
 
-    def show(self,**flowParameters):
-        '''
+    def show( self, **flowParameters ):
+        """
          show gives information on datapath switch including information on its flow tables and ports.
-        '''
-        args = utilities.parse_args(["TCPIP","TCPPORT"],**flowParameters)
-        tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
-        tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
-        command = "dpctl show tcp:" + str(tcpIP) + ":" + str(tcpPort)
-        response = self.execute(cmd=command,prompt="miss_send_len=",timeout=240)
-        if utilities.assert_matches(expect='get_config_reply',actual=response,onpass="show command executed",onfail="show command execution Failed"):
+        """
+        args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters )
+        tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+        tcpPort = args[ "TCPPORT" ] if args[
+            "TCPPORT" ] is not None else "6634"
+        command = "dpctl show tcp:" + str( tcpIP ) + ":" + str( tcpPort )
+        response = self.execute(
+            cmd=command,
+            prompt="miss_send_len=",
+            timeout=240 )
+        if utilities.assert_matches( expect='get_config_reply', actual=response, onpass="show command executed", onfail="show command execution Failed" ):
             main.last_result = main.TRUE
             return main.TRUE
-        else :
+        else:
             main.last_result = main.FALSE
             return main.FALSE
 
-    def showStatus(self,**flowParameters):
-        '''
-         showStatus gives a series of key-value pairs that report the status of switch. 
-         If key is specified, only the key-value pairs whose key names begin with key are printed. 
-        '''
-        args = utilities.parse_args(["TCPIP","TCPPORT","KEY"],**flowParameters)
-        tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
-        tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
-        key = args["KEY"] if args["KEY"] != None else ""
-        command = "dpctl status tcp:" + str(tcpIP) + ":" + str(tcpPort) + " " + key
-        response = self.execute(cmd=command,prompt="(.*)",timeout=240)
-        if utilities.assert_matches(expect='(.*)',actual=response,onpass="show command executed",onfail="show command execution Failed"):
+    def showStatus( self, **flowParameters ):
+        """
+         showStatus gives a series of key-value pairs that report the status of switch.
+         If key is specified, only the key-value pairs whose key names begin with key are printed.
+        """
+        args = utilities.parse_args(
+            [ "TCPIP", "TCPPORT", "KEY" ], **flowParameters )
+        tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+        tcpPort = args[ "TCPPORT" ] if args[
+            "TCPPORT" ] is not None else "6634"
+        key = args[ "KEY" ] if args[ "KEY" ] is not None else ""
+        command = "dpctl status tcp:" + \
+            str( tcpIP ) + ":" + str( tcpPort ) + " " + key
+        response = self.execute( cmd=command, prompt="(.*)", timeout=240 )
+        if utilities.assert_matches( expect='(.*)', actual=response, onpass="show command executed", onfail="show command execution Failed" ):
             main.last_result = main.TRUE
             return main.TRUE
-        else :
+        else:
             main.last_result = main.FALSE
             return main.FALSE
 
-    def desc_set(self,**flowParameters):
-        '''
-         desc_set Sets the switch description (as returned in ofp_desc_stats) to string (max length is DESC_STR_LEN)
-        '''
-        args = utilities.parse_args(["TCPIP","TCPPORT","STRING"],**flowParameters)
-        tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
-        tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
-        string = " " + args["STRING"] if args["STRING"] != None else " DESC_STR_LEN"
-        command = "dpctl desc tcp:" + str(tcpIP) + ":" + str(tcpPort) + str(string)
-        response = self.execute(cmd=command,prompt="ETH-Tutorial",timeout=240)
-        if utilities.assert_matches(expect='@',actual=response,onpass="desc command executed",onfail="desc command execution Failed"):
+    def desc_set( self, **flowParameters ):
+        """
+         desc_set Sets the switch description ( as returned in ofp_desc_stats ) to string ( max length is DESC_STR_LEN )
+        """
+        args = utilities.parse_args( [
+				     "TCPIP",
+                                     "TCPPORT",
+                                     "STRING" ],
+           			     **flowParameters )
+
+        tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+        tcpPort = args[ "TCPPORT" ] if args[
+            "TCPPORT" ] is not None else "6634"
+        string = " " + args[ "STRING" ] if args[
+            "STRING" ] is not None else " DESC_STR_LEN"
+        command = "dpctl desc tcp:" + \
+            str( tcpIP ) + ":" + str( tcpPort ) + str( string )
+        response = self.execute(
+            cmd=command,
+            prompt="ETH-Tutorial",
+            timeout=240 )
+        if utilities.assert_matches( expect='@', actual=response, onpass="desc command executed", onfail="desc command execution Failed" ):
             main.last_result = main.TRUE
             return main.TRUE
-        else :
+        else:
             main.last_result = main.FALSE
             return main.FALSE
 
-    def dumpDesc(self,**flowParameters):
-        '''
-         dumpDesc Sets the switch description (as returned in ofp_desc_stats) to string (max length is DESC_STR_LEN)
-        '''
-        args = utilities.parse_args(["TCPIP","TCPPORT","STRING"],**flowParameters)
-        tcpIP = args["TCPIP"] if args["TCPIP"] != None else "127.0.0.1"
-        tcpPort = args["TCPPORT"] if args["TCPPORT"] != None else "6634"
-        command = "dpctl dump-desc tcp:" + str(tcpIP) + ":" + str(tcpPort) 
-        response = self.execute(cmd=command,prompt="Serial Num:",timeout=240)
-        if utilities.assert_matches(expect='stats_reply',actual=response,onpass="desc command executed",onfail="desc command execution Failed"):
+    def dumpDesc( self, **flowParameters ):
+        """
+         dumpDesc Sets the switch description ( as returned in ofp_desc_stats ) to string ( max length is DESC_STR_LEN )
+        """
+        args = utilities.parse_args( [
+				     "TCPIP",
+                                     "TCPPORT",
+                                     "STRING" ],
+            			     **flowParameters )
+
+        tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
+        tcpPort = args[ "TCPPORT" ] if args[
+            "TCPPORT" ] is not None else "6634"
+        command = "dpctl dump-desc tcp:" + str( tcpIP ) + ":" + str( tcpPort )
+        response = self.execute(
+            cmd=command,
+            prompt="Serial Num:",
+            timeout=240 )
+        if utilities.assert_matches( expect='stats_reply', actual=response, onpass="desc command executed", onfail="desc command execution Failed" ):
             main.last_result = main.TRUE
             return main.TRUE
-        else :
+        else:
             main.last_result = main.FALSE
             return main.FALSE
 
 if __name__ != "__main__":
     import sys
-    sys.modules[__name__] = DpctlCliDriver()
+    sys.modules[ __name__ ] = DpctlCliDriver()
+
diff --git a/TestON/drivers/common/cli/toolsdriver.py b/TestON/drivers/common/cli/toolsdriver.py
index 2c165f9..ec4585f 100644
--- a/TestON/drivers/common/cli/toolsdriver.py
+++ b/TestON/drivers/common/cli/toolsdriver.py
@@ -1,13 +1,13 @@
 #!/usr/bin/env python
-'''
+"""
 Created on 26-Nov-2012
 
-@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
+author:: Raghav Kashyap( raghavkashyap@paxterrasolutions.com )
 
     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
@@ -15,18 +15,23 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
-'''  
+"""
 import pexpect
-import struct, fcntl, os, sys, signal
+import struct
+import fcntl
+import os
 import sys
-sys.path.append("../")
+import signal
+import sys
+sys.path.append( "../" )
 from drivers.common.clidriver import CLI
 
 
-class Tools(CLI):
+class Tools( CLI ):
     # The common functions for Tools included in toolsdriver
-    def __init__(self):
-        super(CLI, self).__init__()
+
+    def __init__( self ):
+        super( CLI, self ).__init__()
diff --git a/TestON/drivers/common/clidriver.py b/TestON/drivers/common/clidriver.py
index 878839e..55ff522 100644
--- a/TestON/drivers/common/clidriver.py
+++ b/TestON/drivers/common/clidriver.py
@@ -1,15 +1,15 @@
 #!/usr/bin/env python
-'''
+"""
 Created on 24-Oct-2012
-    
-@authors: Anil Kumar (anilkumar.s@paxterrasolutions.com),
-          Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
+
+author:s: Anil Kumar ( anilkumar.s@paxterrasolutions.com ),
+          Raghav Kashyap( raghavkashyap@paxterrasolutions.com )
 
 
     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
@@ -17,78 +17,117 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
-          
-'''
+
+"""
 import pexpect
-import struct, fcntl, os, sys, signal
-import sys, re
-sys.path.append("../")
+import struct
+import fcntl
+import os
+import sys
+import signal
+import sys
+import re
+sys.path.append( "../" )
 
 from drivers.component import Component
-class CLI(Component):
-    '''
+
+
+class CLI( Component ):
+
+    """
         This will define common functions for CLI included.
-    '''
-    def __init__(self):
-        super(Component, self).__init__()
-        
-    def connect(self,**connectargs):
-        '''
+    """
+    def __init__( self ):
+        super( Component, self ).__init__()
+
+    def connect( self, **connectargs ):
+        """
            Connection will establish to the remote host using ssh.
            It will take user_name ,ip_address and password as arguments<br>
-           and will return the handle. 
-        '''
+           and will return the handle.
+        """
         for key in connectargs:
-            vars(self)[key] = connectargs[key]
+            vars( self )[ key ] = connectargs[ key ]
 
-        connect_result = super(CLI, self).connect()
+        connect_result = super( CLI, self ).connect()
         ssh_newkey = 'Are you sure you want to continue connecting'
-        refused = "ssh: connect to host "+self.ip_address+" port 22: Connection refused"
+        refused = "ssh: connect to host " + \
+            self.ip_address + " port 22: Connection refused"
         if self.port:
-            self.handle =pexpect.spawn('ssh -p '+self.port+' '+self.user_name+'@'+self.ip_address, env = {"TERM": "vt100"} , maxread=50000)
-        else :
-            self.handle =pexpect.spawn('ssh -X '+self.user_name+'@'+self.ip_address,maxread=1000000,timeout=60)
+            self.handle = pexpect.spawn(
+                'ssh -p ' +
+                self.port +
+                ' ' +
+                self.user_name +
+                '@' +
+                self.ip_address,
+                env={
+                    "TERM": "vt100" },
+                maxread=50000 )
+        else:
+            self.handle = pexpect.spawn(
+                'ssh -X ' +
+                self.user_name +
+                '@' +
+                self.ip_address,
+                maxread=1000000,
+                timeout=60 )
 
         self.handle.logfile = self.logfile_handler
-	i = 5
-	while i == 5:
-	    i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF,pexpect.TIMEOUT,refused,'teston>','>|#|\$'],120)
-	    if i==0:
-	        main.log.info("ssh key confirmation received, send yes")
-	        self.handle.sendline('yes')
-	        i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF])
-	    if i==1:
-	        main.log.info("ssh connection asked for password, gave password")
-	        self.handle.sendline(self.pwd)
-	        self.handle.expect('>|#|\$')
-	    elif i==2:
-	        main.log.error("Connection timeout")
-	        return main.FALSE
-	    elif i==3: #timeout
-	        main.log.error("No route to the Host "+self.user_name+"@"+self.ip_address)
-	        return main.FALSE
-	    elif i==4:
-	        main.log.error("ssh: connect to host "+self.ip_address+" port 22: Connection refused")
-	        return main.FALSE
-	    elif i==6:
-	        main.log.info("Password not required logged in")
+        i = 5
+        while i == 5:
+            i = self.handle.expect( [
+				    ssh_newkey,
+                                    'password:',
+                                    pexpect.EOF,
+                                    pexpect.TIMEOUT,
+                                    refused,
+                                    'teston>',
+                                    '>|#|\$' ],
+                		    120 )
+            if i == 0:
+                main.log.info( "ssh key confirmation received, send yes" )
+                self.handle.sendline( 'yes' )
+                i = self.handle.expect(
+                    [ ssh_newkey, 'password:', pexpect.EOF ] )
+            if i == 1:
+                main.log.info(
+                    "ssh connection asked for password, gave password" )
+                self.handle.sendline( self.pwd )
+                self.handle.expect( '>|#|\$' )
+            elif i == 2:
+                main.log.error( "Connection timeout" )
+                return main.FALSE
+            elif i == 3:  # timeout
+                main.log.error(
+                    "No route to the Host " +
+                    self.user_name +
+                    "@" +
+                    self.ip_address )
+                return main.FALSE
+            elif i == 4:
+                main.log.error(
+                    "ssh: connect to host " +
+                    self.ip_address +
+                    " port 22: Connection refused" )
+                return main.FALSE
+            elif i == 6:
+                main.log.info( "Password not required logged in" )
 
-        self.handle.sendline("")
-        self.handle.expect('>|#|\$')
+        self.handle.sendline( "" )
+        self.handle.expect( '>|#|\$' )
         return self.handle
 
-    
-    def disconnect(self):
-        result = super(CLI, self).disconnect(self)
+    def disconnect( self ):
+        result = super( CLI, self ).disconnect( self )
         result = main.TRUE
-        #self.execute(cmd="exit",timeout=120,prompt="(.*)")
-    
-    
-    def execute(self, **execparams):
-        '''
+        # self.execute( cmd="exit",timeout=120,prompt="(.*)" )
+
+    def execute( self, **execparams ):
+        """
         It facilitates the command line execution of a given command. It has arguments as :
         cmd => represents command to be executed,
         prompt => represents expect command prompt or output,
@@ -96,127 +135,171 @@
         more => to provide a key press if it is on.
 
         It will return output of command exection.
-        '''
-
-        result = super(CLI, self).execute(self)
+        """
+        result = super( CLI, self ).execute( self )
         defaultPrompt = '.*[$>\#]'
-        args = utilities.parse_args(["CMD", "TIMEOUT", "PROMPT", "MORE"], **execparams)
-        expectPrompt = args["PROMPT"] if args["PROMPT"] else defaultPrompt
+        args = utilities.parse_args( [
+				     "CMD",
+                                     "TIMEOUT",
+                                     "PROMPT",
+                                     "MORE" ],
+            			     **execparams )
+
+        expectPrompt = args[ "PROMPT" ] if args[ "PROMPT" ] else defaultPrompt
         self.LASTRSP = ""
-        timeoutVar = args["TIMEOUT"] if args["TIMEOUT"] else 10
+        timeoutVar = args[ "TIMEOUT" ] if args[ "TIMEOUT" ] else 10
         cmd = ''
-        if args["CMD"]:
-            cmd = args["CMD"]
-        else :
+        if args[ "CMD" ]:
+            cmd = args[ "CMD" ]
+        else:
             return 0
-        if args["MORE"] == None:
-            args["MORE"] = " "
-        self.handle.sendline(cmd)
+        if args[ "MORE" ] is None:
+            args[ "MORE" ] = " "
+        self.handle.sendline( cmd )
         self.lastCommand = cmd
-        index = self.handle.expect([expectPrompt, "--More--", 'Command not found.', pexpect.TIMEOUT,"^:$"], timeout = timeoutVar)
+        index = self.handle.expect( [
+				    expectPrompt,
+                                    "--More--",
+                                    'Command not found.',
+                                    pexpect.TIMEOUT,
+                                    "^:$" ],
+            			    timeout=timeoutVar )
         if index == 0:
-            self.LASTRSP = self.LASTRSP + self.handle.before + self.handle.after
-            main.log.info("Executed :"+str(cmd)+" \t\t Expected Prompt '"+ str(expectPrompt)+"' Found")
+            self.LASTRSP = self.LASTRSP + \
+                self.handle.before + self.handle.after
+            main.log.info(
+                "Executed :" + str(
+                    cmd ) + " \t\t Expected Prompt '" + str(
+                        expectPrompt) + "' Found" )
         elif index == 1:
             self.LASTRSP = self.LASTRSP + self.handle.before
-            self.handle.send(args["MORE"])
-            main.log.info("Found More screen to go , Sending a key to proceed")
-            indexMore = self.handle.expect(["--More--", expectPrompt], timeout = timeoutVar)
+            self.handle.send( args[ "MORE" ] )
+            main.log.info(
+                "Found More screen to go , Sending a key to proceed" )
+            indexMore = self.handle.expect(
+                [ "--More--", expectPrompt ], timeout=timeoutVar )
             while indexMore == 0:
-                main.log.info("Found anoother More screen to go , Sending a key to proceed")
-                self.handle.send(args["MORE"])
-                indexMore = self.handle.expect(["--More--", expectPrompt], timeout = timeoutVar)
+                main.log.info(
+                    "Found anoother More screen to go , Sending a key to proceed" )
+                self.handle.send( args[ "MORE" ] )
+                indexMore = self.handle.expect(
+                    [ "--More--", expectPrompt ], timeout=timeoutVar )
                 self.LASTRSP = self.LASTRSP + self.handle.before
-        elif index ==2:
-            main.log.error("Command not found")
+        elif index == 2:
+            main.log.error( "Command not found" )
             self.LASTRSP = self.LASTRSP + self.handle.before
-        elif index ==3:
-            main.log.error("Expected Prompt not found , Time Out!!") 
-            main.log.error( expectPrompt ) 
+        elif index == 3:
+            main.log.error( "Expected Prompt not found , Time Out!!" )
+            main.log.error( expectPrompt )
             return "Expected Prompt not found , Time Out!!"
-        
+
         elif index == 4:
             self.LASTRSP = self.LASTRSP + self.handle.before
-            #self.handle.send(args["MORE"])
-            self.handle.sendcontrol("D")
-            main.log.info("Found More screen to go , Sending a key to proceed")
-            indexMore = self.handle.expect(["^:$", expectPrompt], timeout = timeoutVar)
+            # self.handle.send( args[ "MORE" ] )
+            self.handle.sendcontrol( "D" )
+            main.log.info(
+                "Found More screen to go , Sending a key to proceed" )
+            indexMore = self.handle.expect(
+                [ "^:$", expectPrompt ], timeout=timeoutVar )
             while indexMore == 0:
-                main.log.info("Found another More screen to go , Sending a key to proceed")
-                self.handle.sendcontrol("D")
-                indexMore = self.handle.expect(["^:$", expectPrompt], timeout = timeoutVar)
+                main.log.info(
+                    "Found another More screen to go , Sending a key to proceed" )
+                self.handle.sendcontrol( "D" )
+                indexMore = self.handle.expect(
+                    [ "^:$", expectPrompt ], timeout=timeoutVar )
                 self.LASTRSP = self.LASTRSP + self.handle.before
-        
-        main.last_response = self.remove_contol_chars(self.LASTRSP)
+
+        main.last_response = self.remove_contol_chars( self.LASTRSP )
         return self.LASTRSP
-    
-    def remove_contol_chars(self,response):
-        #RE_XML_ILLEGAL = '([\u0000-\u0008\u000b-\u000c\u000e-\u001f\ufffe-\uffff])|([%s-%s][^%s-%s])|([^%s-%s][%s-%s])|([%s-%s]$)|(^[%s-%s])'%(unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff))  
-        #response = re.sub(RE_XML_ILLEGAL, "\n", response) 
-        response = re.sub(r"[\x01-\x1F\x7F]", "", response)
-        #response = re.sub(r"\[\d+\;1H", "\n", response)
-        response = re.sub(r"\[\d+\;\d+H", "", response)
+
+    def remove_contol_chars( self, response ):
+        # RE_XML_ILLEGAL = '([\u0000-\u0008\u000b-\u000c\u000e-\u001f\ufffe-\uffff])|([%s-%s][^%s-%s])|([^%s-%s][%s-%s])|([%s-%s]$)|(^[%s-%s])'%( unichr( 0xd800 ),unichr( 0xdbff ),unichr( 0xdc00 ),unichr( 0xdfff ),unichr( 0xd800 ),unichr( 0xdbff ),unichr( 0xdc00 ),unichr( 0xdfff ),unichr( 0xd800 ),unichr( 0xdbff ),unichr( 0xdc00 ),unichr( 0xdfff ) )
+        # response = re.sub( RE_XML_ILLEGAL, "\n", response )
+        response = re.sub( r"[\x01-\x1F\x7F]", "", response )
+        # response = re.sub( r"\[\d+\;1H", "\n", response )
+        response = re.sub( r"\[\d+\;\d+H", "", response )
         return response
-        
-    def runAsSudoUser(self,handle,pwd,default):
-        
-        i = handle.expect([".ssword:*",default, pexpect.EOF])
-        if i==0:
-            handle.sendline(pwd)
-            handle.sendline("\r")
 
-        if i==1:
-            handle.expect(default)
-        
-        if i==2:
-            main.log.error("Unable to run as Sudo user")
-            
+    def runAsSudoUser( self, handle, pwd, default ):
+
+        i = handle.expect( [ ".ssword:*", default, pexpect.EOF ] )
+        if i == 0:
+            handle.sendline( pwd )
+            handle.sendline( "\r" )
+
+        if i == 1:
+            handle.expect( default )
+
+        if i == 2:
+            main.log.error( "Unable to run as Sudo user" )
+
         return handle
-        
-    def onfail(self):
-        if main.componentDictionary[self.name].has_key('onfail'):
-            commandList = main.componentDictionary[self.name]['onfail'].split(",")
-            for command in commandList :
-                response = self.execute(cmd=command,prompt="(.*)",timeout=120)
 
-    def secureCopy(self,user_name, ip_address,filepath, pwd,dst_path):
-        
-        #scp openflow@192.168.56.101:/home/openflow/sample /home/paxterra/Desktop/
+    def onfail( self ):
+        if 'onfail' in main.componentDictionary[ self.name ]:
+            commandList = main.componentDictionary[
+                self.name ][ 'onfail' ].split( "," )
+            for command in commandList:
+                response = self.execute(
+                    cmd=command,
+                    prompt="(.*)",
+                    timeout=120 )
 
-        '''
+    def secureCopy( self, user_name, ip_address, filepath, pwd, dst_path ):
+
+        # scp openflow@192.168.56.101:/home/openflow/sample
+        # /home/paxterra/Desktop/
+        """
            Connection will establish to the remote host using ssh.
            It will take user_name ,ip_address and password as arguments<br>
-           and will return the handle. 
-        '''
+           and will return the handle.
+        """
         ssh_newkey = 'Are you sure you want to continue connecting'
-        refused = "ssh: connect to host "+ip_address+" port 22: Connection refused"
-        cmd = 'scp '+str(user_name)+'@'+str(ip_address)+':'+str(filepath)+' '+str(dst_path)
-        main.log.info("Sending: " + cmd )
-        self.handle =pexpect.spawn( cmd )
-        i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF,pexpect.TIMEOUT,refused],120)
+        refused = "ssh: connect to host " + \
+            ip_address + " port 22: Connection refused"
         
-        if i==0:    
-            main.log.info("ssh key confirmation received, send yes")
-            self.handle.sendline('yes')
-            i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF])
-        if i==1:
-            main.log.info("ssh connection asked for password, gave password")
-            self.handle.sendline(pwd)
-            #self.handle.expect(user_name)
-            
-        elif i==2:
-            main.log.error("Connection timeout")
+	cmd = 'scp ' + str( user_name ) + '@' + str( ip_address ) + ':' + \
+	      str( filepath ) + ' ' + str(dst_path )
+
+        main.log.info( "Sending: " + cmd )
+        self.handle = pexpect.spawn( cmd )
+        i = self.handle.expect( [
+				ssh_newkey,
+                              	'password:',
+                              	pexpect.EOF,
+                              	pexpect.TIMEOUT,
+                              	refused ],
+            			120 )
+
+        if i == 0:
+            main.log.info( "ssh key confirmation received, send yes" )
+            self.handle.sendline( 'yes' )
+            i = self.handle.expect( [ ssh_newkey, 'password:', pexpect.EOF ] )
+        if i == 1:
+            main.log.info( "ssh connection asked for password, gave password" )
+            self.handle.sendline( pwd )
+            # self.handle.expect( user_name )
+
+        elif i == 2:
+            main.log.error( "Connection timeout" )
             pass
-        elif i==3: #timeout
-            main.log.error("No route to the Host "+user_name+"@"+ip_address)
+        elif i == 3:  # timeout
+            main.log.error(
+                "No route to the Host " +
+                user_name +
+                "@" +
+                ip_address )
             return main.FALSE
-        elif i==4:
-            main.log.error("ssh: connect to host "+ip_address+" port 22: Connection refused")
+        elif i == 4:
+            main.log.error(
+                "ssh: connect to host " +
+                ip_address +
+                " port 22: Connection refused" )
             return main.FALSE
 
-        self.handle.sendline("")
-        self.handle.expect("$")
+        self.handle.sendline( "" )
+        self.handle.expect( "$" )
         print self.handle.before
-        
+
         return self.handle
-    
+
diff --git a/TestON/drivers/component.py b/TestON/drivers/component.py
index ec94283..1e87d03 100644
--- a/TestON/drivers/component.py
+++ b/TestON/drivers/component.py
@@ -1,16 +1,16 @@
 #!/usr/bin/env python
 import logging
-'''
+"""
 Created on 24-Oct-2012
-    
-@authors: Anil Kumar (anilkumar.s@paxterrasolutions.com),
-          Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
+
+author:s: Anil Kumar ( anilkumar.s@paxterrasolutions.com ),
+          Raghav Kashyap( raghavkashyap@paxterrasolutions.com )
 
 
     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,99 +18,104 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with TestON.  If not, see <http://www.gnu.org/licenses/>.		
+    along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
 
-          
-'''
 
+"""
 import re
 from logging import Logger
 
-class Component(object):
-    '''
+
+class Component( object ):
+
+    """
     This is the tempalte class for components
-    '''
-    def __init__(self):
+    """
+    def __init__( self ):
         self.default = ''
-        self.wrapped = sys.modules[__name__]
-        
-    def __getattr__(self, name):
-        ''' 
+        self.wrapped = sys.modules[ __name__ ]
+
+    def __getattr__( self, name ):
+        """
          This will invoke, if the attribute wasn't found the usual ways.
           Here it will look for assert_attribute and will execute when AttributeError occurs.
           It will return the result of the assert_attribute.
-        '''
+        """
         try:
-            return getattr(self.wrapped, name)
+            return getattr( self.wrapped, name )
         except AttributeError:
             try:
-                def experimentHandling(**kwargs):
+                def experimentHandling( **kwargs ):
                     if main.EXPERIMENTAL_MODE == main.TRUE:
-                        result = self.experimentRun(**kwargs)
-                        main.log.info("EXPERIMENTAL MODE. API "+str(name)+" not yet implemented. Returning dummy values")
-                        return result 
+                        result = self.experimentRun( **kwargs )
+                        main.log.info( "EXPERIMENTAL MODE. API " + str(
+                            name ) + " not yet implemented. Returning dummy values" )
+                        return result
                     else:
                         return main.FALSE
                 return experimentHandling
-            except TypeError,e:
-                main.log.error("Arguments for experimental mode does not have key 'retruns'" + e)
-        
-        
-    def connect(self):
-        
-        vars(main)[self.name+'log'] = logging.getLogger(self.name)
-                    
-        session_file = main.logdir+"/"+self.name+".session"
-        self.log_handler = logging.FileHandler(session_file)
-        self.log_handler.setLevel(logging.DEBUG)
-            
-        vars(main)[self.name+'log'].setLevel(logging.DEBUG)
-        _formatter = logging.Formatter("%(asctime)s  %(name)-10s: %(levelname)-8s: %(message)s")
-        self.log_handler.setFormatter(_formatter)
-        vars(main)[self.name+'log'].addHandler(self.log_handler)
-        # Adding header for the component log     
-        vars(main)[self.name+'log'].info(main.logHeader)
+            except TypeError as e:
+                main.log.error(
+                    "Arguments for experimental mode does not have key 'retruns'" +
+                    e )
+
+    def connect( self ):
+
+        vars( main )[ self.name + 'log' ] = logging.getLogger( self.name )
+
+        session_file = main.logdir + "/" + self.name + ".session"
+        self.log_handler = logging.FileHandler( session_file )
+        self.log_handler.setLevel( logging.DEBUG )
+
+        vars( main )[ self.name + 'log' ].setLevel( logging.DEBUG )
+        _formatter = logging.Formatter(
+            "%(asctime)s  %(name)-10s: %(levelname)-8s: %(message)s" )
+        self.log_handler.setFormatter( _formatter )
+        vars( main )[ self.name + 'log' ].addHandler( self.log_handler )
+        # Adding header for the component log
+        vars( main )[ self.name + 'log' ].info( main.logHeader )
         # Opening the session log to append command's execution output
-        self.logfile_handler = open(session_file,"a")
-        
+        self.logfile_handler = open( session_file, "a" )
+
         return "Dummy"
-    
-    def execute(self,cmd):
+
+    def execute( self, cmd ):
         return main.TRUE
-        #import commands
-        #return commands.getoutput(cmd)
-        
-    def disconnect(self):
-        return main.TRUE 
-    
-    def config(self):
+        # import commands
+        # return commands.getoutput( cmd )
+
+    def disconnect( self ):
+        return main.TRUE
+
+    def config( self ):
         self = self
         # Need to update the configuration code
-        
-    def cleanup(self):
+
+    def cleanup( self ):
         return main.TRUE
-    
-    def log(self,message):
-        '''
-        Here finding the for the component to which the 
+
+    def log( self, message ):
+        """
+        Here finding the for the component to which the
         log message based on the called child object.
-        '''
-        vars(main)[self.name+'log'].info("\n"+message+"\n")
-        
-    def close_log_handles(self) :
-        vars(main)[self.name+'log'].removeHandler(self.log_handler)
+        """
+        vars( main )[ self.name + 'log' ].info( "\n" + message + "\n" )
+
+    def close_log_handles( self ):
+        vars( main )[ self.name + 'log' ].removeHandler( self.log_handler )
         if self.logfile_handler:
             self.logfile_handler.close()
-    
-    def get_version(self):
+
+    def get_version( self ):
         return "Version unknown"
 
-    def experimentRun(self,**kwargs):
-        args = utilities.parse_args(["RETURNS"],**kwargs)
-        return  args["RETURNS"]    
+    def experimentRun( self, **kwargs ):
+        args = utilities.parse_args( [ "RETURNS" ], **kwargs )
+        return args[ "RETURNS" ]
 
 
 if __name__ != "__main__":
     import sys
-    sys.modules[__name__] = Component()
+    sys.modules[ __name__ ] = Component()
+
diff --git a/TestON/tests/ClassTest/ClassTest.py b/TestON/tests/ClassTest/ClassTest.py
index 6d7a153..0fd8ccc 100644
--- a/TestON/tests/ClassTest/ClassTest.py
+++ b/TestON/tests/ClassTest/ClassTest.py
@@ -3,24 +3,25 @@
 import os
 import re
 
+
 class ClassTest:
-    def __init__(self):
+
+    def __init__( self ):
         self.default = ''
 
-    def CASE1(self, main):
+    def CASE1( self, main ):
         import time
         import imp
 
-        init = imp.load_source('ClassInit',
-            '/home/admin/ONLabTest/TestON/tests/ClassTest/Dependency/ClassInit.py')
+        init = imp.load_source(
+            'ClassInit',
+            '/home/admin/ONLabTest/TestON/tests/ClassTest/Dependency/ClassInit.py' )
 
-        ip1_from_class = init.getIp1()  
-        init.printMain(main)
+        ip1_from_class = init.getIp1()
+        init.printMain( main )
 
-        main.log.info(ip1_from_class)
+        main.log.info( ip1_from_class )
 
-    def CASE2(self, main):
+    def CASE2( self, main ):
 
-
-        main.log.info("Case 2")
-
+        main.log.info( "Case 2" )
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.py b/TestON/tests/IntentPerfNext/IntentPerfNext.py
index 5c8bb2f..daa1ae2 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.py
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.py
@@ -1,379 +1,386 @@
-#Intent Performance Test for ONOS-next
+# Intent Performance Test for ONOS-next
 #
-#andrew@onlab.us
+# andrew@onlab.us
 #
-#November 5, 2014
+# November 5, 2014
+
 
 class IntentPerfNext:
-    def __init__(self):
+
+    def __init__( self ):
         self.default = ""
 
-    def CASE1(self, main):
-        '''
+    def CASE1( self, main ):
+        """
         ONOS startup sequence
-        '''
-
+        """
         import time
         global cluster_count
-        cluster_count = 1 
+        cluster_count = 1
 
-        cell_name = main.params['ENV']['cellName']
+        cell_name = main.params[ 'ENV' ][ 'cellName' ]
 
-        git_pull = main.params['GIT']['autoPull']
-        checkout_branch = main.params['GIT']['checkout']
+        git_pull = main.params[ 'GIT' ][ 'autoPull' ]
+        checkout_branch = main.params[ 'GIT' ][ 'checkout' ]
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS4_ip = main.params['CTRL']['ip4']
-        ONOS5_ip = main.params['CTRL']['ip5']
-        ONOS6_ip = main.params['CTRL']['ip6']
-        ONOS7_ip = main.params['CTRL']['ip7']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+        ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+        ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
+        ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
 
-        main.ONOSbench.onos_uninstall(node_ip=ONOS1_ip)
-        main.ONOSbench.onos_uninstall(node_ip=ONOS2_ip)
-        main.ONOSbench.onos_uninstall(node_ip=ONOS3_ip)
-        main.ONOSbench.onos_uninstall(node_ip=ONOS4_ip)
-        main.ONOSbench.onos_uninstall(node_ip=ONOS5_ip)
-        main.ONOSbench.onos_uninstall(node_ip=ONOS6_ip)
-        main.ONOSbench.onos_uninstall(node_ip=ONOS7_ip)
+        main.ONOSbench.onos_uninstall( node_ip=ONOS1_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS2_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS3_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS4_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS5_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS6_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS7_ip )
 
-        MN1_ip = main.params['MN']['ip1']
-        BENCH_ip = main.params['BENCH']['ip']
-    
-        main.case("Setting up test environment")
+        MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+        BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
 
-        main.step("Creating cell file")
+        main.case( "Setting up test environment" )
+
+        main.step( "Creating cell file" )
         cell_file_result = main.ONOSbench.create_cell_file(
-                BENCH_ip, cell_name, MN1_ip,
-                "onos-core,onos-app-metrics,onos-gui",
-                #ONOS1_ip, ONOS2_ip, ONOS3_ip)
-                ONOS1_ip)
+            BENCH_ip, cell_name, MN1_ip,
+            "onos-core,onos-app-metrics,onos-gui",
+            # ONOS1_ip, ONOS2_ip, ONOS3_ip )
+            ONOS1_ip )
 
-        main.step("Applying cell file to environment")
-        cell_apply_result = main.ONOSbench.set_cell(cell_name)
+        main.step( "Applying cell file to environment" )
+        cell_apply_result = main.ONOSbench.set_cell( cell_name )
         verify_cell_result = main.ONOSbench.verify_cell()
 
-        main.step("Removing raft logs")
+        main.step( "Removing raft logs" )
         main.ONOSbench.onos_remove_raft_logs()
 
-        main.step("Git checkout and pull "+checkout_branch)
+        main.step( "Git checkout and pull " + checkout_branch )
         if git_pull == 'on':
             checkout_result = \
-                main.ONOSbench.git_checkout(checkout_branch)
+                main.ONOSbench.git_checkout( checkout_branch )
             pull_result = main.ONOSbench.git_pull()
-           
-            #If you used git pull, auto compile
-            main.step("Using onos-build to compile ONOS")
+
+            # If you used git pull, auto compile
+            main.step( "Using onos-build to compile ONOS" )
             build_result = main.ONOSbench.onos_build()
         else:
             checkout_result = main.TRUE
             pull_result = main.TRUE
             build_result = main.TRUE
-            main.log.info("Git pull skipped by configuration")
+            main.log.info( "Git pull skipped by configuration" )
 
-        main.log.report("Commit information - ")
-        main.ONOSbench.get_version(report=True)
+        main.log.report( "Commit information - " )
+        main.ONOSbench.get_version( report=True )
 
-        main.step("Creating ONOS package")
+        main.step( "Creating ONOS package" )
         package_result = main.ONOSbench.onos_package()
 
-        main.step("Installing ONOS package")
-        install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
-        #install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
-        #install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
+        main.step( "Installing ONOS package" )
+        install1_result = main.ONOSbench.onos_install( node=ONOS1_ip )
+        #install2_result = main.ONOSbench.onos_install( node=ONOS2_ip )
+        #install3_result = main.ONOSbench.onos_install( node=ONOS3_ip )
 
-        main.step("Set cell for ONOScli env")
-        main.ONOS1cli.set_cell(cell_name)
-        #main.ONOS2cli.set_cell(cell_name)
-        #main.ONOS3cli.set_cell(cell_name)
+        main.step( "Set cell for ONOScli env" )
+        main.ONOS1cli.set_cell( cell_name )
+        # main.ONOS2cli.set_cell( cell_name )
+        # main.ONOS3cli.set_cell( cell_name )
 
-        time.sleep(5)
+        time.sleep( 5 )
 
-        main.step("Start onos cli")
-        cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
-        #cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
-        #cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
+        main.step( "Start onos cli" )
+        cli1 = main.ONOS1cli.start_onos_cli( ONOS1_ip )
+        #cli2 = main.ONOS2cli.start_onos_cli( ONOS2_ip )
+        #cli3 = main.ONOS3cli.start_onos_cli( ONOS3_ip )
 
-        utilities.assert_equals(expect=main.TRUE,
-                actual = cell_file_result and cell_apply_result and\
-                         verify_cell_result and checkout_result and\
-                         pull_result and build_result and\
-                         install1_result, #and install2_result and\
-                         #install3_result,
-                onpass="ONOS started successfully",
-                onfail="Failed to start ONOS")
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=cell_file_result and cell_apply_result and
+                                 verify_cell_result and checkout_result and
+                                 pull_result and build_result and
+                                 install1_result,  # and install2_result and
+                                 # install3_result,
+                                 onpass="ONOS started successfully",
+                                 onfail="Failed to start ONOS" )
 
-    def CASE2(self, main):
-        '''
+    def CASE2( self, main ):
+        """
         Single intent add latency
 
-        '''
+        """
         import time
         import json
         import requests
         import os
         import numpy
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS_user = main.params['CTRL']['user']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS_user = main.params[ 'CTRL' ][ 'user' ]
 
-        default_sw_port = main.params['CTRL']['port1']
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
 
-        #number of iterations of case
-        num_iter = main.params['TEST']['numIter']
-        num_ignore = int(main.params['TEST']['numIgnore'])
+        # number of iterations of case
+        num_iter = main.params[ 'TEST' ][ 'numIter' ]
+        num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
 
-        #Timestamp keys for json metrics output
-        submit_time = main.params['JSON']['submittedTime']
-        install_time = main.params['JSON']['installedTime']
-        wdRequest_time = main.params['JSON']['wdRequestTime']
-        withdrawn_time = main.params['JSON']['withdrawnTime']
-        
+        # Timestamp keys for json metrics output
+        submit_time = main.params[ 'JSON' ][ 'submittedTime' ]
+        install_time = main.params[ 'JSON' ][ 'installedTime' ]
+        wdRequest_time = main.params[ 'JSON' ][ 'wdRequestTime' ]
+        withdrawn_time = main.params[ 'JSON' ][ 'withdrawnTime' ]
+
         intent_add_lat_list = []
 
-        #Assign 'linear' switch format for basic intent testing
+        # Assign 'linear' switch format for basic intent testing
         main.Mininet1.assign_sw_controller(
-                sw="1", ip1=ONOS1_ip,port1=default_sw_port)
+            sw="1", ip1=ONOS1_ip, port1=default_sw_port )
         main.Mininet1.assign_sw_controller(
-                sw="2", ip1=ONOS2_ip,port1=default_sw_port)
+            sw="2", ip1=ONOS2_ip, port1=default_sw_port )
         main.Mininet1.assign_sw_controller(
-                sw="3", ip1=ONOS2_ip,port1=default_sw_port)
+            sw="3", ip1=ONOS2_ip, port1=default_sw_port )
         main.Mininet1.assign_sw_controller(
-                sw="4", ip1=ONOS2_ip,port1=default_sw_port)
+            sw="4", ip1=ONOS2_ip, port1=default_sw_port )
         main.Mininet1.assign_sw_controller(
-                sw="5", ip1=ONOS3_ip,port1=default_sw_port)
+            sw="5", ip1=ONOS3_ip, port1=default_sw_port )
 
-        time.sleep(10)
+        time.sleep( 10 )
 
-        main.log.report("Single intent add latency test")
+        main.log.report( "Single intent add latency test" )
 
         devices_json_str = main.ONOS1cli.devices()
-        devices_json_obj = json.loads(devices_json_str)
+        devices_json_obj = json.loads( devices_json_str )
         device_id_list = []
 
-        #Obtain device id list in ONOS format.
-        #They should already be in order (1,2,3,10,11,12,13, etc)
+        # Obtain device id list in ONOS format.
+        # They should already be in order ( 1,2,3,10,11,12,13, etc )
         for device in devices_json_obj:
-            device_id_list.append(device['id'])
+            device_id_list.append( device[ 'id' ] )
 
-        for i in range(0, int(num_iter)):
-            #add_point_intent(ingr_device,  egr_device,
-            #                 ingr_port,    egr_port)
+        for i in range( 0, int( num_iter ) ):
+            # add_point_intent( ingr_device,  egr_device,
+            #                 ingr_port,    egr_port )
             main.ONOS1cli.add_point_intent(
-                device_id_list[0]+"/1", device_id_list[4]+"/1")
-        
-            #Allow some time for intents to propagate
-            time.sleep(5)
+                device_id_list[ 0 ] + "/1", device_id_list[ 4 ] + "/1" )
 
-            #Obtain metrics from ONOS 1, 2, 3
+            # Allow some time for intents to propagate
+            time.sleep( 5 )
+
+            # Obtain metrics from ONOS 1, 2, 3
             intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
             intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
             intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
 
-            intents_json_obj_1 = json.loads(intents_json_str_1)
-            intents_json_obj_2 = json.loads(intents_json_str_2)
-            intents_json_obj_3 = json.loads(intents_json_str_3)
+            intents_json_obj_1 = json.loads( intents_json_str_1 )
+            intents_json_obj_2 = json.loads( intents_json_str_2 )
+            intents_json_obj_3 = json.loads( intents_json_str_3 )
 
-            #Parse values from the json object
+            # Parse values from the json object
             intent_submit_1 = \
-                    intents_json_obj_1[submit_time]['value']
+                intents_json_obj_1[ submit_time ][ 'value' ]
             intent_submit_2 = \
-                    intents_json_obj_2[submit_time]['value']
+                intents_json_obj_2[ submit_time ][ 'value' ]
             intent_submit_3 = \
-                    intents_json_obj_3[submit_time]['value']
+                intents_json_obj_3[ submit_time ][ 'value' ]
 
             intent_install_1 = \
-                    intents_json_obj_1[install_time]['value']
+                intents_json_obj_1[ install_time ][ 'value' ]
             intent_install_2 = \
-                    intents_json_obj_2[install_time]['value']
+                intents_json_obj_2[ install_time ][ 'value' ]
             intent_install_3 = \
-                    intents_json_obj_3[install_time]['value']
+                intents_json_obj_3[ install_time ][ 'value' ]
 
             intent_install_lat_1 = \
-                    int(intent_install_1) - int(intent_submit_1)
+                int( intent_install_1 ) - int( intent_submit_1 )
             intent_install_lat_2 = \
-                    int(intent_install_2) - int(intent_submit_2)
+                int( intent_install_2 ) - int( intent_submit_2 )
             intent_install_lat_3 = \
-                    int(intent_install_3) - int(intent_submit_3)
-            
-            intent_install_lat_avg = \
-                    (intent_install_lat_1 + 
-                     intent_install_lat_2 +
-                     intent_install_lat_3 ) / 3
+                int( intent_install_3 ) - int( intent_submit_3 )
 
-            main.log.info("Intent add latency avg for iteration "+str(i)+
-                    ": "+str(intent_install_lat_avg)+" ms")
+            intent_install_lat_avg = \
+                ( intent_install_lat_1 +
+                  intent_install_lat_2 +
+                  intent_install_lat_3 ) / 3
+
+            main.log.info( "Intent add latency avg for iteration " + str( i ) +
+                           ": " + str( intent_install_lat_avg ) + " ms" )
 
             if intent_install_lat_avg > 0.0 and \
                intent_install_lat_avg < 1000 and i > num_ignore:
-                intent_add_lat_list.append(intent_install_lat_avg)
+                intent_add_lat_list.append( intent_install_lat_avg )
             else:
-                main.log.info("Intent add latency exceeded "+
-                        "threshold. Skipping iteration "+str(i))
+                main.log.info( "Intent add latency exceeded " +
+                               "threshold. Skipping iteration " + str( i ) )
 
-            time.sleep(3)
-            
-            #TODO: Possibly put this in the driver function
-            main.log.info("Removing intents for next iteration")
+            time.sleep( 3 )
+
+            # TODO: Possibly put this in the driver function
+            main.log.info( "Removing intents for next iteration" )
             json_temp = \
-                    main.ONOS1cli.intents(json_format=True)
-            json_obj_intents = json.loads(json_temp)
+                main.ONOS1cli.intents( json_format=True )
+            json_obj_intents = json.loads( json_temp )
             if json_obj_intents:
                 for intents in json_obj_intents:
-                    temp_id = intents['id']
-                    main.ONOS1cli.remove_intent(temp_id)
-                    main.log.info("Removing intent id: "+
-                        str(temp_id))
-                    main.ONOS1cli.remove_intent(temp_id)
+                    temp_id = intents[ 'id' ]
+                    main.ONOS1cli.remove_intent( temp_id )
+                    main.log.info( "Removing intent id: " +
+                                   str( temp_id ) )
+                    main.ONOS1cli.remove_intent( temp_id )
             else:
-                main.log.info("Intents were not installed correctly")
+                main.log.info( "Intents were not installed correctly" )
 
-            time.sleep(5)
+            time.sleep( 5 )
 
-        intent_add_lat_avg = sum(intent_add_lat_list) /\
-                             len(intent_add_lat_list)
+        intent_add_lat_avg = sum( intent_add_lat_list ) /\
+            len( intent_add_lat_list )
         intent_add_lat_std = \
-            round(numpy.std(intent_add_lat_list),1)
-        #END ITERATION FOR LOOP
-        main.log.report("Single intent add latency - ")
-        main.log.report("Avg: "+str(intent_add_lat_avg)+" ms")
-        main.log.report("Std Deviation: "+str(intent_add_lat_std)+" ms")
+            round( numpy.std( intent_add_lat_list ), 1 )
+        # END ITERATION FOR LOOP
+        main.log.report( "Single intent add latency - " )
+        main.log.report( "Avg: " + str( intent_add_lat_avg ) + " ms" )
+        main.log.report(
+            "Std Deviation: " +
+            str( intent_add_lat_std ) +
+            " ms" )
 
-    def CASE3(self, main):
-        '''
+    def CASE3( self, main ):
+        """
         Intent Reroute latency
-        '''
+        """
         import time
         import json
         import requests
         import os
         import numpy
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS_user = main.params['CTRL']['user']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS_user = main.params[ 'CTRL' ][ 'user' ]
 
-        default_sw_port = main.params['CTRL']['port1']
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
 
-        #number of iterations of case
-        num_iter = main.params['TEST']['numIter']
-        num_ignore = int(main.params['TEST']['numIgnore'])
+        # number of iterations of case
+        num_iter = main.params[ 'TEST' ][ 'numIter' ]
+        num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
 
-        #Timestamp keys for json metrics output
-        submit_time = main.params['JSON']['submittedTime']
-        install_time = main.params['JSON']['installedTime']
-        wdRequest_time = main.params['JSON']['wdRequestTime']
-        withdrawn_time = main.params['JSON']['withdrawnTime']
+        # Timestamp keys for json metrics output
+        submit_time = main.params[ 'JSON' ][ 'submittedTime' ]
+        install_time = main.params[ 'JSON' ][ 'installedTime' ]
+        wdRequest_time = main.params[ 'JSON' ][ 'wdRequestTime' ]
+        withdrawn_time = main.params[ 'JSON' ][ 'withdrawnTime' ]
 
         devices_json_str = main.ONOS1cli.devices()
-        devices_json_obj = json.loads(devices_json_str)
+        devices_json_obj = json.loads( devices_json_str )
 
         device_id_list = []
 
-        #Obtain device id list in ONOS format.
-        #They should already be in order (1,2,3,10,11,12,13, etc)
+        # Obtain device id list in ONOS format.
+        # They should already be in order ( 1,2,3,10,11,12,13, etc )
         for device in devices_json_obj:
-            device_id_list.append(device['id'])
+            device_id_list.append( device[ 'id' ] )
 
         intent_reroute_lat_list = []
 
-        for i in range(0, int(num_iter)):
-            #add_point_intent(ingr_device, ingr_port, 
-            #                 egr_device, egr_port)
-            if len(device_id_list) > 0:
+        for i in range( 0, int( num_iter ) ):
+            # add_point_intent( ingr_device, ingr_port,
+            #                 egr_device, egr_port )
+            if len( device_id_list ) > 0:
                 main.ONOS1cli.add_point_intent(
-                    device_id_list[0]+"/2", device_id_list[4]+"/1")
+                    device_id_list[ 0 ] + "/2", device_id_list[ 4 ] + "/1" )
             else:
-                main.log.info("Failed to fetch devices from ONOS")
+                main.log.info( "Failed to fetch devices from ONOS" )
 
-            time.sleep(5)
+            time.sleep( 5 )
 
-            intents_str = main.ONOS1cli.intents(json_format=True)
-            intents_obj = json.loads(intents_str)
+            intents_str = main.ONOS1cli.intents( json_format=True )
+            intents_obj = json.loads( intents_str )
             for intent in intents_obj:
-                if intent['state'] == "INSTALLED":
-                    main.log.info("Intent installed successfully")
-                    intent_id = intent['id']
+                if intent[ 'state' ] == "INSTALLED":
+                    main.log.info( "Intent installed successfully" )
+                    intent_id = intent[ 'id' ]
                 else:
-                    #TODO: Add error handling
-                    main.log.info("Intent installation failed")
+                    # TODO: Add error handling
+                    main.log.info( "Intent installation failed" )
                     intent_id = ""
 
-            #NOTE: this interface is specific to
+            # NOTE: this interface is specific to
             #      topo-intentFlower.py topology
             #      reroute case.
-            main.log.info("Disabling interface s2-eth3")
+            main.log.info( "Disabling interface s2-eth3" )
             main.Mininet1.handle.sendline(
-                    "sh ifconfig s2-eth3 down")
-            t0_system = time.time()*1000
-                    
-            #TODO: Check for correct intent reroute
-            time.sleep(5)
+                "sh ifconfig s2-eth3 down" )
+            t0_system = time.time() * 1000
 
-            #Obtain metrics from ONOS 1, 2, 3
+            # TODO: Check for correct intent reroute
+            time.sleep( 5 )
+
+            # Obtain metrics from ONOS 1, 2, 3
             intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
             intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
             intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
 
-            intents_json_obj_1 = json.loads(intents_json_str_1)
-            intents_json_obj_2 = json.loads(intents_json_str_2)
-            intents_json_obj_3 = json.loads(intents_json_str_3)
+            intents_json_obj_1 = json.loads( intents_json_str_1 )
+            intents_json_obj_2 = json.loads( intents_json_str_2 )
+            intents_json_obj_3 = json.loads( intents_json_str_3 )
 
-            #Parse values from the json object
+            # Parse values from the json object
             intent_install_1 = \
-                    intents_json_obj_1[install_time]['value']
+                intents_json_obj_1[ install_time ][ 'value' ]
             intent_install_2 = \
-                    intents_json_obj_2[install_time]['value']
+                intents_json_obj_2[ install_time ][ 'value' ]
             intent_install_3 = \
-                    intents_json_obj_3[install_time]['value']
+                intents_json_obj_3[ install_time ][ 'value' ]
 
             intent_reroute_lat_1 = \
-                    int(intent_install_1) - int(t0_system)
+                int( intent_install_1 ) - int( t0_system )
             intent_reroute_lat_2 = \
-                    int(intent_install_2) - int(t0_system)
+                int( intent_install_2 ) - int( t0_system )
             intent_reroute_lat_3 = \
-                    int(intent_install_3) - int(t0_system)
-            
+                int( intent_install_3 ) - int( t0_system )
+
             intent_reroute_lat_avg = \
-                    (intent_reroute_lat_1 + 
-                     intent_reroute_lat_2 +
-                     intent_reroute_lat_3 ) / 3
-    
-            main.log.info("Intent reroute latency avg for iteration "+
-                    str(i)+": "+str(intent_reroute_lat_avg))
+                ( intent_reroute_lat_1 +
+                  intent_reroute_lat_2 +
+                  intent_reroute_lat_3 ) / 3
+
+            main.log.info( "Intent reroute latency avg for iteration " +
+                           str( i ) + ": " + str( intent_reroute_lat_avg ) )
 
             if intent_reroute_lat_avg > 0.0 and \
                intent_reroute_lat_avg < 1000 and i > num_ignore:
-                intent_reroute_lat_list.append(intent_reroute_lat_avg)
+                intent_reroute_lat_list.append( intent_reroute_lat_avg )
             else:
-                main.log.info("Intent reroute latency exceeded "+
-                        "threshold. Skipping iteration "+str(i))
+                main.log.info( "Intent reroute latency exceeded " +
+                               "threshold. Skipping iteration " + str( i ) )
 
-            main.log.info("Removing intents for next iteration")
-            main.ONOS1cli.remove_intent(intent_id)
-            
-            main.log.info("Bringing Mininet interface up for next "+
-                "iteration")
+            main.log.info( "Removing intents for next iteration" )
+            main.ONOS1cli.remove_intent( intent_id )
+
+            main.log.info( "Bringing Mininet interface up for next " +
+                           "iteration" )
             main.Mininet1.handle.sendline(
-                    "sh ifconfig s2-eth3 up")
-        
-        intent_reroute_lat_avg = sum(intent_reroute_lat_list) /\
-                             len(intent_reroute_lat_list)
+                "sh ifconfig s2-eth3 up" )
+
+        intent_reroute_lat_avg = sum( intent_reroute_lat_list ) /\
+            len( intent_reroute_lat_list )
         intent_reroute_lat_std = \
-            round(numpy.std(intent_reroute_lat_list),1)
-        #END ITERATION FOR LOOP
-        main.log.report("Single intent reroute latency - ")
-        main.log.report("Avg: "+str(intent_reroute_lat_avg)+" ms")
-        main.log.report("Std Deviation: "+str(intent_reroute_lat_std)+" ms")
-        
-    def CASE7(self, main):
-        '''
+            round( numpy.std( intent_reroute_lat_list ), 1 )
+        # END ITERATION FOR LOOP
+        main.log.report( "Single intent reroute latency - " )
+        main.log.report( "Avg: " + str( intent_reroute_lat_avg ) + " ms" )
+        main.log.report(
+            "Std Deviation: " +
+            str( intent_reroute_lat_std ) +
+            " ms" )
+
+    def CASE7( self, main ):
+        """
         Batch intent reroute latency
-        '''
+        """
         import time
         import json
         import requests
@@ -381,440 +388,445 @@
         import numpy
 
         ONOS_ip_list = []
-        for i in range(1, 8):
-            ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)])
+        for i in range( 1, 8 ):
+            ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
 
-        ONOS_user = main.params['CTRL']['user']
-        default_sw_port = main.params['CTRL']['port1']
-    
-        batch_intent_size = main.params['TEST']['batchIntentSize']
-        batch_thresh_min = int(main.params['TEST']['batchThresholdMin'])
-        batch_thresh_max = int(main.params['TEST']['batchThresholdMax'])
-        install_time = main.params['JSON']['installedTime']
+        ONOS_user = main.params[ 'CTRL' ][ 'user' ]
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
 
-        #number of iterations of case
-        num_iter = main.params['TEST']['numIter']
-        num_ignore = int(main.params['TEST']['numIgnore'])
-        num_switch = int(main.params['TEST']['numSwitch'])
-        n_thread = main.params['TEST']['numMult']
+        batch_intent_size = main.params[ 'TEST' ][ 'batchIntentSize' ]
+        batch_thresh_min = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
+        batch_thresh_max = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
+        install_time = main.params[ 'JSON' ][ 'installedTime' ]
 
-        main.log.report("Batch intent installation test of "+
-               batch_intent_size +" intents")
+        # number of iterations of case
+        num_iter = main.params[ 'TEST' ][ 'numIter' ]
+        num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
+        num_switch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
+        n_thread = main.params[ 'TEST' ][ 'numMult' ]
+
+        main.log.report( "Batch intent installation test of " +
+                         batch_intent_size + " intents" )
 
         batch_result_list = []
 
-        #Assign 'linear' switch format for basic intent testing
+        # Assign 'linear' switch format for basic intent testing
         main.Mininet1.assign_sw_controller(
-                sw="1", ip1=ONOS1_ip,port1=default_sw_port)
+            sw="1", ip1=ONOS1_ip, port1=default_sw_port )
         main.Mininet1.assign_sw_controller(
-                sw="2", ip1=ONOS2_ip,port1=default_sw_port)
+            sw="2", ip1=ONOS2_ip, port1=default_sw_port )
         main.Mininet1.assign_sw_controller(
-                sw="3", ip1=ONOS2_ip,port1=default_sw_port)
+            sw="3", ip1=ONOS2_ip, port1=default_sw_port )
         main.Mininet1.assign_sw_controller(
-                sw="4", ip1=ONOS2_ip,port1=default_sw_port)
+            sw="4", ip1=ONOS2_ip, port1=default_sw_port )
         main.Mininet1.assign_sw_controller(
-                sw="5", ip1=ONOS3_ip,port1=default_sw_port)
+            sw="5", ip1=ONOS3_ip, port1=default_sw_port )
 
-        time.sleep(10)
+        time.sleep( 10 )
 
-        main.log.info("Getting list of available devices")
+        main.log.info( "Getting list of available devices" )
         device_id_list = []
         json_str = main.ONOS1cli.devices()
-        json_obj = json.loads(json_str)
+        json_obj = json.loads( json_str )
         for device in json_obj:
-            device_id_list.append(device['id'])
+            device_id_list.append( device[ 'id' ] )
 
         batch_install_lat = []
         batch_withdraw_lat = []
         sleep_time = 10
-        
+
         base_dir = "/tmp/"
         max_install_lat = []
 
-        for i in range(0, int(num_iter)):
-            main.log.info("Pushing "+
-                    str(int(batch_intent_size)*int(n_thread))+
-                    " intents. Iteration "+str(i))
-            
+        for i in range( 0, int( num_iter ) ):
+            main.log.info( "Pushing " +
+                           str( int( batch_intent_size ) * int( n_thread ) ) +
+                           " intents. Iteration " + str( i ) )
+
             main.ONOS1cli.push_test_intents(
                 "of:0000000000000001/1",
                 "of:0000000000000005/1",
-                1000, num_mult="1", app_id="1")
-               
-            #TODO: Check for installation success then proceed
-            time.sleep(30)
-            
-            #NOTE: this interface is specific to
+                1000, num_mult="1", app_id="1" )
+
+            # TODO: Check for installation success then proceed
+            time.sleep( 30 )
+
+            # NOTE: this interface is specific to
             #      topo-intentFlower.py topology
             #      reroute case.
-            main.log.info("Disabling interface s2-eth3")
+            main.log.info( "Disabling interface s2-eth3" )
             main.Mininet1.handle.sendline(
-                    "sh ifconfig s2-eth3 down")
-            t0_system = time.time()*1000
+                "sh ifconfig s2-eth3 down" )
+            t0_system = time.time() * 1000
 
-            #TODO: Wait sufficient time for intents to install
-            time.sleep(10)
+            # TODO: Wait sufficient time for intents to install
+            time.sleep( 10 )
 
-            #TODO: get intent installation time
-            
-            #Obtain metrics from ONOS 1, 2, 3
+            # TODO: get intent installation time
+
+            # Obtain metrics from ONOS 1, 2, 3
             intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
             intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
             intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
 
-            intents_json_obj_1 = json.loads(intents_json_str_1)
-            intents_json_obj_2 = json.loads(intents_json_str_2)
-            intents_json_obj_3 = json.loads(intents_json_str_3)
+            intents_json_obj_1 = json.loads( intents_json_str_1 )
+            intents_json_obj_2 = json.loads( intents_json_str_2 )
+            intents_json_obj_3 = json.loads( intents_json_str_3 )
 
-            #Parse values from the json object
+            # Parse values from the json object
             intent_install_1 = \
-                    intents_json_obj_1[install_time]['value']
+                intents_json_obj_1[ install_time ][ 'value' ]
             intent_install_2 = \
-                    intents_json_obj_2[install_time]['value']
+                intents_json_obj_2[ install_time ][ 'value' ]
             intent_install_3 = \
-                    intents_json_obj_3[install_time]['value']
+                intents_json_obj_3[ install_time ][ 'value' ]
 
             intent_reroute_lat_1 = \
-                    int(intent_install_1) - int(t0_system)
+                int( intent_install_1 ) - int( t0_system )
             intent_reroute_lat_2 = \
-                    int(intent_install_2) - int(t0_system)
+                int( intent_install_2 ) - int( t0_system )
             intent_reroute_lat_3 = \
-                    int(intent_install_3) - int(t0_system)
-            
+                int( intent_install_3 ) - int( t0_system )
+
             intent_reroute_lat_avg = \
-                    (intent_reroute_lat_1 + 
-                     intent_reroute_lat_2 +
-                     intent_reroute_lat_3 ) / 3
-    
-            main.log.info("Intent reroute latency avg for iteration "+
-                    str(i)+": "+str(intent_reroute_lat_avg))
-            #TODO: Remove intents for next iteration
-            
-            time.sleep(5)
+                ( intent_reroute_lat_1 +
+                  intent_reroute_lat_2 +
+                  intent_reroute_lat_3 ) / 3
+
+            main.log.info( "Intent reroute latency avg for iteration " +
+                           str( i ) + ": " + str( intent_reroute_lat_avg ) )
+            # TODO: Remove intents for next iteration
+
+            time.sleep( 5 )
 
             intents_str = main.ONOS1cli.intents()
-            intents_json = json.loads(intents_str)
+            intents_json = json.loads( intents_str )
             for intents in intents_json:
-                intent_id = intents['id']
+                intent_id = intents[ 'id' ]
                 if intent_id:
-                    main.ONOS1cli.remove_intent(intent_id)
+                    main.ONOS1cli.remove_intent( intent_id )
 
             main.Mininet1.handle.sendline(
-                    "sh ifconfig s2-eth3 up")
-            
-            main.log.info("Intents removed and port back up")
+                "sh ifconfig s2-eth3 up" )
 
+            main.log.info( "Intents removed and port back up" )
 
-    def CASE4(self, main):
-        '''
+    def CASE4( self, main ):
+        """
         Batch intent install
-        '''
-        
+        """
         import time
         import json
         import requests
         import os
         import numpy
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS4_ip = main.params['CTRL']['ip4']
-        ONOS5_ip = main.params['CTRL']['ip5']
-        ONOS6_ip = main.params['CTRL']['ip6']
-        ONOS7_ip = main.params['CTRL']['ip7']
-       
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+        ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+        ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
+        ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
+
         ONOS_ip_list = []
-        for i in range(1, 8):
-            ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)])
+        for i in range( 1, 8 ):
+            ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
 
-        ONOS_user = main.params['CTRL']['user']
+        ONOS_user = main.params[ 'CTRL' ][ 'user' ]
 
-        default_sw_port = main.params['CTRL']['port1']
-    
-        batch_intent_size = main.params['TEST']['batchIntentSize']
-        batch_thresh_min = int(main.params['TEST']['batchThresholdMin'])
-        batch_thresh_max = int(main.params['TEST']['batchThresholdMax'])
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
 
-        #number of iterations of case
-        num_iter = main.params['TEST']['numIter']
-        num_ignore = int(main.params['TEST']['numIgnore'])
-        num_switch = int(main.params['TEST']['numSwitch'])
-        n_thread = main.params['TEST']['numMult']
+        batch_intent_size = main.params[ 'TEST' ][ 'batchIntentSize' ]
+        batch_thresh_min = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
+        batch_thresh_max = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
+
+        # number of iterations of case
+        num_iter = main.params[ 'TEST' ][ 'numIter' ]
+        num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
+        num_switch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
+        n_thread = main.params[ 'TEST' ][ 'numMult' ]
         #n_thread = 105
 
         #*****
         global cluster_count
         #*****
-       
-        #Switch assignment NOTE: hardcoded 
+
+        # Switch assignment NOTE: hardcoded
         if cluster_count == 1:
-            for i in range(1, num_switch+1):
+            for i in range( 1, num_switch + 1 ):
                 main.Mininet1.assign_sw_controller(
-                    sw=str(i), 
+                    sw=str( i ),
                     ip1=ONOS1_ip,
-                    port1=default_sw_port)
+                    port1=default_sw_port )
         if cluster_count == 3:
-            for i in range(1, 3):
+            for i in range( 1, 3 ):
                 main.Mininet1.assign_sw_controller(
-                    sw=str(i),
+                    sw=str( i ),
                     ip1=ONOS1_ip,
-                    port1=default_sw_port)
-            for i in range(3, 6):
+                    port1=default_sw_port )
+            for i in range( 3, 6 ):
                 main.Mininet1.assign_sw_controller(
-                    sw=str(i),
+                    sw=str( i ),
                     ip1=ONOS2_ip,
-                    port1=default_sw_port)
-            for i in range(6, 9):
+                    port1=default_sw_port )
+            for i in range( 6, 9 ):
                 main.Mininet1.assign_sw_controller(
-                    sw=str(i),
+                    sw=str( i ),
                     ip1=ONOS3_ip,
-                    port1=default_sw_port)
+                    port1=default_sw_port )
         if cluster_count == 5:
             main.Mininet1.assign_sw_controller(
-                    sw="1",
-                    ip1=ONOS1_ip,
-                    port1=default_sw_port)
+                sw="1",
+                ip1=ONOS1_ip,
+                port1=default_sw_port )
             main.Mininet1.assign_sw_controller(
-                    sw="2",
-                    ip1=ONOS2_ip,
-                    port1=default_sw_port)
-            for i in range(3, 6):
+                sw="2",
+                ip1=ONOS2_ip,
+                port1=default_sw_port )
+            for i in range( 3, 6 ):
                 main.Mininet1.assign_sw_controller(
-                    sw=str(i),
+                    sw=str( i ),
                     ip1=ONOS3_ip,
-                    port1=default_sw_port)
+                    port1=default_sw_port )
             main.Mininet1.assign_sw_controller(
-                    sw="6",
-                    ip1=ONOS4_ip,
-                    port1=default_sw_port)
+                sw="6",
+                ip1=ONOS4_ip,
+                port1=default_sw_port )
             main.Mininet1.assign_sw_controller(
-                    sw="7",
-                    ip1=ONOS5_ip,
-                    port1=default_sw_port)
+                sw="7",
+                ip1=ONOS5_ip,
+                port1=default_sw_port )
             main.Mininet1.assign_sw_controller(
-                    sw="8",
-                    ip1=ONOS5_ip,
-                    port1=default_sw_port)
-        
+                sw="8",
+                ip1=ONOS5_ip,
+                port1=default_sw_port )
+
         if cluster_count == 7:
-            for i in range(1,9):
+            for i in range( 1, 9 ):
                 if i < 8:
                     main.Mininet1.assign_sw_controller(
-                        sw=str(i),
-                        ip1=ONOS_ip_list[i-1],
-                        port1=default_sw_port)
-                elif i >= 8: 
+                        sw=str( i ),
+                        ip1=ONOS_ip_list[ i - 1 ],
+                        port1=default_sw_port )
+                elif i >= 8:
                     main.Mininet1.assign_sw_controller(
-                        sw=str(i),
-                        ip1=ONOS_ip_list[6],
-                        port1=default_sw_port)
+                        sw=str( i ),
+                        ip1=ONOS_ip_list[ 6 ],
+                        port1=default_sw_port )
 
-        time.sleep(30)
+        time.sleep( 30 )
 
-        main.log.report("Batch intent installation test of "+
-               batch_intent_size +" intents")
+        main.log.report( "Batch intent installation test of " +
+                         batch_intent_size + " intents" )
 
         batch_result_list = []
 
-        main.log.info("Getting list of available devices")
+        main.log.info( "Getting list of available devices" )
         device_id_list = []
         json_str = main.ONOS1cli.devices()
-        json_obj = json.loads(json_str)
+        json_obj = json.loads( json_str )
         for device in json_obj:
-            device_id_list.append(device['id'])
+            device_id_list.append( device[ 'id' ] )
 
         batch_install_lat = []
         batch_withdraw_lat = []
         sleep_time = 10
-        
+
         base_dir = "/tmp/"
         max_install_lat = []
 
-        for i in range(0, int(num_iter)):
-            main.log.info("Pushing "+
-                    str(int(batch_intent_size)*int(n_thread))+
-                    " intents. Iteration "+str(i))
-               
-            for node in range(1, cluster_count+1):
-                save_dir = base_dir + "batch_intent_"+str(node)+".txt" 
+        for i in range( 0, int( num_iter ) ):
+            main.log.info( "Pushing " +
+                           str( int( batch_intent_size ) * int( n_thread ) ) +
+                           " intents. Iteration " + str( i ) )
+
+            for node in range( 1, cluster_count + 1 ):
+                save_dir = base_dir + "batch_intent_" + str( node ) + ".txt"
                 main.ONOSbench.push_test_intents_shell(
-                "of:0000000000000001/"+str(node),
-                "of:0000000000000008/"+str(node),
-                int(batch_intent_size),
-                save_dir, ONOS_ip_list[node-1],
-                num_mult=n_thread, app_id=node)
-         
-            #Wait sufficient time for intents to start
-            #installing
-           
-            time.sleep(sleep_time)
-            print sleep_time 
+                    "of:0000000000000001/" + str( node ),
+                    "of:0000000000000008/" + str( node ),
+                    int( batch_intent_size ),
+                    save_dir, ONOS_ip_list[ node - 1 ],
+                    num_mult=n_thread, app_id=node )
+
+            # Wait sufficient time for intents to start
+            # installing
+
+            time.sleep( sleep_time )
+            print sleep_time
 
             intent = ""
             counter = 300
-            while len(intent) > 0 and counter > 0:
+            while len( intent ) > 0 and counter > 0:
                 main.ONOS1cli.handle.sendline(
-                    "intents | wc -l")
+                    "intents | wc -l" )
                 main.ONOS1cli.handle.expect(
-                    "intents | wc -l")
+                    "intents | wc -l" )
                 main.ONOS1cli.handle.expect(
-                    "onos>")
+                    "onos>" )
                 intent_temp = main.ONOS1cli.handle.before()
                 print intent_temp
 
                 intent = main.ONOS1cli.intents()
-                intent = json.loads(intent)
-                counter = counter-1
-                time.sleep(1)
+                intent = json.loads( intent )
+                counter = counter - 1
+                time.sleep( 1 )
 
-            time.sleep(5)
+            time.sleep( 5 )
 
-            for node in range(1, cluster_count+1):
-                save_dir = base_dir + "batch_intent_"+str(node)+".txt"
-                with open(save_dir) as f_onos:
+            for node in range( 1, cluster_count + 1 ):
+                save_dir = base_dir + "batch_intent_" + str( node ) + ".txt"
+                with open( save_dir ) as f_onos:
                     line_count = 0
                     for line in f_onos:
-                        line = line[1:]
-                        line = line.split(": ")
-                        result = line[1].split(" ")[0]
-                        #TODO: add parameters before appending latency
+                        line = line[ 1: ]
+                        line = line.split( ": " )
+                        result = line[ 1 ].split( " " )[ 0 ]
+                        # TODO: add parameters before appending latency
                         if line_count == 0:
-                            batch_install_lat.append(int(result))
+                            batch_install_lat.append( int( result ) )
                         elif line_count == 1:
-                            batch_withdraw_lat.append(int(result))
+                            batch_withdraw_lat.append( int( result ) )
                         line_count += 1
-                main.log.info("Batch install latency for ONOS"+
-                    str(node)+" with "+\
-                    str(batch_intent_size) + "intents: "+\
-                    str(batch_install_lat))
-            
-            if len(batch_install_lat) > 0 and int(i) > num_ignore:
-                max_install_lat.append(max(batch_install_lat))
-            elif len(batch_install_lat) == 0:
-                #If I failed to read anything from the file,
-                #increase the wait time before checking intents
+                main.log.info( "Batch install latency for ONOS" +
+                               str( node ) + " with " +
+                               str( batch_intent_size ) + "intents: " +
+                               str( batch_install_lat ) )
+
+            if len( batch_install_lat ) > 0 and int( i ) > num_ignore:
+                max_install_lat.append( max( batch_install_lat ) )
+            elif len( batch_install_lat ) == 0:
+                # If I failed to read anything from the file,
+                # increase the wait time before checking intents
                 sleep_time += 30
             batch_install_lat = []
 
-            #Sleep in between iterations
-            time.sleep(5)
+            # Sleep in between iterations
+            time.sleep( 5 )
 
-        main.log.report("Avg of batch installation latency "+
-            ": "+
-            str(sum(max_install_lat) / len(max_install_lat)))
-        main.log.report("Std Deviation of batch installation latency "+
-            ": "+
-            str(numpy.std(max_install_lat)))
+        main.log.report( "Avg of batch installation latency " +
+                         ": " +
+                         str( sum( max_install_lat ) /
+                              len( max_install_lat ) ) )
+        main.log.report( "Std Deviation of batch installation latency " +
+                         ": " +
+                         str( numpy.std( max_install_lat ) ) )
 
-    def CASE5(self,main):
-        '''
+    def CASE5( self, main ):
+        """
         Increase number of nodes and initiate CLI
-        '''
+        """
         import time
         import json
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS4_ip = main.params['CTRL']['ip4']
-        ONOS5_ip = main.params['CTRL']['ip5']
-        ONOS6_ip = main.params['CTRL']['ip6']
-        ONOS7_ip = main.params['CTRL']['ip7']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+        ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+        ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
+        ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
 
         global cluster_count
         cluster_count += 2
-        main.log.report("Increasing cluster size to "+
-                str(cluster_count))
+        main.log.report( "Increasing cluster size to " +
+                         str( cluster_count ) )
 
         install_result = main.FALSE
 
         if cluster_count == 3:
             install_result1 = \
-                main.ONOSbench.onos_install(node=ONOS2_ip)
+                main.ONOSbench.onos_install( node=ONOS2_ip )
             install_result2 = \
-                main.ONOSbench.onos_install(node=ONOS3_ip)
-            time.sleep(5)
+                main.ONOSbench.onos_install( node=ONOS3_ip )
+            time.sleep( 5 )
 
-            main.log.info("Starting ONOS CLI")
-            main.ONOS2cli.start_onos_cli(ONOS2_ip)
-            main.ONOS3cli.start_onos_cli(ONOS3_ip)
+            main.log.info( "Starting ONOS CLI" )
+            main.ONOS2cli.start_onos_cli( ONOS2_ip )
+            main.ONOS3cli.start_onos_cli( ONOS3_ip )
 
             install_result = install_result1 and install_result2
 
         if cluster_count == 5:
-            main.log.info("Installing ONOS on node 4 and 5")
+            main.log.info( "Installing ONOS on node 4 and 5" )
             install_result1 = \
-                main.ONOSbench.onos_install(node=ONOS4_ip)
+                main.ONOSbench.onos_install( node=ONOS4_ip )
             install_result2 = \
-                main.ONOSbench.onos_install(node=ONOS5_ip)
+                main.ONOSbench.onos_install( node=ONOS5_ip )
 
-            main.log.info("Starting ONOS CLI")
-            main.ONOS4cli.start_onos_cli(ONOS4_ip)
-            main.ONOS5cli.start_onos_cli(ONOS5_ip)
+            main.log.info( "Starting ONOS CLI" )
+            main.ONOS4cli.start_onos_cli( ONOS4_ip )
+            main.ONOS5cli.start_onos_cli( ONOS5_ip )
 
             install_result = install_result1 and install_result2
 
         if cluster_count == 7:
-            main.log.info("Installing ONOS on node 6 and 7")
+            main.log.info( "Installing ONOS on node 6 and 7" )
             install_result1 = \
-                main.ONOSbench.onos_install(node=ONOS6_ip)
+                main.ONOSbench.onos_install( node=ONOS6_ip )
             install_result2 = \
-                main.ONOSbench.onos_install(node=ONOS7_ip)
+                main.ONOSbench.onos_install( node=ONOS7_ip )
 
-            main.log.info("Starting ONOS CLI")
-            main.ONOS6cli.start_onos_cli(ONOS6_ip)
-            main.ONOS7cli.start_onos_cli(ONOS7_ip)
+            main.log.info( "Starting ONOS CLI" )
+            main.ONOS6cli.start_onos_cli( ONOS6_ip )
+            main.ONOS7cli.start_onos_cli( ONOS7_ip )
 
             install_result = install_result1 and install_result2
 
-        time.sleep(5)
+        time.sleep( 5 )
 
         if install_result == main.TRUE:
             assertion = main.TRUE
         else:
             assertion = main.FALSE
 
-        utilities.assert_equals(expect=main.TRUE, actual=assertion,
-            onpass="Scale out to "+str(cluster_count)+\
-                   " nodes successful",
-            onfail="Scale out to "+str(cluster_count)+\
-                   " nodes failed")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=assertion,
+            onpass="Scale out to " +
+            str( cluster_count ) +
+            " nodes successful",
+            onfail="Scale out to " +
+            str( cluster_count ) +
+            " nodes failed" )
 
-    def CASE9(self, main):
+    def CASE9( self, main ):
         count = 0
-        sw_num1 = 1 
+        sw_num1 = 1
         sw_num2 = 1
         appid = 0
         port_num1 = 1
         port_num2 = 1
-       
-        time.sleep(30)
+
+        time.sleep( 30 )
 
         while True:
-            #main.ONOS1cli.push_test_intents(
+            # main.ONOS1cli.push_test_intents(
                     #"of:0000000000001001/1",
                 #"of:0000000000002001/1",
-                #    100, num_mult="10", app_id="1")
-            #main.ONOS2cli.push_test_intents(
+                #    100, num_mult="10", app_id="1" )
+            # main.ONOS2cli.push_test_intents(
             #    "of:0000000000001002/1",
             #    "of:0000000000002002/1",
-            #    100, num_mult="10", app_id="2")
-            #main.ONOS2cli.push_test_intents(
+            #    100, num_mult="10", app_id="2" )
+            # main.ONOS2cli.push_test_intents(
             #    "of:0000000000001003/1",
             #    "of:0000000000002003/1",
-            #    100, num_mult="10", app_id="3")
+            #    100, num_mult="10", app_id="3" )
             count += 1
-           
+
             if count >= 100:
                 main.ONOSbench.handle.sendline(
-                    "onos 10.128.174.1 intents-events-metrics >>"+\
-                    " /tmp/metrics_intents_temp.txt &")
+                    "onos 10.128.174.1 intents-events-metrics >>" +
+                    " /tmp/metrics_intents_temp.txt &" )
                 count = 0
 
-            arg1 = "of:000000000000100"+str(sw_num1)+"/"+str(port_num1)
-            arg2 = "of:000000000000200"+str(sw_num2)+"/"+str(port_num2)
-            
+            arg1 = "of:000000000000100" + \
+                str( sw_num1 ) + "/" + str( port_num1 )
+            arg2 = "of:000000000000200" + \
+                str( sw_num2 ) + "/" + str( port_num2 )
+
             sw_num1 += 1
 
             if sw_num1 > 7:
@@ -825,22 +837,21 @@
 
             if sw_num2 > 7:
                 sw_num2 = 1
-            
+
             main.ONOSbench.push_test_intents_shell(
                 arg1,
-                arg2, 
+                arg2,
                 100, "/tmp/temp.txt", "10.128.174.1",
-                num_mult="10", app_id=appid,report=False)
-            #main.ONOSbench.push_test_intents_shell(
+                num_mult="10", app_id=appid, report=False )
+            # main.ONOSbench.push_test_intents_shell(
             #    "of:0000000000001002/1",
             #    "of:0000000000002002/1",
             #    133, "/tmp/temp2.txt", "10.128.174.2",
-            #    num_mult="6", app_id="2",report=False)
-            #main.ONOSbench.push_test_intents_shell(
+            #    num_mult="6", app_id="2",report=False )
+            # main.ONOSbench.push_test_intents_shell(
             #    "of:0000000000001003/1",
             #    "of:0000000000002003/1",
             #    133, "/tmp/temp3.txt", "10.128.174.3",
-            #    num_mult="6", app_id="3",report=False)
-   
-            time.sleep(0.2)
+            #    num_mult="6", app_id="3",report=False )
 
+            time.sleep( 0.2 )
diff --git a/TestON/tests/LincOETest/LincOETest.py b/TestON/tests/LincOETest/LincOETest.py
old mode 100755
new mode 100644
index bb52ca8..6c59c5b
--- a/TestON/tests/LincOETest/LincOETest.py
+++ b/TestON/tests/LincOETest/LincOETest.py
@@ -1,8 +1,8 @@
-#LincOETest
+# LincOETest
 #
-#Packet-Optical Intent Testing
+# Packet-Optical Intent Testing
 #
-#andrew@onlab.us
+# andrew@onlab.us
 
 
 import time
@@ -10,12 +10,14 @@
 import os
 import re
 
+
 class LincOETest:
-    def __init__(self):
+
+    def __init__( self ):
         self.default = ''
 
-    def CASE1(self, main):
-        '''
+    def CASE1( self, main ):
+        """
         Startup sequence:
         git pull
         mvn clean install
@@ -24,91 +26,93 @@
         onos-verify-cell
         onos-install -f
         onos-wait-for-start
-        '''
+        """
         import time
 
-        cell_name = main.params['ENV']['cellName']
+        cell_name = main.params[ 'ENV' ][ 'cellName' ]
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS1_port = main.params['CTRL']['port1']
-        
-        git_pull_trigger = main.params['GIT']['autoPull']
-        git_checkout_branch = main.params['GIT']['checkout']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
 
-        main.case("Setting up test environment")
-        
-        main.step("Creating cell file")
-        #params: (bench ip, cell name, mininet ip, *onos ips)
+        git_pull_trigger = main.params[ 'GIT' ][ 'autoPull' ]
+        git_checkout_branch = main.params[ 'GIT' ][ 'checkout' ]
+
+        main.case( "Setting up test environment" )
+
+        main.step( "Creating cell file" )
+        # params: ( bench ip, cell name, mininet ip, *onos ips )
         cell_file_result = main.ONOSbench.create_cell_file(
-                "10.128.20.10", cell_name, "10.128.10.90",
-                "onos-core-trivial,onos-app-fwd",
-                "10.128.174.1")
+            "10.128.20.10", cell_name, "10.128.10.90",
+            "onos-core-trivial,onos-app-fwd",
+            "10.128.174.1" )
 
-        main.step("Applying cell variable to environment")
-        #cell_result = main.ONOSbench.set_cell(cell_name)
-        cell_result = main.ONOSbench.set_cell("temp_cell_2")
+        main.step( "Applying cell variable to environment" )
+        #cell_result = main.ONOSbench.set_cell( cell_name )
+        cell_result = main.ONOSbench.set_cell( "temp_cell_2" )
         verify_result = main.ONOSbench.verify_cell()
-       
+
         if git_pull_trigger == 'on':
-            main.step("Git checkout and pull master")
-            main.ONOSbench.git_checkout(git_checkout_branch)
+            main.step( "Git checkout and pull master" )
+            main.ONOSbench.git_checkout( git_checkout_branch )
             git_pull_result = main.ONOSbench.git_pull()
         else:
-            main.log.info("Git checkout and pull skipped by config")
+            main.log.info( "Git checkout and pull skipped by config" )
             git_pull_result = main.TRUE
 
-        main.step("Using mvn clean & install")
+        main.step( "Using mvn clean & install" )
         #clean_install_result = main.ONOSbench.clean_install()
         clean_install_result = main.TRUE
 
-        main.step("Creating ONOS package")
+        main.step( "Creating ONOS package" )
         package_result = main.ONOSbench.onos_package()
 
-        main.step("Installing ONOS package")
+        main.step( "Installing ONOS package" )
         onos_install_result = main.ONOSbench.onos_install()
         onos1_isup = main.ONOSbench.isup()
-   
-        main.step("Starting ONOS service")
-        start_result = main.ONOSbench.onos_start(ONOS1_ip)
 
-        main.step("Setting cell for ONOScli")
-        main.ONOScli.set_cell(cell_name)
+        main.step( "Starting ONOS service" )
+        start_result = main.ONOSbench.onos_start( ONOS1_ip )
 
-        main.step("Starting ONOScli")
-        main.ONOScli.start_onos_cli(ONOS1_ip)
+        main.step( "Setting cell for ONOScli" )
+        main.ONOScli.set_cell( cell_name )
 
-        case1_result = (clean_install_result and package_result and\
-                cell_result and verify_result and onos_install_result and\
-                onos1_isup and start_result )
-        utilities.assert_equals(expect=main.TRUE, actual=case1_result,
-                onpass="Test startup successful",
-                onfail="Test startup NOT successful")
+        main.step( "Starting ONOScli" )
+        main.ONOScli.start_onos_cli( ONOS1_ip )
 
-        time.sleep(10)
+        case1_result = ( clean_install_result and package_result and
+                         cell_result and verify_result and onos_install_result and
+                         onos1_isup and start_result )
+        utilities.assert_equals( expect=main.TRUE, actual=case1_result,
+                                 onpass="Test startup successful",
+                                 onfail="Test startup NOT successful" )
 
-    def CASE2(self, main):
-        '''
+        time.sleep( 10 )
+
+    def CASE2( self, main ):
+        """
         Configure topology
-        '''
+        """
         import time
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        default_sw_port = main.params['CTRL']['port1'] 
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
 
-        #Assign packet level switches to controller 
-        main.Mininet1.assign_sw_controller(sw="1",
-                ip1=ONOS1_ip, port1=default_sw_port)
-        main.Mininet1.assign_sw_controller(sw="2",
-                ip1=ONOS1_ip, port1=default_sw_port)
+        # Assign packet level switches to controller
+        main.Mininet1.assign_sw_controller(
+            sw="1",
+            ip1=ONOS1_ip,
+            port1=default_sw_port )
+        main.Mininet1.assign_sw_controller(
+            sw="2",
+            ip1=ONOS1_ip,
+            port1=default_sw_port )
 
-        #Check devices in controller
-        #This should include Linc-OE devices as well
+        # Check devices in controller
+        # This should include Linc-OE devices as well
         devices = main.ONOScli.devices()
-        main.log.info(devices)
+        main.log.info( devices )
 
-    def CASE3(self, main):
-        '''
+    def CASE3( self, main ):
+        """
         Install multi-layer intents
-        '''
-
-
+        """
diff --git a/TestON/tests/LincOETest/LincOETest.topo b/TestON/tests/LincOETest/LincOETest.topo
index 221256e..9881845 100755
--- a/TestON/tests/LincOETest/LincOETest.topo
+++ b/TestON/tests/LincOETest/LincOETest.topo
@@ -11,7 +11,7 @@
         </ONOSbench>
 
         <ONOScli>
-            <host>10.128.20.10</host>
+            <host>10.128.20.10<</host>
             <user>admin</user>
             <password>onos_test</password>
             <type>OnosCliDriver</type>
@@ -20,7 +20,7 @@
         </ONOScli>
 
         <ONOS1>
-            <host>10.128.174.1</host>
+            <host>10.128.174.1<</host>
             <user>sdn</user>
             <password>rocks</password>
             <type>OnosDriver</type>
diff --git a/TestON/tests/MultiProd/MultiProd.py b/TestON/tests/MultiProd/MultiProd.py
old mode 100755
new mode 100644
index dda3ad4..6b67f63
--- a/TestON/tests/MultiProd/MultiProd.py
+++ b/TestON/tests/MultiProd/MultiProd.py
@@ -1,6 +1,6 @@
 
-#Testing the basic functionality of ONOS Next
-#For sanity and driver functionality excercises only.
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
 
 import time
 import sys
@@ -9,527 +9,648 @@
 import time
 import json
 
-time.sleep(1)
+time.sleep( 1 )
+
+
 class MultiProd:
-    def __init__(self):
+
+    def __init__( self ):
         self.default = ''
 
-    def CASE1(self, main):
-        '''
+    def CASE1( self, main ):
+        """
         Startup sequence:
         cell <name>
         onos-verify-cell
-        onos-remove-raft-logs        
+        onos-remove-raft-logs
         git pull
         mvn clean install
         onos-package
         onos-install -f
         onos-wait-for-start
-        '''
-        
-        cell_name = main.params['ENV']['cellName']
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS1_port = main.params['CTRL']['port1']
-        ONOS2_port = main.params['CTRL']['port2']
-        ONOS3_port = main.params['CTRL']['port3']   
-       
-        main.case("Setting up test environment")
-        main.log.report("This testcase is testing setting up test environment") 
-        main.log.report("__________________________________")
- 
-        main.step("Applying cell variable to environment")
-        cell_result1 = main.ONOSbench.set_cell(cell_name)
-        #cell_result2 = main.ONOScli1.set_cell(cell_name)
-        #cell_result3 = main.ONOScli2.set_cell(cell_name)
-        #cell_result4 = main.ONOScli3.set_cell(cell_name)
-        verify_result = main.ONOSbench.verify_cell() 
+        """
+        cell_name = main.params[ 'ENV' ][ 'cellName' ]
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+        ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
+        ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
+
+        main.case( "Setting up test environment" )
+        main.log.report(
+            "This testcase is testing setting up test environment" )
+        main.log.report( "__________________________________" )
+
+        main.step( "Applying cell variable to environment" )
+        cell_result1 = main.ONOSbench.set_cell( cell_name )
+        #cell_result2 = main.ONOScli1.set_cell( cell_name )
+        #cell_result3 = main.ONOScli2.set_cell( cell_name )
+        #cell_result4 = main.ONOScli3.set_cell( cell_name )
+        verify_result = main.ONOSbench.verify_cell()
         cell_result = cell_result1
 
-        main.step("Removing raft logs before a clen installation of ONOS")
-        remove_log_Result = main.ONOSbench.onos_remove_raft_logs()        
+        main.step( "Removing raft logs before a clen installation of ONOS" )
+        remove_log_Result = main.ONOSbench.onos_remove_raft_logs()
 
-        main.step("Git checkout and pull master and get version")
-        main.ONOSbench.git_checkout("master")
+        main.step( "Git checkout and pull master and get version" )
+        main.ONOSbench.git_checkout( "master" )
         git_pull_result = main.ONOSbench.git_pull()
         print "git_pull_result = ", git_pull_result
-        version_result = main.ONOSbench.get_version(report=True)
+        version_result = main.ONOSbench.get_version( report=True )
 
         if git_pull_result == 1:
-            main.step("Using mvn clean & install")
+            main.step( "Using mvn clean & install" )
             clean_install_result = main.ONOSbench.clean_install()
-            #clean_install_result = main.TRUE 
+            #clean_install_result = main.TRUE
 
-        main.step("Creating ONOS package")
+        main.step( "Creating ONOS package" )
         package_result = main.ONOSbench.onos_package()
 
-        #main.step("Creating a cell")
-        #cell_create_result = main.ONOSbench.create_cell_file(**************)
+        #main.step( "Creating a cell" )
+        # cell_create_result = main.ONOSbench.create_cell_file( **************
+        # )
 
-        main.step("Installing ONOS package")
-        onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip)
-        onos2_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS2_ip)
-        onos3_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS3_ip)
-        onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result        
+        main.step( "Installing ONOS package" )
+        onos1_install_result = main.ONOSbench.onos_install(
+            options="-f",
+            node=ONOS1_ip )
+        onos2_install_result = main.ONOSbench.onos_install(
+            options="-f",
+            node=ONOS2_ip )
+        onos3_install_result = main.ONOSbench.onos_install(
+            options="-f",
+            node=ONOS3_ip )
+        onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result
         if onos_install_result == main.TRUE:
-            main.log.report("Installing ONOS package successful")
+            main.log.report( "Installing ONOS package successful" )
         else:
-            main.log.report("Installing ONOS package failed")
-        	
-        onos1_isup = main.ONOSbench.isup(ONOS1_ip)
-        onos2_isup = main.ONOSbench.isup(ONOS2_ip)
-        onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+            main.log.report( "Installing ONOS package failed" )
+
+        onos1_isup = main.ONOSbench.isup( ONOS1_ip )
+        onos2_isup = main.ONOSbench.isup( ONOS2_ip )
+        onos3_isup = main.ONOSbench.isup( ONOS3_ip )
         onos_isup = onos1_isup and onos2_isup and onos3_isup
         if onos_isup == main.TRUE:
-            main.log.report("ONOS instances are up and ready")
+            main.log.report( "ONOS instances are up and ready" )
         else:
-            main.log.report("ONOS instances may not be up")          
+            main.log.report( "ONOS instances may not be up" )
 
-        main.step("Starting ONOS service")
+        main.step( "Starting ONOS service" )
         start_result = main.TRUE
-        #start_result = main.ONOSbench.onos_start(ONOS1_ip)
-        startcli1 = main.ONOScli1.start_onos_cli(ONOS_ip = ONOS1_ip)
-        startcli2 = main.ONOScli2.start_onos_cli(ONOS_ip = ONOS2_ip)
-        startcli3 = main.ONOScli3.start_onos_cli(ONOS_ip = ONOS3_ip)
+        #start_result = main.ONOSbench.onos_start( ONOS1_ip )
+        startcli1 = main.ONOScli1.start_onos_cli( ONOS_ip=ONOS1_ip )
+        startcli2 = main.ONOScli2.start_onos_cli( ONOS_ip=ONOS2_ip )
+        startcli3 = main.ONOScli3.start_onos_cli( ONOS_ip=ONOS3_ip )
         print startcli1
         print startcli2
         print startcli3
-            
-        case1_result = (package_result and\
-                cell_result and verify_result and onos_install_result and\
-                onos_isup and start_result )
-        utilities.assert_equals(expect=main.TRUE, actual=case1_result,
-                onpass="Test startup successful",
-                onfail="Test startup NOT successful")
 
-    def CASE11(self, main):
-        '''
+        case1_result = ( package_result and
+                         cell_result and verify_result and onos_install_result and
+                         onos_isup and start_result )
+        utilities.assert_equals( expect=main.TRUE, actual=case1_result,
+                                 onpass="Test startup successful",
+                                 onfail="Test startup NOT successful" )
+
+    def CASE11( self, main ):
+        """
         Cleanup sequence:
         onos-service <node_ip> stop
         onos-uninstall
 
         TODO: Define rest of cleanup
-        
-        '''
 
-      	ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-	
-        main.case("Cleaning up test environment")
+        """
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
 
-        main.step("Testing ONOS kill function")
-        kill_result1 = main.ONOSbench.onos_kill(ONOS1_ip)
-        kill_result2 = main.ONOSbench.onos_kill(ONOS2_ip)
-        kill_result3 = main.ONOSbench.onos_kill(ONOS3_ip)
-	
-        main.step("Stopping ONOS service")
-        stop_result1 = main.ONOSbench.onos_stop(ONOS1_ip)
-        stop_result2 = main.ONOSbench.onos_stop(ONOS2_ip)
-        stop_result3 = main.ONOSbench.onos_stop(ONOS3_ip)
+        main.case( "Cleaning up test environment" )
 
-        main.step("Uninstalling ONOS service") 
+        main.step( "Testing ONOS kill function" )
+        kill_result1 = main.ONOSbench.onos_kill( ONOS1_ip )
+        kill_result2 = main.ONOSbench.onos_kill( ONOS2_ip )
+        kill_result3 = main.ONOSbench.onos_kill( ONOS3_ip )
+
+        main.step( "Stopping ONOS service" )
+        stop_result1 = main.ONOSbench.onos_stop( ONOS1_ip )
+        stop_result2 = main.ONOSbench.onos_stop( ONOS2_ip )
+        stop_result3 = main.ONOSbench.onos_stop( ONOS3_ip )
+
+        main.step( "Uninstalling ONOS service" )
         uninstall_result = main.ONOSbench.onos_uninstall()
 
-    def CASE3(self, main):
-        '''
+    def CASE3( self, main ):
+        """
         Test 'onos' command and its functionality in driver
-        '''
-       
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']	
+        """
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
 
-        main.case("Testing 'onos' command")
+        main.case( "Testing 'onos' command" )
 
-        main.step("Sending command 'onos -w <onos-ip> system:name'")
+        main.step( "Sending command 'onos -w <onos-ip> system:name'" )
         cmdstr1 = "system:name"
-        cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1) 
-        main.log.info("onos command returned: "+cmd_result1)
-        cmd_result2 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr1)
-        main.log.info("onos command returned: "+cmd_result2)
-        cmd_result3 = main.ONOSbench.onos_cli(ONOS3_ip, cmdstr1)
-        main.log.info("onos command returned: "+cmd_result3)
+        cmd_result1 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr1 )
+        main.log.info( "onos command returned: " + cmd_result1 )
+        cmd_result2 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr1 )
+        main.log.info( "onos command returned: " + cmd_result2 )
+        cmd_result3 = main.ONOSbench.onos_cli( ONOS3_ip, cmdstr1 )
+        main.log.info( "onos command returned: " + cmd_result3 )
 
-        main.step("Sending command 'onos -w <onos-ip> onos:topology'")
+        main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
         cmdstr2 = "onos:topology"
-        cmd_result4 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
-        main.log.info("onos command returned: "+cmd_result4)
-        cmd_result5 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr2)
-        main.log.info("onos command returned: "+cmd_result5)
-        cmd_result6 = main.ONOSbench.onos_cli(ONOS6_ip, cmdstr2)
-        main.log.info("onos command returned: "+cmd_result6)
+        cmd_result4 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
+        main.log.info( "onos command returned: " + cmd_result4 )
+        cmd_result5 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr2 )
+        main.log.info( "onos command returned: " + cmd_result5 )
+        cmd_result6 = main.ONOSbench.onos_cli( ONOS6_ip, cmdstr2 )
+        main.log.info( "onos command returned: " + cmd_result6 )
 
-
-    def CASE4(self, main):
+    def CASE4( self, main ):
         import re
         import time
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS1_port = main.params['CTRL']['port1']
-        ONOS2_port = main.params['CTRL']['port2']
-        ONOS3_port = main.params['CTRL']['port3']
-        
-        main.log.report("This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode")
-        main.log.report("__________________________________")        
-        main.case("Pingall Test(No intents are added)")
-        main.step("Assigning switches to controllers")
-        for i in range(1,29): #1 to (num of switches +1)
-            main.Mininet1.assign_sw_controller(sw=str(i),count=3, 
-                    ip1=ONOS1_ip, port1=ONOS1_port,
-                    ip2=ONOS2_ip, port2=ONOS2_port,
-		            ip3=ONOS3_ip, port3=ONOS3_port)
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+        ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
+        ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
+
+        main.log.report(
+            "This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode" )
+        main.log.report( "__________________________________" )
+        main.case( "Pingall Test(No intents are added)" )
+        main.step( "Assigning switches to controllers" )
+        for i in range( 1, 29 ):  # 1 to ( num of switches +1 )
+            main.Mininet1.assign_sw_controller(
+                sw=str( i ),
+                count=3,
+                ip1=ONOS1_ip,
+                port1=ONOS1_port,
+                ip2=ONOS2_ip,
+                port2=ONOS2_port,
+                ip3=ONOS3_ip,
+                port3=ONOS3_port )
 
         switch_mastership = main.TRUE
-        for i in range (1,29):
-            response = main.Mininet1.get_sw_controller("s"+str(i))
-            print("Response is " + str(response))
-            if re.search("tcp:"+ONOS1_ip,response):
+        for i in range( 1, 29 ):
+            response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+            print( "Response is " + str( response ) )
+            if re.search( "tcp:" + ONOS1_ip, response ):
                 switch_mastership = switch_mastership and main.TRUE
             else:
                 switch_mastership = main.FALSE
 
         if switch_mastership == main.TRUE:
-            main.log.report("Controller assignment successfull")
+            main.log.report( "Controller assignment successfull" )
         else:
-             main.log.report("Controller assignment failed")
-        #REACTIVE FWD test
-        main.step("Pingall")
+            main.log.report( "Controller assignment failed" )
+        # REACTIVE FWD test
+        main.step( "Pingall" )
         ping_result = main.FALSE
         time1 = time.time()
         ping_result = main.Mininet1.pingall()
         time2 = time.time()
-        print "Time for pingall: %2f seconds" % (time2 - time1)
-      
+        print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
         case4_result = switch_mastership and ping_result
         if ping_result == main.TRUE:
-            main.log.report("Pingall Test in reactive mode to discover the hosts successful")
+            main.log.report(
+                "Pingall Test in reactive mode to discover the hosts successful" )
         else:
-            main.log.report("Pingall Test in reactive mode to discover the hosts failed")
+            main.log.report(
+                "Pingall Test in reactive mode to discover the hosts failed" )
 
-        utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case4_result,
+            onpass="Controller assignment and Pingall Test successful",
+            onfail="Controller assignment and Pingall Test NOT successful" )
 
-    
-
-    def CASE5(self,main) :
+    def CASE5( self, main ):
         import json
         from subprocess import Popen, PIPE
-        from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        
-        main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes")
-        main.log.report("__________________________________")        
-        main.case ("Testing Mininet topology with the topology of multi instances ONOS") 
-        main.step("Collecting topology information from ONOS")
+        # assumes that sts is already in you PYTHONPATH
+        from sts.topology.teston_topology import TestONTopology
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+
+        main.log.report(
+            "This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes" )
+        main.log.report( "__________________________________" )
+        main.case(
+            "Testing Mininet topology with the topology of multi instances ONOS" )
+        main.step( "Collecting topology information from ONOS" )
         devices1 = main.ONOScli1.devices()
         devices2 = main.ONOScli2.devices()
         devices3 = main.ONOScli3.devices()
-        #print "devices1 = ", devices1
-        #print "devices2 = ", devices2
-        #print "devices3 = ", devices3
+        # print "devices1 = ", devices1
+        # print "devices2 = ", devices2
+        # print "devices3 = ", devices3
         hosts1 = main.ONOScli1.hosts()
         hosts2 = main.ONOScli2.hosts()
         hosts3 = main.ONOScli3.hosts()
-        #print "hosts1 = ", hosts1
-        #print "hosts2 = ", hosts2
-        #print "hosts3 = ", hosts3
+        # print "hosts1 = ", hosts1
+        # print "hosts2 = ", hosts2
+        # print "hosts3 = ", hosts3
         ports1 = main.ONOScli1.ports()
         ports2 = main.ONOScli2.ports()
         ports3 = main.ONOScli3.ports()
-        #print "ports1 = ", ports1
-        #print "ports2 = ", ports2    
-        #print "ports3 = ", ports3
+        # print "ports1 = ", ports1
+        # print "ports2 = ", ports2
+        # print "ports3 = ", ports3
         links1 = main.ONOScli1.links()
         links2 = main.ONOScli2.links()
         links3 = main.ONOScli3.links()
-        #print "links1 = ", links1
-        #print "links2 = ", links2
-        #print "links3 = ", links3
-        
-        print "**************"
-        
-        main.step("Start continuous pings")
-        main.Mininet2.pingLong(src=main.params['PING']['source1'],
-                            target=main.params['PING']['target1'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source2'],
-                            target=main.params['PING']['target2'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source3'],
-                            target=main.params['PING']['target3'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source4'],
-                            target=main.params['PING']['target4'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source5'],
-                            target=main.params['PING']['target5'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source6'],
-                            target=main.params['PING']['target6'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source7'],
-                            target=main.params['PING']['target7'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source8'],
-                            target=main.params['PING']['target8'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source9'],
-                            target=main.params['PING']['target9'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source10'],
-                            target=main.params['PING']['target10'],pingTime=500)
+        # print "links1 = ", links1
+        # print "links2 = ", links2
+        # print "links3 = ", links3
 
-        main.step("Create TestONTopology object")
+        print "**************"
+
+        main.step( "Start continuous pings" )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source1' ],
+            target=main.params[ 'PING' ][ 'target1' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source2' ],
+            target=main.params[ 'PING' ][ 'target2' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source3' ],
+            target=main.params[ 'PING' ][ 'target3' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source4' ],
+            target=main.params[ 'PING' ][ 'target4' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source5' ],
+            target=main.params[ 'PING' ][ 'target5' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source6' ],
+            target=main.params[ 'PING' ][ 'target6' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source7' ],
+            target=main.params[ 'PING' ][ 'target7' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source8' ],
+            target=main.params[ 'PING' ][ 'target8' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source9' ],
+            target=main.params[ 'PING' ][ 'target9' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source10' ],
+            target=main.params[ 'PING' ][ 'target10' ],
+            pingTime=500 )
+
+        main.step( "Create TestONTopology object" )
         global ctrls
         ctrls = []
         count = 1
         while True:
             temp = ()
-            if ('ip' + str(count)) in main.params['CTRL']:
-                temp = temp + (getattr(main,('ONOS' + str(count))),)
-                temp = temp + ("ONOS"+str(count),)
-                temp = temp + (main.params['CTRL']['ip'+str(count)],)
-                temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
-                ctrls.append(temp)
+            if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
+                temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
+                temp = temp + ( "ONOS" + str( count ), )
+                temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
+                temp = temp + \
+                    ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
+                ctrls.append( temp )
                 count = count + 1
             else:
                 break
         global MNTopo
-        Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+        Topo = TestONTopology(
+            main.Mininet1,
+            ctrls )  # can also add Intent API info for intent operations
         MNTopo = Topo
 
         Topology_Check = main.TRUE
-        main.step("Compare ONOS Topology to MN Topology")
-        
-        switches_results1 =  main.Mininet1.compare_switches(MNTopo, json.loads(devices1))
+        main.step( "Compare ONOS Topology to MN Topology" )
+
+        switches_results1 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices1 ) )
         print "switches_Result1 = ", switches_results1
-        utilities.assert_equals(expect=main.TRUE, actual=switches_results1,
-                onpass="ONOS1 Switches view is correct",
-                onfail="ONOS1 Switches view is incorrect")
+        utilities.assert_equals( expect=main.TRUE, actual=switches_results1,
+                                 onpass="ONOS1 Switches view is correct",
+                                 onfail="ONOS1 Switches view is incorrect" )
 
-        switches_results2 =  main.Mininet1.compare_switches(MNTopo, json.loads(devices2))
-        utilities.assert_equals(expect=main.TRUE, actual=switches_results2,
-                onpass="ONOS2 Switches view is correct",
-                onfail="ONOS2 Switches view is incorrect")
-    
-        switches_results3 =  main.Mininet1.compare_switches(MNTopo, json.loads(devices3))
-        utilities.assert_equals(expect=main.TRUE, actual=switches_results3,
-                onpass="ONOS3 Switches view is correct",
-                onfail="ONOS3 Switches view is incorrect")
+        switches_results2 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices2 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=switches_results2,
+                                 onpass="ONOS2 Switches view is correct",
+                                 onfail="ONOS2 Switches view is incorrect" )
 
-        '''
-        ports_results1 =  main.Mininet1.compare_ports(MNTopo, json.loads(ports1))
-        utilities.assert_equals(expect=main.TRUE, actual=ports_results1,
+        switches_results3 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices3 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
+                                 onpass="ONOS3 Switches view is correct",
+                                 onfail="ONOS3 Switches view is incorrect" )
+
+        """
+        ports_results1 =  main.Mininet1.compare_ports( MNTopo, json.loads( ports1 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=ports_results1,
                 onpass="ONOS1 Ports view is correct",
-                onfail="ONOS1 Ports view is incorrect")
+                onfail="ONOS1 Ports view is incorrect" )
 
-        ports_results2 =  main.Mininet1.compare_ports(MNTopo, json.loads(ports2))
-        utilities.assert_equals(expect=main.TRUE, actual=ports_results2,
+        ports_results2 =  main.Mininet1.compare_ports( MNTopo, json.loads( ports2 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=ports_results2,
                 onpass="ONOS2 Ports view is correct",
-                onfail="ONOS2 Ports view is incorrect")
+                onfail="ONOS2 Ports view is incorrect" )
 
-        ports_results3 =  main.Mininet1.compare_ports(MNTopo, json.loads(ports3))
-        utilities.assert_equals(expect=main.TRUE, actual=ports_results3,
+        ports_results3 =  main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
                 onpass="ONOS3 Ports view is correct",
-                onfail="ONOS3 Ports view is incorrect")
-        '''        
+                onfail="ONOS3 Ports view is incorrect" )
+        """
+        links_results1 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links1 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=links_results1,
+                                 onpass="ONOS1 Links view is correct",
+                                 onfail="ONOS1 Links view is incorrect" )
 
-        links_results1 =  main.Mininet1.compare_links(MNTopo, json.loads(links1))
-        utilities.assert_equals(expect=main.TRUE, actual=links_results1,
-                onpass="ONOS1 Links view is correct",
-                onfail="ONOS1 Links view is incorrect")
+        links_results2 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links2 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=links_results2,
+                                 onpass="ONOS2 Links view is correct",
+                                 onfail="ONOS2 Links view is incorrect" )
 
-        links_results2 =  main.Mininet1.compare_links(MNTopo, json.loads(links2))
-        utilities.assert_equals(expect=main.TRUE, actual=links_results2,
-                onpass="ONOS2 Links view is correct",
-                onfail="ONOS2 Links view is incorrect")
-
-        links_results3 =  main.Mininet1.compare_links(MNTopo, json.loads(links3))
-        utilities.assert_equals(expect=main.TRUE, actual=links_results3,
-                onpass="ONOS2 Links view is correct",
-                onfail="ONOS2 Links view is incorrect")
+        links_results3 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links3 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=links_results3,
+                                 onpass="ONOS2 Links view is correct",
+                                 onfail="ONOS2 Links view is incorrect" )
 
         #topo_result = switches_results1 and switches_results2 and switches_results3\
-                #and ports_results1 and ports_results2 and ports_results3\
-                #and links_results1 and links_results2 and links_results3
-        
+        # and ports_results1 and ports_results2 and ports_results3\
+        # and links_results1 and links_results2 and links_results3
+
         topo_result = switches_results1 and switches_results2 and switches_results3\
-                and links_results1 and links_results2 and links_results3
+            and links_results1 and links_results2 and links_results3
 
         if topo_result == main.TRUE:
-            main.log.report("Topology Check Test with mininet and ONOS instances successful")
+            main.log.report(
+                "Topology Check Test with mininet and ONOS instances successful" )
         else:
-            main.log.report("Topology Check Test with mininet and ONOS instances failed")
+            main.log.report(
+                "Topology Check Test with mininet and ONOS instances failed" )
 
-        utilities.assert_equals(expect=main.TRUE, actual=topo_result,
-                onpass="Topology Check Test successful",
-                onfail="Topology Check Test NOT successful")
+        utilities.assert_equals( expect=main.TRUE, actual=topo_result,
+                                 onpass="Topology Check Test successful",
+                                 onfail="Topology Check Test NOT successful" )
 
+    def CASE10( self ):
+        main.log.report(
+            "This testcase uninstalls the reactive forwarding app" )
+        main.log.report( "__________________________________" )
+        main.case( "Uninstalling reactive forwarding app" )
+        # Unistall onos-app-fwd app to disable reactive forwarding
+        appUninstall_result1 = main.ONOScli1.feature_uninstall(
+            "onos-app-fwd" )
+        appUninstall_result2 = main.ONOScli2.feature_uninstall(
+            "onos-app-fwd" )
+        appUninstall_result3 = main.ONOScli3.feature_uninstall(
+            "onos-app-fwd" )
+        main.log.info( "onos-app-fwd uninstalled" )
 
+        # After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+        # So sleep for 15s
+        time.sleep( 15 )
 
-
-    def CASE10(self):
-        main.log.report("This testcase uninstalls the reactive forwarding app")
-        main.log.report("__________________________________")
-        main.case("Uninstalling reactive forwarding app")
-        #Unistall onos-app-fwd app to disable reactive forwarding
-        appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-fwd")
-        appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-fwd")
-        appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-fwd")
-        main.log.info("onos-app-fwd uninstalled")
-
-        #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
-        #So sleep for 15s
-        time.sleep(15)
-        
         hosts = main.ONOScli1.hosts()
-        main.log.info(hosts)
-        
+        main.log.info( hosts )
+
         case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3
-        utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case10_result,
+            onpass="Reactive forwarding app uninstallation successful",
+            onfail="Reactive forwarding app uninstallation failed" )
 
-
-    def CASE6(self):
-        main.log.report("This testcase is testing the addition of host intents and then doing pingall")
-        main.log.report("__________________________________")        
-        main.case("Obtaining hostsfor adding host intents")
-        main.step("Get hosts")
+    def CASE6( self ):
+        main.log.report(
+            "This testcase is testing the addition of host intents and then doing pingall" )
+        main.log.report( "__________________________________" )
+        main.case( "Obtaining hostsfor adding host intents" )
+        main.step( "Get hosts" )
         hosts = main.ONOScli1.hosts()
-        main.log.info(hosts)
+        main.log.info( hosts )
 
-        main.step("Get all devices id")
+        main.step( "Get all devices id" )
         devices_id_list = main.ONOScli1.get_all_devices_id()
-        main.log.info(devices_id_list) 
+        main.log.info( devices_id_list )
 
-        #ONOS displays the hosts in hex format unlike mininet which does in decimal format
-        #So take care while adding intents
-        
-        '''
-        main.step("Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1") 
-        '''
+        # ONOS displays the hosts in hex format unlike mininet which does in decimal format
+        # So take care while adding intents
 
-        for i in range(8,18):
-            main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
-            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
-            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
-            #NOTE: get host can return None
-            #TODO: handle this
-            host1_id = main.ONOScli1.get_host(host1)['id']
-            host2_id = main.ONOScli1.get_host(host2)['id']
-            tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
+        """
+        main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
+        """
+        for i in range( 8, 18 ):
+            main.log.info(
+                "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) )
+            host1 = "00:00:00:00:00:" + \
+                str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+            host2 = "00:00:00:00:00:" + \
+                str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+            # NOTE: get host can return None
+            # TODO: handle this
+            host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
+            host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
+            tmp_result = main.ONOScli1.add_host_intent( host1_id, host2_id )
 
         flowHandle = main.ONOScli1.flows()
-        #print "flowHandle = ", flowHandle
-        main.log.info("flows:" +flowHandle)
+        # print "flowHandle = ", flowHandle
+        main.log.info( "flows:" + flowHandle )
 
         count = 1
         i = 8
         Ping_Result = main.TRUE
-        while i <18 :
-            main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
-            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
-            if ping == main.FALSE and count <5:
-                count+=1
+        while i < 18:
+            main.log.info(
+                "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+            ping = main.Mininet1.pingHost(
+                src="h" + str( i ), target="h" + str( i + 10 ) )
+            if ping == main.FALSE and count < 5:
+                count += 1
                 #i = 8
                 Ping_Result = main.FALSE
-                main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
-                time.sleep(2)
-            elif ping==main.FALSE:
-                main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
-                i=19
+                main.log.report( "Ping between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 " failed. Making attempt number " +
+                                 str( count ) +
+                                 " in 2 seconds" )
+                time.sleep( 2 )
+            elif ping == main.FALSE:
+                main.log.report( "All ping attempts between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 "have failed" )
+                i = 19
                 Ping_Result = main.FALSE
-            elif ping==main.TRUE:
-                main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
-                i+=1
+            elif ping == main.TRUE:
+                main.log.info( "Ping test between h" +
+                               str( i ) +
+                               " and h" +
+                               str( i +
+                                    10 ) +
+                               "passed!" )
+                i += 1
                 Ping_Result = main.TRUE
             else:
-                main.log.info("Unknown error")
+                main.log.info( "Unknown error" )
                 Ping_Result = main.ERROR
-        if Ping_Result==main.FALSE:
-            main.log.report("Host intents have not ben installed correctly. Cleaning up")
-            #main.cleanup()
-            #main.exit()
-        if Ping_Result==main.TRUE:
-            main.log.report("Host intents have been installed correctly")
+        if Ping_Result == main.FALSE:
+            main.log.report(
+                "Host intents have not ben installed correctly. Cleaning up" )
+            # main.cleanup()
+            # main.exit()
+        if Ping_Result == main.TRUE:
+            main.log.report( "Host intents have been installed correctly" )
 
         case6_result = Ping_Result
-        utilities.assert_equals(expect=main.TRUE, actual=case6_result,
-                onpass="Host intent addition and Pingall Test successful",
-                onfail="Host intent addition and Pingall Test NOT successful")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case6_result,
+            onpass="Host intent addition and Pingall Test successful",
+            onfail="Host intent addition and Pingall Test NOT successful" )
 
+    def CASE7( self, main ):
 
-    def CASE7 (self,main):
-       
-        ONOS1_ip = main.params['CTRL']['ip1']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
 
-        link_sleep = int(main.params['timers']['LinkDiscovery'])
+        link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
 
-        main.log.report("This testscase is killing a link to ensure that link discovery is consistent")
-        main.log.report("__________________________________")        
-        main.case("Killing a link to Ensure that Link Discovery is Working Properly")
-        main.step("Start continuous pings")
-       
-        main.Mininet2.pingLong(src=main.params['PING']['source1'],
-                            target=main.params['PING']['target1'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source2'],
-                            target=main.params['PING']['target2'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source3'],
-                            target=main.params['PING']['target3'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source4'],
-                            target=main.params['PING']['target4'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source5'],
-                            target=main.params['PING']['target5'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source6'],
-                            target=main.params['PING']['target6'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source7'],
-                            target=main.params['PING']['target7'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source8'],
-                            target=main.params['PING']['target8'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source9'],
-                            target=main.params['PING']['target9'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source10'],
-                            target=main.params['PING']['target10'],pingTime=500)
+        main.log.report(
+            "This testscase is killing a link to ensure that link discovery is consistent" )
+        main.log.report( "__________________________________" )
+        main.case(
+            "Killing a link to Ensure that Link Discovery is Working Properly" )
+        main.step( "Start continuous pings" )
 
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source1' ],
+            target=main.params[ 'PING' ][ 'target1' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source2' ],
+            target=main.params[ 'PING' ][ 'target2' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source3' ],
+            target=main.params[ 'PING' ][ 'target3' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source4' ],
+            target=main.params[ 'PING' ][ 'target4' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source5' ],
+            target=main.params[ 'PING' ][ 'target5' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source6' ],
+            target=main.params[ 'PING' ][ 'target6' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source7' ],
+            target=main.params[ 'PING' ][ 'target7' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source8' ],
+            target=main.params[ 'PING' ][ 'target8' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source9' ],
+            target=main.params[ 'PING' ][ 'target9' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source10' ],
+            target=main.params[ 'PING' ][ 'target10' ],
+            pingTime=500 )
 
-        main.step("Determine the current number of switches and links")
+        main.step( "Determine the current number of switches and links" )
         topology_output = main.ONOScli1.topology()
-        topology_result = main.ONOSbench.get_topology(topology_output)
-        activeSwitches = topology_result['devices']
-        links = topology_result['links']
-        print "activeSwitches = ", type(activeSwitches)
-        print "links = ", type(links)
-        main.log.info("Currently there are %s switches and %s links"  %(str(activeSwitches), str(links)))
+        topology_result = main.ONOSbench.get_topology( topology_output )
+        activeSwitches = topology_result[ 'devices' ]
+        links = topology_result[ 'links' ]
+        print "activeSwitches = ", type( activeSwitches )
+        print "links = ", type( links )
+        main.log.info(
+            "Currently there are %s switches and %s links" %
+            ( str( activeSwitches ), str( links ) ) )
 
-        main.step("Kill Link between s3 and s28")
-        main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
-        time.sleep(link_sleep)
+        main.step( "Kill Link between s3 and s28" )
+        main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
+        time.sleep( link_sleep )
         topology_output = main.ONOScli2.topology()
-        Link_Down = main.ONOSbench.check_status(topology_output,activeSwitches,str(int(links)-2))
+        Link_Down = main.ONOSbench.check_status(
+            topology_output, activeSwitches, str(
+                int( links ) - 2 ) )
         if Link_Down == main.TRUE:
-            main.log.report("Link Down discovered properly")
-        utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
-                onpass="Link Down discovered properly",
-                onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
-        
-        main.step("Bring link between s3 and s28 back up")
-        Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
-        time.sleep(link_sleep)
-        topology_output = main.ONOScli2.topology()
-        Link_Up = main.ONOSbench.check_status(topology_output,activeSwitches,str(links))
-        if Link_Up == main.TRUE:
-            main.log.report("Link up discovered properly")
-        utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
-                onpass="Link up discovered properly",
-                onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
+            main.log.report( "Link Down discovered properly" )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=Link_Down,
+            onpass="Link Down discovered properly",
+            onfail="Link down was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
 
-        main.step("Compare ONOS Topology to MN Topology")
-        main.case ("Testing Mininet topology with the topology of multi instances ONOS") 
-        main.step("Collecting topology information from ONOS")
+        main.step( "Bring link between s3 and s28 back up" )
+        Link_Up = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
+        time.sleep( link_sleep )
+        topology_output = main.ONOScli2.topology()
+        Link_Up = main.ONOSbench.check_status(
+            topology_output,
+            activeSwitches,
+            str( links ) )
+        if Link_Up == main.TRUE:
+            main.log.report( "Link up discovered properly" )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=Link_Up,
+            onpass="Link up discovered properly",
+            onfail="Link up was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
+
+        main.step( "Compare ONOS Topology to MN Topology" )
+        main.case(
+            "Testing Mininet topology with the topology of multi instances ONOS" )
+        main.step( "Collecting topology information from ONOS" )
         devices1 = main.ONOScli1.devices()
         devices2 = main.ONOScli2.devices()
         devices3 = main.ONOScli3.devices()
@@ -539,625 +660,864 @@
         hosts1 = main.ONOScli1.hosts()
         hosts2 = main.ONOScli2.hosts()
         hosts3 = main.ONOScli3.hosts()
-        #print "hosts1 = ", hosts1
-        #print "hosts2 = ", hosts2
-        #print "hosts3 = ", hosts3
+        # print "hosts1 = ", hosts1
+        # print "hosts2 = ", hosts2
+        # print "hosts3 = ", hosts3
         ports1 = main.ONOScli1.ports()
         ports2 = main.ONOScli2.ports()
         ports3 = main.ONOScli3.ports()
-        #print "ports1 = ", ports1
-        #print "ports2 = ", ports2    
-        #print "ports3 = ", ports3
+        # print "ports1 = ", ports1
+        # print "ports2 = ", ports2
+        # print "ports3 = ", ports3
         links1 = main.ONOScli1.links()
         links2 = main.ONOScli2.links()
         links3 = main.ONOScli3.links()
-        #print "links1 = ", links1
-        #print "links2 = ", links2
-        #print "links3 = ", links3
-        
-        print "**************"
-        
-        main.step("Start continuous pings")
-        main.Mininet2.pingLong(src=main.params['PING']['source1'],
-                            target=main.params['PING']['target1'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source2'],
-                            target=main.params['PING']['target2'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source3'],
-                            target=main.params['PING']['target3'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source4'],
-                            target=main.params['PING']['target4'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source5'],
-                            target=main.params['PING']['target5'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source6'],
-                            target=main.params['PING']['target6'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source7'],
-                            target=main.params['PING']['target7'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source8'],
-                            target=main.params['PING']['target8'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source9'],
-                            target=main.params['PING']['target9'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source10'],
-                            target=main.params['PING']['target10'],pingTime=500)
+        # print "links1 = ", links1
+        # print "links2 = ", links2
+        # print "links3 = ", links3
 
-        main.step("Create TestONTopology object")
+        print "**************"
+
+        main.step( "Start continuous pings" )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source1' ],
+            target=main.params[ 'PING' ][ 'target1' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source2' ],
+            target=main.params[ 'PING' ][ 'target2' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source3' ],
+            target=main.params[ 'PING' ][ 'target3' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source4' ],
+            target=main.params[ 'PING' ][ 'target4' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source5' ],
+            target=main.params[ 'PING' ][ 'target5' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source6' ],
+            target=main.params[ 'PING' ][ 'target6' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source7' ],
+            target=main.params[ 'PING' ][ 'target7' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source8' ],
+            target=main.params[ 'PING' ][ 'target8' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source9' ],
+            target=main.params[ 'PING' ][ 'target9' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source10' ],
+            target=main.params[ 'PING' ][ 'target10' ],
+            pingTime=500 )
+
+        main.step( "Create TestONTopology object" )
         global ctrls
         ctrls = []
         count = 1
         while True:
             temp = ()
-            if ('ip' + str(count)) in main.params['CTRL']:
-                temp = temp + (getattr(main,('ONOS' + str(count))),)
-                temp = temp + ("ONOS"+str(count),)
-                temp = temp + (main.params['CTRL']['ip'+str(count)],)
-                temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
-                ctrls.append(temp)
+            if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
+                temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
+                temp = temp + ( "ONOS" + str( count ), )
+                temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
+                temp = temp + \
+                    ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
+                ctrls.append( temp )
                 count = count + 1
             else:
                 break
         global MNTopo
-        Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+        Topo = TestONTopology(
+            main.Mininet1,
+            ctrls )  # can also add Intent API info for intent operations
         MNTopo = Topo
 
         Topology_Check = main.TRUE
-        main.step("Compare ONOS Topology to MN Topology")
-        
-        switches_results1 =  main.Mininet1.compare_switches(MNTopo, json.loads(devices1))
+        main.step( "Compare ONOS Topology to MN Topology" )
+
+        switches_results1 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices1 ) )
         print "switches_Result1 = ", switches_results1
-        utilities.assert_equals(expect=main.TRUE, actual=switches_results1,
-                onpass="ONOS1 Switches view is correct",
-                onfail="ONOS1 Switches view is incorrect")
+        utilities.assert_equals( expect=main.TRUE, actual=switches_results1,
+                                 onpass="ONOS1 Switches view is correct",
+                                 onfail="ONOS1 Switches view is incorrect" )
 
-        switches_results2 =  main.Mininet1.compare_switches(MNTopo, json.loads(devices2))
-        utilities.assert_equals(expect=main.TRUE, actual=switches_results2,
-                onpass="ONOS2 Switches view is correct",
-                onfail="ONOS2 Switches view is incorrect")
-    
-        switches_results3 =  main.Mininet1.compare_switches(MNTopo, json.loads(devices3))
-        utilities.assert_equals(expect=main.TRUE, actual=switches_results3,
-                onpass="ONOS3 Switches view is correct",
-                onfail="ONOS3 Switches view is incorrect")
+        switches_results2 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices2 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=switches_results2,
+                                 onpass="ONOS2 Switches view is correct",
+                                 onfail="ONOS2 Switches view is incorrect" )
 
-        '''
-        ports_results1 =  main.Mininet1.compare_ports(MNTopo, json.loads(ports1))
-        utilities.assert_equals(expect=main.TRUE, actual=ports_results1,
+        switches_results3 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices3 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
+                                 onpass="ONOS3 Switches view is correct",
+                                 onfail="ONOS3 Switches view is incorrect" )
+
+        """
+        ports_results1 =  main.Mininet1.compare_ports( MNTopo, json.loads( ports1 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=ports_results1,
                 onpass="ONOS1 Ports view is correct",
-                onfail="ONOS1 Ports view is incorrect")
+                onfail="ONOS1 Ports view is incorrect" )
 
-        ports_results2 =  main.Mininet1.compare_ports(MNTopo, json.loads(ports2))
-        utilities.assert_equals(expect=main.TRUE, actual=ports_results2,
+        ports_results2 =  main.Mininet1.compare_ports( MNTopo, json.loads( ports2 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=ports_results2,
                 onpass="ONOS2 Ports view is correct",
-                onfail="ONOS2 Ports view is incorrect")
+                onfail="ONOS2 Ports view is incorrect" )
 
-        ports_results3 =  main.Mininet1.compare_ports(MNTopo, json.loads(ports3))
-        utilities.assert_equals(expect=main.TRUE, actual=ports_results3,
+        ports_results3 =  main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
                 onpass="ONOS3 Ports view is correct",
-                onfail="ONOS3 Ports view is incorrect")
-        '''        
+                onfail="ONOS3 Ports view is incorrect" )
+        """
+        links_results1 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links1 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=links_results1,
+                                 onpass="ONOS1 Links view is correct",
+                                 onfail="ONOS1 Links view is incorrect" )
 
-        links_results1 =  main.Mininet1.compare_links(MNTopo, json.loads(links1))
-        utilities.assert_equals(expect=main.TRUE, actual=links_results1,
-                onpass="ONOS1 Links view is correct",
-                onfail="ONOS1 Links view is incorrect")
+        links_results2 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links2 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=links_results2,
+                                 onpass="ONOS2 Links view is correct",
+                                 onfail="ONOS2 Links view is incorrect" )
 
-        links_results2 =  main.Mininet1.compare_links(MNTopo, json.loads(links2))
-        utilities.assert_equals(expect=main.TRUE, actual=links_results2,
-                onpass="ONOS2 Links view is correct",
-                onfail="ONOS2 Links view is incorrect")
+        links_results3 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links3 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=links_results3,
+                                 onpass="ONOS2 Links view is correct",
+                                 onfail="ONOS2 Links view is incorrect" )
 
-        links_results3 =  main.Mininet1.compare_links(MNTopo, json.loads(links3))
-        utilities.assert_equals(expect=main.TRUE, actual=links_results3,
-                onpass="ONOS2 Links view is correct",
-                onfail="ONOS2 Links view is incorrect")
-               
         #topo_result = switches_results1 and switches_results2 and switches_results3\
-                #and ports_results1 and ports_results2 and ports_results3\
-                #and links_results1 and links_results2 and links_results3
-        
+        # and ports_results1 and ports_results2 and ports_results3\
+        # and links_results1 and links_results2 and links_results3
+
         topo_result = switches_results1 and switches_results2 and switches_results3\
-                and links_results1 and links_results2 and links_results3
+            and links_results1 and links_results2 and links_results3
 
-        utilities.assert_equals(expect=main.TRUE, actual=topo_result and Link_Up and Link_Down,
-                onpass="Topology Check Test successful",
-                onfail="Topology Check Test NOT successful")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=topo_result and Link_Up and Link_Down,
+            onpass="Topology Check Test successful",
+            onfail="Topology Check Test NOT successful" )
 
-
-    def CASE8(self):
-        '''
+    def CASE8( self ):
+        """
         Intent removal
-        ''' 
-        main.log.report("This testcase removes host any previously added intents")
-        main.log.report("__________________________________")        
-        main.log.info("Removing any previously installed intents")
-        main.case("Removing intents")
-        main.step("Obtain the intent id's")
-        intent_result = main.ONOScli1.intents(json_format = False)
-        
-        intent_linewise = intent_result.split("\n")
+        """
+        main.log.report(
+            "This testcase removes host any previously added intents" )
+        main.log.report( "__________________________________" )
+        main.log.info( "Removing any previously installed intents" )
+        main.case( "Removing intents" )
+        main.step( "Obtain the intent id's" )
+        intent_result = main.ONOScli1.intents( json_format=False )
+
+        intent_linewise = intent_result.split( "\n" )
         intentList = []
         for line in intent_linewise:
-            if line.startswith("id="):
-                intentList.append(line)
+            if line.startswith( "id=" ):
+                intentList.append( line )
 
         intentids = []
         for line in intentList:
-            intentids.append(line.split(",")[0].split("=")[1])
+            intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
         for id in intentids:
-            main.log.info("id = " +id)
+            main.log.info( "id = " + id )
 
-        main.step("Iterate through the intentids list and remove each intent")
+        main.step(
+            "Iterate through the intentids list and remove each intent" )
         for id in intentids:
-            main.ONOScli1.remove_intent(intent_id = id)
+            main.ONOScli1.remove_intent( intent_id=id )
 
-        intent_result = main.ONOScli1.intents(json_format = False)
-        main.log.info("intent_result = " +intent_result)
+        intent_result = main.ONOScli1.intents( json_format=False )
+        main.log.info( "intent_result = " + intent_result )
         case8_result = main.TRUE
-        
+
         i = 8
         Ping_Result = main.TRUE
-        while i <18 :
-            main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
-            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
-            if ping==main.TRUE:
+        while i < 18:
+            main.log.info(
+                "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+            ping = main.Mininet1.pingHost(
+                src="h" + str( i ), target="h" + str( i + 10 ) )
+            if ping == main.TRUE:
                 i = 19
                 Ping_Result = main.TRUE
-            elif ping==main.FALSE:
-                i+=1
+            elif ping == main.FALSE:
+                i += 1
                 Ping_Result = main.FALSE
             else:
-                main.log.info("Unknown error")
+                main.log.info( "Unknown error" )
                 Ping_Result = main.ERROR
-        
-        #Note: If the ping result failed, that means the intents have been withdrawn correctly.
-        if Ping_Result==main.TRUE:
-            main.log.report("Host intents have not been withdrawn correctly")
-            #main.cleanup()
-            #main.exit()
-        if Ping_Result==main.FALSE:
-            main.log.report("Host intents have been withdrawn correctly")
+
+        # Note: If the ping result failed, that means the intents have been
+        # withdrawn correctly.
+        if Ping_Result == main.TRUE:
+            main.log.report( "Host intents have not been withdrawn correctly" )
+            # main.cleanup()
+            # main.exit()
+        if Ping_Result == main.FALSE:
+            main.log.report( "Host intents have been withdrawn correctly" )
 
         case8_result = case8_result and Ping_Result
 
         if case8_result == main.FALSE:
-            main.log.report("Intent removal successful")
+            main.log.report( "Intent removal successful" )
         else:
-            main.log.report("Intent removal failed")
-                        
-        utilities.assert_equals(expect=main.FALSE, actual=case8_result,
-                onpass="Intent removal test failed",
-                onfail="Intent removal test successful")
-             
+            main.log.report( "Intent removal failed" )
 
-    def CASE9(self):
-        '''
+        utilities.assert_equals( expect=main.FALSE, actual=case8_result,
+                                 onpass="Intent removal test failed",
+                                 onfail="Intent removal test successful" )
+
+    def CASE9( self ):
+        """
         This test case adds point intents. Make sure you run test case 8 which is host intent removal before executing this test case.
         Else the host intent's flows will persist on switches and the pings would work even if there is some issue with the point intent's flows
-        '''
-        main.log.report("This testcase adds point intents and then does pingall")
-        main.log.report("__________________________________")        
-        main.log.info("Adding point intents")
-        main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)") 
-        main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
+        """
+        main.log.report(
+            "This testcase adds point intents and then does pingall" )
+        main.log.report( "__________________________________" )
+        main.log.info( "Adding point intents" )
+        main.case(
+            "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
+        main.step(
+            "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003008/1",
+            "of:0000000000006018/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-        
-        main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
 
-        main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006018/1",
+            "of:0000000000003008/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-            
-        main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-            
-        main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
 
-        main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
+        main.step(
+            "Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003009/1",
+            "of:0000000000006019/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-            
-        main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-            
-        main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
 
-
-        main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006019/1",
+            "of:0000000000003009/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003010/1",
+            "of:0000000000006020/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
 
-        print("_______________________________________________________________________________________")
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006020/1",
+            "of:0000000000003010/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003011/1",
+            "of:0000000000006021/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006021/1",
+            "of:0000000000003011/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003012/1",
+            "of:0000000000006022/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006022/1",
+            "of:0000000000003012/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003013/1",
+            "of:0000000000006023/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006023/1",
+            "of:0000000000003013/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003014/1",
+            "of:0000000000006024/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006024/1",
+            "of:0000000000003014/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003015/1",
+            "of:0000000000006025/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006025/1",
+            "of:0000000000003015/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003016/1",
+            "of:0000000000006026/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006026/1",
+            "of:0000000000003016/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003017/1",
+            "of:0000000000006027/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006027/1",
+            "of:0000000000003017/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        print(
+            "_______________________________________________________________________________________" )
 
         flowHandle = main.ONOScli1.flows()
-        #print "flowHandle = ", flowHandle
-        main.log.info("flows :" + flowHandle)        
+        # print "flowHandle = ", flowHandle
+        main.log.info( "flows :" + flowHandle )
 
         count = 1
         i = 8
         Ping_Result = main.TRUE
-        while i <18 :
-            main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
-            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
-            if ping == main.FALSE and count <5:
-                count+=1
+        while i < 18:
+            main.log.info(
+                "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+            ping = main.Mininet1.pingHost(
+                src="h" + str( i ), target="h" + str( i + 10 ) )
+            if ping == main.FALSE and count < 5:
+                count += 1
                 #i = 8
                 Ping_Result = main.FALSE
-                main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
-                time.sleep(2)
-            elif ping==main.FALSE:
-                main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
-                i=19
+                main.log.report( "Ping between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 " failed. Making attempt number " +
+                                 str( count ) +
+                                 " in 2 seconds" )
+                time.sleep( 2 )
+            elif ping == main.FALSE:
+                main.log.report( "All ping attempts between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 "have failed" )
+                i = 19
                 Ping_Result = main.FALSE
-            elif ping==main.TRUE:
-                main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
-                i+=1
+            elif ping == main.TRUE:
+                main.log.info( "Ping test between h" +
+                               str( i ) +
+                               " and h" +
+                               str( i +
+                                    10 ) +
+                               "passed!" )
+                i += 1
                 Ping_Result = main.TRUE
             else:
-                main.log.info("Unknown error")
+                main.log.info( "Unknown error" )
                 Ping_Result = main.ERROR
-        if Ping_Result==main.FALSE:
-            main.log.report("Ping all test after Point intents addition failed. Cleaning up")
-            #main.cleanup()
-            #main.exit()
-        if Ping_Result==main.TRUE:
-            main.log.report("Ping all test after Point intents addition successful")
+        if Ping_Result == main.FALSE:
+            main.log.report(
+                "Ping all test after Point intents addition failed. Cleaning up" )
+            # main.cleanup()
+            # main.exit()
+        if Ping_Result == main.TRUE:
+            main.log.report(
+                "Ping all test after Point intents addition successful" )
 
         case8_result = Ping_Result
-        utilities.assert_equals(expect=main.TRUE, actual=case8_result,
-                onpass="Ping all test after Point intents addition successful",
-                onfail="Ping all test after Point intents addition failed")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case8_result,
+            onpass="Ping all test after Point intents addition successful",
+            onfail="Ping all test after Point intents addition failed" )
 
-    def CASE31(self):
-        ''' 
-            This test case adds point intent related to SDN-IP matching on ICMP (ethertype=IPV4, ipProto=1)
-        '''
+    def CASE31( self ):
+        """
+            This test case adds point intent related to SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
+        """
         import json
 
-        main.log.report("This test case adds point intent related to SDN-IP matching on ICMP")
-        main.case("Adding bidirectional point intent related to SDN-IP matching on ICMP")
-        main.step("Adding bidirectional point intent")
-        #add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=1  of:0000000000003008/1 of:0000000000006018/1
-        
-        hosts_json = json.loads(main.ONOScli1.hosts())
-        for  i in range(8,11):
-            main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
-            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
-            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
-            host1_id = main.ONOScli1.get_host(host1)['id']
-            host2_id = main.ONOScli1.get_host(host2)['id']
+        main.log.report(
+            "This test case adds point intent related to SDN-IP matching on ICMP" )
+        main.case(
+            "Adding bidirectional point intent related to SDN-IP matching on ICMP" )
+        main.step( "Adding bidirectional point intent" )
+        # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
+        # --ethType=IPV4 --ipProto=1  of:0000000000003008/1
+        # of:0000000000006018/1
+
+        hosts_json = json.loads( main.ONOScli1.hosts() )
+        for i in range( 8, 11 ):
+            main.log.info(
+                "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
+            host1 = "00:00:00:00:00:" + \
+                str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+            host2 = "00:00:00:00:00:" + \
+                str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+            host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
+            host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
             for host in hosts_json:
-                if host['id'] == host1_id:
-                    ip1 = host['ips'][0]
-                    ip1 = str(ip1+"/32")
-                    device1 = host['location']['device']
-                    device1 = str(device1+"/1")
-                elif host['id'] == host2_id:
-                    ip2 = str(host['ips'][0])+"/32"
-                    device2 = host['location']["device"]
-                    device2 = str(device2+"/1")
-                
-            p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
-                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
-            
-            get_intent_result = main.ONOScli1.intents(json_format = False)
-            main.log.info(get_intent_result)
- 
-            p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1, 
-                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto']) 
-            
-            get_intent_result = main.ONOScli1.intents(json_format = False)
-            main.log.info(get_intent_result)
-            if (p_intent_result1 and p_intent_result2) == main.TRUE:
+                if host[ 'id' ] == host1_id:
+                    ip1 = host[ 'ips' ][ 0 ]
+                    ip1 = str( ip1 + "/32" )
+                    device1 = host[ 'location' ][ 'device' ]
+                    device1 = str( device1 + "/1" )
+                elif host[ 'id' ] == host2_id:
+                    ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
+                    device2 = host[ 'location' ][ "device" ]
+                    device2 = str( device2 + "/1" )
+
+            p_intent_result1 = main.ONOScli1.add_point_intent(
+                ingress_device=device1,
+                egress_device=device2,
+                ipSrc=ip1,
+                ipDst=ip2,
+                ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+                ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
+
+            get_intent_result = main.ONOScli1.intents( json_format=False )
+            main.log.info( get_intent_result )
+
+            p_intent_result2 = main.ONOScli1.add_point_intent(
+                ingress_device=device2,
+                egress_device=device1,
+                ipSrc=ip2,
+                ipDst=ip1,
+                ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+                ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
+
+            get_intent_result = main.ONOScli1.intents( json_format=False )
+            main.log.info( get_intent_result )
+            if ( p_intent_result1 and p_intent_result2 ) == main.TRUE:
                 #get_intent_result = main.ONOScli1.intents()
-                #main.log.info(get_intent_result)
-                main.log.info("Point intent related to SDN-IP matching on ICMP install successful")
-       
-        time.sleep(15) 
-        get_intent_result = main.ONOScli1.intents(json_format = False)
-        main.log.info("intents = "+ get_intent_result)
+                # main.log.info( get_intent_result )
+                main.log.info(
+                    "Point intent related to SDN-IP matching on ICMP install successful" )
+
+        time.sleep( 15 )
+        get_intent_result = main.ONOScli1.intents( json_format=False )
+        main.log.info( "intents = " + get_intent_result )
         get_flows_result = main.ONOScli1.flows()
-        main.log.info("flows = " + get_flows_result)
-        
+        main.log.info( "flows = " + get_flows_result )
+
         count = 1
         i = 8
         Ping_Result = main.TRUE
-        while i <11 :
-            main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
-            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
-            if ping == main.FALSE and count <3:
-                count+=1
+        while i < 11:
+            main.log.info(
+                "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+            ping = main.Mininet1.pingHost(
+                src="h" + str( i ), target="h" + str( i + 10 ) )
+            if ping == main.FALSE and count < 3:
+                count += 1
                 #i = 8
                 Ping_Result = main.FALSE
-                main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
-                time.sleep(2)
-            elif ping==main.FALSE:
-                main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
-                i=19
+                main.log.report( "Ping between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 " failed. Making attempt number " +
+                                 str( count ) +
+                                 " in 2 seconds" )
+                time.sleep( 2 )
+            elif ping == main.FALSE:
+                main.log.report( "All ping attempts between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 "have failed" )
+                i = 19
                 Ping_Result = main.FALSE
-            elif ping==main.TRUE:
-                main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
-                i+=1
+            elif ping == main.TRUE:
+                main.log.info( "Ping test between h" +
+                               str( i ) +
+                               " and h" +
+                               str( i +
+                                    10 ) +
+                               "passed!" )
+                i += 1
                 Ping_Result = main.TRUE
             else:
-                main.log.info("Unknown error")
+                main.log.info( "Unknown error" )
                 Ping_Result = main.ERROR
-        if Ping_Result==main.FALSE:
-            main.log.report("Ping test after Point intents related to SDN-IP matching on ICMP failed.")
-            #main.cleanup()
-            #main.exit()
-        if Ping_Result==main.TRUE:
-            main.log.report("Ping all test after Point intents related to SDN-IP matching on ICMP successful")
-                   
+        if Ping_Result == main.FALSE:
+            main.log.report(
+                "Ping test after Point intents related to SDN-IP matching on ICMP failed." )
+            # main.cleanup()
+            # main.exit()
+        if Ping_Result == main.TRUE:
+            main.log.report(
+                "Ping all test after Point intents related to SDN-IP matching on ICMP successful" )
+
         case31_result = Ping_Result and p_intent_result1 and p_intent_result2
-        utilities.assert_equals(expect=main.TRUE, actual=case31_result,
-                onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
-                onfail="Point intent related to SDN-IP matching on ICMP and ping test failed")
-   
-    def CASE32(self):
-        ''' 
-            This test case adds point intent related to SDN-IP matching on TCP (ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001)
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case31_result,
+            onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
+            onfail="Point intent related to SDN-IP matching on ICMP and ping test failed" )
+
+    def CASE32( self ):
+        """
+            This test case adds point intent related to SDN-IP matching on TCP ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
             Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001
-        '''
+        """
         import json
 
-        main.log.report("This test case adds point intent related to SDN-IP matching on TCP")
-        main.case("Adding bidirectional point intent related to SDN-IP matching on TCP")
-        main.step("Adding bidirectional point intent")
+        main.log.report(
+            "This test case adds point intent related to SDN-IP matching on TCP" )
+        main.case(
+            "Adding bidirectional point intent related to SDN-IP matching on TCP" )
+        main.step( "Adding bidirectional point intent" )
         """
         add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001  of:0000000000003008/1 of:0000000000006018/1
 
         add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001  of:0000000000006018/1 of:0000000000003008/1
-    
+
         add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001  of:0000000000003008/1 of:0000000000006018/1
 
         add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001  of:0000000000006018/1 of:0000000000003008/1
 
-        """           
-    
-        hosts_json = json.loads(main.ONOScli1.hosts())
-        for  i in range(8,9):
-            main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
-            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
-            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
-            host1_id = main.ONOScli1.get_host(host1)['id']
-            host2_id = main.ONOScli1.get_host(host2)['id']
+        """
+        hosts_json = json.loads( main.ONOScli1.hosts() )
+        for i in range( 8, 9 ):
+            main.log.info(
+                "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
+            host1 = "00:00:00:00:00:" + \
+                str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+            host2 = "00:00:00:00:00:" + \
+                str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+            host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
+            host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
             for host in hosts_json:
-                if host['id'] == host1_id:
-                    ip1 = host['ips'][0]
-                    ip1 = str(ip1+"/32")
-                    device1 = host['location']['device']
-                    device1 = str(device1+"/1")
-                elif host['id'] == host2_id:
-                    ip2 = str(host['ips'][0])+"/32"
-                    device2 = host['location']["device"]
-                    device2 = str(device2+"/1")
-                
-            p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
-                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort']) 
-            p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1, 
-                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
+                if host[ 'id' ] == host1_id:
+                    ip1 = host[ 'ips' ][ 0 ]
+                    ip1 = str( ip1 + "/32" )
+                    device1 = host[ 'location' ][ 'device' ]
+                    device1 = str( device1 + "/1" )
+                elif host[ 'id' ] == host2_id:
+                    ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
+                    device2 = host[ 'location' ][ "device" ]
+                    device2 = str( device2 + "/1" )
 
-            p_intent_result3 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
-                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
-            p_intent_result4 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
-                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort']) 
+            p_intent_result1 = main.ONOScli1.add_point_intent(
+                ingress_device=device1,
+                egress_device=device2,
+                ipSrc=ip1,
+                ipDst=ip2,
+                ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+                ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+                tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
+            p_intent_result2 = main.ONOScli1.add_point_intent(
+                ingress_device=device2,
+                egress_device=device1,
+                ipSrc=ip2,
+                ipDst=ip1,
+                ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+                ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+                tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
+
+            p_intent_result3 = main.ONOScli1.add_point_intent(
+                ingress_device=device1,
+                egress_device=device2,
+                ipSrc=ip1,
+                ipDst=ip2,
+                ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+                ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+                tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
+            p_intent_result4 = main.ONOScli1.add_point_intent(
+                ingress_device=device2,
+                egress_device=device1,
+                ipSrc=ip2,
+                ipDst=ip1,
+                ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+                ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+                tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
 
             p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4
-            if p_intent_result ==main.TRUE:
-                get_intent_result = main.ONOScli1.intents(json_format = False)
-                main.log.info(get_intent_result)
-                main.log.info("Point intent related to SDN-IP matching on TCP install successful")
-        
-        iperf_result = main.Mininet1.iperf('h8', 'h18') 
-        if iperf_result == main.TRUE:
-            main.log.report("iperf test successful")
-        else:
-            main.log.report("iperf test failed")
+            if p_intent_result == main.TRUE:
+                get_intent_result = main.ONOScli1.intents( json_format=False )
+                main.log.info( get_intent_result )
+                main.log.info(
+                    "Point intent related to SDN-IP matching on TCP install successful" )
 
+        iperf_result = main.Mininet1.iperf( 'h8', 'h18' )
+        if iperf_result == main.TRUE:
+            main.log.report( "iperf test successful" )
+        else:
+            main.log.report( "iperf test failed" )
 
         case32_result = p_intent_result and iperf_result
-        utilities.assert_equals(expect=main.TRUE, actual=case32_result,
-                onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
-                onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case32_result,
+            onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
+            onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed" )
 
-
-    def CASE33(self):
-        ''' 
-            This test case adds multipoint to singlepoint  intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address 
+    def CASE33( self ):
+        """
+            This test case adds multipoint to singlepoint  intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address
             Here the mac address to be rewritten is the mac address of the egress device
-        '''
+        """
         import json
         import time
 
-        main.log.report("This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action")
-        main.case("Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip")
-        main.step("Adding bidirectional multipoint to singlepoint intent")
+        main.log.report(
+            "This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action" )
+        main.case(
+            "Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip" )
+        main.step( "Adding bidirectional multipoint to singlepoint intent" )
         """
         add-multi-to-single-intent --ipDst=10.0.3.0/24 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1 of:0000000000006018/1
-        
-        add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1 
-        """    
-        
-        main.case("Installing multipoint to single point intent with rewrite mac address")
-        main.step("Uninstalling proxy arp app")
-        #Unistall onos-app-proxyarp app to disable reactive forwarding
-        appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-proxyarp")
-        appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-proxyarp")
-        appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-proxyarp")
-        main.log.info("onos-app-proxyarp uninstalled") 
 
-        main.step("Changing ipaddress of hosts h8,h9 and h18")
-        main.Mininet1.changeIP(host='h8', intf='h8-eth0', newIP='10.0.1.1', newNetmask='255.255.255.0') 
-        main.Mininet1.changeIP(host='h9', intf='h9-eth0', newIP='10.0.2.1', newNetmask='255.255.255.0')
-        main.Mininet1.changeIP(host='h10', intf='h10-eth0', newIP='10.0.3.1', newNetmask='255.255.255.0')
+        add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1
+        """
+        main.case(
+            "Installing multipoint to single point intent with rewrite mac address" )
+        main.step( "Uninstalling proxy arp app" )
+        # Unistall onos-app-proxyarp app to disable reactive forwarding
+        appUninstall_result1 = main.ONOScli1.feature_uninstall(
+            "onos-app-proxyarp" )
+        appUninstall_result2 = main.ONOScli2.feature_uninstall(
+            "onos-app-proxyarp" )
+        appUninstall_result3 = main.ONOScli3.feature_uninstall(
+            "onos-app-proxyarp" )
+        main.log.info( "onos-app-proxyarp uninstalled" )
 
-        main.step("Changing default gateway of hosts h8,h9 and h18")
-        main.Mininet1.changeDefaultGateway(host='h8', newGW='10.0.1.254')
-        main.Mininet1.changeDefaultGateway(host='h9', newGW='10.0.2.254')
-        main.Mininet1.changeDefaultGateway(host='h10', newGW='10.0.3.254')
+        main.step( "Changing ipaddress of hosts h8,h9 and h18" )
+        main.Mininet1.changeIP(
+            host='h8',
+            intf='h8-eth0',
+            newIP='10.0.1.1',
+            newNetmask='255.255.255.0' )
+        main.Mininet1.changeIP(
+            host='h9',
+            intf='h9-eth0',
+            newIP='10.0.2.1',
+            newNetmask='255.255.255.0' )
+        main.Mininet1.changeIP(
+            host='h10',
+            intf='h10-eth0',
+            newIP='10.0.3.1',
+            newNetmask='255.255.255.0' )
 
-        main.step("Assigning random mac address to the default gateways since proxyarp app is uninstalled")
-        main.Mininet1.addStaticMACAddress(host='h8', GW='10.0.1.254', macaddr='00:00:00:00:11:11')
-        main.Mininet1.addStaticMACAddress(host='h9', GW='10.0.2.254', macaddr='00:00:00:00:22:22')
-        main.Mininet1.addStaticMACAddress(host='h10', GW='10.0.3.254', macaddr='00:00:00:00:33:33')
-         
-        main.step("Verify static gateway and MAC address assignment")
-        main.Mininet1.verifyStaticGWandMAC(host='h8')
-        main.Mininet1.verifyStaticGWandMAC(host='h9')
-        main.Mininet1.verifyStaticGWandMAC(host='h10')
-        
-        main.step("Adding multipoint to singlepoint intent")               
-        p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device1'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'],
-                                 egress_device=main.params['MULTIPOINT_INTENT']['device3'], ipDst=main.params['MULTIPOINT_INTENT']['ip1'], setEthDst=main.params['MULTIPOINT_INTENT']['mac1']) 
-        
-        p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device3'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'],                            
-                                egress_device=main.params['MULTIPOINT_INTENT']['device1'], ipDst=main.params['MULTIPOINT_INTENT']['ip2'], setEthDst=main.params['MULTIPOINT_INTENT']['mac2'])    
+        main.step( "Changing default gateway of hosts h8,h9 and h18" )
+        main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
+        main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
+        main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
 
+        main.step(
+            "Assigning random mac address to the default gateways since proxyarp app is uninstalled" )
+        main.Mininet1.addStaticMACAddress(
+            host='h8',
+            GW='10.0.1.254',
+            macaddr='00:00:00:00:11:11' )
+        main.Mininet1.addStaticMACAddress(
+            host='h9',
+            GW='10.0.2.254',
+            macaddr='00:00:00:00:22:22' )
+        main.Mininet1.addStaticMACAddress(
+            host='h10',
+            GW='10.0.3.254',
+            macaddr='00:00:00:00:33:33' )
 
-        get_intent_result = main.ONOScli1.intents(json_format = False)
-        main.log.info("intents = "+ get_intent_result)
-        
-        time.sleep(10)
-        get_flows_result = main.ONOScli1.flows(json_format = False)
-        main.log.info("flows = " + get_flows_result) 
+        main.step( "Verify static gateway and MAC address assignment" )
+        main.Mininet1.verifyStaticGWandMAC( host='h8' )
+        main.Mininet1.verifyStaticGWandMAC( host='h9' )
+        main.Mininet1.verifyStaticGWandMAC( host='h10' )
+
+        main.step( "Adding multipoint to singlepoint intent" )
+        p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
+            ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
+            ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
+            egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
+            ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
+            setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
+
+        p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
+            ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
+            ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
+            egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
+            ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
+            setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
+
+        get_intent_result = main.ONOScli1.intents( json_format=False )
+        main.log.info( "intents = " + get_intent_result )
+
+        time.sleep( 10 )
+        get_flows_result = main.ONOScli1.flows( json_format=False )
+        main.log.info( "flows = " + get_flows_result )
 
         count = 1
         i = 8
         Ping_Result = main.TRUE
-       
-        main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+2))
-        ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+2))
-        if ping == main.FALSE and count <3:
-            count+=1
+
+        main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
+        ping = main.Mininet1.pingHost(
+            src="h" + str( i ), target="h" + str( i + 2 ) )
+        if ping == main.FALSE and count < 3:
+            count += 1
             Ping_Result = main.FALSE
-            main.log.report("Ping between h" + str(i) + " and h" + str(i+2) + " failed. Making attempt number "+str(count) + " in 2 seconds")
-            time.sleep(2)
-        elif ping==main.FALSE:
-            main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
+            main.log.report( "Ping between h" +
+                             str( i ) +
+                             " and h" +
+                             str( i +
+                                  2 ) +
+                             " failed. Making attempt number " +
+                             str( count ) +
+                             " in 2 seconds" )
+            time.sleep( 2 )
+        elif ping == main.FALSE:
+            main.log.report( "All ping attempts between h" +
+                             str( i ) +
+                             " and h" +
+                             str( i +
+                                  10 ) +
+                             "have failed" )
             Ping_Result = main.FALSE
-        elif ping==main.TRUE:
-            main.log.info("Ping test between h" + str(i) + " and h" + str(i+2) + "passed!")
+        elif ping == main.TRUE:
+            main.log.info( "Ping test between h" +
+                           str( i ) +
+                           " and h" +
+                           str( i +
+                                2 ) +
+                           "passed!" )
             Ping_Result = main.TRUE
         else:
-            main.log.info("Unknown error")
+            main.log.info( "Unknown error" )
             Ping_Result = main.ERROR
-        
-        if Ping_Result==main.FALSE:
-            main.log.report("Ping test failed.")
-            #main.cleanup()
-            #main.exit()
-        if Ping_Result==main.TRUE:
-            main.log.report("Ping all successful")
 
+        if Ping_Result == main.FALSE:
+            main.log.report( "Ping test failed." )
+            # main.cleanup()
+            # main.exit()
+        if Ping_Result == main.TRUE:
+            main.log.report( "Ping all successful" )
 
         p_intent_result = p_intent_result1 and p_intent_result2
-        if p_intent_result ==main.TRUE:
-            main.log.info("Multi point intent with rewrite mac address installation successful")
+        if p_intent_result == main.TRUE:
+            main.log.info(
+                "Multi point intent with rewrite mac address installation successful" )
         else:
-            main.log.info("Multi point intent with rewrite mac address installation failed")
-      
+            main.log.info(
+                "Multi point intent with rewrite mac address installation failed" )
+
         case33_result = p_intent_result and Ping_Result
-        utilities.assert_equals(expect=main.TRUE, actual=case33_result,
-                onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful",
-                onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed")  
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case33_result,
+            onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful",
+            onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed" )
diff --git a/TestON/tests/MultiProd13/MultiProd13.py b/TestON/tests/MultiProd13/MultiProd13.py
old mode 100755
new mode 100644
index 1276d33..f26cd5c
--- a/TestON/tests/MultiProd13/MultiProd13.py
+++ b/TestON/tests/MultiProd13/MultiProd13.py
@@ -1,6 +1,6 @@
 
-#Testing the basic functionality of ONOS Next
-#For sanity and driver functionality excercises only.
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
 
 import time
 import sys
@@ -9,527 +9,648 @@
 import time
 import json
 
-time.sleep(1)
+time.sleep( 1 )
+
+
 class MultiProd13:
-    def __init__(self):
+
+    def __init__( self ):
         self.default = ''
 
-    def CASE1(self, main):
-        '''
+    def CASE1( self, main ):
+        """
         Startup sequence:
         cell <name>
         onos-verify-cell
-        onos-remove-raft-logs        
+        onos-remove-raft-logs
         git pull
         mvn clean install
         onos-package
         onos-install -f
         onos-wait-for-start
-        '''
-        
-        cell_name = main.params['ENV']['cellName']
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS1_port = main.params['CTRL']['port1']
-        ONOS2_port = main.params['CTRL']['port2']
-        ONOS3_port = main.params['CTRL']['port3']   
-       
-        main.case("Setting up test environment")
-        main.log.report("This testcase is testing setting up test environment") 
-        main.log.report("__________________________________")
- 
-        main.step("Applying cell variable to environment")
-        cell_result1 = main.ONOSbench.set_cell(cell_name)
-        #cell_result2 = main.ONOScli1.set_cell(cell_name)
-        #cell_result3 = main.ONOScli2.set_cell(cell_name)
-        #cell_result4 = main.ONOScli3.set_cell(cell_name)
-        verify_result = main.ONOSbench.verify_cell() 
+        """
+        cell_name = main.params[ 'ENV' ][ 'cellName' ]
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+        ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
+        ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
+
+        main.case( "Setting up test environment" )
+        main.log.report(
+            "This testcase is testing setting up test environment" )
+        main.log.report( "__________________________________" )
+
+        main.step( "Applying cell variable to environment" )
+        cell_result1 = main.ONOSbench.set_cell( cell_name )
+        #cell_result2 = main.ONOScli1.set_cell( cell_name )
+        #cell_result3 = main.ONOScli2.set_cell( cell_name )
+        #cell_result4 = main.ONOScli3.set_cell( cell_name )
+        verify_result = main.ONOSbench.verify_cell()
         cell_result = cell_result1
 
-        main.step("Removing raft logs before a clen installation of ONOS")
-        remove_log_Result = main.ONOSbench.onos_remove_raft_logs()        
+        main.step( "Removing raft logs before a clen installation of ONOS" )
+        remove_log_Result = main.ONOSbench.onos_remove_raft_logs()
 
-        main.step("Git checkout and pull master and get version")
-        main.ONOSbench.git_checkout("master")
+        main.step( "Git checkout and pull master and get version" )
+        main.ONOSbench.git_checkout( "master" )
         git_pull_result = main.ONOSbench.git_pull()
         print "git_pull_result = ", git_pull_result
-        version_result = main.ONOSbench.get_version(report=True)
+        version_result = main.ONOSbench.get_version( report=True )
 
         if git_pull_result == 1:
-            main.step("Using mvn clean & install")
+            main.step( "Using mvn clean & install" )
             clean_install_result = main.ONOSbench.clean_install()
-            #clean_install_result = main.TRUE 
+            #clean_install_result = main.TRUE
 
-        main.step("Creating ONOS package")
+        main.step( "Creating ONOS package" )
         package_result = main.ONOSbench.onos_package()
 
-        #main.step("Creating a cell")
-        #cell_create_result = main.ONOSbench.create_cell_file(**************)
+        #main.step( "Creating a cell" )
+        # cell_create_result = main.ONOSbench.create_cell_file( **************
+        # )
 
-        main.step("Installing ONOS package")
-        onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip)
-        onos2_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS2_ip)
-        onos3_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS3_ip)
-        onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result        
+        main.step( "Installing ONOS package" )
+        onos1_install_result = main.ONOSbench.onos_install(
+            options="-f",
+            node=ONOS1_ip )
+        onos2_install_result = main.ONOSbench.onos_install(
+            options="-f",
+            node=ONOS2_ip )
+        onos3_install_result = main.ONOSbench.onos_install(
+            options="-f",
+            node=ONOS3_ip )
+        onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result
         if onos_install_result == main.TRUE:
-            main.log.report("Installing ONOS package successful")
+            main.log.report( "Installing ONOS package successful" )
         else:
-            main.log.report("Installing ONOS package failed")
-        	
-        onos1_isup = main.ONOSbench.isup(ONOS1_ip)
-        onos2_isup = main.ONOSbench.isup(ONOS2_ip)
-        onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+            main.log.report( "Installing ONOS package failed" )
+
+        onos1_isup = main.ONOSbench.isup( ONOS1_ip )
+        onos2_isup = main.ONOSbench.isup( ONOS2_ip )
+        onos3_isup = main.ONOSbench.isup( ONOS3_ip )
         onos_isup = onos1_isup and onos2_isup and onos3_isup
         if onos_isup == main.TRUE:
-            main.log.report("ONOS instances are up and ready")
+            main.log.report( "ONOS instances are up and ready" )
         else:
-            main.log.report("ONOS instances may not be up")          
+            main.log.report( "ONOS instances may not be up" )
 
-        main.step("Starting ONOS service")
+        main.step( "Starting ONOS service" )
         start_result = main.TRUE
-        #start_result = main.ONOSbench.onos_start(ONOS1_ip)
-        startcli1 = main.ONOScli1.start_onos_cli(ONOS_ip = ONOS1_ip)
-        startcli2 = main.ONOScli2.start_onos_cli(ONOS_ip = ONOS2_ip)
-        startcli3 = main.ONOScli3.start_onos_cli(ONOS_ip = ONOS3_ip)
+        #start_result = main.ONOSbench.onos_start( ONOS1_ip )
+        startcli1 = main.ONOScli1.start_onos_cli( ONOS_ip=ONOS1_ip )
+        startcli2 = main.ONOScli2.start_onos_cli( ONOS_ip=ONOS2_ip )
+        startcli3 = main.ONOScli3.start_onos_cli( ONOS_ip=ONOS3_ip )
         print startcli1
         print startcli2
         print startcli3
-            
-        case1_result = (package_result and\
-                cell_result and verify_result and onos_install_result and\
-                onos_isup and start_result )
-        utilities.assert_equals(expect=main.TRUE, actual=case1_result,
-                onpass="Test startup successful",
-                onfail="Test startup NOT successful")
 
-    def CASE11(self, main):
-        '''
+        case1_result = ( package_result and
+                         cell_result and verify_result and onos_install_result and
+                         onos_isup and start_result )
+        utilities.assert_equals( expect=main.TRUE, actual=case1_result,
+                                 onpass="Test startup successful",
+                                 onfail="Test startup NOT successful" )
+
+    def CASE11( self, main ):
+        """
         Cleanup sequence:
         onos-service <node_ip> stop
         onos-uninstall
 
         TODO: Define rest of cleanup
-        
-        '''
 
-      	ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-	
-        main.case("Cleaning up test environment")
+        """
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
 
-        main.step("Testing ONOS kill function")
-        kill_result1 = main.ONOSbench.onos_kill(ONOS1_ip)
-        kill_result2 = main.ONOSbench.onos_kill(ONOS2_ip)
-        kill_result3 = main.ONOSbench.onos_kill(ONOS3_ip)
-	
-        main.step("Stopping ONOS service")
-        stop_result1 = main.ONOSbench.onos_stop(ONOS1_ip)
-        stop_result2 = main.ONOSbench.onos_stop(ONOS2_ip)
-        stop_result3 = main.ONOSbench.onos_stop(ONOS3_ip)
+        main.case( "Cleaning up test environment" )
 
-        main.step("Uninstalling ONOS service") 
+        main.step( "Testing ONOS kill function" )
+        kill_result1 = main.ONOSbench.onos_kill( ONOS1_ip )
+        kill_result2 = main.ONOSbench.onos_kill( ONOS2_ip )
+        kill_result3 = main.ONOSbench.onos_kill( ONOS3_ip )
+
+        main.step( "Stopping ONOS service" )
+        stop_result1 = main.ONOSbench.onos_stop( ONOS1_ip )
+        stop_result2 = main.ONOSbench.onos_stop( ONOS2_ip )
+        stop_result3 = main.ONOSbench.onos_stop( ONOS3_ip )
+
+        main.step( "Uninstalling ONOS service" )
         uninstall_result = main.ONOSbench.onos_uninstall()
 
-    def CASE3(self, main):
-        '''
+    def CASE3( self, main ):
+        """
         Test 'onos' command and its functionality in driver
-        '''
-       
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']	
+        """
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
 
-        main.case("Testing 'onos' command")
+        main.case( "Testing 'onos' command" )
 
-        main.step("Sending command 'onos -w <onos-ip> system:name'")
+        main.step( "Sending command 'onos -w <onos-ip> system:name'" )
         cmdstr1 = "system:name"
-        cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1) 
-        main.log.info("onos command returned: "+cmd_result1)
-        cmd_result2 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr1)
-        main.log.info("onos command returned: "+cmd_result2)
-        cmd_result3 = main.ONOSbench.onos_cli(ONOS3_ip, cmdstr1)
-        main.log.info("onos command returned: "+cmd_result3)
+        cmd_result1 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr1 )
+        main.log.info( "onos command returned: " + cmd_result1 )
+        cmd_result2 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr1 )
+        main.log.info( "onos command returned: " + cmd_result2 )
+        cmd_result3 = main.ONOSbench.onos_cli( ONOS3_ip, cmdstr1 )
+        main.log.info( "onos command returned: " + cmd_result3 )
 
-        main.step("Sending command 'onos -w <onos-ip> onos:topology'")
+        main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
         cmdstr2 = "onos:topology"
-        cmd_result4 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
-        main.log.info("onos command returned: "+cmd_result4)
-        cmd_result5 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr2)
-        main.log.info("onos command returned: "+cmd_result5)
-        cmd_result6 = main.ONOSbench.onos_cli(ONOS6_ip, cmdstr2)
-        main.log.info("onos command returned: "+cmd_result6)
+        cmd_result4 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
+        main.log.info( "onos command returned: " + cmd_result4 )
+        cmd_result5 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr2 )
+        main.log.info( "onos command returned: " + cmd_result5 )
+        cmd_result6 = main.ONOSbench.onos_cli( ONOS6_ip, cmdstr2 )
+        main.log.info( "onos command returned: " + cmd_result6 )
 
-
-    def CASE4(self, main):
+    def CASE4( self, main ):
         import re
         import time
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS1_port = main.params['CTRL']['port1']
-        ONOS2_port = main.params['CTRL']['port2']
-        ONOS3_port = main.params['CTRL']['port3']
-        
-        main.log.report("This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode")
-        main.log.report("__________________________________")        
-        main.case("Pingall Test(No intents are added)")
-        main.step("Assigning switches to controllers")
-        for i in range(1,29): #1 to (num of switches +1)
-            main.Mininet1.assign_sw_controller(sw=str(i),count=3, 
-                    ip1=ONOS1_ip, port1=ONOS1_port,
-                    ip2=ONOS2_ip, port2=ONOS2_port,
-		            ip3=ONOS3_ip, port3=ONOS3_port)
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+        ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
+        ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
+
+        main.log.report(
+            "This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode" )
+        main.log.report( "__________________________________" )
+        main.case( "Pingall Test(No intents are added)" )
+        main.step( "Assigning switches to controllers" )
+        for i in range( 1, 29 ):  # 1 to ( num of switches +1 )
+            main.Mininet1.assign_sw_controller(
+                sw=str( i ),
+                count=3,
+                ip1=ONOS1_ip,
+                port1=ONOS1_port,
+                ip2=ONOS2_ip,
+                port2=ONOS2_port,
+                ip3=ONOS3_ip,
+                port3=ONOS3_port )
 
         switch_mastership = main.TRUE
-        for i in range (1,29):
-            response = main.Mininet1.get_sw_controller("s"+str(i))
-            print("Response is " + str(response))
-            if re.search("tcp:"+ONOS1_ip,response):
+        for i in range( 1, 29 ):
+            response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+            print( "Response is " + str( response ) )
+            if re.search( "tcp:" + ONOS1_ip, response ):
                 switch_mastership = switch_mastership and main.TRUE
             else:
                 switch_mastership = main.FALSE
 
         if switch_mastership == main.TRUE:
-            main.log.report("Controller assignment successfull")
+            main.log.report( "Controller assignment successfull" )
         else:
-             main.log.report("Controller assignment failed")
-        #REACTIVE FWD test
-        main.step("Pingall")
+            main.log.report( "Controller assignment failed" )
+        # REACTIVE FWD test
+        main.step( "Pingall" )
         ping_result = main.FALSE
         time1 = time.time()
         ping_result = main.Mininet1.pingall()
         time2 = time.time()
-        print "Time for pingall: %2f seconds" % (time2 - time1)
-      
+        print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
         case4_result = switch_mastership and ping_result
         if ping_result == main.TRUE:
-            main.log.report("Pingall Test in reactive mode to discover the hosts successful")
+            main.log.report(
+                "Pingall Test in reactive mode to discover the hosts successful" )
         else:
-            main.log.report("Pingall Test in reactive mode to discover the hosts failed")
+            main.log.report(
+                "Pingall Test in reactive mode to discover the hosts failed" )
 
-        utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case4_result,
+            onpass="Controller assignment and Pingall Test successful",
+            onfail="Controller assignment and Pingall Test NOT successful" )
 
-    
-
-    def CASE5(self,main) :
+    def CASE5( self, main ):
         import json
         from subprocess import Popen, PIPE
-        from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        
-        main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes")
-        main.log.report("__________________________________")        
-        main.case ("Testing Mininet topology with the topology of multi instances ONOS") 
-        main.step("Collecting topology information from ONOS")
+        # assumes that sts is already in you PYTHONPATH
+        from sts.topology.teston_topology import TestONTopology
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+
+        main.log.report(
+            "This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes" )
+        main.log.report( "__________________________________" )
+        main.case(
+            "Testing Mininet topology with the topology of multi instances ONOS" )
+        main.step( "Collecting topology information from ONOS" )
         devices1 = main.ONOScli1.devices()
         devices2 = main.ONOScli2.devices()
         devices3 = main.ONOScli3.devices()
-        #print "devices1 = ", devices1
-        #print "devices2 = ", devices2
-        #print "devices3 = ", devices3
+        # print "devices1 = ", devices1
+        # print "devices2 = ", devices2
+        # print "devices3 = ", devices3
         hosts1 = main.ONOScli1.hosts()
         hosts2 = main.ONOScli2.hosts()
         hosts3 = main.ONOScli3.hosts()
-        #print "hosts1 = ", hosts1
-        #print "hosts2 = ", hosts2
-        #print "hosts3 = ", hosts3
+        # print "hosts1 = ", hosts1
+        # print "hosts2 = ", hosts2
+        # print "hosts3 = ", hosts3
         ports1 = main.ONOScli1.ports()
         ports2 = main.ONOScli2.ports()
         ports3 = main.ONOScli3.ports()
-        #print "ports1 = ", ports1
-        #print "ports2 = ", ports2    
-        #print "ports3 = ", ports3
+        # print "ports1 = ", ports1
+        # print "ports2 = ", ports2
+        # print "ports3 = ", ports3
         links1 = main.ONOScli1.links()
         links2 = main.ONOScli2.links()
         links3 = main.ONOScli3.links()
-        #print "links1 = ", links1
-        #print "links2 = ", links2
-        #print "links3 = ", links3
-        
-        print "**************"
-        
-        main.step("Start continuous pings")
-        main.Mininet2.pingLong(src=main.params['PING']['source1'],
-                            target=main.params['PING']['target1'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source2'],
-                            target=main.params['PING']['target2'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source3'],
-                            target=main.params['PING']['target3'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source4'],
-                            target=main.params['PING']['target4'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source5'],
-                            target=main.params['PING']['target5'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source6'],
-                            target=main.params['PING']['target6'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source7'],
-                            target=main.params['PING']['target7'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source8'],
-                            target=main.params['PING']['target8'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source9'],
-                            target=main.params['PING']['target9'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source10'],
-                            target=main.params['PING']['target10'],pingTime=500)
+        # print "links1 = ", links1
+        # print "links2 = ", links2
+        # print "links3 = ", links3
 
-        main.step("Create TestONTopology object")
+        print "**************"
+
+        main.step( "Start continuous pings" )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source1' ],
+            target=main.params[ 'PING' ][ 'target1' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source2' ],
+            target=main.params[ 'PING' ][ 'target2' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source3' ],
+            target=main.params[ 'PING' ][ 'target3' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source4' ],
+            target=main.params[ 'PING' ][ 'target4' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source5' ],
+            target=main.params[ 'PING' ][ 'target5' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source6' ],
+            target=main.params[ 'PING' ][ 'target6' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source7' ],
+            target=main.params[ 'PING' ][ 'target7' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source8' ],
+            target=main.params[ 'PING' ][ 'target8' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source9' ],
+            target=main.params[ 'PING' ][ 'target9' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source10' ],
+            target=main.params[ 'PING' ][ 'target10' ],
+            pingTime=500 )
+
+        main.step( "Create TestONTopology object" )
         global ctrls
         ctrls = []
         count = 1
         while True:
             temp = ()
-            if ('ip' + str(count)) in main.params['CTRL']:
-                temp = temp + (getattr(main,('ONOS' + str(count))),)
-                temp = temp + ("ONOS"+str(count),)
-                temp = temp + (main.params['CTRL']['ip'+str(count)],)
-                temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
-                ctrls.append(temp)
+            if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
+                temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
+                temp = temp + ( "ONOS" + str( count ), )
+                temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
+                temp = temp + \
+                    ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
+                ctrls.append( temp )
                 count = count + 1
             else:
                 break
         global MNTopo
-        Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+        Topo = TestONTopology(
+            main.Mininet1,
+            ctrls )  # can also add Intent API info for intent operations
         MNTopo = Topo
 
         Topology_Check = main.TRUE
-        main.step("Compare ONOS Topology to MN Topology")
-        
-        switches_results1 =  main.Mininet1.compare_switches(MNTopo, json.loads(devices1))
+        main.step( "Compare ONOS Topology to MN Topology" )
+
+        switches_results1 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices1 ) )
         print "switches_Result1 = ", switches_results1
-        utilities.assert_equals(expect=main.TRUE, actual=switches_results1,
-                onpass="ONOS1 Switches view is correct",
-                onfail="ONOS1 Switches view is incorrect")
+        utilities.assert_equals( expect=main.TRUE, actual=switches_results1,
+                                 onpass="ONOS1 Switches view is correct",
+                                 onfail="ONOS1 Switches view is incorrect" )
 
-        switches_results2 =  main.Mininet1.compare_switches(MNTopo, json.loads(devices2))
-        utilities.assert_equals(expect=main.TRUE, actual=switches_results2,
-                onpass="ONOS2 Switches view is correct",
-                onfail="ONOS2 Switches view is incorrect")
-    
-        switches_results3 =  main.Mininet1.compare_switches(MNTopo, json.loads(devices3))
-        utilities.assert_equals(expect=main.TRUE, actual=switches_results3,
-                onpass="ONOS3 Switches view is correct",
-                onfail="ONOS3 Switches view is incorrect")
+        switches_results2 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices2 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=switches_results2,
+                                 onpass="ONOS2 Switches view is correct",
+                                 onfail="ONOS2 Switches view is incorrect" )
 
-        '''
-        ports_results1 =  main.Mininet1.compare_ports(MNTopo, json.loads(ports1))
-        utilities.assert_equals(expect=main.TRUE, actual=ports_results1,
+        switches_results3 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices3 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
+                                 onpass="ONOS3 Switches view is correct",
+                                 onfail="ONOS3 Switches view is incorrect" )
+
+        """
+        ports_results1 =  main.Mininet1.compare_ports( MNTopo, json.loads( ports1 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=ports_results1,
                 onpass="ONOS1 Ports view is correct",
-                onfail="ONOS1 Ports view is incorrect")
+                onfail="ONOS1 Ports view is incorrect" )
 
-        ports_results2 =  main.Mininet1.compare_ports(MNTopo, json.loads(ports2))
-        utilities.assert_equals(expect=main.TRUE, actual=ports_results2,
+        ports_results2 =  main.Mininet1.compare_ports( MNTopo, json.loads( ports2 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=ports_results2,
                 onpass="ONOS2 Ports view is correct",
-                onfail="ONOS2 Ports view is incorrect")
+                onfail="ONOS2 Ports view is incorrect" )
 
-        ports_results3 =  main.Mininet1.compare_ports(MNTopo, json.loads(ports3))
-        utilities.assert_equals(expect=main.TRUE, actual=ports_results3,
+        ports_results3 =  main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
                 onpass="ONOS3 Ports view is correct",
-                onfail="ONOS3 Ports view is incorrect")
-        '''        
+                onfail="ONOS3 Ports view is incorrect" )
+        """
+        links_results1 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links1 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=links_results1,
+                                 onpass="ONOS1 Links view is correct",
+                                 onfail="ONOS1 Links view is incorrect" )
 
-        links_results1 =  main.Mininet1.compare_links(MNTopo, json.loads(links1))
-        utilities.assert_equals(expect=main.TRUE, actual=links_results1,
-                onpass="ONOS1 Links view is correct",
-                onfail="ONOS1 Links view is incorrect")
+        links_results2 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links2 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=links_results2,
+                                 onpass="ONOS2 Links view is correct",
+                                 onfail="ONOS2 Links view is incorrect" )
 
-        links_results2 =  main.Mininet1.compare_links(MNTopo, json.loads(links2))
-        utilities.assert_equals(expect=main.TRUE, actual=links_results2,
-                onpass="ONOS2 Links view is correct",
-                onfail="ONOS2 Links view is incorrect")
-
-        links_results3 =  main.Mininet1.compare_links(MNTopo, json.loads(links3))
-        utilities.assert_equals(expect=main.TRUE, actual=links_results3,
-                onpass="ONOS2 Links view is correct",
-                onfail="ONOS2 Links view is incorrect")
+        links_results3 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links3 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=links_results3,
+                                 onpass="ONOS2 Links view is correct",
+                                 onfail="ONOS2 Links view is incorrect" )
 
         #topo_result = switches_results1 and switches_results2 and switches_results3\
-                #and ports_results1 and ports_results2 and ports_results3\
-                #and links_results1 and links_results2 and links_results3
-        
+        # and ports_results1 and ports_results2 and ports_results3\
+        # and links_results1 and links_results2 and links_results3
+
         topo_result = switches_results1 and switches_results2 and switches_results3\
-                and links_results1 and links_results2 and links_results3
+            and links_results1 and links_results2 and links_results3
 
         if topo_result == main.TRUE:
-            main.log.report("Topology Check Test with mininet and ONOS instances successful")
+            main.log.report(
+                "Topology Check Test with mininet and ONOS instances successful" )
         else:
-            main.log.report("Topology Check Test with mininet and ONOS instances failed")
+            main.log.report(
+                "Topology Check Test with mininet and ONOS instances failed" )
 
-        utilities.assert_equals(expect=main.TRUE, actual=topo_result,
-                onpass="Topology Check Test successful",
-                onfail="Topology Check Test NOT successful")
+        utilities.assert_equals( expect=main.TRUE, actual=topo_result,
+                                 onpass="Topology Check Test successful",
+                                 onfail="Topology Check Test NOT successful" )
 
+    def CASE10( self ):
+        main.log.report(
+            "This testcase uninstalls the reactive forwarding app" )
+        main.log.report( "__________________________________" )
+        main.case( "Uninstalling reactive forwarding app" )
+        # Unistall onos-app-fwd app to disable reactive forwarding
+        appUninstall_result1 = main.ONOScli1.feature_uninstall(
+            "onos-app-fwd" )
+        appUninstall_result2 = main.ONOScli2.feature_uninstall(
+            "onos-app-fwd" )
+        appUninstall_result3 = main.ONOScli3.feature_uninstall(
+            "onos-app-fwd" )
+        main.log.info( "onos-app-fwd uninstalled" )
 
+        # After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+        # So sleep for 15s
+        time.sleep( 15 )
 
-
-    def CASE10(self):
-        main.log.report("This testcase uninstalls the reactive forwarding app")
-        main.log.report("__________________________________")
-        main.case("Uninstalling reactive forwarding app")
-        #Unistall onos-app-fwd app to disable reactive forwarding
-        appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-fwd")
-        appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-fwd")
-        appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-fwd")
-        main.log.info("onos-app-fwd uninstalled")
-
-        #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
-        #So sleep for 15s
-        time.sleep(15)
-        
         hosts = main.ONOScli1.hosts()
-        main.log.info(hosts)
-        
+        main.log.info( hosts )
+
         case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3
-        utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case10_result,
+            onpass="Reactive forwarding app uninstallation successful",
+            onfail="Reactive forwarding app uninstallation failed" )
 
-
-    def CASE6(self):
-        main.log.report("This testcase is testing the addition of host intents and then doing pingall")
-        main.log.report("__________________________________")        
-        main.case("Obtaining hostsfor adding host intents")
-        main.step("Get hosts")
+    def CASE6( self ):
+        main.log.report(
+            "This testcase is testing the addition of host intents and then doing pingall" )
+        main.log.report( "__________________________________" )
+        main.case( "Obtaining hostsfor adding host intents" )
+        main.step( "Get hosts" )
         hosts = main.ONOScli1.hosts()
-        main.log.info(hosts)
+        main.log.info( hosts )
 
-        main.step("Get all devices id")
+        main.step( "Get all devices id" )
         devices_id_list = main.ONOScli1.get_all_devices_id()
-        main.log.info(devices_id_list) 
+        main.log.info( devices_id_list )
 
-        #ONOS displays the hosts in hex format unlike mininet which does in decimal format
-        #So take care while adding intents
-        
-        '''
-        main.step("Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
-        hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1") 
-        '''
+        # ONOS displays the hosts in hex format unlike mininet which does in decimal format
+        # So take care while adding intents
 
-        for i in range(8,18):
-            main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
-            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
-            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
-            #NOTE: get host can return None
-            #TODO: handle this
-            host1_id = main.ONOScli1.get_host(host1)['id']
-            host2_id = main.ONOScli1.get_host(host2)['id']
-            tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
+        """
+        main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
+        hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
+        """
+        for i in range( 8, 18 ):
+            main.log.info(
+                "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) )
+            host1 = "00:00:00:00:00:" + \
+                str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+            host2 = "00:00:00:00:00:" + \
+                str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+            # NOTE: get host can return None
+            # TODO: handle this
+            host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
+            host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
+            tmp_result = main.ONOScli1.add_host_intent( host1_id, host2_id )
 
         flowHandle = main.ONOScli1.flows()
-        #print "flowHandle = ", flowHandle
-        main.log.info("flows:" +flowHandle)
+        # print "flowHandle = ", flowHandle
+        main.log.info( "flows:" + flowHandle )
 
         count = 1
         i = 8
         Ping_Result = main.TRUE
-        while i <18 :
-            main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
-            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
-            if ping == main.FALSE and count <5:
-                count+=1
+        while i < 18:
+            main.log.info(
+                "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+            ping = main.Mininet1.pingHost(
+                src="h" + str( i ), target="h" + str( i + 10 ) )
+            if ping == main.FALSE and count < 5:
+                count += 1
                 #i = 8
                 Ping_Result = main.FALSE
-                main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
-                time.sleep(2)
-            elif ping==main.FALSE:
-                main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
-                i=19
+                main.log.report( "Ping between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 " failed. Making attempt number " +
+                                 str( count ) +
+                                 " in 2 seconds" )
+                time.sleep( 2 )
+            elif ping == main.FALSE:
+                main.log.report( "All ping attempts between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 "have failed" )
+                i = 19
                 Ping_Result = main.FALSE
-            elif ping==main.TRUE:
-                main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
-                i+=1
+            elif ping == main.TRUE:
+                main.log.info( "Ping test between h" +
+                               str( i ) +
+                               " and h" +
+                               str( i +
+                                    10 ) +
+                               "passed!" )
+                i += 1
                 Ping_Result = main.TRUE
             else:
-                main.log.info("Unknown error")
+                main.log.info( "Unknown error" )
                 Ping_Result = main.ERROR
-        if Ping_Result==main.FALSE:
-            main.log.report("Host intents have not ben installed correctly. Cleaning up")
-            #main.cleanup()
-            #main.exit()
-        if Ping_Result==main.TRUE:
-            main.log.report("Host intents have been installed correctly")
+        if Ping_Result == main.FALSE:
+            main.log.report(
+                "Host intents have not ben installed correctly. Cleaning up" )
+            # main.cleanup()
+            # main.exit()
+        if Ping_Result == main.TRUE:
+            main.log.report( "Host intents have been installed correctly" )
 
         case6_result = Ping_Result
-        utilities.assert_equals(expect=main.TRUE, actual=case6_result,
-                onpass="Host intent addition and Pingall Test successful",
-                onfail="Host intent addition and Pingall Test NOT successful")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case6_result,
+            onpass="Host intent addition and Pingall Test successful",
+            onfail="Host intent addition and Pingall Test NOT successful" )
 
+    def CASE7( self, main ):
 
-    def CASE7 (self,main):
-       
-        ONOS1_ip = main.params['CTRL']['ip1']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
 
-        link_sleep = int(main.params['timers']['LinkDiscovery'])
+        link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
 
-        main.log.report("This testscase is killing a link to ensure that link discovery is consistent")
-        main.log.report("__________________________________")        
-        main.case("Killing a link to Ensure that Link Discovery is Working Properly")
-        main.step("Start continuous pings")
-       
-        main.Mininet2.pingLong(src=main.params['PING']['source1'],
-                            target=main.params['PING']['target1'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source2'],
-                            target=main.params['PING']['target2'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source3'],
-                            target=main.params['PING']['target3'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source4'],
-                            target=main.params['PING']['target4'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source5'],
-                            target=main.params['PING']['target5'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source6'],
-                            target=main.params['PING']['target6'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source7'],
-                            target=main.params['PING']['target7'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source8'],
-                            target=main.params['PING']['target8'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source9'],
-                            target=main.params['PING']['target9'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source10'],
-                            target=main.params['PING']['target10'],pingTime=500)
+        main.log.report(
+            "This testscase is killing a link to ensure that link discovery is consistent" )
+        main.log.report( "__________________________________" )
+        main.case(
+            "Killing a link to Ensure that Link Discovery is Working Properly" )
+        main.step( "Start continuous pings" )
 
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source1' ],
+            target=main.params[ 'PING' ][ 'target1' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source2' ],
+            target=main.params[ 'PING' ][ 'target2' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source3' ],
+            target=main.params[ 'PING' ][ 'target3' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source4' ],
+            target=main.params[ 'PING' ][ 'target4' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source5' ],
+            target=main.params[ 'PING' ][ 'target5' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source6' ],
+            target=main.params[ 'PING' ][ 'target6' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source7' ],
+            target=main.params[ 'PING' ][ 'target7' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source8' ],
+            target=main.params[ 'PING' ][ 'target8' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source9' ],
+            target=main.params[ 'PING' ][ 'target9' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source10' ],
+            target=main.params[ 'PING' ][ 'target10' ],
+            pingTime=500 )
 
-        main.step("Determine the current number of switches and links")
+        main.step( "Determine the current number of switches and links" )
         topology_output = main.ONOScli1.topology()
-        topology_result = main.ONOSbench.get_topology(topology_output)
-        activeSwitches = topology_result['devices']
-        links = topology_result['links']
-        print "activeSwitches = ", type(activeSwitches)
-        print "links = ", type(links)
-        main.log.info("Currently there are %s switches and %s links"  %(str(activeSwitches), str(links)))
+        topology_result = main.ONOSbench.get_topology( topology_output )
+        activeSwitches = topology_result[ 'devices' ]
+        links = topology_result[ 'links' ]
+        print "activeSwitches = ", type( activeSwitches )
+        print "links = ", type( links )
+        main.log.info(
+            "Currently there are %s switches and %s links" %
+            ( str( activeSwitches ), str( links ) ) )
 
-        main.step("Kill Link between s3 and s28")
-        main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
-        time.sleep(link_sleep)
+        main.step( "Kill Link between s3 and s28" )
+        main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
+        time.sleep( link_sleep )
         topology_output = main.ONOScli2.topology()
-        Link_Down = main.ONOSbench.check_status(topology_output,activeSwitches,str(int(links)-2))
+        Link_Down = main.ONOSbench.check_status(
+            topology_output, activeSwitches, str(
+                int( links ) - 2 ) )
         if Link_Down == main.TRUE:
-            main.log.report("Link Down discovered properly")
-        utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
-                onpass="Link Down discovered properly",
-                onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
-        
-        main.step("Bring link between s3 and s28 back up")
-        Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
-        time.sleep(link_sleep)
-        topology_output = main.ONOScli2.topology()
-        Link_Up = main.ONOSbench.check_status(topology_output,activeSwitches,str(links))
-        if Link_Up == main.TRUE:
-            main.log.report("Link up discovered properly")
-        utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
-                onpass="Link up discovered properly",
-                onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
+            main.log.report( "Link Down discovered properly" )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=Link_Down,
+            onpass="Link Down discovered properly",
+            onfail="Link down was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
 
-        main.step("Compare ONOS Topology to MN Topology")
-        main.case ("Testing Mininet topology with the topology of multi instances ONOS") 
-        main.step("Collecting topology information from ONOS")
+        main.step( "Bring link between s3 and s28 back up" )
+        Link_Up = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
+        time.sleep( link_sleep )
+        topology_output = main.ONOScli2.topology()
+        Link_Up = main.ONOSbench.check_status(
+            topology_output,
+            activeSwitches,
+            str( links ) )
+        if Link_Up == main.TRUE:
+            main.log.report( "Link up discovered properly" )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=Link_Up,
+            onpass="Link up discovered properly",
+            onfail="Link up was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
+
+        main.step( "Compare ONOS Topology to MN Topology" )
+        main.case(
+            "Testing Mininet topology with the topology of multi instances ONOS" )
+        main.step( "Collecting topology information from ONOS" )
         devices1 = main.ONOScli1.devices()
         devices2 = main.ONOScli2.devices()
         devices3 = main.ONOScli3.devices()
@@ -539,625 +660,864 @@
         hosts1 = main.ONOScli1.hosts()
         hosts2 = main.ONOScli2.hosts()
         hosts3 = main.ONOScli3.hosts()
-        #print "hosts1 = ", hosts1
-        #print "hosts2 = ", hosts2
-        #print "hosts3 = ", hosts3
+        # print "hosts1 = ", hosts1
+        # print "hosts2 = ", hosts2
+        # print "hosts3 = ", hosts3
         ports1 = main.ONOScli1.ports()
         ports2 = main.ONOScli2.ports()
         ports3 = main.ONOScli3.ports()
-        #print "ports1 = ", ports1
-        #print "ports2 = ", ports2    
-        #print "ports3 = ", ports3
+        # print "ports1 = ", ports1
+        # print "ports2 = ", ports2
+        # print "ports3 = ", ports3
         links1 = main.ONOScli1.links()
         links2 = main.ONOScli2.links()
         links3 = main.ONOScli3.links()
-        #print "links1 = ", links1
-        #print "links2 = ", links2
-        #print "links3 = ", links3
-        
-        print "**************"
-        
-        main.step("Start continuous pings")
-        main.Mininet2.pingLong(src=main.params['PING']['source1'],
-                            target=main.params['PING']['target1'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source2'],
-                            target=main.params['PING']['target2'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source3'],
-                            target=main.params['PING']['target3'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source4'],
-                            target=main.params['PING']['target4'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source5'],
-                            target=main.params['PING']['target5'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source6'],
-                            target=main.params['PING']['target6'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source7'],
-                            target=main.params['PING']['target7'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source8'],
-                            target=main.params['PING']['target8'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source9'],
-                            target=main.params['PING']['target9'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source10'],
-                            target=main.params['PING']['target10'],pingTime=500)
+        # print "links1 = ", links1
+        # print "links2 = ", links2
+        # print "links3 = ", links3
 
-        main.step("Create TestONTopology object")
+        print "**************"
+
+        main.step( "Start continuous pings" )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source1' ],
+            target=main.params[ 'PING' ][ 'target1' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source2' ],
+            target=main.params[ 'PING' ][ 'target2' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source3' ],
+            target=main.params[ 'PING' ][ 'target3' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source4' ],
+            target=main.params[ 'PING' ][ 'target4' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source5' ],
+            target=main.params[ 'PING' ][ 'target5' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source6' ],
+            target=main.params[ 'PING' ][ 'target6' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source7' ],
+            target=main.params[ 'PING' ][ 'target7' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source8' ],
+            target=main.params[ 'PING' ][ 'target8' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source9' ],
+            target=main.params[ 'PING' ][ 'target9' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source10' ],
+            target=main.params[ 'PING' ][ 'target10' ],
+            pingTime=500 )
+
+        main.step( "Create TestONTopology object" )
         global ctrls
         ctrls = []
         count = 1
         while True:
             temp = ()
-            if ('ip' + str(count)) in main.params['CTRL']:
-                temp = temp + (getattr(main,('ONOS' + str(count))),)
-                temp = temp + ("ONOS"+str(count),)
-                temp = temp + (main.params['CTRL']['ip'+str(count)],)
-                temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
-                ctrls.append(temp)
+            if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
+                temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
+                temp = temp + ( "ONOS" + str( count ), )
+                temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
+                temp = temp + \
+                    ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
+                ctrls.append( temp )
                 count = count + 1
             else:
                 break
         global MNTopo
-        Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+        Topo = TestONTopology(
+            main.Mininet1,
+            ctrls )  # can also add Intent API info for intent operations
         MNTopo = Topo
 
         Topology_Check = main.TRUE
-        main.step("Compare ONOS Topology to MN Topology")
-        
-        switches_results1 =  main.Mininet1.compare_switches(MNTopo, json.loads(devices1))
+        main.step( "Compare ONOS Topology to MN Topology" )
+
+        switches_results1 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices1 ) )
         print "switches_Result1 = ", switches_results1
-        utilities.assert_equals(expect=main.TRUE, actual=switches_results1,
-                onpass="ONOS1 Switches view is correct",
-                onfail="ONOS1 Switches view is incorrect")
+        utilities.assert_equals( expect=main.TRUE, actual=switches_results1,
+                                 onpass="ONOS1 Switches view is correct",
+                                 onfail="ONOS1 Switches view is incorrect" )
 
-        switches_results2 =  main.Mininet1.compare_switches(MNTopo, json.loads(devices2))
-        utilities.assert_equals(expect=main.TRUE, actual=switches_results2,
-                onpass="ONOS2 Switches view is correct",
-                onfail="ONOS2 Switches view is incorrect")
-    
-        switches_results3 =  main.Mininet1.compare_switches(MNTopo, json.loads(devices3))
-        utilities.assert_equals(expect=main.TRUE, actual=switches_results3,
-                onpass="ONOS3 Switches view is correct",
-                onfail="ONOS3 Switches view is incorrect")
+        switches_results2 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices2 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=switches_results2,
+                                 onpass="ONOS2 Switches view is correct",
+                                 onfail="ONOS2 Switches view is incorrect" )
 
-        '''
-        ports_results1 =  main.Mininet1.compare_ports(MNTopo, json.loads(ports1))
-        utilities.assert_equals(expect=main.TRUE, actual=ports_results1,
+        switches_results3 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices3 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
+                                 onpass="ONOS3 Switches view is correct",
+                                 onfail="ONOS3 Switches view is incorrect" )
+
+        """
+        ports_results1 =  main.Mininet1.compare_ports( MNTopo, json.loads( ports1 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=ports_results1,
                 onpass="ONOS1 Ports view is correct",
-                onfail="ONOS1 Ports view is incorrect")
+                onfail="ONOS1 Ports view is incorrect" )
 
-        ports_results2 =  main.Mininet1.compare_ports(MNTopo, json.loads(ports2))
-        utilities.assert_equals(expect=main.TRUE, actual=ports_results2,
+        ports_results2 =  main.Mininet1.compare_ports( MNTopo, json.loads( ports2 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=ports_results2,
                 onpass="ONOS2 Ports view is correct",
-                onfail="ONOS2 Ports view is incorrect")
+                onfail="ONOS2 Ports view is incorrect" )
 
-        ports_results3 =  main.Mininet1.compare_ports(MNTopo, json.loads(ports3))
-        utilities.assert_equals(expect=main.TRUE, actual=ports_results3,
+        ports_results3 =  main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
                 onpass="ONOS3 Ports view is correct",
-                onfail="ONOS3 Ports view is incorrect")
-        '''        
+                onfail="ONOS3 Ports view is incorrect" )
+        """
+        links_results1 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links1 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=links_results1,
+                                 onpass="ONOS1 Links view is correct",
+                                 onfail="ONOS1 Links view is incorrect" )
 
-        links_results1 =  main.Mininet1.compare_links(MNTopo, json.loads(links1))
-        utilities.assert_equals(expect=main.TRUE, actual=links_results1,
-                onpass="ONOS1 Links view is correct",
-                onfail="ONOS1 Links view is incorrect")
+        links_results2 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links2 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=links_results2,
+                                 onpass="ONOS2 Links view is correct",
+                                 onfail="ONOS2 Links view is incorrect" )
 
-        links_results2 =  main.Mininet1.compare_links(MNTopo, json.loads(links2))
-        utilities.assert_equals(expect=main.TRUE, actual=links_results2,
-                onpass="ONOS2 Links view is correct",
-                onfail="ONOS2 Links view is incorrect")
+        links_results3 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links3 ) )
+        utilities.assert_equals( expect=main.TRUE, actual=links_results3,
+                                 onpass="ONOS2 Links view is correct",
+                                 onfail="ONOS2 Links view is incorrect" )
 
-        links_results3 =  main.Mininet1.compare_links(MNTopo, json.loads(links3))
-        utilities.assert_equals(expect=main.TRUE, actual=links_results3,
-                onpass="ONOS2 Links view is correct",
-                onfail="ONOS2 Links view is incorrect")
-               
         #topo_result = switches_results1 and switches_results2 and switches_results3\
-                #and ports_results1 and ports_results2 and ports_results3\
-                #and links_results1 and links_results2 and links_results3
-        
+        # and ports_results1 and ports_results2 and ports_results3\
+        # and links_results1 and links_results2 and links_results3
+
         topo_result = switches_results1 and switches_results2 and switches_results3\
-                and links_results1 and links_results2 and links_results3
+            and links_results1 and links_results2 and links_results3
 
-        utilities.assert_equals(expect=main.TRUE, actual=topo_result and Link_Up and Link_Down,
-                onpass="Topology Check Test successful",
-                onfail="Topology Check Test NOT successful")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=topo_result and Link_Up and Link_Down,
+            onpass="Topology Check Test successful",
+            onfail="Topology Check Test NOT successful" )
 
-
-    def CASE8(self):
-        '''
+    def CASE8( self ):
+        """
         Intent removal
-        ''' 
-        main.log.report("This testcase removes host any previously added intents")
-        main.log.report("__________________________________")        
-        main.log.info("Removing any previously installed intents")
-        main.case("Removing intents")
-        main.step("Obtain the intent id's")
-        intent_result = main.ONOScli1.intents(json_format = False)
-        
-        intent_linewise = intent_result.split("\n")
+        """
+        main.log.report(
+            "This testcase removes host any previously added intents" )
+        main.log.report( "__________________________________" )
+        main.log.info( "Removing any previously installed intents" )
+        main.case( "Removing intents" )
+        main.step( "Obtain the intent id's" )
+        intent_result = main.ONOScli1.intents( json_format=False )
+
+        intent_linewise = intent_result.split( "\n" )
         intentList = []
         for line in intent_linewise:
-            if line.startswith("id="):
-                intentList.append(line)
+            if line.startswith( "id=" ):
+                intentList.append( line )
 
         intentids = []
         for line in intentList:
-            intentids.append(line.split(",")[0].split("=")[1])
+            intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
         for id in intentids:
-            main.log.info("id = " +id)
+            main.log.info( "id = " + id )
 
-        main.step("Iterate through the intentids list and remove each intent")
+        main.step(
+            "Iterate through the intentids list and remove each intent" )
         for id in intentids:
-            main.ONOScli1.remove_intent(intent_id = id)
+            main.ONOScli1.remove_intent( intent_id=id )
 
-        intent_result = main.ONOScli1.intents(json_format = False)
-        main.log.info("intent_result = " +intent_result)
+        intent_result = main.ONOScli1.intents( json_format=False )
+        main.log.info( "intent_result = " + intent_result )
         case8_result = main.TRUE
-        
+
         i = 8
         Ping_Result = main.TRUE
-        while i <18 :
-            main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
-            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
-            if ping==main.TRUE:
+        while i < 18:
+            main.log.info(
+                "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+            ping = main.Mininet1.pingHost(
+                src="h" + str( i ), target="h" + str( i + 10 ) )
+            if ping == main.TRUE:
                 i = 19
                 Ping_Result = main.TRUE
-            elif ping==main.FALSE:
-                i+=1
+            elif ping == main.FALSE:
+                i += 1
                 Ping_Result = main.FALSE
             else:
-                main.log.info("Unknown error")
+                main.log.info( "Unknown error" )
                 Ping_Result = main.ERROR
-        
-        #Note: If the ping result failed, that means the intents have been withdrawn correctly.
-        if Ping_Result==main.TRUE:
-            main.log.report("Host intents have not been withdrawn correctly")
-            #main.cleanup()
-            #main.exit()
-        if Ping_Result==main.FALSE:
-            main.log.report("Host intents have been withdrawn correctly")
+
+        # Note: If the ping result failed, that means the intents have been
+        # withdrawn correctly.
+        if Ping_Result == main.TRUE:
+            main.log.report( "Host intents have not been withdrawn correctly" )
+            # main.cleanup()
+            # main.exit()
+        if Ping_Result == main.FALSE:
+            main.log.report( "Host intents have been withdrawn correctly" )
 
         case8_result = case8_result and Ping_Result
 
         if case8_result == main.FALSE:
-            main.log.report("Intent removal successful")
+            main.log.report( "Intent removal successful" )
         else:
-            main.log.report("Intent removal failed")
-                        
-        utilities.assert_equals(expect=main.FALSE, actual=case8_result,
-                onpass="Intent removal test failed",
-                onfail="Intent removal test successful")
-             
+            main.log.report( "Intent removal failed" )
 
-    def CASE9(self):
-        '''
+        utilities.assert_equals( expect=main.FALSE, actual=case8_result,
+                                 onpass="Intent removal test failed",
+                                 onfail="Intent removal test successful" )
+
+    def CASE9( self ):
+        """
         This test case adds point intents. Make sure you run test case 8 which is host intent removal before executing this test case.
         Else the host intent's flows will persist on switches and the pings would work even if there is some issue with the point intent's flows
-        '''
-        main.log.report("This testcase adds point intents and then does pingall")
-        main.log.report("__________________________________")        
-        main.log.info("Adding point intents")
-        main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)") 
-        main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
+        """
+        main.log.report(
+            "This testcase adds point intents and then does pingall" )
+        main.log.report( "__________________________________" )
+        main.log.info( "Adding point intents" )
+        main.case(
+            "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
+        main.step(
+            "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003008/1",
+            "of:0000000000006018/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-        
-        main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
 
-        main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006018/1",
+            "of:0000000000003008/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-            
-        main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-            
-        main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
 
-        main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
+        main.step(
+            "Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003009/1",
+            "of:0000000000006019/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-            
-        main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-            
-        main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
 
-
-        main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006019/1",
+            "of:0000000000003009/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003010/1",
+            "of:0000000000006020/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
 
-        print("_______________________________________________________________________________________")
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006020/1",
+            "of:0000000000003010/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003011/1",
+            "of:0000000000006021/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006021/1",
+            "of:0000000000003011/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003012/1",
+            "of:0000000000006022/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006022/1",
+            "of:0000000000003012/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003013/1",
+            "of:0000000000006023/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006023/1",
+            "of:0000000000003013/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003014/1",
+            "of:0000000000006024/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006024/1",
+            "of:0000000000003014/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003015/1",
+            "of:0000000000006025/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006025/1",
+            "of:0000000000003015/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003016/1",
+            "of:0000000000006026/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006026/1",
+            "of:0000000000003016/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B" )
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000003017/1",
+            "of:0000000000006027/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOScli1.add_point_intent(
+            "of:0000000000006027/1",
+            "of:0000000000003017/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        print(
+            "_______________________________________________________________________________________" )
 
         flowHandle = main.ONOScli1.flows()
-        #print "flowHandle = ", flowHandle
-        main.log.info("flows :" + flowHandle)        
+        # print "flowHandle = ", flowHandle
+        main.log.info( "flows :" + flowHandle )
 
         count = 1
         i = 8
         Ping_Result = main.TRUE
-        while i <18 :
-            main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
-            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
-            if ping == main.FALSE and count <5:
-                count+=1
+        while i < 18:
+            main.log.info(
+                "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+            ping = main.Mininet1.pingHost(
+                src="h" + str( i ), target="h" + str( i + 10 ) )
+            if ping == main.FALSE and count < 5:
+                count += 1
                 #i = 8
                 Ping_Result = main.FALSE
-                main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
-                time.sleep(2)
-            elif ping==main.FALSE:
-                main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
-                i=19
+                main.log.report( "Ping between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 " failed. Making attempt number " +
+                                 str( count ) +
+                                 " in 2 seconds" )
+                time.sleep( 2 )
+            elif ping == main.FALSE:
+                main.log.report( "All ping attempts between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 "have failed" )
+                i = 19
                 Ping_Result = main.FALSE
-            elif ping==main.TRUE:
-                main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
-                i+=1
+            elif ping == main.TRUE:
+                main.log.info( "Ping test between h" +
+                               str( i ) +
+                               " and h" +
+                               str( i +
+                                    10 ) +
+                               "passed!" )
+                i += 1
                 Ping_Result = main.TRUE
             else:
-                main.log.info("Unknown error")
+                main.log.info( "Unknown error" )
                 Ping_Result = main.ERROR
-        if Ping_Result==main.FALSE:
-            main.log.report("Ping all test after Point intents addition failed. Cleaning up")
-            #main.cleanup()
-            #main.exit()
-        if Ping_Result==main.TRUE:
-            main.log.report("Ping all test after Point intents addition successful")
+        if Ping_Result == main.FALSE:
+            main.log.report(
+                "Ping all test after Point intents addition failed. Cleaning up" )
+            # main.cleanup()
+            # main.exit()
+        if Ping_Result == main.TRUE:
+            main.log.report(
+                "Ping all test after Point intents addition successful" )
 
         case8_result = Ping_Result
-        utilities.assert_equals(expect=main.TRUE, actual=case8_result,
-                onpass="Ping all test after Point intents addition successful",
-                onfail="Ping all test after Point intents addition failed")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case8_result,
+            onpass="Ping all test after Point intents addition successful",
+            onfail="Ping all test after Point intents addition failed" )
 
-    def CASE31(self):
-        ''' 
-            This test case adds point intent related to SDN-IP matching on ICMP (ethertype=IPV4, ipProto=1)
-        '''
+    def CASE31( self ):
+        """
+            This test case adds point intent related to SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
+        """
         import json
 
-        main.log.report("This test case adds point intent related to SDN-IP matching on ICMP")
-        main.case("Adding bidirectional point intent related to SDN-IP matching on ICMP")
-        main.step("Adding bidirectional point intent")
-        #add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=1  of:0000000000003008/1 of:0000000000006018/1
-        
-        hosts_json = json.loads(main.ONOScli1.hosts())
-        for  i in range(8,11):
-            main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
-            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
-            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
-            host1_id = main.ONOScli1.get_host(host1)['id']
-            host2_id = main.ONOScli1.get_host(host2)['id']
+        main.log.report(
+            "This test case adds point intent related to SDN-IP matching on ICMP" )
+        main.case(
+            "Adding bidirectional point intent related to SDN-IP matching on ICMP" )
+        main.step( "Adding bidirectional point intent" )
+        # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
+        # --ethType=IPV4 --ipProto=1  of:0000000000003008/1
+        # of:0000000000006018/1
+
+        hosts_json = json.loads( main.ONOScli1.hosts() )
+        for i in range( 8, 11 ):
+            main.log.info(
+                "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
+            host1 = "00:00:00:00:00:" + \
+                str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+            host2 = "00:00:00:00:00:" + \
+                str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+            host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
+            host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
             for host in hosts_json:
-                if host['id'] == host1_id:
-                    ip1 = host['ips'][0]
-                    ip1 = str(ip1+"/32")
-                    device1 = host['location']['device']
-                    device1 = str(device1+"/1")
-                elif host['id'] == host2_id:
-                    ip2 = str(host['ips'][0])+"/32"
-                    device2 = host['location']["device"]
-                    device2 = str(device2+"/1")
-                
-            p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
-                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
-            
-            get_intent_result = main.ONOScli1.intents(json_format = False)
-            main.log.info(get_intent_result)
- 
-            p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1, 
-                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto']) 
-            
-            get_intent_result = main.ONOScli1.intents(json_format = False)
-            main.log.info(get_intent_result)
-            if (p_intent_result1 and p_intent_result2) == main.TRUE:
+                if host[ 'id' ] == host1_id:
+                    ip1 = host[ 'ips' ][ 0 ]
+                    ip1 = str( ip1 + "/32" )
+                    device1 = host[ 'location' ][ 'device' ]
+                    device1 = str( device1 + "/1" )
+                elif host[ 'id' ] == host2_id:
+                    ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
+                    device2 = host[ 'location' ][ "device" ]
+                    device2 = str( device2 + "/1" )
+
+            p_intent_result1 = main.ONOScli1.add_point_intent(
+                ingress_device=device1,
+                egress_device=device2,
+                ipSrc=ip1,
+                ipDst=ip2,
+                ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+                ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
+
+            get_intent_result = main.ONOScli1.intents( json_format=False )
+            main.log.info( get_intent_result )
+
+            p_intent_result2 = main.ONOScli1.add_point_intent(
+                ingress_device=device2,
+                egress_device=device1,
+                ipSrc=ip2,
+                ipDst=ip1,
+                ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+                ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
+
+            get_intent_result = main.ONOScli1.intents( json_format=False )
+            main.log.info( get_intent_result )
+            if ( p_intent_result1 and p_intent_result2 ) == main.TRUE:
                 #get_intent_result = main.ONOScli1.intents()
-                #main.log.info(get_intent_result)
-                main.log.info("Point intent related to SDN-IP matching on ICMP install successful")
-       
-        time.sleep(15) 
-        get_intent_result = main.ONOScli1.intents(json_format = False)
-        main.log.info("intents = "+ get_intent_result)
+                # main.log.info( get_intent_result )
+                main.log.info(
+                    "Point intent related to SDN-IP matching on ICMP install successful" )
+
+        time.sleep( 15 )
+        get_intent_result = main.ONOScli1.intents( json_format=False )
+        main.log.info( "intents = " + get_intent_result )
         get_flows_result = main.ONOScli1.flows()
-        main.log.info("flows = " + get_flows_result)
-        
+        main.log.info( "flows = " + get_flows_result )
+
         count = 1
         i = 8
         Ping_Result = main.TRUE
-        while i <11 :
-            main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
-            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
-            if ping == main.FALSE and count <3:
-                count+=1
+        while i < 11:
+            main.log.info(
+                "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+            ping = main.Mininet1.pingHost(
+                src="h" + str( i ), target="h" + str( i + 10 ) )
+            if ping == main.FALSE and count < 3:
+                count += 1
                 #i = 8
                 Ping_Result = main.FALSE
-                main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
-                time.sleep(2)
-            elif ping==main.FALSE:
-                main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
-                i=19
+                main.log.report( "Ping between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 " failed. Making attempt number " +
+                                 str( count ) +
+                                 " in 2 seconds" )
+                time.sleep( 2 )
+            elif ping == main.FALSE:
+                main.log.report( "All ping attempts between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 "have failed" )
+                i = 19
                 Ping_Result = main.FALSE
-            elif ping==main.TRUE:
-                main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
-                i+=1
+            elif ping == main.TRUE:
+                main.log.info( "Ping test between h" +
+                               str( i ) +
+                               " and h" +
+                               str( i +
+                                    10 ) +
+                               "passed!" )
+                i += 1
                 Ping_Result = main.TRUE
             else:
-                main.log.info("Unknown error")
+                main.log.info( "Unknown error" )
                 Ping_Result = main.ERROR
-        if Ping_Result==main.FALSE:
-            main.log.report("Ping test after Point intents related to SDN-IP matching on ICMP failed.")
-            #main.cleanup()
-            #main.exit()
-        if Ping_Result==main.TRUE:
-            main.log.report("Ping all test after Point intents related to SDN-IP matching on ICMP successful")
-                   
+        if Ping_Result == main.FALSE:
+            main.log.report(
+                "Ping test after Point intents related to SDN-IP matching on ICMP failed." )
+            # main.cleanup()
+            # main.exit()
+        if Ping_Result == main.TRUE:
+            main.log.report(
+                "Ping all test after Point intents related to SDN-IP matching on ICMP successful" )
+
         case31_result = Ping_Result and p_intent_result1 and p_intent_result2
-        utilities.assert_equals(expect=main.TRUE, actual=case31_result,
-                onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
-                onfail="Point intent related to SDN-IP matching on ICMP and ping test failed")
-   
-    def CASE32(self):
-        ''' 
-            This test case adds point intent related to SDN-IP matching on TCP (ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001)
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case31_result,
+            onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
+            onfail="Point intent related to SDN-IP matching on ICMP and ping test failed" )
+
+    def CASE32( self ):
+        """
+            This test case adds point intent related to SDN-IP matching on TCP ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
             Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001
-        '''
+        """
         import json
 
-        main.log.report("This test case adds point intent related to SDN-IP matching on TCP")
-        main.case("Adding bidirectional point intent related to SDN-IP matching on TCP")
-        main.step("Adding bidirectional point intent")
+        main.log.report(
+            "This test case adds point intent related to SDN-IP matching on TCP" )
+        main.case(
+            "Adding bidirectional point intent related to SDN-IP matching on TCP" )
+        main.step( "Adding bidirectional point intent" )
         """
         add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001  of:0000000000003008/1 of:0000000000006018/1
 
         add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001  of:0000000000006018/1 of:0000000000003008/1
-    
+
         add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001  of:0000000000003008/1 of:0000000000006018/1
 
         add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001  of:0000000000006018/1 of:0000000000003008/1
 
-        """           
-    
-        hosts_json = json.loads(main.ONOScli1.hosts())
-        for  i in range(8,9):
-            main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
-            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
-            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
-            host1_id = main.ONOScli1.get_host(host1)['id']
-            host2_id = main.ONOScli1.get_host(host2)['id']
+        """
+        hosts_json = json.loads( main.ONOScli1.hosts() )
+        for i in range( 8, 9 ):
+            main.log.info(
+                "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
+            host1 = "00:00:00:00:00:" + \
+                str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+            host2 = "00:00:00:00:00:" + \
+                str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+            host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
+            host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
             for host in hosts_json:
-                if host['id'] == host1_id:
-                    ip1 = host['ips'][0]
-                    ip1 = str(ip1+"/32")
-                    device1 = host['location']['device']
-                    device1 = str(device1+"/1")
-                elif host['id'] == host2_id:
-                    ip2 = str(host['ips'][0])+"/32"
-                    device2 = host['location']["device"]
-                    device2 = str(device2+"/1")
-                
-            p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
-                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort']) 
-            p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1, 
-                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
+                if host[ 'id' ] == host1_id:
+                    ip1 = host[ 'ips' ][ 0 ]
+                    ip1 = str( ip1 + "/32" )
+                    device1 = host[ 'location' ][ 'device' ]
+                    device1 = str( device1 + "/1" )
+                elif host[ 'id' ] == host2_id:
+                    ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
+                    device2 = host[ 'location' ][ "device" ]
+                    device2 = str( device2 + "/1" )
 
-            p_intent_result3 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
-                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
-            p_intent_result4 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
-                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort']) 
+            p_intent_result1 = main.ONOScli1.add_point_intent(
+                ingress_device=device1,
+                egress_device=device2,
+                ipSrc=ip1,
+                ipDst=ip2,
+                ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+                ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+                tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
+            p_intent_result2 = main.ONOScli1.add_point_intent(
+                ingress_device=device2,
+                egress_device=device1,
+                ipSrc=ip2,
+                ipDst=ip1,
+                ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+                ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+                tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
+
+            p_intent_result3 = main.ONOScli1.add_point_intent(
+                ingress_device=device1,
+                egress_device=device2,
+                ipSrc=ip1,
+                ipDst=ip2,
+                ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+                ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+                tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
+            p_intent_result4 = main.ONOScli1.add_point_intent(
+                ingress_device=device2,
+                egress_device=device1,
+                ipSrc=ip2,
+                ipDst=ip1,
+                ethType=main.params[ 'SDNIP' ][ 'ethType' ],
+                ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
+                tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
 
             p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4
-            if p_intent_result ==main.TRUE:
-                get_intent_result = main.ONOScli1.intents(json_format = False)
-                main.log.info(get_intent_result)
-                main.log.info("Point intent related to SDN-IP matching on TCP install successful")
-        
-        iperf_result = main.Mininet1.iperf('h8', 'h18') 
-        if iperf_result == main.TRUE:
-            main.log.report("iperf test successful")
-        else:
-            main.log.report("iperf test failed")
+            if p_intent_result == main.TRUE:
+                get_intent_result = main.ONOScli1.intents( json_format=False )
+                main.log.info( get_intent_result )
+                main.log.info(
+                    "Point intent related to SDN-IP matching on TCP install successful" )
 
+        iperf_result = main.Mininet1.iperf( 'h8', 'h18' )
+        if iperf_result == main.TRUE:
+            main.log.report( "iperf test successful" )
+        else:
+            main.log.report( "iperf test failed" )
 
         case32_result = p_intent_result and iperf_result
-        utilities.assert_equals(expect=main.TRUE, actual=case32_result,
-                onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
-                onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case32_result,
+            onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
+            onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed" )
 
-
-    def CASE33(self):
-        ''' 
-            This test case adds multipoint to singlepoint  intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address 
+    def CASE33( self ):
+        """
+            This test case adds multipoint to singlepoint  intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address
             Here the mac address to be rewritten is the mac address of the egress device
-        '''
+        """
         import json
         import time
 
-        main.log.report("This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action")
-        main.case("Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip")
-        main.step("Adding bidirectional multipoint to singlepoint intent")
+        main.log.report(
+            "This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action" )
+        main.case(
+            "Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip" )
+        main.step( "Adding bidirectional multipoint to singlepoint intent" )
         """
         add-multi-to-single-intent --ipDst=10.0.3.0/24 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1 of:0000000000006018/1
-        
-        add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1 
-        """    
-        
-        main.case("Installing multipoint to single point intent with rewrite mac address")
-        main.step("Uninstalling proxy arp app")
-        #Unistall onos-app-proxyarp app to disable reactive forwarding
-        appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-proxyarp")
-        appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-proxyarp")
-        appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-proxyarp")
-        main.log.info("onos-app-proxyarp uninstalled") 
 
-        main.step("Changing ipaddress of hosts h8,h9 and h18")
-        main.Mininet1.changeIP(host='h8', intf='h8-eth0', newIP='10.0.1.1', newNetmask='255.255.255.0') 
-        main.Mininet1.changeIP(host='h9', intf='h9-eth0', newIP='10.0.2.1', newNetmask='255.255.255.0')
-        main.Mininet1.changeIP(host='h10', intf='h10-eth0', newIP='10.0.3.1', newNetmask='255.255.255.0')
+        add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1
+        """
+        main.case(
+            "Installing multipoint to single point intent with rewrite mac address" )
+        main.step( "Uninstalling proxy arp app" )
+        # Unistall onos-app-proxyarp app to disable reactive forwarding
+        appUninstall_result1 = main.ONOScli1.feature_uninstall(
+            "onos-app-proxyarp" )
+        appUninstall_result2 = main.ONOScli2.feature_uninstall(
+            "onos-app-proxyarp" )
+        appUninstall_result3 = main.ONOScli3.feature_uninstall(
+            "onos-app-proxyarp" )
+        main.log.info( "onos-app-proxyarp uninstalled" )
 
-        main.step("Changing default gateway of hosts h8,h9 and h18")
-        main.Mininet1.changeDefaultGateway(host='h8', newGW='10.0.1.254')
-        main.Mininet1.changeDefaultGateway(host='h9', newGW='10.0.2.254')
-        main.Mininet1.changeDefaultGateway(host='h10', newGW='10.0.3.254')
+        main.step( "Changing ipaddress of hosts h8,h9 and h18" )
+        main.Mininet1.changeIP(
+            host='h8',
+            intf='h8-eth0',
+            newIP='10.0.1.1',
+            newNetmask='255.255.255.0' )
+        main.Mininet1.changeIP(
+            host='h9',
+            intf='h9-eth0',
+            newIP='10.0.2.1',
+            newNetmask='255.255.255.0' )
+        main.Mininet1.changeIP(
+            host='h10',
+            intf='h10-eth0',
+            newIP='10.0.3.1',
+            newNetmask='255.255.255.0' )
 
-        main.step("Assigning random mac address to the default gateways since proxyarp app is uninstalled")
-        main.Mininet1.addStaticMACAddress(host='h8', GW='10.0.1.254', macaddr='00:00:00:00:11:11')
-        main.Mininet1.addStaticMACAddress(host='h9', GW='10.0.2.254', macaddr='00:00:00:00:22:22')
-        main.Mininet1.addStaticMACAddress(host='h10', GW='10.0.3.254', macaddr='00:00:00:00:33:33')
-         
-        main.step("Verify static gateway and MAC address assignment")
-        main.Mininet1.verifyStaticGWandMAC(host='h8')
-        main.Mininet1.verifyStaticGWandMAC(host='h9')
-        main.Mininet1.verifyStaticGWandMAC(host='h10')
-        
-        main.step("Adding multipoint to singlepoint intent")               
-        p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device1'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'],
-                                 egress_device=main.params['MULTIPOINT_INTENT']['device3'], ipDst=main.params['MULTIPOINT_INTENT']['ip1'], setEthDst=main.params['MULTIPOINT_INTENT']['mac1']) 
-        
-        p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device3'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'],                            
-                                egress_device=main.params['MULTIPOINT_INTENT']['device1'], ipDst=main.params['MULTIPOINT_INTENT']['ip2'], setEthDst=main.params['MULTIPOINT_INTENT']['mac2'])    
+        main.step( "Changing default gateway of hosts h8,h9 and h18" )
+        main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
+        main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
+        main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
 
+        main.step(
+            "Assigning random mac address to the default gateways since proxyarp app is uninstalled" )
+        main.Mininet1.addStaticMACAddress(
+            host='h8',
+            GW='10.0.1.254',
+            macaddr='00:00:00:00:11:11' )
+        main.Mininet1.addStaticMACAddress(
+            host='h9',
+            GW='10.0.2.254',
+            macaddr='00:00:00:00:22:22' )
+        main.Mininet1.addStaticMACAddress(
+            host='h10',
+            GW='10.0.3.254',
+            macaddr='00:00:00:00:33:33' )
 
-        get_intent_result = main.ONOScli1.intents(json_format = False)
-        main.log.info("intents = "+ get_intent_result)
-        
-        time.sleep(10)
-        get_flows_result = main.ONOScli1.flows(json_format = False)
-        main.log.info("flows = " + get_flows_result) 
+        main.step( "Verify static gateway and MAC address assignment" )
+        main.Mininet1.verifyStaticGWandMAC( host='h8' )
+        main.Mininet1.verifyStaticGWandMAC( host='h9' )
+        main.Mininet1.verifyStaticGWandMAC( host='h10' )
+
+        main.step( "Adding multipoint to singlepoint intent" )
+        p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
+            ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
+            ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
+            egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
+            ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
+            setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
+
+        p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
+            ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
+            ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
+            egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
+            ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
+            setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
+
+        get_intent_result = main.ONOScli1.intents( json_format=False )
+        main.log.info( "intents = " + get_intent_result )
+
+        time.sleep( 10 )
+        get_flows_result = main.ONOScli1.flows( json_format=False )
+        main.log.info( "flows = " + get_flows_result )
 
         count = 1
         i = 8
         Ping_Result = main.TRUE
-       
-        main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+2))
-        ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+2))
-        if ping == main.FALSE and count <3:
-            count+=1
+
+        main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
+        ping = main.Mininet1.pingHost(
+            src="h" + str( i ), target="h" + str( i + 2 ) )
+        if ping == main.FALSE and count < 3:
+            count += 1
             Ping_Result = main.FALSE
-            main.log.report("Ping between h" + str(i) + " and h" + str(i+2) + " failed. Making attempt number "+str(count) + " in 2 seconds")
-            time.sleep(2)
-        elif ping==main.FALSE:
-            main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
+            main.log.report( "Ping between h" +
+                             str( i ) +
+                             " and h" +
+                             str( i +
+                                  2 ) +
+                             " failed. Making attempt number " +
+                             str( count ) +
+                             " in 2 seconds" )
+            time.sleep( 2 )
+        elif ping == main.FALSE:
+            main.log.report( "All ping attempts between h" +
+                             str( i ) +
+                             " and h" +
+                             str( i +
+                                  10 ) +
+                             "have failed" )
             Ping_Result = main.FALSE
-        elif ping==main.TRUE:
-            main.log.info("Ping test between h" + str(i) + " and h" + str(i+2) + "passed!")
+        elif ping == main.TRUE:
+            main.log.info( "Ping test between h" +
+                           str( i ) +
+                           " and h" +
+                           str( i +
+                                2 ) +
+                           "passed!" )
             Ping_Result = main.TRUE
         else:
-            main.log.info("Unknown error")
+            main.log.info( "Unknown error" )
             Ping_Result = main.ERROR
-        
-        if Ping_Result==main.FALSE:
-            main.log.report("Ping test failed.")
-            #main.cleanup()
-            #main.exit()
-        if Ping_Result==main.TRUE:
-            main.log.report("Ping all successful")
 
+        if Ping_Result == main.FALSE:
+            main.log.report( "Ping test failed." )
+            # main.cleanup()
+            # main.exit()
+        if Ping_Result == main.TRUE:
+            main.log.report( "Ping all successful" )
 
         p_intent_result = p_intent_result1 and p_intent_result2
-        if p_intent_result ==main.TRUE:
-            main.log.info("Multi point intent with rewrite mac address installation successful")
+        if p_intent_result == main.TRUE:
+            main.log.info(
+                "Multi point intent with rewrite mac address installation successful" )
         else:
-            main.log.info("Multi point intent with rewrite mac address installation failed")
-      
+            main.log.info(
+                "Multi point intent with rewrite mac address installation failed" )
+
         case33_result = p_intent_result and Ping_Result
-        utilities.assert_equals(expect=main.TRUE, actual=case33_result,
-                onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful",
-                onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed")  
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case33_result,
+            onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful",
+            onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed" )
diff --git a/TestON/tests/OnosCHO/OnosCHO.params b/TestON/tests/OnosCHO/OnosCHO.params
index 7856a28..c0325a9 100644
--- a/TestON/tests/OnosCHO/OnosCHO.params
+++ b/TestON/tests/OnosCHO/OnosCHO.params
@@ -12,7 +12,7 @@
     # 10. Remove all intents on ONOS
     # 1,2,3,[4,5,6,5,7,8,5,10,5,9,5,7,8,5,10,5]*2
 
-    <testcases>1,2,3,9</testcases>
+    <testcases>1,2,3,[4,5,6,5,70,80,5,10,5,9,5,71,81,5,10,5]*100</testcases>
     <ENV>
         <cellName>choTest5</cellName>
     </ENV>
diff --git a/TestON/tests/OnosCHO/OnosCHO.py b/TestON/tests/OnosCHO/OnosCHO.py
index 3a838fa..3be5cbb 100644
--- a/TestON/tests/OnosCHO/OnosCHO.py
+++ b/TestON/tests/OnosCHO/OnosCHO.py
@@ -6,8 +6,10 @@
 import json
 import itertools
 
+
 class OnosCHO:
-    def __init__(self):
+
+    def __init__( self ):
         self.default = ''
         global deviceDPIDs
         global hostMACs
@@ -16,8 +18,9 @@
         global devicePortsEnabledCount
         global installedIntents
         global randomLink1, randomLink2, randomLink3, numSwitches, numLinks
-    def CASE1(self, main):
-        '''
+
+    def CASE1( self, main ):
+        """
         Startup sequence:
         git pull
         mvn clean install
@@ -26,167 +29,187 @@
         onos-verify-cell
         onos-install -f
         onos-wait-for-start
-        '''
+        """
         import time
-        cell_name = main.params['ENV']['cellName']
-        git_pull = main.params['GIT']['autoPull']
-        numCtrls = main.params['CTRL']['numCtrl']
-        git_branch = main.params['GIT']['branch']
+        cell_name = main.params[ 'ENV' ][ 'cellName' ]
+        git_pull = main.params[ 'GIT' ][ 'autoPull' ]
+        numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
+        git_branch = main.params[ 'GIT' ][ 'branch' ]
 
-        main.case("Set up test environment")
-        main.log.report("Set up test environment")
-        main.log.report("_______________________")
-                
-        main.step("Git checkout and pull "+git_branch)
+        main.case( "Set up test environment" )
+        main.log.report( "Set up test environment" )
+        main.log.report( "_______________________" )
+
+        main.step( "Git checkout and pull " + git_branch )
         if git_pull == 'on':
-            checkout_result = main.ONOSbench.git_checkout(git_branch)
+            checkout_result = main.ONOSbench.git_checkout( git_branch )
             pull_result = main.ONOSbench.git_pull()
-            cp_result = (checkout_result and pull_result)
+            cp_result = ( checkout_result and pull_result )
         else:
             checkout_result = main.TRUE
             pull_result = main.TRUE
-            main.log.info("Skipped git checkout and pull")
-            cp_result = (checkout_result and pull_result)
-        utilities.assert_equals(expect=main.TRUE, actual=cp_result,
-                onpass="Test step PASS",
-                onfail="Test step FAIL")
-		
-        main.step("mvn clean & install")
+            main.log.info( "Skipped git checkout and pull" )
+            cp_result = ( checkout_result and pull_result )
+        utilities.assert_equals( expect=main.TRUE, actual=cp_result,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
+        main.step( "mvn clean & install" )
         mvn_result = main.ONOSbench.clean_install()
-        utilities.assert_equals(expect=main.TRUE, actual=mvn_result,
-                onpass="Test step PASS",
-                onfail="Test step FAIL")
+        utilities.assert_equals( expect=main.TRUE, actual=mvn_result,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
 
-        main.ONOSbench.get_version(report=True)
+        main.ONOSbench.get_version( report=True )
 
-        main.step("Apply Cell environment for ONOS")
-        cell_result = main.ONOSbench.set_cell(cell_name)
-        utilities.assert_equals(expect=main.TRUE, actual=cell_result,
-                onpass="Test step PASS",
-                onfail="Test step FAIL")
+        main.step( "Apply Cell environment for ONOS" )
+        cell_result = main.ONOSbench.set_cell( cell_name )
+        utilities.assert_equals( expect=main.TRUE, actual=cell_result,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
 
-        main.step("Create ONOS package")
+        main.step( "Create ONOS package" )
         packageResult = main.ONOSbench.onos_package()
-        utilities.assert_equals(expect=main.TRUE, actual=packageResult,
-                onpass="Test step PASS",
-                onfail="Test step FAIL")
+        utilities.assert_equals( expect=main.TRUE, actual=packageResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
 
-        main.step("Uninstall ONOS package on all Nodes")
-        uninstallResult=main.TRUE
-        for i in range(1,int(numCtrls)+1):
-            ONOS_ip = main.params['CTRL']['ip'+str(i)]
-            main.log.info("Unintsalling package on ONOS Node IP: "+ONOS_ip)
-            u_result= main.ONOSbench.onos_uninstall(ONOS_ip)
-            utilities.assert_equals(expect=main.TRUE, actual=u_result,
-                onpass="Test step PASS",
-                onfail="Test step FAIL")
-            uninstallResult=(uninstallResult and u_result)
+        main.step( "Uninstall ONOS package on all Nodes" )
+        uninstallResult = main.TRUE
+        for i in range( 1, int( numCtrls ) + 1 ):
+            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+            main.log.info( "Unintsalling package on ONOS Node IP: " + ONOS_ip )
+            u_result = main.ONOSbench.onos_uninstall( ONOS_ip )
+            utilities.assert_equals( expect=main.TRUE, actual=u_result,
+                                     onpass="Test step PASS",
+                                     onfail="Test step FAIL" )
+            uninstallResult = ( uninstallResult and u_result )
 
-        main.step("Removing copy-cat logs from ONOS nodes")
+        main.step( "Removing copy-cat logs from ONOS nodes" )
         main.ONOSbench.onos_remove_raft_logs()
 
-        main.step("Install ONOS package on all Nodes")
-        installResult=main.TRUE
-        for i in range(1,int(numCtrls)+1):
-            ONOS_ip = main.params['CTRL']['ip'+str(i)]
-            main.log.info("Intsalling package on ONOS Node IP: "+ONOS_ip)
-            i_result= main.ONOSbench.onos_install(node=ONOS_ip)
-            utilities.assert_equals(expect=main.TRUE, actual=i_result,
-                onpass="Test step PASS",
-                onfail="Test step FAIL")
-            installResult=(installResult and i_result)
+        main.step( "Install ONOS package on all Nodes" )
+        installResult = main.TRUE
+        for i in range( 1, int( numCtrls ) + 1 ):
+            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+            main.log.info( "Intsalling package on ONOS Node IP: " + ONOS_ip )
+            i_result = main.ONOSbench.onos_install( node=ONOS_ip )
+            utilities.assert_equals( expect=main.TRUE, actual=i_result,
+                                     onpass="Test step PASS",
+                                     onfail="Test step FAIL" )
+            installResult = ( installResult and i_result )
 
-        main.step("Verify ONOS nodes UP status")
-        statusResult=main.TRUE
-        for i in range(1,int(numCtrls)+1):
-            ONOS_ip = main.params['CTRL']['ip'+str(i)]
-            main.log.info("ONOS Node "+ONOS_ip+" status:")
-            onos_status = main.ONOSbench.onos_status(node=ONOS_ip)
-            utilities.assert_equals(expect=main.TRUE, actual=onos_status,
-                onpass="Test step PASS",
-                onfail="Test step FAIL")
-            statusResult=(statusResult and onos_status)   
+        main.step( "Verify ONOS nodes UP status" )
+        statusResult = main.TRUE
+        for i in range( 1, int( numCtrls ) + 1 ):
+            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+            main.log.info( "ONOS Node " + ONOS_ip + " status:" )
+            onos_status = main.ONOSbench.onos_status( node=ONOS_ip )
+            utilities.assert_equals( expect=main.TRUE, actual=onos_status,
+                                     onpass="Test step PASS",
+                                     onfail="Test step FAIL" )
+            statusResult = ( statusResult and onos_status )
 
-        main.step("Start ONOS CLI on all nodes")
+        main.step( "Start ONOS CLI on all nodes" )
         cliResult = main.TRUE
-        time.sleep(15) # need to wait here for sometime. This will be removed once ONOS is stable enough
-        for i in range(1,int(numCtrls)+1):
-            ONOS_ip = main.params['CTRL']['ip'+str(i)]
-            ONOScli = 'ONOScli'+str(i)
-            main.log.info("ONOS Node "+ONOS_ip+" cli start:")
-            exec "startcli=main."+ONOScli+".start_onos_cli(ONOS_ip)"
-            utilities.assert_equals(expect=main.TRUE, actual=startcli,
-                onpass="Test step PASS",
-                onfail="Test step FAIL")
-            cliResult = (cliResult and startcli) 
+        karafTimeout = "3600000"
+        # need to wait here for sometime. This will be removed once ONOS is
+        # stable enough
+        time.sleep( 15 )
+        for i in range( 1, int( numCtrls ) + 1 ):
+            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+            ONOScli = 'ONOScli' + str( i )
+            main.log.info( "ONOS Node " + ONOS_ip + " cli start:" )
+            exec "startcli=main." + ONOScli + \
+                ".start_onos_cli(ONOS_ip, karafTimeout=karafTimeout)"
+            utilities.assert_equals( expect=main.TRUE, actual=startcli,
+                                     onpass="Test step PASS",
+                                     onfail="Test step FAIL" )
+            cliResult = ( cliResult and startcli )
 
-        case1Result = (cp_result and cell_result 
-                and packageResult and installResult and statusResult and cliResult)
-        utilities.assert_equals(expect=main.TRUE, actual=case1Result,
-                onpass="Set up test environment PASS",
-                onfail="Set up test environment FAIL")
+        case1Result = ( cp_result and cell_result
+                        and packageResult and installResult and statusResult and cliResult )
+        utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+                                 onpass="Set up test environment PASS",
+                                 onfail="Set up test environment FAIL" )
 
-    def CASE2(self, main):
-        ''' 
+    def CASE2( self, main ):
+        """
         This test script still needs more refactoring
-        '''
+        """
         import re
         import time
         import copy
-        numCtrls = main.params['CTRL']['numCtrl']
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS4_ip = main.params['CTRL']['ip4']
-        ONOS5_ip = main.params['CTRL']['ip5']
-        ONOS1_port = main.params['CTRL']['port1']
-        ONOS2_port = main.params['CTRL']['port2']
-        ONOS3_port = main.params['CTRL']['port3']
-        ONOS4_port = main.params['CTRL']['port4']
-        ONOS5_port = main.params['CTRL']['port5']
+        numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+        ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+        ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+        ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
+        ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
+        ONOS4_port = main.params[ 'CTRL' ][ 'port4' ]
+        ONOS5_port = main.params[ 'CTRL' ][ 'port5' ]
 
-        numCtrls = main.params['CTRL']['numCtrl']
-        main.log.report("Assign and Balance all Mininet switches across controllers")
-        main.log.report("_________________________________________________________")
-        time.sleep(15) # need to wait here for sometime. This will be removed once ONOS is stable enough
-        main.case("Assign and Balance all Mininet switches across controllers")
-        main.step("Assign switches to controllers")
-        for i in range(1,26): #1 to (num of switches +1)
-            main.Mininet1.assign_sw_controller(sw=str(i),count=int(numCtrls), 
-                    ip1=ONOS1_ip, port1=ONOS1_port,
-                    ip2=ONOS2_ip, port2=ONOS2_port,
-		            ip3=ONOS3_ip, port3=ONOS3_port, ip4=ONOS4_ip, port4=ONOS4_port, 
-			    ip5=ONOS5_ip, port5=ONOS5_port)
+        numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
+        main.log.report(
+            "Assign and Balance all Mininet switches across controllers" )
+        main.log.report(
+            "_________________________________________________________" )
+        # need to wait here for sometime. This will be removed once ONOS is
+        # stable enough
+        time.sleep( 15 )
+        main.case(
+            "Assign and Balance all Mininet switches across controllers" )
+        main.step( "Assign switches to controllers" )
+        for i in range( 1, 26 ):  # 1 to ( num of switches +1 )
+            main.Mininet1.assign_sw_controller(
+                sw=str( i ),
+                count=int( numCtrls ),
+                ip1=ONOS1_ip,
+                port1=ONOS1_port,
+                ip2=ONOS2_ip,
+                port2=ONOS2_port,
+                ip3=ONOS3_ip,
+                port3=ONOS3_port,
+                ip4=ONOS4_ip,
+                port4=ONOS4_port,
+                ip5=ONOS5_ip,
+                port5=ONOS5_port )
 
         switch_mastership = main.TRUE
-        for i in range (1,26):
-            response = main.Mininet1.get_sw_controller("s"+str(i))
-            print("Response is " + str(response))
-            if re.search("tcp:"+ONOS1_ip,response):
+        for i in range( 1, 26 ):
+            response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+            print( "Response is " + str( response ) )
+            if re.search( "tcp:" + ONOS1_ip, response ):
                 switch_mastership = switch_mastership and main.TRUE
             else:
                 switch_mastership = main.FALSE
 
         if switch_mastership == main.TRUE:
-            main.log.report("Controller assignment successfull")
+            main.log.report( "Controller assignment successfull" )
         else:
-             main.log.report("Controller assignment failed")
-        time.sleep(5)
+            main.log.report( "Controller assignment failed" )
+        time.sleep( 5 )
 
-        main.step("Balance devices across controllers")
-        for i in range(int(numCtrls)):
+        main.step( "Balance devices across controllers" )
+        for i in range( int( numCtrls ) ):
             balanceResult = main.ONOScli1.balance_masters()
-            time.sleep(3) # giving some breathing time for ONOS to complete re-balance
+            # giving some breathing time for ONOS to complete re-balance
+            time.sleep( 3 )
 
-        utilities.assert_equals(expect=main.TRUE, actual=balanceResult,
-                onpass="Assign and Balance devices test PASS",
-                onfail="Assign and Balance devices test FAIL")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=balanceResult,
+            onpass="Assign and Balance devices test PASS",
+            onfail="Assign and Balance devices test FAIL" )
 
-    def CASE3(self,main) :
-        ''' 
+    def CASE3( self, main ):
+        """
         This Test case will be extended to collect and store more data related
         ONOS state.
-        '''
+        """
         import re
         import copy
         deviceDPIDs = []
@@ -195,117 +218,136 @@
         deviceActiveLinksCount = []
         devicePortsEnabledCount = []
 
-        main.log.report("Collect and Store topology details from ONOS before running any Tests")
-        main.log.report("____________________________________________________________________")        
-        main.case ("Collect and Store Topology Deatils from ONOS")
+        main.log.report(
+            "Collect and Store topology details from ONOS before running any Tests" )
+        main.log.report(
+            "____________________________________________________________________" )
+        main.case( "Collect and Store Topology Deatils from ONOS" )
 
-        main.step("Collect and store current number of switches and links")
+        main.step( "Collect and store current number of switches and links" )
         topology_output = main.ONOScli1.topology()
-        topology_result = main.ONOSbench.get_topology(topology_output)
-        numSwitches = topology_result['devices']
-        numLinks = topology_result['links']
-        main.log.info("Currently there are %s switches and %s links"  %(str(numSwitches), str(numLinks)))
+        topology_result = main.ONOSbench.get_topology( topology_output )
+        numSwitches = topology_result[ 'devices' ]
+        numLinks = topology_result[ 'links' ]
+        main.log.info(
+            "Currently there are %s switches and %s links" %
+            ( str( numSwitches ), str( numLinks ) ) )
 
-        main.step("Store Device DPIDs")
-        for i in range(1,26):
-            deviceDPIDs.append("of:00000000000000"+format(i, '02x'))
-        print "Device DPIDs in Store: \n", str(deviceDPIDs)
+        main.step( "Store Device DPIDs" )
+        for i in range( 1, 26 ):
+            deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
+        print "Device DPIDs in Store: \n", str( deviceDPIDs )
 
-        main.step("Store Host MACs")
-        for i in range(1,26):
-            hostMACs.append("00:00:00:00:00:"+format(i, '02x')+"/-1")
-        print "Host MACs in Store: \n", str(hostMACs)
+        main.step( "Store Host MACs" )
+        for i in range( 1, 26 ):
+            hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
+        print "Host MACs in Store: \n", str( hostMACs )
 
-        main.step("Collect and store all Devices Links")
-        linksResult = main.ONOScli1.links(json_format=False)
-        ansi_escape = re.compile(r'\x1b[^m]*m')
-        linksResult = ansi_escape.sub('', linksResult)
-        linksResult = linksResult.replace(" links","").replace("\r\r","")
-        linksResult=linksResult.splitlines()
-        linksResult = linksResult[1:]
-        deviceLinks = copy.copy(linksResult)
-        print "Device Links Stored: \n", str(deviceLinks)
-        print "Length of Links Store", len(deviceLinks) # this will be asserted to check with the params provided count of links
+        main.step( "Collect and store all Devices Links" )
+        linksResult = main.ONOScli1.links( json_format=False )
+        ansi_escape = re.compile( r'\x1b[^m]*m' )
+        linksResult = ansi_escape.sub( '', linksResult )
+        linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
+        linksResult = linksResult.splitlines()
+        linksResult = linksResult[ 1: ]
+        deviceLinks = copy.copy( linksResult )
+        print "Device Links Stored: \n", str( deviceLinks )
+        # this will be asserted to check with the params provided count of
+        # links
+        print "Length of Links Store", len( deviceLinks )
 
-        main.step("Collect and store each Device ports enabled Count")
-        for i in range(1,26):
-            portResult = main.ONOScli1.getDevicePortsEnabledCount("of:00000000000000"+format(i, '02x'))
-            portTemp = re.split(r'\t+', portResult)
-            portCount = portTemp[1].replace("\r\r\n\x1b[32m","")
-            devicePortsEnabledCount.append(portCount)
-        print "Device Enabled Port Counts Stored: \n", str(devicePortsEnabledCount)
+        main.step( "Collect and store each Device ports enabled Count" )
+        for i in range( 1, 26 ):
+            portResult = main.ONOScli1.getDevicePortsEnabledCount(
+                "of:00000000000000" +
+                format(
+                    i,
+                    '02x' ) )
+            portTemp = re.split( r'\t+', portResult )
+            portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+            devicePortsEnabledCount.append( portCount )
+        print "Device Enabled Port Counts Stored: \n", str( devicePortsEnabledCount )
 
-        main.step("Collect and store each Device active links Count")
-        for i in range(1,26):
-            linkCountResult = main.ONOScli1.getDeviceLinksActiveCount("of:00000000000000"+format(i, '02x'))
-            linkCountTemp = re.split(r'\t+', linkCountResult)
-            linkCount = linkCountTemp[1].replace("\r\r\n\x1b[32m","")
-            deviceActiveLinksCount.append(linkCount)
-        print "Device Active Links Count Stored: \n", str(deviceActiveLinksCount)
+        main.step( "Collect and store each Device active links Count" )
+        for i in range( 1, 26 ):
+            linkCountResult = main.ONOScli1.getDeviceLinksActiveCount(
+                "of:00000000000000" +
+                format(
+                    i,
+                    '02x' ) )
+            linkCountTemp = re.split( r'\t+', linkCountResult )
+            linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+            deviceActiveLinksCount.append( linkCount )
+        print "Device Active Links Count Stored: \n", str( deviceActiveLinksCount )
 
-        caseResult = main.TRUE  # just returning TRUE for now as this one just collects data
-        utilities.assert_equals(expect=main.TRUE, actual=case1Result,
-                onpass="Saving ONOS topology data test PASS",
-                onfail="Saving ONOS topology data test FAIL")
+        # just returning TRUE for now as this one just collects data
+        caseResult = main.TRUE
+        utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+                                 onpass="Saving ONOS topology data test PASS",
+                                 onfail="Saving ONOS topology data test FAIL" )
 
-    def CASE4(self,main) :
-        ''' 
-        Enable onos-app-fwd, Verify Reactive forwarding through ping all and Disable it 
-        '''
+    def CASE4( self, main ):
+        """
+        Enable onos-app-fwd, Verify Reactive forwarding through ping all and Disable it
+        """
         import re
         import copy
         import time
-        numCtrls = main.params['CTRL']['numCtrl']
-        main.log.report("Enable Reactive forwarding and Verify ping all")
-        main.log.report("______________________________________________")        
-        main.case ("Enable Reactive forwarding and Verify ping all")
-        main.step("Enable Reactive forwarding")
+        numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
+        main.log.report( "Enable Reactive forwarding and Verify ping all" )
+        main.log.report( "______________________________________________" )
+        main.case( "Enable Reactive forwarding and Verify ping all" )
+        main.step( "Enable Reactive forwarding" )
         installResult = main.TRUE
-        for i in range(1,int(numCtrls)+1):
+        for i in range( 1, int( numCtrls ) + 1 ):
             onosFeature = 'onos-app-fwd'
-            ONOS_ip = main.params['CTRL']['ip'+str(i)]
-            ONOScli = 'ONOScli'+str(i)
-            main.log.info("Enabling Reactive mode on ONOS Node "+ONOS_ip)
-            exec "inResult=main."+ONOScli+".feature_install(onosFeature)"
+            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+            ONOScli = 'ONOScli' + str( i )
+            main.log.info( "Enabling Reactive mode on ONOS Node " + ONOS_ip )
+            exec "inResult=main." + ONOScli + ".feature_install(onosFeature)"
+            time.sleep( 3 )
             installResult = inResult and installResult
 
-        time.sleep(5)
+        time.sleep( 5 )
 
-        main.step("Verify Pingall")
+        main.step( "Verify Pingall" )
         ping_result = main.FALSE
         time1 = time.time()
         ping_result = main.Mininet1.pingall()
         time2 = time.time()
-        timeDiff = round((time2-time1),2)
-        main.log.report("Time taken for Ping All: "+str(timeDiff)+" seconds")
+        timeDiff = round( ( time2 - time1 ), 2 )
+        main.log.report(
+            "Time taken for Ping All: " +
+            str( timeDiff ) +
+            " seconds" )
 
         if ping_result == main.TRUE:
-            main.log.report("Pingall Test in Reactive mode successful")
+            main.log.report( "Pingall Test in Reactive mode successful" )
         else:
-            main.log.report("Pingall Test in Reactive mode failed")
+            main.log.report( "Pingall Test in Reactive mode failed" )
 
-        main.step("Disable Reactive forwarding")
+        main.step( "Disable Reactive forwarding" )
         uninstallResult = main.TRUE
-        for i in range(1,int(numCtrls)+1):
+        for i in range( 1, int( numCtrls ) + 1 ):
             onosFeature = 'onos-app-fwd'
-            ONOS_ip = main.params['CTRL']['ip'+str(i)]
-            ONOScli = 'ONOScli'+str(i)
-            main.log.info("Disabling Reactive mode on ONOS Node "+ONOS_ip)
-            exec "unResult=main."+ONOScli+".feature_uninstall(onosFeature)"
+            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+            ONOScli = 'ONOScli' + str( i )
+            main.log.info( "Disabling Reactive mode on ONOS Node " + ONOS_ip )
+            exec "unResult=main." + ONOScli + ".feature_uninstall(onosFeature)"
             uninstallResult = unResult and uninstallResult
 
-        #Waiting for reative flows to be cleared.
-        time.sleep(10)
+        # Waiting for reative flows to be cleared.
+        time.sleep( 10 )
 
         case3Result = installResult and ping_result and uninstallResult
-        utilities.assert_equals(expect=main.TRUE, actual=case3Result,
-                onpass="Reactive Mode Pingall test PASS",
-                onfail="Reactive Mode Pingall test FAIL")
+        utilities.assert_equals( expect=main.TRUE, actual=case3Result,
+                                 onpass="Reactive Mode Pingall test PASS",
+                                 onfail="Reactive Mode Pingall test FAIL" )
 
-    def CASE5(self,main) :
-        '''
+    def CASE5( self, main ):
+        """
         Compare current ONOS topology with reference data
-        '''  
+        """
         import re
         devicesDPID_tmp = []
         hostMACs_tmp = []
@@ -313,276 +355,529 @@
         deviceActiveLinksCount_tmp = []
         devicePortsEnabledCount_tmp = []
 
-        main.log.report("Compare ONOS topology with reference data in Stores")
-        main.log.report("__________________________________________________")        
-        main.case ("Compare ONOS topology with reference data")
-	     
-        main.step("Compare current Device ports enabled with reference")
-        for i in range(1,26):
-            portResult = main.ONOScli1.getDevicePortsEnabledCount("of:00000000000000"+format(i, '02x'))
-            portTemp = re.split(r'\t+', portResult)
-            portCount = portTemp[1].replace("\r\r\n\x1b[32m","")
-            devicePortsEnabledCount_tmp.append(portCount)
-            time.sleep(2)
-        print ("Device Enabled ports EXPECTED: \n"+ str(devicePortsEnabledCount))
-        print ("Device Enabled ports ACTUAL: \n"+ str(devicePortsEnabledCount_tmp))
-        if (cmp(devicePortsEnabledCount,devicePortsEnabledCount_tmp)==0):
+        main.log.report(
+            "Compare ONOS topology with reference data in Stores" )
+        main.log.report( "__________________________________________________" )
+        main.case( "Compare ONOS topology with reference data" )
+
+        main.step( "Compare current Device ports enabled with reference" )
+        for i in range( 1, 26 ):
+            portResult = main.ONOScli1.getDevicePortsEnabledCount(
+                "of:00000000000000" +
+                format(
+                    i,
+                    '02x' ) )
+            portTemp = re.split( r'\t+', portResult )
+            portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+            devicePortsEnabledCount_tmp.append( portCount )
+            time.sleep( 2 )
+        print (
+            "Device Enabled ports EXPECTED: \n" +
+            str( devicePortsEnabledCount ) )
+        print (
+            "Device Enabled ports ACTUAL: \n" +
+            str( devicePortsEnabledCount_tmp ) )
+        if ( cmp( devicePortsEnabledCount,
+                  devicePortsEnabledCount_tmp ) == 0 ):
             stepResult1 = main.TRUE
         else:
             stepResult1 = main.FALSE
 
-        main.step("Compare Device active links with reference")
-        for i in range(1,26):
-            linkResult = main.ONOScli1.getDeviceLinksActiveCount("of:00000000000000"+format(i, '02x'))
-            linkTemp = re.split(r'\t+', linkResult)
-            linkCount = linkTemp[1].replace("\r\r\n\x1b[32m","")
-            deviceActiveLinksCount_tmp.append(linkCount)
-            time.sleep(3)
-        print ("Device Active links EXPECTED: \n"+str(deviceActiveLinksCount))
-        print ("Device Active links ACTUAL: \n"+str(deviceActiveLinksCount_tmp))
-        if (cmp(deviceActiveLinksCount,deviceActiveLinksCount_tmp)==0):
+        main.step( "Compare Device active links with reference" )
+        for i in range( 1, 26 ):
+            linkResult = main.ONOScli1.getDeviceLinksActiveCount(
+                "of:00000000000000" +
+                format(
+                    i,
+                    '02x' ) )
+            linkTemp = re.split( r'\t+', linkResult )
+            linkCount = linkTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+            deviceActiveLinksCount_tmp.append( linkCount )
+            time.sleep( 3 )
+        print (
+            "Device Active links EXPECTED: \n" +
+            str( deviceActiveLinksCount ) )
+        print (
+            "Device Active links ACTUAL: \n" +
+            str( deviceActiveLinksCount_tmp ) )
+        if ( cmp( deviceActiveLinksCount, deviceActiveLinksCount_tmp ) == 0 ):
             stepResult2 = main.TRUE
         else:
             stepResult2 = main.FALSE
 
-        '''
-        place holder for comparing devices, hosts and paths if required. 
+        """
+        place holder for comparing devices, hosts and paths if required.
         Links and ports data would be incorrect with out devices anyways.
-        '''
-
-        caseResult=(stepResult1 and stepResult2)
-        utilities.assert_equals(expect=main.TRUE, actual=case1Result,
-                onpass="Compare Topology test PASS",
-                onfail="Compare Topology test FAIL")
+        """
+        caseResult = ( stepResult1 and stepResult2 )
+        utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+                                 onpass="Compare Topology test PASS",
+                                 onfail="Compare Topology test FAIL" )
         if caseResult == main.TRUE:
-            main.log.report("Compare Topology test Pass")
+            main.log.report( "Compare Topology test Pass" )
 
-    def CASE6(self):
-        '''
+    def CASE6( self ):
+        """
         Install 300 host intents and verify ping all
-        '''
-        main.log.report("Add 300 host intents and verify pingall")
-        main.log.report("_______________________________________")
+        """
+        main.log.report( "Add 300 host intents and verify pingall" )
+        main.log.report( "_______________________________________" )
         import itertools
-        main.case("Install 300 host intents")
-        main.step("Add host Intents")
-        intentResult=main.TRUE
-        hostCombos = list(itertools.combinations(hostMACs, 2))
-        for i in range(len(hostCombos)):
-            iResult = main.ONOScli1.add_host_intent(hostCombos[i][0],hostCombos[i][1])
-            intentResult=(intentResult and iResult)
+        main.case( "Install 300 host intents" )
+        main.step( "Add host Intents" )
+        intentResult = main.TRUE
+        hostCombos = list( itertools.combinations( hostMACs, 2 ) )
+        for i in range( len( hostCombos ) ):
+            iResult = main.ONOScli1.add_host_intent(
+                hostCombos[ i ][ 0 ],
+                hostCombos[ i ][ 1 ] )
+            intentResult = ( intentResult and iResult )
 
-        main.step("Verify Ping across all hosts")
+        main.step( "Verify Ping across all hosts" )
         pingResult = main.FALSE
         time1 = time.time()
         pingResult = main.Mininet1.pingall()
         time2 = time.time()
-        timeDiff = round((time2-time1),2)
-        main.log.report("Time taken for Ping All: "+str(timeDiff)+" seconds")
-        utilities.assert_equals(expect=main.TRUE, actual=pingResult,
-                onpass="PING ALL PASS",
-                onfail="PING ALL FAIL")
+        timeDiff = round( ( time2 - time1 ), 2 )
+        main.log.report(
+            "Time taken for Ping All: " +
+            str( timeDiff ) +
+            " seconds" )
+        utilities.assert_equals( expect=main.TRUE, actual=pingResult,
+                                 onpass="PING ALL PASS",
+                                 onfail="PING ALL FAIL" )
 
-        case4Result=(intentResult and pingResult)
-        utilities.assert_equals(expect=main.TRUE, actual=case4Result,
-                onpass="Install 300 Host Intents and Ping All test PASS",
-                onfail="Install 300 Host Intents and Ping All test FAIL")
+        case4Result = ( intentResult and pingResult )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case4Result,
+            onpass="Install 300 Host Intents and Ping All test PASS",
+            onfail="Install 300 Host Intents and Ping All test FAIL" )
 
-    def CASE7(self,main):
-        '''
-        Randomly bring some core links down and verify ping all
-        '''
+    def CASE70( self, main ):
+        """
+        Randomly bring some core links down and verify ping all ( Host Intents Scenario )
+        """
         import random
-        ONOS1_ip = main.params['CTRL']['ip1']
-        link1End1 = main.params['CORELINKS']['linkS3a']
-        link1End2 = main.params['CORELINKS']['linkS3b'].split(',')
-        link2End1 = main.params['CORELINKS']['linkS14a']
-        link2End2 = main.params['CORELINKS']['linkS14b'].split(',')
-        link3End1 = main.params['CORELINKS']['linkS18a']
-        link3End2 = main.params['CORELINKS']['linkS18b'].split(',')
-        switchLinksToToggle = main.params['CORELINKS']['toggleLinks']
-        link_sleep = int(main.params['timers']['LinkDiscovery'])
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
+        link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
+        link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
+        link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
+        link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
+        link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
+        switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
+        link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
 
-        main.log.report("Randomly bring some core links down and verify ping all")
-        main.log.report("____________________________________________________")        
-        main.case("Randomly bring some core links down and verify ping all")
-        main.step("Verify number of Switch links to toggle on each Core Switch are between 1 - 5")
-        if (int(switchLinksToToggle) == 0 or int(switchLinksToToggle) > 5):
-            main.log.info("Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5")
+        main.log.report(
+            "Host intents - Randomly bring some core links down and verify ping all" )
+        main.log.report(
+            "_________________________________________________________________" )
+        main.case(
+            "Host intents - Randomly bring some core links down and verify ping all" )
+        main.step(
+            "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
+        if ( int( switchLinksToToggle ) ==
+             0 or int( switchLinksToToggle ) > 5 ):
+            main.log.info(
+                "Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
             main.cleanup()
             main.exit()
         else:
-            main.log.info("User provided Core switch links range to toggle is correct, proceeding to run the test")
+            main.log.info(
+                "User provided Core switch links range to toggle is correct, proceeding to run the test" )
 
-        main.step("Cut links on Core devices using user provided range")
-        randomLink1 = random.sample(link1End2,int(switchLinksToToggle))
-        randomLink2 = random.sample(link2End2,int(switchLinksToToggle))
-        randomLink3 = random.sample(link3End2,int(switchLinksToToggle))
-        for i in range(int(switchLinksToToggle)):
-            main.Mininet1.link(END1=link1End1,END2=randomLink1[i],OPTION="down")
-            main.Mininet1.link(END1=link2End1,END2=randomLink2[i],OPTION="down")
-            main.Mininet1.link(END1=link3End1,END2=randomLink3[i],OPTION="down")
-        time.sleep(link_sleep)
+        main.step( "Cut links on Core devices using user provided range" )
+        randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
+        randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
+        randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
+        for i in range( int( switchLinksToToggle ) ):
+            main.Mininet1.link(
+                END1=link1End1,
+                END2=randomLink1[ i ],
+                OPTION="down" )
+            main.Mininet1.link(
+                END1=link2End1,
+                END2=randomLink2[ i ],
+                OPTION="down" )
+            main.Mininet1.link(
+                END1=link3End1,
+                END2=randomLink3[ i ],
+                OPTION="down" )
+        time.sleep( link_sleep )
 
         topology_output = main.ONOScli2.topology()
-        linkDown = main.ONOSbench.check_status(topology_output,numSwitches,str(int(numLinks)-int(switchLinksToToggle)*6))
-        utilities.assert_equals(expect=main.TRUE,actual=linkDown,
-                onpass="Link Down discovered properly",
-                onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
+        linkDown = main.ONOSbench.check_status(
+            topology_output, numSwitches, str(
+                int( numLinks ) - int( switchLinksToToggle ) * 6 ) )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=linkDown,
+            onpass="Link Down discovered properly",
+            onfail="Link down was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
 
-        main.step("Verify Ping across all hosts")
+        main.step( "Verify Ping across all hosts" )
         pingResultLinkDown = main.FALSE
         time1 = time.time()
         pingResultLinkDown = main.Mininet1.pingall()
         time2 = time.time()
-        timeDiff = round((time2-time1),2)
-        main.log.report("Time taken for Ping All: "+str(timeDiff)+" seconds")
-        utilities.assert_equals(expect=main.TRUE, actual=pingResultLinkDown,
-                onpass="PING ALL PASS",
-                onfail="PING ALL FAIL")
+        timeDiff = round( ( time2 - time1 ), 2 )
+        main.log.report(
+            "Time taken for Ping All: " +
+            str( timeDiff ) +
+            " seconds" )
+        utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+                                 onpass="PING ALL PASS",
+                                 onfail="PING ALL FAIL" )
 
         caseResult7 = linkDown and pingResultLinkDown
-        utilities.assert_equals(expect=main.TRUE, actual=caseResult7,
-                onpass="Random Link cut Test PASS",
-                onfail="Random Link cut Test FAIL")
+        utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
+                                 onpass="Random Link cut Test PASS",
+                                 onfail="Random Link cut Test FAIL" )
 
-    def CASE8(self,main):
-        '''
-        Bring the core links up that are down and verify ping all
-        '''
+    def CASE80( self, main ):
+        """
+        Bring the core links up that are down and verify ping all ( Host Intents Scenario )
+        """
         import random
-        ONOS1_ip = main.params['CTRL']['ip1']
-        link1End1 = main.params['CORELINKS']['linkS3a']
-        link2End1 = main.params['CORELINKS']['linkS14a']
-        link3End1 = main.params['CORELINKS']['linkS18a']
-        link_sleep = int(main.params['timers']['LinkDiscovery'])
-        switchLinksToToggle = main.params['CORELINKS']['toggleLinks']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
+        link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
+        link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
+        link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+        switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
 
-        main.log.report("Bring the core links up that are down and verify ping all")
-        main.log.report("_____________________________________________________")        
-        main.case("Bring the core links up that are down and verify ping all")
-        main.step("Bring randomly cut links on Core devices up")
-        for i in range(int(switchLinksToToggle)): 
-            main.Mininet1.link(END1=link1End1,END2=randomLink1[i],OPTION="up")
-            main.Mininet1.link(END1=link2End1,END2=randomLink2[i],OPTION="up")
-            main.Mininet1.link(END1=link3End1,END2=randomLink3[i],OPTION="up")
-        time.sleep(link_sleep)
+        main.log.report(
+            "Host intents - Bring the core links up that are down and verify ping all" )
+        main.log.report(
+            "__________________________________________________________________" )
+        main.case(
+            "Host intents - Bring the core links up that are down and verify ping all" )
+        main.step( "Bring randomly cut links on Core devices up" )
+        for i in range( int( switchLinksToToggle ) ):
+            main.Mininet1.link(
+                END1=link1End1,
+                END2=randomLink1[ i ],
+                OPTION="up" )
+            main.Mininet1.link(
+                END1=link2End1,
+                END2=randomLink2[ i ],
+                OPTION="up" )
+            main.Mininet1.link(
+                END1=link3End1,
+                END2=randomLink3[ i ],
+                OPTION="up" )
+        time.sleep( link_sleep )
 
         topology_output = main.ONOScli2.topology()
-        linkUp = main.ONOSbench.check_status(topology_output,numSwitches,str(numLinks))
-        utilities.assert_equals(expect=main.TRUE,actual=linkUp,
-                onpass="Link up discovered properly",
-                onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
+        linkUp = main.ONOSbench.check_status(
+            topology_output,
+            numSwitches,
+            str( numLinks ) )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=linkUp,
+            onpass="Link up discovered properly",
+            onfail="Link up was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
 
-        main.step("Verify Ping across all hosts")
+        main.step( "Verify Ping across all hosts" )
         pingResultLinkUp = main.FALSE
         time1 = time.time()
         pingResultLinkUp = main.Mininet1.pingall()
         time2 = time.time()
-        timeDiff = round((time2-time1),2)
-        main.log.report("Time taken for Ping All: "+str(timeDiff)+" seconds")
-        utilities.assert_equals(expect=main.TRUE, actual=pingResultLinkUp,
-                onpass="PING ALL PASS",
-                onfail="PING ALL FAIL")
+        timeDiff = round( ( time2 - time1 ), 2 )
+        main.log.report(
+            "Time taken for Ping All: " +
+            str( timeDiff ) +
+            " seconds" )
+        utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+                                 onpass="PING ALL PASS",
+                                 onfail="PING ALL FAIL" )
 
         caseResult8 = linkUp and pingResultLinkUp
-        utilities.assert_equals(expect=main.TRUE, actual=caseResult8,
-                onpass="Link Up Test PASS",
-                onfail="Link Up Test FAIL")    
+        utilities.assert_equals( expect=main.TRUE, actual=caseResult8,
+                                 onpass="Link Up Test PASS",
+                                 onfail="Link Up Test FAIL" )
 
-    def CASE9(self):
-        '''
+    def CASE71( self, main ):
+        """
+        Randomly bring some core links down and verify ping all ( Point Intents Scenario )
+        """
+        import random
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
+        link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
+        link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
+        link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
+        link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
+        link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
+        switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
+        link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+
+        main.log.report(
+            "Point Intents - Randomly bring some core links down and verify ping all" )
+        main.log.report(
+            "__________________________________________________________________" )
+        main.case(
+            "Point Intents - Randomly bring some core links down and verify ping all" )
+        main.step(
+            "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
+        if ( int( switchLinksToToggle ) ==
+             0 or int( switchLinksToToggle ) > 5 ):
+            main.log.info(
+                "Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
+            main.cleanup()
+            main.exit()
+        else:
+            main.log.info(
+                "User provided Core switch links range to toggle is correct, proceeding to run the test" )
+
+        main.step( "Cut links on Core devices using user provided range" )
+        randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
+        randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
+        randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
+        for i in range( int( switchLinksToToggle ) ):
+            main.Mininet1.link(
+                END1=link1End1,
+                END2=randomLink1[ i ],
+                OPTION="down" )
+            main.Mininet1.link(
+                END1=link2End1,
+                END2=randomLink2[ i ],
+                OPTION="down" )
+            main.Mininet1.link(
+                END1=link3End1,
+                END2=randomLink3[ i ],
+                OPTION="down" )
+        time.sleep( link_sleep )
+
+        topology_output = main.ONOScli2.topology()
+        linkDown = main.ONOSbench.check_status(
+            topology_output, numSwitches, str(
+                int( numLinks ) - int( switchLinksToToggle ) * 6 ) )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=linkDown,
+            onpass="Link Down discovered properly",
+            onfail="Link down was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
+
+        main.step( "Verify Ping across all hosts" )
+        pingResultLinkDown = main.FALSE
+        time1 = time.time()
+        pingResultLinkDown = main.Mininet1.pingall()
+        time2 = time.time()
+        timeDiff = round( ( time2 - time1 ), 2 )
+        main.log.report(
+            "Time taken for Ping All: " +
+            str( timeDiff ) +
+            " seconds" )
+        utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+                                 onpass="PING ALL PASS",
+                                 onfail="PING ALL FAIL" )
+
+        caseResult7 = linkDown and pingResultLinkDown
+        utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
+                                 onpass="Random Link cut Test PASS",
+                                 onfail="Random Link cut Test FAIL" )
+
+    def CASE81( self, main ):
+        """
+        Bring the core links up that are down and verify ping all ( Point Intents Scenario )
+        """
+        import random
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
+        link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
+        link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
+        link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+        switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
+
+        main.log.report(
+            "Point intents - Bring the core links up that are down and verify ping all" )
+        main.log.report(
+            "___________________________________________________________________" )
+        main.case(
+            "Point intents - Bring the core links up that are down and verify ping all" )
+        main.step( "Bring randomly cut links on Core devices up" )
+        for i in range( int( switchLinksToToggle ) ):
+            main.Mininet1.link(
+                END1=link1End1,
+                END2=randomLink1[ i ],
+                OPTION="up" )
+            main.Mininet1.link(
+                END1=link2End1,
+                END2=randomLink2[ i ],
+                OPTION="up" )
+            main.Mininet1.link(
+                END1=link3End1,
+                END2=randomLink3[ i ],
+                OPTION="up" )
+        time.sleep( link_sleep )
+
+        topology_output = main.ONOScli2.topology()
+        linkUp = main.ONOSbench.check_status(
+            topology_output,
+            numSwitches,
+            str( numLinks ) )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=linkUp,
+            onpass="Link up discovered properly",
+            onfail="Link up was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
+
+        main.step( "Verify Ping across all hosts" )
+        pingResultLinkUp = main.FALSE
+        time1 = time.time()
+        pingResultLinkUp = main.Mininet1.pingall()
+        time2 = time.time()
+        timeDiff = round( ( time2 - time1 ), 2 )
+        main.log.report(
+            "Time taken for Ping All: " +
+            str( timeDiff ) +
+            " seconds" )
+        utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+                                 onpass="PING ALL PASS",
+                                 onfail="PING ALL FAIL" )
+
+        caseResult8 = linkUp and pingResultLinkUp
+        utilities.assert_equals( expect=main.TRUE, actual=caseResult8,
+                                 onpass="Link Up Test PASS",
+                                 onfail="Link Up Test FAIL" )
+
+    def CASE9( self ):
+        """
         Install 114 point intents and verify Ping all works
-        '''
+        """
         import copy
-        main.log.report("Install 114 point intents and verify Ping all")
-        main.log.report("___________________________________________")        
-        main.case("Install 114 point intents and Ping all")
-        deviceLinks_copy = copy.copy(deviceLinks)
-        main.step("Install 114 point intents")
-        for i in range(len(deviceLinks_copy)):
-            pointLink = str(deviceLinks_copy[i]).replace("src=","").replace("dst=","").split(',')
-            point1 = pointLink[0].split('/')
-            point2 = pointLink[1].split('/')
-            installResult = main.ONOScli1.add_point_intent(point1[0],point2[0],int(point1[1]),int(point2[1]))
+        main.log.report( "Install 114 point intents and verify Ping all" )
+        main.log.report( "___________________________________________" )
+        main.case( "Install 114 point intents and Ping all" )
+        deviceLinks_copy = copy.copy( deviceLinks )
+        main.step( "Install 114 point intents" )
+        for i in range( len( deviceLinks_copy ) ):
+            pointLink = str(
+                deviceLinks_copy[ i ] ).replace(
+                "src=",
+                "" ).replace(
+                "dst=",
+                "" ).split( ',' )
+            point1 = pointLink[ 0 ].split( '/' )
+            point2 = pointLink[ 1 ].split( '/' )
+            installResult = main.ONOScli1.add_point_intent(
+                point1[ 0 ], point2[ 0 ], int(
+                    point1[ 1 ] ), int(
+                    point2[ 1 ] ) )
             if installResult == main.TRUE:
-                print "Installed Point intent between :",point1[0], int(point1[1]), point2[0], int(point2[1])
+                print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
 
-        main.step("Obtain the intent id's")
+        main.step( "Obtain the intent id's" )
         intentsList = main.ONOScli1.getAllIntentIds()
-        ansi_escape = re.compile(r'\x1b[^m]*m')
-        intentsList = ansi_escape.sub('', intentsList)
-        intentsList = intentsList.replace(" onos:intents | grep id=","").replace("id=","").replace("\r\r","")
-        intentsList=intentsList.splitlines()
-        intentsList = intentsList[1:]
+        ansi_escape = re.compile( r'\x1b[^m]*m' )
+        intentsList = ansi_escape.sub( '', intentsList )
+        intentsList = intentsList.replace(
+            " onos:intents | grep id=",
+            "" ).replace(
+            "id=",
+            "" ).replace(
+            "\r\r",
+             "" )
+        intentsList = intentsList.splitlines()
+        intentsList = intentsList[ 1: ]
         intentIdList = []
-        for i in range(len(intentsList)):
-            intentsTemp = intentsList[i].split(',')
-            intentIdList.append(intentsTemp[0])
+        for i in range( len( intentsList ) ):
+            intentsTemp = intentsList[ i ].split( ',' )
+            intentIdList.append( intentsTemp[ 0 ] )
         print "Intent IDs: ", intentIdList
-        print "Total Intents installed: ", len(intentIdList)
+        print "Total Intents installed: ", len( intentIdList )
 
-        main.step("Verify Ping across all hosts")
+        main.step( "Verify Ping across all hosts" )
         pingResult = main.FALSE
         time1 = time.time()
         pingResult = main.Mininet1.pingall()
         time2 = time.time()
-        timeDiff = round((time2-time1),2)
-        main.log.report("Time taken for Ping All: "+str(timeDiff)+" seconds")
-        utilities.assert_equals(expect=main.TRUE, actual=pingResult,
-                onpass="PING ALL PASS",
-                onfail="PING ALL FAIL")
+        timeDiff = round( ( time2 - time1 ), 2 )
+        main.log.report(
+            "Time taken for Ping All: " +
+            str( timeDiff ) +
+            " seconds" )
+        utilities.assert_equals( expect=main.TRUE, actual=pingResult,
+                                 onpass="PING ALL PASS",
+                                 onfail="PING ALL FAIL" )
 
         case8_result = installResult and pingResult
-        utilities.assert_equals(expect=main.TRUE, actual=case8_result,
-                onpass="Ping all test after Point intents addition successful",
-                onfail="Ping all test after Point intents addition failed")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case8_result,
+            onpass="Ping all test after Point intents addition successful",
+            onfail="Ping all test after Point intents addition failed" )
 
-    def CASE10(self):
-        '''
+    def CASE10( self ):
+        """
          Remove all Intents
-        ''' 
-        main.log.report("Remove all intents that were installed previously")
-        main.log.report("______________________________________________")        
-        main.log.info("Remove all intents")
-        main.case("Removing intents")
-        main.step("Obtain the intent id's first")
+        """
+        main.log.report( "Remove all intents that were installed previously" )
+        main.log.report( "______________________________________________" )
+        main.log.info( "Remove all intents" )
+        main.case( "Removing intents" )
+        main.step( "Obtain the intent id's first" )
         intentsList = main.ONOScli1.getAllIntentIds()
-        ansi_escape = re.compile(r'\x1b[^m]*m')
-        intentsList = ansi_escape.sub('', intentsList)
-        intentsList = intentsList.replace(" onos:intents | grep id=","").replace("id=","").replace("\r\r","")
-        intentsList=intentsList.splitlines()
-        intentsList = intentsList[1:]
+        ansi_escape = re.compile( r'\x1b[^m]*m' )
+        intentsList = ansi_escape.sub( '', intentsList )
+        intentsList = intentsList.replace(
+            " onos:intents | grep id=",
+            "" ).replace(
+            "id=",
+            "" ).replace(
+            "\r\r",
+             "" )
+        intentsList = intentsList.splitlines()
+        intentsList = intentsList[ 1: ]
         intentIdList = []
         step1Result = main.TRUE
-        if (len(intentsList) > 1):
-            for i in range(len(intentsList)):
-                intentsTemp = intentsList[i].split(',')
-                intentIdList.append(intentsTemp[0])
+        if ( len( intentsList ) > 1 ):
+            for i in range( len( intentsList ) ):
+                intentsTemp = intentsList[ i ].split( ',' )
+                intentIdList.append( intentsTemp[ 0 ] )
             print "Intent IDs: ", intentIdList
-            for id in range(len(intentIdList)):
-                print "Removing intent id (round 1) :", intentIdList[id]
-                main.ONOScli1.remove_intent(intent_id = intentIdList[id])
-                time.sleep(1)
+            for id in range( len( intentIdList ) ):
+                print "Removing intent id (round 1) :", intentIdList[ id ]
+                main.ONOScli1.remove_intent( intent_id=intentIdList[ id ] )
+                time.sleep( 1 )
 
-            main.log.info("Verify all intents are removed and if any leftovers try remove one more time")
+            main.log.info(
+                "Verify all intents are removed and if any leftovers try remove one more time" )
             intentsList1 = main.ONOScli1.getAllIntentIds()
-            ansi_escape = re.compile(r'\x1b[^m]*m')
-            intentsList1 = ansi_escape.sub('', intentsList1)
-            intentsList1 = intentsList1.replace(" onos:intents | grep id=","").replace(" state=","").replace("\r\r","")
-            intentsList1=intentsList1.splitlines()
-            intentsList1 = intentsList1[1:]
+            ansi_escape = re.compile( r'\x1b[^m]*m' )
+            intentsList1 = ansi_escape.sub( '', intentsList1 )
+            intentsList1 = intentsList1.replace(
+                " onos:intents | grep id=",
+                "" ).replace(
+                " state=",
+                "" ).replace(
+                "\r\r",
+                "" )
+            intentsList1 = intentsList1.splitlines()
+            intentsList1 = intentsList1[ 1: ]
             print "Round 2 (leftover) intents to remove: ", intentsList1
             intentIdList1 = []
-            if (len(intentsList1) > 1):
-                for i in range(len(intentsList1)):
-                    intentsTemp1 = intentsList[i].split(',')
-                    intentIdList1.append(intentsTemp1[0])
+            if ( len( intentsList1 ) > 1 ):
+                for i in range( len( intentsList1 ) ):
+                    intentsTemp1 = intentsList[ i ].split( ',' )
+                    intentIdList1.append( intentsTemp1[ 0 ] )
                 print "Leftover Intent IDs: ", intentIdList1
-                for id in range(len(intentIdList1)):
-                    print "Removing intent id (round 2):", intentIdList1[id]
-                    main.ONOScli1.remove_intent(intent_id = intentIdList1[id])
-                    time.sleep(2)
+                for id in range( len( intentIdList1 ) ):
+                    print "Removing intent id (round 2):", intentIdList1[ id ]
+                    main.ONOScli1.remove_intent(
+                        intent_id=intentIdList1[ id ] )
+                    time.sleep( 2 )
             else:
                 print "There are no more intents that need to be removed"
                 step1Result = main.TRUE
@@ -591,6 +886,6 @@
             step1Result = main.FALSE
 
         caseResult7 = step1Result
-        utilities.assert_equals(expect=main.TRUE, actual=caseResult7,
-                onpass="Intent removal test successful",
-                onfail="Intent removal test failed")
\ No newline at end of file
+        utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
+                                 onpass="Intent removal test successful",
+                                 onfail="Intent removal test failed" )
diff --git a/TestON/tests/PingallExample/PingallExample.params b/TestON/tests/PingallExample/PingallExample.params
index aecaab6..8d0d10b 100644
--- a/TestON/tests/PingallExample/PingallExample.params
+++ b/TestON/tests/PingallExample/PingallExample.params
@@ -1,12 +1,12 @@
 <PARAMS>
     <testcases>1,2,3</testcases>
     <ENV>
-        <cellName>HA</cellName>
+        <cellName>kelvin</cellName>
     </ENV>
     <Git>True</Git>
 
     <CTRL>
-        <ip1>10.128.30.11</ip1>
+        <ip1>10.128.10.21</ip1>
         <port1>6633</port1>
     </CTRL>
 </PARAMS>
diff --git a/TestON/tests/PingallExample/PingallExample.topo b/TestON/tests/PingallExample/PingallExample.topo
index 1712756..dba7a5d 100644
--- a/TestON/tests/PingallExample/PingallExample.topo
+++ b/TestON/tests/PingallExample/PingallExample.topo
@@ -2,7 +2,7 @@
     <COMPONENT>
 
         <ONOSbench>
-            <host>10.128.30.10</host>
+            <host>10.128.10.20</host>
             <user>admin</user>
             <password></password>
             <type>OnosDriver</type>
@@ -11,7 +11,7 @@
         </ONOSbench>
 
         <ONOScli1>
-            <host>10.128.30.10</host>
+            <host>10.128.10.20</host>
             <user>admin</user>
             <password></password>
             <type>OnosCliDriver</type>
@@ -20,16 +20,16 @@
         </ONOScli1>
 
         <ONOS1>
-            <host>10.128.30.11</host>
-            <user>sdn</user>
-            <password>rocks</password>
+            <host>10.128.10.21</host>
+            <user>admin</user>
+            <password></password>
             <type>OnosDriver</type>
             <connect_order>3</connect_order>
             <COMPONENTS> </COMPONENTS>
         </ONOS1>
 
         <Mininet1>
-            <host>10.128.30.9</host>
+            <host>10.128.10.20</host>
             <user>admin</user>
             <password></password>
             <type>MininetCliDriver</type>
diff --git a/TestON/tests/ProdFunc/ProdFunc.py b/TestON/tests/ProdFunc/ProdFunc.py
old mode 100644
new mode 100755
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.py b/TestON/tests/ProdFunc13/ProdFunc13.py
old mode 100755
new mode 100644
index a815fea..1775ebb
--- a/TestON/tests/ProdFunc13/ProdFunc13.py
+++ b/TestON/tests/ProdFunc13/ProdFunc13.py
@@ -1,6 +1,6 @@
 
-#Testing the basic functionality of ONOS Next
-#For sanity and driver functionality excercises only.
+# Testing the basic functionality of ONOS Next
+# For sanity and driver functionality excercises only.
 
 import time
 import sys
@@ -8,13 +8,16 @@
 import re
 import json
 
-time.sleep(1)
+time.sleep( 1 )
+
+
 class ProdFunc13:
-    def __init__(self):
+
+    def __init__( self ):
         self.default = ''
 
-    def CASE1(self, main):
-        '''
+    def CASE1( self, main ):
+        """
         Startup sequence:
         cell <name>
         onos-verify-cell
@@ -24,1077 +27,1312 @@
         onos-package
         onos-install -f
         onos-wait-for-start
-        '''
-        
-        cell_name = main.params['ENV']['cellName']
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS1_port = main.params['CTRL']['port1']
-        
-        main.case("Setting up test environment")
-        main.log.report("This testcase is testing setting up test environment")
-        main.log.report("__________________________________") 
+        """
+        cell_name = main.params[ 'ENV' ][ 'cellName' ]
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
 
-        main.step("Applying cell variable to environment")
-        cell_result = main.ONOSbench.set_cell(cell_name)
+        main.case( "Setting up test environment" )
+        main.log.report(
+            "This testcase is testing setting up test environment" )
+        main.log.report( "__________________________________" )
+
+        main.step( "Applying cell variable to environment" )
+        cell_result = main.ONOSbench.set_cell( cell_name )
         verify_result = main.ONOSbench.verify_cell()
-        
-        main.step("Removing raft logs before a clen installation of ONOS")
+
+        main.step( "Removing raft logs before a clen installation of ONOS" )
         main.ONOSbench.onos_remove_raft_logs()
 
-        main.step("Git checkout and pull master and get version")
-        main.ONOSbench.git_checkout("master")
+        main.step( "Git checkout and pull master and get version" )
+        main.ONOSbench.git_checkout( "master" )
         git_pull_result = main.ONOSbench.git_pull()
-        main.log.info("git_pull_result = " +git_pull_result)
-        version_result = main.ONOSbench.get_version(report=True)
-    
+        main.log.info( "git_pull_result = " + git_pull_result )
+        version_result = main.ONOSbench.get_version( report=True )
+
         if git_pull_result == 1:
-            main.step("Using mvn clean & install")
+            main.step( "Using mvn clean & install" )
             clean_install_result = main.ONOSbench.clean_install()
             #clean_install_result = main.TRUE
         elif git_pull_result == 0:
-            main.log.report("Git Pull Failed, look into logs for detailed reason")
+            main.log.report(
+                "Git Pull Failed, look into logs for detailed reason" )
             main.cleanup()
-            main.exit() 
-         
-        main.step("Creating ONOS package")
+            main.exit()
+
+        main.step( "Creating ONOS package" )
         package_result = main.ONOSbench.onos_package()
 
-
-        main.step("Installing ONOS package")
+        main.step( "Installing ONOS package" )
         onos_install_result = main.ONOSbench.onos_install()
         if onos_install_result == main.TRUE:
-            main.log.report("Installing ONOS package successful")
+            main.log.report( "Installing ONOS package successful" )
         else:
-            main.log.report("Installing ONOS package failed")
+            main.log.report( "Installing ONOS package failed" )
 
         onos1_isup = main.ONOSbench.isup()
         if onos1_isup == main.TRUE:
-            main.log.report("ONOS instance is up and ready")  
+            main.log.report( "ONOS instance is up and ready" )
         else:
-            main.log.report("ONOS instance may not be up")  
-       
-        main.step("Starting ONOS service")
-        start_result = main.ONOSbench.onos_start(ONOS1_ip)
-        
-        main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])        
+            main.log.report( "ONOS instance may not be up" )
 
-        case1_result = (package_result and\
-                cell_result and verify_result and onos_install_result and\
-                onos1_isup and start_result )
-        utilities.assert_equals(expect=main.TRUE, actual=case1_result,
-                onpass="Test startup successful",
-                onfail="Test startup NOT successful")
+        main.step( "Starting ONOS service" )
+        start_result = main.ONOSbench.onos_start( ONOS1_ip )
 
-    def CASE2(self, main) :
-        '''  
+        main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
+
+        case1_result = ( package_result and
+                         cell_result and verify_result and onos_install_result and
+                         onos1_isup and start_result )
+        utilities.assert_equals( expect=main.TRUE, actual=case1_result,
+                                 onpass="Test startup successful",
+                                 onfail="Test startup NOT successful" )
+
+    def CASE2( self, main ):
+        """
         Switch Down
-        '''
-        #NOTE: You should probably run a topology check after this
-        import time 
+        """
+        # NOTE: You should probably run a topology check after this
+        import time
         import json
- 
-        main.case("Switch down discovery")
-        main.log.report("This testcase is testing a switch down discovery")
-        main.log.report("__________________________________")
 
-        switch_sleep = int(main.params['timers']['SwitchDiscovery'])
+        main.case( "Switch down discovery" )
+        main.log.report( "This testcase is testing a switch down discovery" )
+        main.log.report( "__________________________________" )
+
+        switch_sleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
 
         description = "Killing a switch to ensure it is discovered correctly"
-        main.log.report(description)
-        main.case(description)
+        main.log.report( description )
+        main.case( description )
 
-        #TODO: Make this switch parameterizable
-        main.step("Kill s28 ")
-        main.log.report("Deleting s28")
-        #FIXME: use new dynamic topo functions
-        main.Mininet1.del_switch("s28")
-        main.log.info("Waiting " + str(switch_sleep) + " seconds for switch down to be discovered")
-        time.sleep(switch_sleep)
-        #Peek at the deleted switch
-        device = main.ONOS2.get_device(dpid="0028")
+        # TODO: Make this switch parameterizable
+        main.step( "Kill s28 " )
+        main.log.report( "Deleting s28" )
+        # FIXME: use new dynamic topo functions
+        main.Mininet1.del_switch( "s28" )
+        main.log.info(
+            "Waiting " +
+            str( switch_sleep ) +
+            " seconds for switch down to be discovered" )
+        time.sleep( switch_sleep )
+        # Peek at the deleted switch
+        device = main.ONOS2.get_device( dpid="0028" )
         print "device = ", device
-        if device[u'available'] == 'False':
+        if device[ u'available' ] == 'False':
             case2_result = main.FALSE
         else:
             case2_result = main.TRUE
-        utilities.assert_equals(expect=main.TRUE, actual=case2_result,
-                onpass="Switch down discovery successful",
-                onfail="Switch down discovery failed")
+        utilities.assert_equals( expect=main.TRUE, actual=case2_result,
+                                 onpass="Switch down discovery successful",
+                                 onfail="Switch down discovery failed" )
 
-    def CASE11(self, main):
-        '''
+    def CASE11( self, main ):
+        """
         Cleanup sequence:
         onos-service <node_ip> stop
         onos-uninstall
 
         TODO: Define rest of cleanup
-        
-        '''
 
-        ONOS1_ip = main.params['CTRL']['ip1']
+        """
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
 
-        main.case("Cleaning up test environment")
+        main.case( "Cleaning up test environment" )
 
-        main.step("Testing ONOS kill function")
-        kill_result = main.ONOSbench.onos_kill(ONOS1_ip)
+        main.step( "Testing ONOS kill function" )
+        kill_result = main.ONOSbench.onos_kill( ONOS1_ip )
 
-        main.step("Stopping ONOS service")
-        stop_result = main.ONOSbench.onos_stop(ONOS1_ip)
+        main.step( "Stopping ONOS service" )
+        stop_result = main.ONOSbench.onos_stop( ONOS1_ip )
 
-        main.step("Uninstalling ONOS service") 
+        main.step( "Uninstalling ONOS service" )
         uninstall_result = main.ONOSbench.onos_uninstall()
 
-    def CASE3(self, main):
-        '''
+    def CASE3( self, main ):
+        """
         Test 'onos' command and its functionality in driver
-        '''
-        
-        ONOS1_ip = main.params['CTRL']['ip1']
+        """
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
 
-        main.case("Testing 'onos' command")
+        main.case( "Testing 'onos' command" )
 
-        main.step("Sending command 'onos -w <onos-ip> system:name'")
+        main.step( "Sending command 'onos -w <onos-ip> system:name'" )
         cmdstr1 = "system:name"
-        cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1) 
-        main.log.info("onos command returned: "+cmd_result1)
+        cmd_result1 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr1 )
+        main.log.info( "onos command returned: " + cmd_result1 )
 
-        main.step("Sending command 'onos -w <onos-ip> onos:topology'")
+        main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
         cmdstr2 = "onos:topology"
-        cmd_result2 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
-        main.log.info("onos command returned: "+cmd_result2)
+        cmd_result2 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
+        main.log.info( "onos command returned: " + cmd_result2 )
 
-
-    def CASE20(self):
-        '''
+    def CASE20( self ):
+        """
             Exit from mininet cli
             reinstall ONOS
-        '''
-        cell_name = main.params['ENV']['cellName']
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS1_port = main.params['CTRL']['port1']
-        
-        main.log.report("This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology")
-        main.log.report("_____________________________________________")
-        main.case("Disconnecting mininet and restarting ONOS")
-        main.step("Disconnecting mininet and restarting ONOS")
+        """
+        cell_name = main.params[ 'ENV' ][ 'cellName' ]
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+
+        main.log.report(
+            "This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology" )
+        main.log.report( "_____________________________________________" )
+        main.case( "Disconnecting mininet and restarting ONOS" )
+        main.step( "Disconnecting mininet and restarting ONOS" )
         mininet_disconnect = main.Mininet1.disconnect()
 
-        main.step("Removing raft logs before a clen installation of ONOS")
+        main.step( "Removing raft logs before a clen installation of ONOS" )
         main.ONOSbench.onos_remove_raft_logs()
 
-        main.step("Applying cell variable to environment")
-        cell_result = main.ONOSbench.set_cell(cell_name)
+        main.step( "Applying cell variable to environment" )
+        cell_result = main.ONOSbench.set_cell( cell_name )
         verify_result = main.ONOSbench.verify_cell()
 
         onos_install_result = main.ONOSbench.onos_install()
         if onos_install_result == main.TRUE:
-            main.log.report("Installing ONOS package successful")
+            main.log.report( "Installing ONOS package successful" )
         else:
-            main.log.report("Installing ONOS package failed")
+            main.log.report( "Installing ONOS package failed" )
 
         onos1_isup = main.ONOSbench.isup()
         if onos1_isup == main.TRUE:
-            main.log.report("ONOS instance is up and ready")
+            main.log.report( "ONOS instance is up and ready" )
         else:
-            main.log.report("ONOS instance may not be up")
+            main.log.report( "ONOS instance may not be up" )
 
-        main.step("Starting ONOS service")
-        start_result = main.ONOSbench.onos_start(ONOS1_ip)
-      
-        main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1']) 
+        main.step( "Starting ONOS service" )
+        start_result = main.ONOSbench.onos_start( ONOS1_ip )
+
+        main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
         print "mininet_disconnect =", mininet_disconnect
         print "onos_install_result =", onos_install_result
         print "onos1_isup =", onos1_isup
         print "start_result =", start_result
- 
-        case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
-        utilities.assert_equals(expect=main.TRUE, actual=case20_result,
-                onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
-                onfail="Exiting functionality mininet topology and reinstalling ONOS failed") 
 
-    def CASE21(self, main):
+        case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case20_result,
+            onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
+            onfail="Exiting functionality mininet topology and reinstalling ONOS failed" )
+
+    def CASE21( self, main ):
         import time
-        '''
+        """
             On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
             which starts the rest and copies the links json file to the onos instance
-            Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt 
+            Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt
             from the json config file
-        ''' 
-        main.log.report("This testcase starts the packet layer topology and REST")
-        main.log.report("_____________________________________________")
-        main.case("Starting LINC-OE and other components")
-        main.step("Starting LINC-OE and other components")
+        """
+        main.log.report(
+            "This testcase starts the packet layer topology and REST" )
+        main.log.report( "_____________________________________________" )
+        main.case( "Starting LINC-OE and other components" )
+        main.step( "Starting LINC-OE and other components" )
         start_console_result = main.LincOE1.start_console()
         optical_mn_script = main.LincOE2.run_optical_mn_script()
-        onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(instance_name = main.params['CTRL']['ip1'], json_file = main.params['OPTICAL']['jsonfile'])
-            
-        print "start_console_result =",start_console_result 
-        print "optical_mn_script = ",optical_mn_script 
-        print "onos_topo_cfg_result =",onos_topo_cfg_result 
+        onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(
+            instance_name=main.params[ 'CTRL' ][ 'ip1' ],
+            json_file=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
+
+        print "start_console_result =", start_console_result
+        print "optical_mn_script = ", optical_mn_script
+        print "onos_topo_cfg_result =", onos_topo_cfg_result
 
         case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result
-        utilities.assert_equals(expect=main.TRUE, actual=case21_result,
-                onpass="Packet optical topology spawned successsfully",
-                onfail="Packet optical topology spawning failed") 
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case21_result,
+            onpass="Packet optical topology spawned successsfully",
+            onfail="Packet optical topology spawning failed" )
 
-
-    def CASE22(self, main):
-        '''
+    def CASE22( self, main ):
+        """
             Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host.
              Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2
             and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed
-        '''
-
-        main.log.report("This testcase compares the optical+packet topology against what is expected")
-        main.case("Topology comparision")
-        main.step("Topology comparision")
-        main.ONOS3.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
-        devices_result = main.ONOS3.devices(json_format = False)
+        """
+        main.log.report(
+            "This testcase compares the optical+packet topology against what is expected" )
+        main.case( "Topology comparision" )
+        main.step( "Topology comparision" )
+        main.ONOS3.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
+        devices_result = main.ONOS3.devices( json_format=False )
 
         print "devices_result = ", devices_result
-        devices_linewise = devices_result.split("\n")
-        devices_linewise = devices_linewise[1:-1]
+        devices_linewise = devices_result.split( "\n" )
+        devices_linewise = devices_linewise[ 1:-1 ]
         roadmCount = 0
         packetLayerSWCount = 0
         for line in devices_linewise:
-            components = line.split(",")
-            availability = components[1].split("=")[1]
-            type = components[3].split("=")[1]
+            components = line.split( "," )
+            availability = components[ 1 ].split( "=" )[ 1 ]
+            type = components[ 3 ].split( "=" )[ 1 ]
             if availability == 'true' and type == 'ROADM':
                 roadmCount += 1
-            elif availability == 'true' and type =='SWITCH':
+            elif availability == 'true' and type == 'SWITCH':
                 packetLayerSWCount += 1
         if roadmCount == 4:
-            print "Number of Optical Switches = %d and is correctly detected" %roadmCount
-            main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is correctly detected")
+            print "Number of Optical Switches = %d and is correctly detected" % roadmCount
+            main.log.info(
+                "Number of Optical Switches = " +
+                str( roadmCount ) +
+                " and is correctly detected" )
             opticalSW_result = main.TRUE
         else:
-            print "Number of Optical Switches = %d and is wrong" %roadCount
-            main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is wrong")
+            print "Number of Optical Switches = %d and is wrong" % roadCount
+            main.log.info(
+                "Number of Optical Switches = " +
+                str( roadmCount ) +
+                " and is wrong" )
             opticalSW_result = main.FALSE
 
         if packetLayerSWCount == 2:
-            print "Number of Packet layer or mininet Switches = %d and is correctly detected" %packetLayerSWCount
-            main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is correctly detected")
+            print "Number of Packet layer or mininet Switches = %d and is correctly detected" % packetLayerSWCount
+            main.log.info(
+                "Number of Packet layer or mininet Switches = " +
+                str( packetLayerSWCount ) +
+                " and is correctly detected" )
             packetSW_result = main.TRUE
         else:
-            print "Number of Packet layer or mininet Switches = %d and is wrong" %packetLayerSWCount
-            main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is wrong")
+            print "Number of Packet layer or mininet Switches = %d and is wrong" % packetLayerSWCount
+            main.log.info(
+                "Number of Packet layer or mininet Switches = " +
+                str( packetLayerSWCount ) +
+                " and is wrong" )
             packetSW_result = main.FALSE
         print "_________________________________"
-        
-        links_result = main.ONOS3.links(json_format = False)
+
+        links_result = main.ONOS3.links( json_format=False )
         print "links_result = ", links_result
         print "_________________________________"
-        
-        #NOTE:Since only point intents are added, there is no requirement to discover the hosts
-                #Therfore, the below portion of the code is commented.
-        '''
+
+        # NOTE:Since only point intents are added, there is no requirement to discover the hosts
+        # Therfore, the below portion of the code is commented.
+        """
         #Discover hosts using pingall
-        pingall_result = main.LincOE2.pingall()    
-    
-        hosts_result = main.ONOS3.hosts(json_format = False)
-        main.log.info("hosts_result = "+hosts_result)   
-        main.log.info("_________________________________")
-        hosts_linewise = hosts_result.split("\n")
-        hosts_linewise = hosts_linewise[1:-1]
+        pingall_result = main.LincOE2.pingall()
+
+        hosts_result = main.ONOS3.hosts( json_format=False )
+        main.log.info( "hosts_result = "+hosts_result )
+        main.log.info( "_________________________________" )
+        hosts_linewise = hosts_result.split( "\n" )
+        hosts_linewise = hosts_linewise[ 1:-1 ]
         hostCount = 0
         for line in hosts_linewise:
-            hostid = line.split(",")[0].split("=")[1]
+            hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
             hostCount +=1
         if hostCount ==2:
             print "Number of hosts = %d and is correctly detected" %hostCount
-            main.log.info("Number of hosts = " + str(hostCount) +" and is correctly detected")
+            main.log.info( "Number of hosts = " + str( hostCount ) +" and is correctly detected" )
             hostDiscovery = main.TRUE
         else:
             print "Number of hosts = %d and is wrong" %hostCount
-            main.log.info("Number of hosts = " + str(hostCount) +" and is wrong")
+            main.log.info( "Number of hosts = " + str( hostCount ) +" and is wrong" )
             hostDiscovery = main.FALSE
-        '''
-
+        """
         case22_result = opticalSW_result and packetSW_result
-        utilities.assert_equals(expect=main.TRUE, actual=case22_result,
-                onpass="Packet optical topology discovery successful",
-                onfail="Packet optical topology discovery failed")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case22_result,
+            onpass="Packet optical topology discovery successful",
+            onfail="Packet optical topology discovery failed" )
 
-    def CASE23(self, main):
+    def CASE23( self, main ):
         import time
-        '''
-            Add bidirectional point intents between 2 packet layer(mininet) devices and 
+        """
+            Add bidirectional point intents between 2 packet layer( mininet ) devices and
             ping mininet hosts
-        '''
-        main.log.report("This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts")
-        main.case("Topology comparision")
-        main.step("Adding point intents")
-        ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0001/1", "of:0000ffffffff0002/1")
+        """
+        main.log.report(
+            "This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts" )
+        main.case( "Topology comparision" )
+        main.step( "Adding point intents" )
+        ptp_intent_result = main.ONOS3.add_point_intent(
+            "of:0000ffffffff0001/1",
+            "of:0000ffffffff0002/1" )
         if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS3.intents(json_format = False)
-            main.log.info("Point to point intent install successful")
+            get_intent_result = main.ONOS3.intents( json_format=False )
+            main.log.info( "Point to point intent install successful" )
 
-        ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0002/1", "of:0000ffffffff0001/1")
+        ptp_intent_result = main.ONOS3.add_point_intent(
+            "of:0000ffffffff0002/1",
+            "of:0000ffffffff0001/1" )
         if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS3.intents(json_format = False)
-            main.log.info("Point to point intent install successful")
+            get_intent_result = main.ONOS3.intents( json_format=False )
+            main.log.info( "Point to point intent install successful" )
 
-        time.sleep(10)
+        time.sleep( 10 )
         flowHandle = main.ONOS3.flows()
-        main.log.info("flows :" + flowHandle)
+        main.log.info( "flows :" + flowHandle )
 
         # Sleep for 30 seconds to provide time for the intent state to change
-        time.sleep(30)
-        intentHandle = main.ONOS3.intents(json_format = False)        
-        main.log.info("intents :" + intentHandle)        
- 
+        time.sleep( 30 )
+        intentHandle = main.ONOS3.intents( json_format=False )
+        main.log.info( "intents :" + intentHandle )
+
         Ping_Result = main.TRUE
         count = 1
-        main.log.info("\n\nh1 is Pinging h2")
-        ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+        main.log.info( "\n\nh1 is Pinging h2" )
+        ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
         #ping = main.LincOE2.pinghost()
-        if ping == main.FALSE and count<5:
-            count+=1
+        if ping == main.FALSE and count < 5:
+            count += 1
             Ping_Result = main.FALSE
-            main.log.info("Ping between h1 and h2  failed. Making attempt number "+str(count) + " in 2 seconds")
-            time.sleep(2)
-        elif ping==main.FALSE:
-            main.log.info("All ping attempts between h1 and h2 have failed")
+            main.log.info(
+                "Ping between h1 and h2  failed. Making attempt number " +
+                str( count ) +
+                " in 2 seconds" )
+            time.sleep( 2 )
+        elif ping == main.FALSE:
+            main.log.info( "All ping attempts between h1 and h2 have failed" )
             Ping_Result = main.FALSE
-        elif ping==main.TRUE:
-            main.log.info("Ping test between h1 and h2 passed!")
+        elif ping == main.TRUE:
+            main.log.info( "Ping test between h1 and h2 passed!" )
             Ping_Result = main.TRUE
         else:
-            main.log.info("Unknown error")
+            main.log.info( "Unknown error" )
             Ping_Result = main.ERROR
-        
-        if Ping_Result==main.FALSE:
-            main.log.report("Point intents for packet optical have not ben installed correctly. Cleaning up")
-        if Ping_Result==main.TRUE:
-            main.log.report("Point Intents for packet optical have been installed correctly")
+
+        if Ping_Result == main.FALSE:
+            main.log.report(
+                "Point intents for packet optical have not ben installed correctly. Cleaning up" )
+        if Ping_Result == main.TRUE:
+            main.log.report(
+                "Point Intents for packet optical have been installed correctly" )
 
         case23_result = Ping_Result
-        utilities.assert_equals(expect=main.TRUE, actual=case23_result,
-                onpass="Point intents addition for packet optical and Pingall Test successful",
-                onfail="Point intents addition for packet optical and Pingall Test NOT successful")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case23_result,
+            onpass="Point intents addition for packet optical and Pingall Test successful",
+            onfail="Point intents addition for packet optical and Pingall Test NOT successful" )
 
-
-
-    def CASE24(self, main):
+    def CASE24( self, main ):
         import time
         import json
-        '''
-            Test Rerouting of Packet Optical by bringing a port down (port 22) of a switch(switchID=1), so that link (between switch1 port22 - switch4-port30) is inactive
+        """
+            Test Rerouting of Packet Optical by bringing a port down ( port 22 ) of a switch( switchID=1 ), so that link ( between switch1 port22 - switch4-port30 ) is inactive
             and do a ping test. If rerouting is successful, ping should pass. also check the flows
-        '''
-        main.log.report("This testcase tests rerouting and pings mininet hosts")
-        main.case("Test rerouting and pings mininet hosts")
-        main.step("Bring a port down and verify the link state")
-        main.LincOE1.port_down(sw_id="1", pt_id="22") 
-        links_nonjson = main.ONOS3.links(json_format = False)
-        main.log.info("links = " +links_nonjson)
+        """
+        main.log.report(
+            "This testcase tests rerouting and pings mininet hosts" )
+        main.case( "Test rerouting and pings mininet hosts" )
+        main.step( "Bring a port down and verify the link state" )
+        main.LincOE1.port_down( sw_id="1", pt_id="22" )
+        links_nonjson = main.ONOS3.links( json_format=False )
+        main.log.info( "links = " + links_nonjson )
 
         links = main.ONOS3.links()
-        main.log.info("links = " +links)
-        
-        links_result = json.loads(links)
+        main.log.info( "links = " + links )
+
+        links_result = json.loads( links )
         links_state_result = main.FALSE
         for item in links_result:
-            if item['src']['device'] == "of:0000ffffffffff01" and item['src']['port'] == "22":
-                if item['dst']['device'] == "of:0000ffffffffff04" and item['dst']['port'] == "30":
-                    links_state = item['state']
+            if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
+                    'src' ][ 'port' ] == "22":
+                if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
+                        'dst' ][ 'port' ] == "30":
+                    links_state = item[ 'state' ]
                     if links_state == "INACTIVE":
-                        main.log.info("Links state is inactive as expected due to one of the ports being down")
-                        main.log.report("Links state is inactive as expected due to one of the ports being down")
+                        main.log.info(
+                            "Links state is inactive as expected due to one of the ports being down" )
+                        main.log.report(
+                            "Links state is inactive as expected due to one of the ports being down" )
                         links_state_result = main.TRUE
                         break
                     else:
-                        main.log.info("Links state is not inactive as expected")
-                        main.log.report("Links state is not inactive as expected")
+                        main.log.info(
+                            "Links state is not inactive as expected" )
+                        main.log.report(
+                            "Links state is not inactive as expected" )
                         links_state_result = main.FALSE
 
         print "links_state_result = ", links_state_result
-        time.sleep(10)
+        time.sleep( 10 )
         flowHandle = main.ONOS3.flows()
-        main.log.info("flows :" + flowHandle)
+        main.log.info( "flows :" + flowHandle )
 
-        main.step("Verify Rerouting by a ping test")
+        main.step( "Verify Rerouting by a ping test" )
         Ping_Result = main.TRUE
-        count = 1        
-        main.log.info("\n\nh1 is Pinging h2")
-        ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+        count = 1
+        main.log.info( "\n\nh1 is Pinging h2" )
+        ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
         #ping = main.LincOE2.pinghost()
-        if ping == main.FALSE and count<5:
-            count+=1
+        if ping == main.FALSE and count < 5:
+            count += 1
             Ping_Result = main.FALSE
-            main.log.info("Ping between h1 and h2  failed. Making attempt number "+str(count) + " in 2 seconds")
-            time.sleep(2)
-        elif ping==main.FALSE:
-            main.log.info("All ping attempts between h1 and h2 have failed")
+            main.log.info(
+                "Ping between h1 and h2  failed. Making attempt number " +
+                str( count ) +
+                " in 2 seconds" )
+            time.sleep( 2 )
+        elif ping == main.FALSE:
+            main.log.info( "All ping attempts between h1 and h2 have failed" )
             Ping_Result = main.FALSE
-        elif ping==main.TRUE:
-            main.log.info("Ping test between h1 and h2 passed!")
+        elif ping == main.TRUE:
+            main.log.info( "Ping test between h1 and h2 passed!" )
             Ping_Result = main.TRUE
         else:
-            main.log.info("Unknown error")
+            main.log.info( "Unknown error" )
             Ping_Result = main.ERROR
 
-        if Ping_Result==main.TRUE:
-            main.log.report("Ping test successful ")
-        if Ping_Result==main.FALSE:
-            main.log.report("Ping test failed")
+        if Ping_Result == main.TRUE:
+            main.log.report( "Ping test successful " )
+        if Ping_Result == main.FALSE:
+            main.log.report( "Ping test failed" )
 
         case24_result = Ping_Result and links_state_result
-        utilities.assert_equals(expect=main.TRUE, actual=case24_result,
-                onpass="Packet optical rerouting successful",
-                onfail="Packet optical rerouting failed")
+        utilities.assert_equals( expect=main.TRUE, actual=case24_result,
+                                 onpass="Packet optical rerouting successful",
+                                 onfail="Packet optical rerouting failed" )
 
-    def CASE4(self, main):
+    def CASE4( self, main ):
         import re
         import time
-        main.log.report("This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode")
-        main.log.report("__________________________________")
-        main.case("Pingall Test")
-        main.step("Assigning switches to controllers")
-        for i in range(1,29):
-            if i ==1:
-                main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
-            elif i>=2 and i<5:
-                main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
-            elif i>=5 and i<8:
-                main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
-            elif i>=8 and i<18:
-                main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
-            elif i>=18 and i<28:
-                main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
+        main.log.report(
+            "This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode" )
+        main.log.report( "__________________________________" )
+        main.case( "Pingall Test" )
+        main.step( "Assigning switches to controllers" )
+        for i in range( 1, 29 ):
+            if i == 1:
+                main.Mininet1.assign_sw_controller(
+                    sw=str( i ),
+                    ip1=ONOS1_ip,
+                    port1=ONOS1_port )
+            elif i >= 2 and i < 5:
+                main.Mininet1.assign_sw_controller(
+                    sw=str( i ),
+                    ip1=ONOS1_ip,
+                    port1=ONOS1_port )
+            elif i >= 5 and i < 8:
+                main.Mininet1.assign_sw_controller(
+                    sw=str( i ),
+                    ip1=ONOS1_ip,
+                    port1=ONOS1_port )
+            elif i >= 8 and i < 18:
+                main.Mininet1.assign_sw_controller(
+                    sw=str( i ),
+                    ip1=ONOS1_ip,
+                    port1=ONOS1_port )
+            elif i >= 18 and i < 28:
+                main.Mininet1.assign_sw_controller(
+                    sw=str( i ),
+                    ip1=ONOS1_ip,
+                    port1=ONOS1_port )
             else:
-                main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
+                main.Mininet1.assign_sw_controller(
+                    sw=str( i ),
+                    ip1=ONOS1_ip,
+                    port1=ONOS1_port )
         Switch_Mastership = main.TRUE
-        for i in range (1,29):
-            if i==1:
-                response = main.Mininet1.get_sw_controller("s"+str(i))
-                print("Response is " + str(response))
-                if re.search("tcp:"+ONOS1_ip,response):
+        for i in range( 1, 29 ):
+            if i == 1:
+                response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+                print( "Response is " + str( response ) )
+                if re.search( "tcp:" + ONOS1_ip, response ):
                     Switch_Mastership = Switch_Mastership and main.TRUE
                 else:
                     Switch_Mastership = main.FALSE
-            elif i>=2 and i<5:
-                response = main.Mininet1.get_sw_controller("s"+str(i))
-                print("Response is " + str(response))
-                if re.search("tcp:"+ONOS1_ip,response):
+            elif i >= 2 and i < 5:
+                response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+                print( "Response is " + str( response ) )
+                if re.search( "tcp:" + ONOS1_ip, response ):
                     Switch_Mastership = Switch_Mastership and main.TRUE
                 else:
                     Switch_Mastership = main.FALSE
-            elif i>=5 and i<8:
-                response = main.Mininet1.get_sw_controller("s"+str(i))
-                print("Response is " + str(response))
-                if re.search("tcp:"+ONOS1_ip,response):
+            elif i >= 5 and i < 8:
+                response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+                print( "Response is " + str( response ) )
+                if re.search( "tcp:" + ONOS1_ip, response ):
                     Switch_Mastership = Switch_Mastership and main.TRUE
                 else:
                     Switch_Mastership = main.FALSE
-            elif i>=8 and i<18:
-                response = main.Mininet1.get_sw_controller("s"+str(i))
-                print("Response is " + str(response))
-                if re.search("tcp:"+ONOS1_ip,response):
+            elif i >= 8 and i < 18:
+                response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+                print( "Response is " + str( response ) )
+                if re.search( "tcp:" + ONOS1_ip, response ):
                     Switch_Mastership = Switch_Mastership and main.TRUE
                 else:
                     Switch_Mastership = main.FALSE
-            elif i>=18 and i<28:
-                response = main.Mininet1.get_sw_controller("s"+str(i))
-                print("Response is " + str(response))
-                if re.search("tcp:"+ONOS1_ip,response):
+            elif i >= 18 and i < 28:
+                response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+                print( "Response is " + str( response ) )
+                if re.search( "tcp:" + ONOS1_ip, response ):
                     Switch_Mastership = Switch_Mastership and main.TRUE
                 else:
                     Switch_Mastership = main.FALSE
             else:
-                response = main.Mininet1.get_sw_controller("s"+str(i))
-                print("Response is" + str(response))
-                if re.search("tcp:" +ONOS1_ip,response):
+                response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+                print( "Response is" + str( response ) )
+                if re.search( "tcp:" + ONOS1_ip, response ):
                     Switch_Mastership = Switch_Mastership and main.TRUE
                 else:
                     Switch_Mastership = main.FALSE
 
         if Switch_Mastership == main.TRUE:
-            main.log.report("Controller assignmnet successful")
+            main.log.report( "Controller assignmnet successful" )
         else:
-            main.log.report("Controller assignmnet failed")
-        utilities.assert_equals(expect = main.TRUE,actual=Switch_Mastership,
-                onpass="MasterControllers assigned correctly")
-        '''
-        for i in range (1,29):
-            main.Mininet1.assign_sw_controller(sw=str(i),count=5,
+            main.log.report( "Controller assignmnet failed" )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=Switch_Mastership,
+            onpass="MasterControllers assigned correctly" )
+        """
+        for i in range ( 1,29 ):
+            main.Mininet1.assign_sw_controller( sw=str( i ),count=5,
                     ip1=ONOS1_ip,port1=ONOS1_port,
                     ip2=ONOS2_ip,port2=ONOS2_port,
                     ip3=ONOS3_ip,port3=ONOS3_port,
                     ip4=ONOS4_ip,port4=ONOS4_port,
-                    ip5=ONOS5_ip,port5=ONOS5_port)
-        '''
-        #REACTIVE FWD test
+                    ip5=ONOS5_ip,port5=ONOS5_port )
+        """
+        # REACTIVE FWD test
 
-        main.step("Get list of hosts from Mininet")
+        main.step( "Get list of hosts from Mininet" )
         host_list = main.Mininet1.get_hosts()
-        main.log.info(host_list)
+        main.log.info( host_list )
 
-        main.step("Get host list in ONOS format")
-        host_onos_list = main.ONOS2.get_hosts_id(host_list)
-        main.log.info(host_onos_list)
-        #time.sleep(5)
-        
-        main.step("Pingall")
+        main.step( "Get host list in ONOS format" )
+        host_onos_list = main.ONOS2.get_hosts_id( host_list )
+        main.log.info( host_onos_list )
+        # time.sleep( 5 )
+
+        main.step( "Pingall" )
         ping_result = main.FALSE
         while ping_result == main.FALSE:
             time1 = time.time()
             ping_result = main.Mininet1.pingall()
             time2 = time.time()
-            print "Time for pingall: %2f seconds" % (time2 - time1)
-      
-        #Start onos cli again because u might have dropped out of onos prompt to the shell prompt
-        #if there was no activity
-        main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+            print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
+        # Start onos cli again because u might have dropped out of onos prompt to the shell prompt
+        # if there was no activity
+        main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
 
         case4_result = Switch_Mastership and ping_result
         if ping_result == main.TRUE:
-            main.log.report("Pingall Test in reactive mode to discover the hosts successful") 
+            main.log.report(
+                "Pingall Test in reactive mode to discover the hosts successful" )
         else:
-            main.log.report("Pingall Test in reactive mode to discover the hosts failed")
+            main.log.report(
+                "Pingall Test in reactive mode to discover the hosts failed" )
 
-        utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")   
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case4_result,
+            onpass="Controller assignment and Pingall Test successful",
+            onfail="Controller assignment and Pingall Test NOT successful" )
 
-    def CASE10(self):
-        main.log.report("This testcase uninstalls the reactive forwarding app")
-        main.log.report("__________________________________")
-        main.case("Uninstalling reactive forwarding app")
-        #Unistall onos-app-fwd app to disable reactive forwarding
-        appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
-        main.log.info("onos-app-fwd uninstalled")
+    def CASE10( self ):
+        main.log.report(
+            "This testcase uninstalls the reactive forwarding app" )
+        main.log.report( "__________________________________" )
+        main.case( "Uninstalling reactive forwarding app" )
+        # Unistall onos-app-fwd app to disable reactive forwarding
+        appUninstall_result = main.ONOS2.feature_uninstall( "onos-app-fwd" )
+        main.log.info( "onos-app-fwd uninstalled" )
 
-        #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
-        #So sleep for 15s
-        time.sleep(15)
+        # After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+        # So sleep for 15s
+        time.sleep( 15 )
 
         flows = main.ONOS2.flows()
-        main.log.info(flows)
+        main.log.info( flows )
 
         case10_result = appUninstall_result
-        utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed") 
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case10_result,
+            onpass="Reactive forwarding app uninstallation successful",
+            onfail="Reactive forwarding app uninstallation failed" )
 
-    
-    def CASE6(self):
-        main.log.report("This testcase is testing the addition of host intents and then does pingall")
-        main.log.report("__________________________________")
-        main.case("Obtaining host id's")
-        main.step("Get hosts")
+    def CASE6( self ):
+        main.log.report(
+            "This testcase is testing the addition of host intents and then does pingall" )
+        main.log.report( "__________________________________" )
+        main.case( "Obtaining host id's" )
+        main.step( "Get hosts" )
         hosts = main.ONOS2.hosts()
-        #main.log.info(hosts)
+        # main.log.info( hosts )
 
-        main.step("Get all devices id")
+        main.step( "Get all devices id" )
         devices_id_list = main.ONOS2.get_all_devices_id()
-        #main.log.info(devices_id_list)
-        
-        #ONOS displays the hosts in hex format unlike mininet which does in decimal format
-        #So take care while adding intents
-        '''
-        main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
-        hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
-        hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
-        hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
-        hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
-        hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
-        hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
-        hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
-        hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
-        hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1") 
-        hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
-        print "_____________________________________________________________________________________"
-        '''
-        
-        for i in range(8,18):
-            main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
-            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
-            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
-            #NOTE: get host can return None
-            #TODO: handle this
-            host1_id = main.ONOS2.get_host(host1)['id']
-            host2_id = main.ONOS2.get_host(host2)['id']
-            tmp_result = main.ONOS2.add_host_intent(host1_id, host2_id )        
+        # main.log.info( devices_id_list )
 
-        time.sleep(10)
-        h_intents = main.ONOS2.intents(json_format = False)
-        main.log.info("intents:" +h_intents)
+        # ONOS displays the hosts in hex format unlike mininet which does in decimal format
+        # So take care while adding intents
+        """
+        main.step( "Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
+        hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
+        hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
+        hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
+        hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
+        hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
+        hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
+        hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
+        hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
+        hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
+        hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
+        print "_____________________________________________________________________________________"
+        """
+        for i in range( 8, 18 ):
+            main.log.info(
+                "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) )
+            host1 = "00:00:00:00:00:" + \
+                str( hex( i )[ 2: ] ).zfill( 2 ).upper()
+            host2 = "00:00:00:00:00:" + \
+                str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
+            # NOTE: get host can return None
+            # TODO: handle this
+            host1_id = main.ONOS2.get_host( host1 )[ 'id' ]
+            host2_id = main.ONOS2.get_host( host2 )[ 'id' ]
+            tmp_result = main.ONOS2.add_host_intent( host1_id, host2_id )
+
+        time.sleep( 10 )
+        h_intents = main.ONOS2.intents( json_format=False )
+        main.log.info( "intents:" + h_intents )
         flowHandle = main.ONOS2.flows()
-        #main.log.info("flow:" +flowHandle)
+        #main.log.info( "flow:" +flowHandle )
 
         count = 1
         i = 8
         Ping_Result = main.TRUE
-        #while i<10:
-        while i <18 :
-            main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
-            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
-            if ping == main.FALSE and count <5:
-                count+=1
+        # while i<10:
+        while i < 18:
+            main.log.info(
+                "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+            ping = main.Mininet1.pingHost(
+                src="h" + str( i ), target="h" + str( i + 10 ) )
+            if ping == main.FALSE and count < 5:
+                count += 1
                 #i = 8
                 Ping_Result = main.FALSE
-                main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
-                time.sleep(2)
-            elif ping==main.FALSE:
-                main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
-                i=19
+                main.log.report( "Ping between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 " failed. Making attempt number " +
+                                 str( count ) +
+                                 " in 2 seconds" )
+                time.sleep( 2 )
+            elif ping == main.FALSE:
+                main.log.report( "All ping attempts between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 "have failed" )
+                i = 19
                 Ping_Result = main.FALSE
-            elif ping==main.TRUE:
-                main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
-                i+=1
+            elif ping == main.TRUE:
+                main.log.info( "Ping test between h" +
+                               str( i ) +
+                               " and h" +
+                               str( i +
+                                    10 ) +
+                               "passed!" )
+                i += 1
                 Ping_Result = main.TRUE
             else:
-                main.log.info("Unknown error")
+                main.log.info( "Unknown error" )
                 Ping_Result = main.ERROR
-        if Ping_Result==main.FALSE:
-            main.log.report("Ping all test after Host intent addition failed. Cleaning up")
-            #main.cleanup()
-            #main.exit()
-        if Ping_Result==main.TRUE:
-            main.log.report("Ping all test after Host intent addition successful")
-            
+        if Ping_Result == main.FALSE:
+            main.log.report(
+                "Ping all test after Host intent addition failed. Cleaning up" )
+            # main.cleanup()
+            # main.exit()
+        if Ping_Result == main.TRUE:
+            main.log.report(
+                "Ping all test after Host intent addition successful" )
+
         case6_result = Ping_Result
-        utilities.assert_equals(expect=main.TRUE, actual=case6_result,
-                onpass="Pingall Test after Host intents addition successful",
-                onfail="Pingall Test after Host intents addition failed")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case6_result,
+            onpass="Pingall Test after Host intents addition successful",
+            onfail="Pingall Test after Host intents addition failed" )
 
-
-    def CASE5(self,main) :
+    def CASE5( self, main ):
         import json
         from subprocess import Popen, PIPE
-        from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
-        #main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+        # assumes that sts is already in you PYTHONPATH
+        from sts.topology.teston_topology import TestONTopology
+        # main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
         deviceResult = main.ONOS2.devices()
         linksResult = main.ONOS2.links()
         #portsResult = main.ONOS2.ports()
         print "**************"
 
-        main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet")
-        main.log.report("__________________________________")
-        main.case("Comparing Mininet topology with the topology of ONOS")
-        main.step("Start continuous pings")
-        main.Mininet2.pingLong(src=main.params['PING']['source1'],
-                            target=main.params['PING']['target1'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source2'],
-                            target=main.params['PING']['target2'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source3'],
-                            target=main.params['PING']['target3'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source4'],
-                            target=main.params['PING']['target4'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source5'],
-                            target=main.params['PING']['target5'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source6'],
-                            target=main.params['PING']['target6'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source7'],
-                            target=main.params['PING']['target7'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source8'],
-                            target=main.params['PING']['target8'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source9'],
-                            target=main.params['PING']['target9'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source10'],
-                            target=main.params['PING']['target10'],pingTime=500)
+        main.log.report(
+            "This testcase is testing if all ONOS nodes are in topology sync with mininet" )
+        main.log.report( "__________________________________" )
+        main.case( "Comparing Mininet topology with the topology of ONOS" )
+        main.step( "Start continuous pings" )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source1' ],
+            target=main.params[ 'PING' ][ 'target1' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source2' ],
+            target=main.params[ 'PING' ][ 'target2' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source3' ],
+            target=main.params[ 'PING' ][ 'target3' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source4' ],
+            target=main.params[ 'PING' ][ 'target4' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source5' ],
+            target=main.params[ 'PING' ][ 'target5' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source6' ],
+            target=main.params[ 'PING' ][ 'target6' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source7' ],
+            target=main.params[ 'PING' ][ 'target7' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source8' ],
+            target=main.params[ 'PING' ][ 'target8' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source9' ],
+            target=main.params[ 'PING' ][ 'target9' ],
+            pingTime=500 )
+        main.Mininet2.pingLong(
+            src=main.params[ 'PING' ][ 'source10' ],
+            target=main.params[ 'PING' ][ 'target10' ],
+            pingTime=500 )
 
-        main.step("Create TestONTopology object")
+        main.step( "Create TestONTopology object" )
         global ctrls
         ctrls = []
         count = 1
         while True:
             temp = ()
-            if ('ip' + str(count)) in main.params['CTRL']:
-                temp = temp + (getattr(main,('ONOS' + str(count))),)
-                temp = temp + ("ONOS"+str(count),)
-                temp = temp + (main.params['CTRL']['ip'+str(count)],)
-                temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
-                ctrls.append(temp)
+            if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
+                temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
+                temp = temp + ( "ONOS" + str( count ), )
+                temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
+                temp = temp + \
+                    ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
+                ctrls.append( temp )
                 count = count + 1
             else:
                 break
         global MNTopo
-        Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+        Topo = TestONTopology(
+            main.Mininet1,
+            ctrls )  # can also add Intent API info for intent operations
         MNTopo = Topo
 
         Topology_Check = main.TRUE
-        main.step("Compare ONOS Topology to MN Topology")
+        main.step( "Compare ONOS Topology to MN Topology" )
         devices_json = main.ONOS2.devices()
         links_json = main.ONOS2.links()
         #ports_json = main.ONOS2.ports()
         print "devices_json= ", devices_json
-        
-        result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
-        result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
-        #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
-            
+
+        result1 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices_json ) )
+        result2 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links_json ) )
+        #result3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports_json ) )
+
         #result = result1 and result2 and result3
         result = result1 and result2
-        
+
         print "***********************"
         if result == main.TRUE:
-            main.log.report("ONOS"+ " Topology matches MN Topology")
+            main.log.report( "ONOS" + " Topology matches MN Topology" )
         else:
-            main.log.report("ONOS"+ " Topology does not match MN Topology") 
+            main.log.report( "ONOS" + " Topology does not match MN Topology" )
 
-        utilities.assert_equals(expect=main.TRUE,actual=result,
-            onpass="ONOS" + " Topology matches MN Topology",
-            onfail="ONOS" + " Topology does not match MN Topology")
-        
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=result,
+            onpass="ONOS" +
+            " Topology matches MN Topology",
+            onfail="ONOS" +
+            " Topology does not match MN Topology" )
+
         Topology_Check = Topology_Check and result
-        utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
-            onpass="Topology checks passed", onfail="Topology checks failed")
-    
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=Topology_Check,
+            onpass="Topology checks passed",
+            onfail="Topology checks failed" )
 
-    def CASE7 (self,main):
-       
-        ONOS1_ip = main.params['CTRL']['ip1']
+    def CASE7( self, main ):
 
-        link_sleep = int(main.params['timers']['LinkDiscovery'])
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
 
-        main.log.report("This testscase is killing a link to ensure that link discovery is consistent")
-        main.log.report("__________________________________")
-        main.log.report("Killing a link to ensure that link discovery is consistent")
-        main.case("Killing a link to Ensure that Link Discovery is Working Properly")
-        '''
-        main.step("Start continuous pings")
-       
-        main.Mininet2.pingLong(src=main.params['PING']['source1'],
-                            target=main.params['PING']['target1'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source2'],
-                            target=main.params['PING']['target2'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source3'],
-                            target=main.params['PING']['target3'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source4'],
-                            target=main.params['PING']['target4'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source5'],
-                            target=main.params['PING']['target5'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source6'],
-                            target=main.params['PING']['target6'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source7'],
-                            target=main.params['PING']['target7'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source8'],
-                            target=main.params['PING']['target8'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source9'],
-                            target=main.params['PING']['target9'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source10'],
-                            target=main.params['PING']['target10'],pingTime=500)
-        '''
+        link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
 
-        main.step("Determine the current number of switches and links")
+        main.log.report(
+            "This testscase is killing a link to ensure that link discovery is consistent" )
+        main.log.report( "__________________________________" )
+        main.log.report(
+            "Killing a link to ensure that link discovery is consistent" )
+        main.case(
+            "Killing a link to Ensure that Link Discovery is Working Properly" )
+        """
+        main.step( "Start continuous pings" )
+
+        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
+                            target=main.params[ 'PING' ][ 'target1' ],pingTime=500 )
+        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
+                            target=main.params[ 'PING' ][ 'target2' ],pingTime=500 )
+        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
+                            target=main.params[ 'PING' ][ 'target3' ],pingTime=500 )
+        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
+                            target=main.params[ 'PING' ][ 'target4' ],pingTime=500 )
+        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
+                            target=main.params[ 'PING' ][ 'target5' ],pingTime=500 )
+        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
+                            target=main.params[ 'PING' ][ 'target6' ],pingTime=500 )
+        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
+                            target=main.params[ 'PING' ][ 'target7' ],pingTime=500 )
+        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
+                            target=main.params[ 'PING' ][ 'target8' ],pingTime=500 )
+        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
+                            target=main.params[ 'PING' ][ 'target9' ],pingTime=500 )
+        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
+                            target=main.params[ 'PING' ][ 'target10' ],pingTime=500 )
+        """
+        main.step( "Determine the current number of switches and links" )
         topology_output = main.ONOS2.topology()
-        topology_result = main.ONOS1.get_topology(topology_output)
-        activeSwitches = topology_result['devices']
-        links = topology_result['links']
-        print "activeSwitches = ", type(activeSwitches)
-        print "links = ", type(links)
-        main.log.info("Currently there are %s switches and %s links"  %(str(activeSwitches), str(links)))
+        topology_result = main.ONOS1.get_topology( topology_output )
+        activeSwitches = topology_result[ 'devices' ]
+        links = topology_result[ 'links' ]
+        print "activeSwitches = ", type( activeSwitches )
+        print "links = ", type( links )
+        main.log.info(
+            "Currently there are %s switches and %s links" %
+            ( str( activeSwitches ), str( links ) ) )
 
-        main.step("Kill Link between s3 and s28")
-        main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
-        time.sleep(link_sleep)
+        main.step( "Kill Link between s3 and s28" )
+        main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
+        time.sleep( link_sleep )
         topology_output = main.ONOS2.topology()
-        Link_Down = main.ONOS1.check_status(topology_output,activeSwitches,str(int(links)-2))
+        Link_Down = main.ONOS1.check_status(
+            topology_output, activeSwitches, str(
+                int( links ) - 2 ) )
         if Link_Down == main.TRUE:
-            main.log.report("Link Down discovered properly")
-        utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
-                onpass="Link Down discovered properly",
-                onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
-       
-        #Check ping result here..add code for it
-         
-        main.step("Bring link between s3 and s28 back up")
-        Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
-        time.sleep(link_sleep)
+            main.log.report( "Link Down discovered properly" )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=Link_Down,
+            onpass="Link Down discovered properly",
+            onfail="Link down was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
+
+        # Check ping result here..add code for it
+
+        main.step( "Bring link between s3 and s28 back up" )
+        Link_Up = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
+        time.sleep( link_sleep )
         topology_output = main.ONOS2.topology()
-        Link_Up = main.ONOS1.check_status(topology_output,activeSwitches,str(links))
+        Link_Up = main.ONOS1.check_status(
+            topology_output,
+            activeSwitches,
+            str( links ) )
         if Link_Up == main.TRUE:
-            main.log.report("Link up discovered properly")
-        utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
-                onpass="Link up discovered properly",
-                onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
-            
-        #NOTE Check ping result here..add code for it
-        
-        
-        main.step("Compare ONOS Topology to MN Topology")
-        Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+            main.log.report( "Link up discovered properly" )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=Link_Up,
+            onpass="Link up discovered properly",
+            onfail="Link up was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
+
+        # NOTE Check ping result here..add code for it
+
+        main.step( "Compare ONOS Topology to MN Topology" )
+        Topo = TestONTopology(
+            main.Mininet1,
+            ctrls )  # can also add Intent API info for intent operations
         MNTopo = Topo
         Topology_Check = main.TRUE
-        
+
         devices_json = main.ONOS2.devices()
         links_json = main.ONOS2.links()
         ports_json = main.ONOS2.ports()
         print "devices_json= ", devices_json
-        
-        result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
-        result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
-        #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
-            
+
+        result1 = main.Mininet1.compare_switches(
+            MNTopo,
+            json.loads( devices_json ) )
+        result2 = main.Mininet1.compare_links(
+            MNTopo,
+            json.loads( links_json ) )
+        #result3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports_json ) )
+
         #result = result1 and result2 and result3
         result = result1 and result2
         print "***********************"
-        
+
         if result == main.TRUE:
-            main.log.report("ONOS"+ " Topology matches MN Topology")
-        utilities.assert_equals(expect=main.TRUE,actual=result,
-            onpass="ONOS" + " Topology matches MN Topology",
-            onfail="ONOS" + " Topology does not match MN Topology")
-        
+            main.log.report( "ONOS" + " Topology matches MN Topology" )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=result,
+            onpass="ONOS" +
+            " Topology matches MN Topology",
+            onfail="ONOS" +
+            " Topology does not match MN Topology" )
+
         Topology_Check = Topology_Check and result
-        utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
-            onpass="Topology checks passed", onfail="Topology checks failed")
-    
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=Topology_Check,
+            onpass="Topology checks passed",
+            onfail="Topology checks failed" )
+
         result = Link_Down and Link_Up and Topology_Check
-        utilities.assert_equals(expect=main.TRUE,actual=result,
-                onpass="Link failure is discovered correctly",
-                onfail="Link Discovery failed")
+        utilities.assert_equals( expect=main.TRUE, actual=result,
+                                 onpass="Link failure is discovered correctly",
+                                 onfail="Link Discovery failed" )
 
-
-    def CASE8(self):
-        '''
+    def CASE8( self ):
+        """
         Host intents removal
-        ''' 
-        main.log.report("This testcase removes any previously added intents before adding the same intents or point intents")
-        main.log.report("__________________________________")        
-        main.log.info("Host intents removal")
-        main.case("Removing host intents")
-        main.step("Obtain the intent id's")
-        intent_result = main.ONOS2.intents(json_format = False)
-        main.log.info("intent_result = " +intent_result)        
- 
-        intent_linewise = intent_result.split("\n")
+        """
+        main.log.report(
+            "This testcase removes any previously added intents before adding the same intents or point intents" )
+        main.log.report( "__________________________________" )
+        main.log.info( "Host intents removal" )
+        main.case( "Removing host intents" )
+        main.step( "Obtain the intent id's" )
+        intent_result = main.ONOS2.intents( json_format=False )
+        main.log.info( "intent_result = " + intent_result )
+
+        intent_linewise = intent_result.split( "\n" )
         intentList = []
         for line in intent_linewise:
-            if line.startswith("id="):
-                intentList.append(line)
-        
+            if line.startswith( "id=" ):
+                intentList.append( line )
+
         intentids = []
         for line in intentList:
-            intentids.append(line.split(",")[0].split("=")[1])
+            intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
         for id in intentids:
             print "id = ", id
-        
-        main.step("Iterate through the intentids list and remove each intent")
+
+        main.step(
+            "Iterate through the intentids list and remove each intent" )
         for id in intentids:
-            main.ONOS2.remove_intent(intent_id = id)
-        
-        intent_result = main.ONOS2.intents(json_format = False)
-        main.log.info("intent_result = " +intent_result)        
+            main.ONOS2.remove_intent( intent_id=id )
+
+        intent_result = main.ONOS2.intents( json_format=False )
+        main.log.info( "intent_result = " + intent_result )
 
         case8_result = main.TRUE
         if case8_result == main.TRUE:
-            main.log.report("Intent removal successful")
+            main.log.report( "Intent removal successful" )
         else:
-            main.log.report("Intent removal failed")
-       
+            main.log.report( "Intent removal failed" )
+
         Ping_Result = main.TRUE
         if case8_result == main.TRUE:
             i = 8
-            while i <18 :
-                main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
-                ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
-                if ping==main.TRUE:
+            while i < 18:
+                main.log.info(
+                    "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+                ping = main.Mininet1.pingHost(
+                    src="h" + str( i ), target="h" + str( i + 10 ) )
+                if ping == main.TRUE:
                     i = 19
                     Ping_Result = Ping_Result and main.TRUE
-                elif ping==main.FALSE:
-                    i+=1
+                elif ping == main.FALSE:
+                    i += 1
                     Ping_Result = Ping_Result and main.FALSE
                 else:
-                    main.log.info("Unknown error")
+                    main.log.info( "Unknown error" )
                     Ping_Result = main.ERROR
 
-            #Note: If the ping result failed, that means the intents have been withdrawn correctly.
-        if Ping_Result==main.TRUE:
-            main.log.report("Host intents have not been withdrawn correctly")
-            #main.cleanup()
-            #main.exit()
-        if Ping_Result==main.FALSE:
-            main.log.report("Host intents have been withdrawn correctly")
+            # Note: If the ping result failed, that means the intents have been
+            # withdrawn correctly.
+        if Ping_Result == main.TRUE:
+            main.log.report( "Host intents have not been withdrawn correctly" )
+            # main.cleanup()
+            # main.exit()
+        if Ping_Result == main.FALSE:
+            main.log.report( "Host intents have been withdrawn correctly" )
 
         case8_result = case8_result and Ping_Result
 
         if case8_result == main.FALSE:
-            main.log.report("Intent removal successful")
+            main.log.report( "Intent removal successful" )
         else:
-            main.log.report("Intent removal failed")
+            main.log.report( "Intent removal failed" )
 
-        utilities.assert_equals(expect=main.FALSE, actual=case8_result,
-                onpass="Intent removal test failed",
-                onfail="Intent removal test passed")
+        utilities.assert_equals( expect=main.FALSE, actual=case8_result,
+                                 onpass="Intent removal test failed",
+                                 onfail="Intent removal test passed" )
 
+    def CASE9( self ):
+        main.log.report(
+            "This testcase adds point intents and then does pingall" )
+        main.log.report( "__________________________________" )
+        main.log.info( "Adding point intents" )
+        main.case(
+            "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
+        main.step(
+            "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000003008/1",
+            "of:0000000000006018/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
 
-    def CASE9(self):
-        main.log.report("This testcase adds point intents and then does pingall")
-        main.log.report("__________________________________") 
-        main.log.info("Adding point intents")
-        main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)") 
-        main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000006018/1",
+            "of:0000000000003008/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-        
-        main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
 
-        main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
+        main.step(
+            "Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13" )
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000003009/1",
+            "of:0000000000006019/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-            
-        main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-            
-        main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
 
-        main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000006019/1",
+            "of:0000000000003009/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-            
-        main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-            
-        main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
-        if ptp_intent_result == main.TRUE:
-            get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
 
-
-        main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
+        main.step(
+            "Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14" )
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000003010/1",
+            "of:0000000000006020/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
-       
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000006020/1",
+            "of:0000000000003010/1" )
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
-            main.log.info("Point to point intent install successful")
-            #main.log.info(get_intent_result)
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
 
-        print("_______________________________________________________________________________________")
+        main.step(
+            "Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15" )
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000003011/1",
+            "of:0000000000006021/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000006021/1",
+            "of:0000000000003011/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16" )
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000003012/1",
+            "of:0000000000006022/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000006022/1",
+            "of:0000000000003012/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17" )
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000003013/1",
+            "of:0000000000006023/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000006023/1",
+            "of:0000000000003013/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18" )
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000003014/1",
+            "of:0000000000006024/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000006024/1",
+            "of:0000000000003014/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19" )
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000003015/1",
+            "of:0000000000006025/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000006025/1",
+            "of:0000000000003015/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A" )
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000003016/1",
+            "of:0000000000006026/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000006026/1",
+            "of:0000000000003016/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        main.step(
+            "Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B" )
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000003017/1",
+            "of:0000000000006027/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        ptp_intent_result = main.ONOS2.add_point_intent(
+            "of:0000000000006027/1",
+            "of:0000000000003017/1" )
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( get_intent_result )
+
+        print(
+            "_______________________________________________________________________________________" )
 
         flowHandle = main.ONOS2.flows()
-        #print "flowHandle = ", flowHandle
-        main.log.info("flows :" + flowHandle)        
+        # print "flowHandle = ", flowHandle
+        main.log.info( "flows :" + flowHandle )
 
         count = 1
         i = 8
         Ping_Result = main.TRUE
-        while i <18 :
-            main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
-            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
-            if ping == main.FALSE and count <5:
-                count+=1
+        while i < 18:
+            main.log.info(
+                "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
+            ping = main.Mininet1.pingHost(
+                src="h" + str( i ), target="h" + str( i + 10 ) )
+            if ping == main.FALSE and count < 5:
+                count += 1
                 #i = 8
                 Ping_Result = main.FALSE
-                main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
-                time.sleep(2)
-            elif ping==main.FALSE:
-                main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
-                i=19
+                main.log.report( "Ping between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 " failed. Making attempt number " +
+                                 str( count ) +
+                                 " in 2 seconds" )
+                time.sleep( 2 )
+            elif ping == main.FALSE:
+                main.log.report( "All ping attempts between h" +
+                                 str( i ) +
+                                 " and h" +
+                                 str( i +
+                                      10 ) +
+                                 "have failed" )
+                i = 19
                 Ping_Result = main.FALSE
-            elif ping==main.TRUE:
-                main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
-                i+=1
+            elif ping == main.TRUE:
+                main.log.info( "Ping test between h" +
+                               str( i ) +
+                               " and h" +
+                               str( i +
+                                    10 ) +
+                               "passed!" )
+                i += 1
                 Ping_Result = main.TRUE
             else:
-                main.log.info("Unknown error")
+                main.log.info( "Unknown error" )
                 Ping_Result = main.ERROR
 
-        if Ping_Result==main.FALSE:
-            main.log.report("Point intents have not ben installed correctly. Cleaning up")
-            #main.cleanup()
-            #main.exit()
-        if Ping_Result==main.TRUE:
-            main.log.report("Point Intents have been installed correctly")
+        if Ping_Result == main.FALSE:
+            main.log.report(
+                "Point intents have not ben installed correctly. Cleaning up" )
+            # main.cleanup()
+            # main.exit()
+        if Ping_Result == main.TRUE:
+            main.log.report( "Point Intents have been installed correctly" )
 
         case9_result = Ping_Result
-        utilities.assert_equals(expect=main.TRUE, actual=case9_result,
-                onpass="Point intents addition and Pingall Test successful",
-                onfail="Point intents addition and Pingall Test NOT successful")
-
-
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case9_result,
+            onpass="Point intents addition and Pingall Test successful",
+            onfail="Point intents addition and Pingall Test NOT successful" )
diff --git a/TestON/tests/SdnIpTest/SdnIpTest.py b/TestON/tests/SdnIpTest/SdnIpTest.py
old mode 100755
new mode 100644
index 4f55c02..081b1ca
--- a/TestON/tests/SdnIpTest/SdnIpTest.py
+++ b/TestON/tests/SdnIpTest/SdnIpTest.py
@@ -2,13 +2,14 @@
 
 # Testing the basic functionality of SDN-IP
 
+
 class SdnIpTest:
-    def __init__(self):
+
+    def __init__( self ):
         self.default = ''
 
-    def CASE1(self, main):
-
-        '''
+    def CASE1( self, main ):
+        """
         Test the SDN-IP functionality
         allRoutes_expected: all expected routes for all BGP peers
         routeIntents_expected: all expected MultiPointToSinglePointIntent intents
@@ -16,230 +17,272 @@
         allRoutes_actual: all routes from ONOS LCI
         routeIntents_actual: actual MultiPointToSinglePointIntent intents from ONOS CLI
         bgpIntents_actual: actual PointToPointIntent intents from ONOS CLI
-        '''
+        """
         import time
         import json
         from operator import eq
         # from datetime import datetime
         from time import localtime, strftime
 
-        main.case("The test case is to help to setup the TestON environment and test new drivers")
+        main.case(
+            "The test case is to help to setup the TestON environment and test new drivers" )
         SDNIP_JSON_FILE_PATH = "../tests/SdnIpTest/sdnip.json"
         # all expected routes for all BGP peers
         allRoutes_expected = []
-        main.step("Start to generate routes for all BGP peers")
+        main.step( "Start to generate routes for all BGP peers" )
         # bgpPeerHosts = []
-        # for i in range(3, 5):
-        #    bgpPeerHosts.append("host" + str(i))
-        # main.log.info("BGP Peer Hosts are:" + bgpPeerHosts)
+        # for i in range( 3, 5 ):
+        #    bgpPeerHosts.append( "host" + str( i ) )
+        # main.log.info( "BGP Peer Hosts are:" + bgpPeerHosts )
 
-        # for i in range(3, 5):
-         #   QuaggaCliHost = "QuaggaCliHost" + str(i)
-          #  prefixes = main.QuaggaCliHost.generate_prefixes(3, 10)
+        # for i in range( 3, 5 ):
+        #   QuaggaCliHost = "QuaggaCliHost" + str( i )
+        #  prefixes = main.QuaggaCliHost.generate_prefixes( 3, 10 )
 
-           # main.log.info(prefixes)
-            # allRoutes_expected.append(prefixes)
-        main.log.info("Generate prefixes for host3")
-        prefixes_host3 = main.QuaggaCliHost3.generate_prefixes(3, 10)
-        main.log.info(prefixes_host3)
+        # main.log.info( prefixes )
+        # allRoutes_expected.append( prefixes )
+        main.log.info( "Generate prefixes for host3" )
+        prefixes_host3 = main.QuaggaCliHost3.generate_prefixes( 3, 10 )
+        main.log.info( prefixes_host3 )
         # generate route with next hop
         for prefix in prefixes_host3:
-            allRoutes_expected.append(prefix + "/" + "192.168.20.1")
-        routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents(prefixes_host3, "192.168.20.1", "00:00:00:00:02:02", SDNIP_JSON_FILE_PATH)
+            allRoutes_expected.append( prefix + "/" + "192.168.20.1" )
+        routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents(
+            prefixes_host3,
+            "192.168.20.1",
+            "00:00:00:00:02:02",
+            SDNIP_JSON_FILE_PATH )
 
-        main.log.info("Generate prefixes for host4")
-        prefixes_host4 = main.QuaggaCliHost4.generate_prefixes(4, 10)
-        main.log.info(prefixes_host4)
+        main.log.info( "Generate prefixes for host4" )
+        prefixes_host4 = main.QuaggaCliHost4.generate_prefixes( 4, 10 )
+        main.log.info( prefixes_host4 )
         # generate route with next hop
         for prefix in prefixes_host4:
-            allRoutes_expected.append(prefix + "/" + "192.168.30.1")
-        routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents(prefixes_host4, "192.168.30.1", "00:00:00:00:03:01", SDNIP_JSON_FILE_PATH)
+            allRoutes_expected.append( prefix + "/" + "192.168.30.1" )
+        routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents(
+            prefixes_host4,
+            "192.168.30.1",
+            "00:00:00:00:03:01",
+            SDNIP_JSON_FILE_PATH )
 
-        routeIntents_expected = routeIntents_expected_host3 + routeIntents_expected_host4
+        routeIntents_expected = routeIntents_expected_host3 + \
+            routeIntents_expected_host4
 
-
-        cell_name = main.params['ENV']['cellName']
-        ONOS1_ip = main.params['CTRL']['ip1']
-        main.step("Set cell for ONOS-cli environment")
-        main.ONOScli.set_cell(cell_name)
+        cell_name = main.params[ 'ENV' ][ 'cellName' ]
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        main.step( "Set cell for ONOS-cli environment" )
+        main.ONOScli.set_cell( cell_name )
         verify_result = main.ONOSbench.verify_cell()
-        main.log.report("Removing raft logs")
+        main.log.report( "Removing raft logs" )
         main.ONOSbench.onos_remove_raft_logs()
-        main.log.report("Uninstalling ONOS")
-        main.ONOSbench.onos_uninstall(ONOS1_ip)
-        main.step("Creating ONOS package")
+        main.log.report( "Uninstalling ONOS" )
+        main.ONOSbench.onos_uninstall( ONOS1_ip )
+        main.step( "Creating ONOS package" )
         package_result = main.ONOSbench.onos_package()
 
-        main.step("Starting ONOS service")
+        main.step( "Starting ONOS service" )
         # TODO: start ONOS from Mininet Script
-        # start_result = main.ONOSbench.onos_start("127.0.0.1")
-        main.step("Installing ONOS package")
-        onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip)
+        # start_result = main.ONOSbench.onos_start( "127.0.0.1" )
+        main.step( "Installing ONOS package" )
+        onos1_install_result = main.ONOSbench.onos_install(
+            options="-f",
+            node=ONOS1_ip )
 
-        main.step("Checking if ONOS is up yet")
-        time.sleep(60)
-        onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+        main.step( "Checking if ONOS is up yet" )
+        time.sleep( 60 )
+        onos1_isup = main.ONOSbench.isup( ONOS1_ip )
         if not onos1_isup:
-            main.log.report("ONOS1 didn't start!")
+            main.log.report( "ONOS1 didn't start!" )
 
-        main.step("Start ONOS-cli")
+        main.step( "Start ONOS-cli" )
         # TODO: change the hardcode in start_onos_cli method in ONOS CLI driver
 
-        main.ONOScli.start_onos_cli(ONOS1_ip)
+        main.ONOScli.start_onos_cli( ONOS1_ip )
 
-        main.step("Get devices in the network")
-        list_result = main.ONOScli.devices(json_format=False)
-        main.log.info(list_result)
-        time.sleep(10)
-        main.log.info("Installing sdn-ip feature")
-        main.ONOScli.feature_install("onos-app-sdnip")
-        time.sleep(10)
-        main.step("Login all BGP peers and add routes into peers")
-        main.log.info("Login Quagga CLI on host3")
-        main.QuaggaCliHost3.loginQuagga("1.168.30.2")
-        main.log.info("Enter configuration model of Quagga CLI on host3")
-        main.QuaggaCliHost3.enter_config(64514)
-        main.log.info("Add routes to Quagga on host3")
-        main.QuaggaCliHost3.add_routes(prefixes_host3, 1)
+        main.step( "Get devices in the network" )
+        list_result = main.ONOScli.devices( json_format=False )
+        main.log.info( list_result )
+        time.sleep( 10 )
+        main.log.info( "Installing sdn-ip feature" )
+        main.ONOScli.feature_install( "onos-app-sdnip" )
+        time.sleep( 10 )
+        main.step( "Login all BGP peers and add routes into peers" )
+        main.log.info( "Login Quagga CLI on host3" )
+        main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+        main.log.info( "Enter configuration model of Quagga CLI on host3" )
+        main.QuaggaCliHost3.enter_config( 64514 )
+        main.log.info( "Add routes to Quagga on host3" )
+        main.QuaggaCliHost3.add_routes( prefixes_host3, 1 )
 
-        main.log.info("Login Quagga CLI on host4")
-        main.QuaggaCliHost4.loginQuagga("1.168.30.3")
-        main.log.info("Enter configuration model of Quagga CLI on host4")
-        main.QuaggaCliHost4.enter_config(64516)
-        main.log.info("Add routes to Quagga on host4")
-        main.QuaggaCliHost4.add_routes(prefixes_host4, 1)
-        time.sleep(60)
+        main.log.info( "Login Quagga CLI on host4" )
+        main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+        main.log.info( "Enter configuration model of Quagga CLI on host4" )
+        main.QuaggaCliHost4.enter_config( 64516 )
+        main.log.info( "Add routes to Quagga on host4" )
+        main.QuaggaCliHost4.add_routes( prefixes_host4, 1 )
+        time.sleep( 60 )
 
         # get all routes inside SDN-IP
-        get_routes_result = main.ONOScli.routes(json_format=True)
+        get_routes_result = main.ONOScli.routes( json_format=True )
 
         # parse routes from ONOS CLI
-        allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
+        allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(
+            get_routes_result )
 
-        allRoutes_str_expected = str(sorted(allRoutes_expected))
-        allRoutes_str_actual = str(allRoutes_actual).replace('u', "")
-        main.step("Check routes installed")
-        main.log.info("Routes expected:")
-        main.log.info(allRoutes_str_expected)
-        main.log.info("Routes get from ONOS CLI:")
-        main.log.info(allRoutes_str_actual)
-        utilities.assert_equals(expect=allRoutes_str_expected, actual=allRoutes_str_actual,
-                                onpass="***Routes in SDN-IP are correct!***",
-                                onfail="***Routes in SDN-IP are wrong!***")
-        if(eq(allRoutes_str_expected, allRoutes_str_actual)):
-            main.log.report("***Routes in SDN-IP after adding routes are correct!***")
+        allRoutes_str_expected = str( sorted( allRoutes_expected ) )
+        allRoutes_str_actual = str( allRoutes_actual ).replace( 'u', "" )
+        main.step( "Check routes installed" )
+        main.log.info( "Routes expected:" )
+        main.log.info( allRoutes_str_expected )
+        main.log.info( "Routes get from ONOS CLI:" )
+        main.log.info( allRoutes_str_actual )
+        utilities.assert_equals(
+            expect=allRoutes_str_expected,
+            actual=allRoutes_str_actual,
+            onpass="***Routes in SDN-IP are correct!***",
+            onfail="***Routes in SDN-IP are wrong!***" )
+        if( eq( allRoutes_str_expected, allRoutes_str_actual ) ):
+            main.log.report(
+                "***Routes in SDN-IP after adding routes are correct!***" )
         else:
-            main.log.report("***Routes in SDN-IP after adding routes are wrong!***")
+            main.log.report(
+                "***Routes in SDN-IP after adding routes are wrong!***" )
 
-        time.sleep(20)
-        get_intents_result = main.ONOScli.intents(json_format=True)
+        time.sleep( 20 )
+        get_intents_result = main.ONOScli.intents( json_format=True )
 
-
-        main.step("Check MultiPointToSinglePointIntent intents installed")
+        main.step( "Check MultiPointToSinglePointIntent intents installed" )
         # route_intents_expected are generated when generating routes
         # get rpoute intents from ONOS CLI
-        routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
-        routeIntents_str_expected = str(sorted(routeIntents_expected))
-        routeIntents_str_actual = str(routeIntents_actual).replace('u', "")
-        main.log.info("MultiPointToSinglePoint intents expected:")
-        main.log.info(routeIntents_str_expected)
-        main.log.info("MultiPointToSinglePoint intents get from ONOS CLI:")
-        main.log.info(routeIntents_str_actual)
-        utilities.assert_equals(expect=True, actual=eq(routeIntents_str_expected, routeIntents_str_actual),
-                                onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***",
-                                onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***")
+        routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(
+            get_intents_result )
+        routeIntents_str_expected = str( sorted( routeIntents_expected ) )
+        routeIntents_str_actual = str( routeIntents_actual ).replace( 'u', "" )
+        main.log.info( "MultiPointToSinglePoint intents expected:" )
+        main.log.info( routeIntents_str_expected )
+        main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
+        main.log.info( routeIntents_str_actual )
+        utilities.assert_equals(
+            expect=True,
+            actual=eq(
+                routeIntents_str_expected,
+                routeIntents_str_actual ),
+            onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***",
+            onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***" )
 
-        if(eq(routeIntents_str_expected, routeIntents_str_actual)):
-            main.log.report("***MultiPointToSinglePoint Intents before deleting routes correct!***")
+        if( eq( routeIntents_str_expected, routeIntents_str_actual ) ):
+            main.log.report(
+                "***MultiPointToSinglePoint Intents before deleting routes correct!***" )
         else:
-            main.log.report("***MultiPointToSinglePoint Intents before deleting routes wrong!***")
+            main.log.report(
+                "***MultiPointToSinglePoint Intents before deleting routes wrong!***" )
 
-        main.step("Check BGP PointToPointIntent intents installed")
+        main.step( "Check BGP PointToPointIntent intents installed" )
         # bgp intents expected
-        bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents(SDNIP_JSON_FILE_PATH)
+        bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents(
+            SDNIP_JSON_FILE_PATH )
         # get BGP intents from ONOS CLI
-        bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents(get_intents_result)
+        bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents(
+            get_intents_result )
 
-        bgpIntents_str_expected = str(bgpIntents_expected).replace('u', "")
-        bgpIntents_str_actual = str(bgpIntents_actual)
-        main.log.info("PointToPointIntent intents expected:")
-        main.log.info(bgpIntents_str_expected)
-        main.log.info("PointToPointIntent intents get from ONOS CLI:")
-        main.log.info(bgpIntents_str_actual)
+        bgpIntents_str_expected = str( bgpIntents_expected ).replace( 'u', "" )
+        bgpIntents_str_actual = str( bgpIntents_actual )
+        main.log.info( "PointToPointIntent intents expected:" )
+        main.log.info( bgpIntents_str_expected )
+        main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
+        main.log.info( bgpIntents_str_actual )
 
-        utilities.assert_equals(expect=True, actual=eq(bgpIntents_str_expected, bgpIntents_str_actual),
-                                onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
-                                onfail="***PointToPointIntent Intents in SDN-IP are wrong!***")
+        utilities.assert_equals(
+            expect=True,
+            actual=eq(
+                bgpIntents_str_expected,
+                bgpIntents_str_actual ),
+            onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
+            onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
 
-
-        if (eq(bgpIntents_str_expected, bgpIntents_str_actual)):
-            main.log.report("***PointToPointIntent Intents in SDN-IP are correct!***")
+        if ( eq( bgpIntents_str_expected, bgpIntents_str_actual ) ):
+            main.log.report(
+                "***PointToPointIntent Intents in SDN-IP are correct!***" )
         else:
-            main.log.report("***PointToPointIntent Intents in SDN-IP are wrong!***")
-
-
+            main.log.report(
+                "***PointToPointIntent Intents in SDN-IP are wrong!***" )
 
         #============================= Ping Test ========================
         # wait until all MultiPointToSinglePoint
-        time.sleep(20)
+        time.sleep( 20 )
         ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
-        ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-before-delete-routes-" + strftime("%Y-%m-%d_%H:%M:%S", localtime()) + ".txt"
-        ping_test_results = main.QuaggaCliHost.ping_test("1.168.30.100", ping_test_script, ping_test_results_file)
-        main.log.info(ping_test_results)
+        ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-before-delete-routes-" + \
+            strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+        ping_test_results = main.QuaggaCliHost.ping_test(
+            "1.168.30.100",
+            ping_test_script,
+            ping_test_results_file )
+        main.log.info( ping_test_results )
 
         # ping test
 
         #============================= Deleting Routes ==================
-        main.step("Check deleting routes installed")
-        main.QuaggaCliHost3.delete_routes(prefixes_host3, 1)
-        main.QuaggaCliHost4.delete_routes(prefixes_host4, 1)
+        main.step( "Check deleting routes installed" )
+        main.QuaggaCliHost3.delete_routes( prefixes_host3, 1 )
+        main.QuaggaCliHost4.delete_routes( prefixes_host4, 1 )
 
-        # main.log.info("main.ONOScli.get_routes_num() = " )
-        # main.log.info(main.ONOScli.get_routes_num())
-        # utilities.assert_equals(expect = "Total SDN-IP routes = 1", actual= main.ONOScli.get_routes_num(),
-        get_routes_result = main.ONOScli.routes(json_format=True)
-        allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
-        main.log.info("allRoutes_actual = ")
-        main.log.info(allRoutes_actual)
+        # main.log.info( "main.ONOScli.get_routes_num() = " )
+        # main.log.info( main.ONOScli.get_routes_num() )
+        # utilities.assert_equals( expect="Total SDN-IP routes = 1", actual=
+        # main.ONOScli.get_routes_num(),
+        get_routes_result = main.ONOScli.routes( json_format=True )
+        allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(
+            get_routes_result )
+        main.log.info( "allRoutes_actual = " )
+        main.log.info( allRoutes_actual )
 
-        utilities.assert_equals(expect="[]", actual=str(allRoutes_actual),
-                                onpass="***Route number in SDN-IP is 0, correct!***",
-                                onfail="***Routes number in SDN-IP is not 0, wrong!***")
+        utilities.assert_equals(
+            expect="[]",
+            actual=str( allRoutes_actual ),
+            onpass="***Route number in SDN-IP is 0, correct!***",
+            onfail="***Routes number in SDN-IP is not 0, wrong!***" )
 
-        if(eq(allRoutes_str_expected, allRoutes_str_actual)):
-            main.log.report("***Routes in SDN-IP after deleting correct!***")
+        if( eq( allRoutes_str_expected, allRoutes_str_actual ) ):
+            main.log.report( "***Routes in SDN-IP after deleting correct!***" )
         else:
-            main.log.report("***Routes in SDN-IP after deleting wrong!***")
+            main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
 
-        main.step("Check intents after deleting routes")
-        get_intents_result = main.ONOScli.intents(json_format=True)
-        routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
-        main.log.info("main.ONOScli.intents()= ")
-        main.log.info(routeIntents_actual)
-        utilities.assert_equals(expect="[]", actual=str(routeIntents_actual),
-                                onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, correct!***",
-                                onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, wrong!***")
+        main.step( "Check intents after deleting routes" )
+        get_intents_result = main.ONOScli.intents( json_format=True )
+        routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(
+            get_intents_result )
+        main.log.info( "main.ONOScli.intents()= " )
+        main.log.info( routeIntents_actual )
+        utilities.assert_equals(
+            expect="[]",
+            actual=str( routeIntents_actual ),
+            onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, correct!***",
+            onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, wrong!***" )
 
-        if(eq(routeIntents_str_expected, routeIntents_str_actual)):
-            main.log.report("***MultiPointToSinglePoint Intents after deleting routes correct!***")
+        if( eq( routeIntents_str_expected, routeIntents_str_actual ) ):
+            main.log.report(
+                "***MultiPointToSinglePoint Intents after deleting routes correct!***" )
         else:
-            main.log.report("***MultiPointToSinglePoint Intents after deleting routes wrong!***")
+            main.log.report(
+                "***MultiPointToSinglePoint Intents after deleting routes wrong!***" )
 
-        time.sleep(20)
+        time.sleep( 20 )
         ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
-        ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-after-delete-routes-" + strftime("%Y-%m-%d_%H:%M:%S", localtime()) + ".txt"
-        ping_test_results = main.QuaggaCliHost.ping_test("1.168.30.100", ping_test_script, ping_test_results_file)
-        main.log.info(ping_test_results)
-        time.sleep(30)
+        ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-after-delete-routes-" + \
+            strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+        ping_test_results = main.QuaggaCliHost.ping_test(
+            "1.168.30.100",
+            ping_test_script,
+            ping_test_results_file )
+        main.log.info( ping_test_results )
+        time.sleep( 30 )
 
-        # main.step("Test whether Mininet is started")
-        # main.Mininet2.handle.sendline("xterm host1")
-        # main.Mininet2.handle.expect("mininet>")
+        # main.step( "Test whether Mininet is started" )
+        # main.Mininet2.handle.sendline( "xterm host1" )
+        # main.Mininet2.handle.expect( "mininet>" )
 
-
-    def CASE2(self, main):
-
-        '''
+    def CASE2( self, main ):
+        """
         Test the SDN-IP functionality
         allRoutes_expected: all expected routes for all BGP peers
         routeIntents_expected: all expected MultiPointToSinglePointIntent intents
@@ -247,217 +290,266 @@
         allRoutes_actual: all routes from ONOS LCI
         routeIntents_actual: actual MultiPointToSinglePointIntent intents from ONOS CLI
         bgpIntents_actual: actual PointToPointIntent intents from ONOS CLI
-        '''
+        """
         import time
         import json
         from operator import eq
         from time import localtime, strftime
 
-        main.case("The test case is to help to setup the TestON environment and test new drivers")
+        main.case(
+            "The test case is to help to setup the TestON environment and test new drivers" )
         SDNIP_JSON_FILE_PATH = "../tests/SdnIpTest/sdnip.json"
         # all expected routes for all BGP peers
         allRoutes_expected = []
-        main.step("Start to generate routes for all BGP peers")
+        main.step( "Start to generate routes for all BGP peers" )
 
-        main.log.info("Generate prefixes for host3")
-        prefixes_host3 = main.QuaggaCliHost3.generate_prefixes(3, 10)
-        main.log.info(prefixes_host3)
+        main.log.info( "Generate prefixes for host3" )
+        prefixes_host3 = main.QuaggaCliHost3.generate_prefixes( 3, 10 )
+        main.log.info( prefixes_host3 )
         # generate route with next hop
         for prefix in prefixes_host3:
-            allRoutes_expected.append(prefix + "/" + "192.168.20.1")
-        routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents(prefixes_host3, "192.168.20.1", "00:00:00:00:02:02", SDNIP_JSON_FILE_PATH)
+            allRoutes_expected.append( prefix + "/" + "192.168.20.1" )
+        routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents(
+            prefixes_host3,
+            "192.168.20.1",
+            "00:00:00:00:02:02",
+            SDNIP_JSON_FILE_PATH )
 
-        main.log.info("Generate prefixes for host4")
-        prefixes_host4 = main.QuaggaCliHost4.generate_prefixes(4, 10)
-        main.log.info(prefixes_host4)
+        main.log.info( "Generate prefixes for host4" )
+        prefixes_host4 = main.QuaggaCliHost4.generate_prefixes( 4, 10 )
+        main.log.info( prefixes_host4 )
         # generate route with next hop
         for prefix in prefixes_host4:
-            allRoutes_expected.append(prefix + "/" + "192.168.30.1")
-        routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents(prefixes_host4, "192.168.30.1", "00:00:00:00:03:01", SDNIP_JSON_FILE_PATH)
+            allRoutes_expected.append( prefix + "/" + "192.168.30.1" )
+        routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents(
+            prefixes_host4,
+            "192.168.30.1",
+            "00:00:00:00:03:01",
+            SDNIP_JSON_FILE_PATH )
 
-        routeIntents_expected = routeIntents_expected_host3 + routeIntents_expected_host4
+        routeIntents_expected = routeIntents_expected_host3 + \
+            routeIntents_expected_host4
 
-        main.log.report("Removing raft logs")
+        main.log.report( "Removing raft logs" )
         main.ONOSbench.onos_remove_raft_logs()
-        main.log.report("Uninstalling ONOS")
-        main.ONOSbench.onos_uninstall(ONOS1_ip)
+        main.log.report( "Uninstalling ONOS" )
+        main.ONOSbench.onos_uninstall( ONOS1_ip )
 
-        cell_name = main.params['ENV']['cellName']
-        ONOS1_ip = main.params['CTRL']['ip1']
-        main.step("Set cell for ONOS-cli environment")
-        main.ONOScli.set_cell(cell_name)
+        cell_name = main.params[ 'ENV' ][ 'cellName' ]
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        main.step( "Set cell for ONOS-cli environment" )
+        main.ONOScli.set_cell( cell_name )
         verify_result = main.ONOSbench.verify_cell()
-        #main.log.report("Removing raft logs")
-        #main.ONOSbench.onos_remove_raft_logs()
-        #main.log.report("Uninstalling ONOS")
-        #main.ONOSbench.onos_uninstall(ONOS1_ip)
-        main.step("Creating ONOS package")
+        #main.log.report( "Removing raft logs" )
+        # main.ONOSbench.onos_remove_raft_logs()
+        #main.log.report( "Uninstalling ONOS" )
+        # main.ONOSbench.onos_uninstall( ONOS1_ip )
+        main.step( "Creating ONOS package" )
         package_result = main.ONOSbench.onos_package()
 
-        main.step("Installing ONOS package")
-        onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip)
+        main.step( "Installing ONOS package" )
+        onos1_install_result = main.ONOSbench.onos_install(
+            options="-f",
+            node=ONOS1_ip )
 
-        main.step("Checking if ONOS is up yet")
-        time.sleep(60)
-        onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+        main.step( "Checking if ONOS is up yet" )
+        time.sleep( 60 )
+        onos1_isup = main.ONOSbench.isup( ONOS1_ip )
         if not onos1_isup:
-            main.log.report("ONOS1 didn't start!")
+            main.log.report( "ONOS1 didn't start!" )
 
-        main.step("Start ONOS-cli")
-        main.ONOScli.start_onos_cli(ONOS1_ip)
+        main.step( "Start ONOS-cli" )
+        main.ONOScli.start_onos_cli( ONOS1_ip )
 
-        main.step("Get devices in the network")
-        list_result = main.ONOScli.devices(json_format=False)
-        main.log.info(list_result)
-        time.sleep(10)
-        main.log.info("Installing sdn-ip feature")
-        main.ONOScli.feature_install("onos-app-sdnip")
-        time.sleep(10)
+        main.step( "Get devices in the network" )
+        list_result = main.ONOScli.devices( json_format=False )
+        main.log.info( list_result )
+        time.sleep( 10 )
+        main.log.info( "Installing sdn-ip feature" )
+        main.ONOScli.feature_install( "onos-app-sdnip" )
+        time.sleep( 10 )
 
-
-        main.step("Check BGP PointToPointIntent intents installed")
+        main.step( "Check BGP PointToPointIntent intents installed" )
         # bgp intents expected
-        bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents(SDNIP_JSON_FILE_PATH)
+        bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents(
+            SDNIP_JSON_FILE_PATH )
         # get BGP intents from ONOS CLI
-        get_intents_result = main.ONOScli.intents(json_format=True)
-        bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents(get_intents_result)
+        get_intents_result = main.ONOScli.intents( json_format=True )
+        bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents(
+            get_intents_result )
 
-        bgpIntents_str_expected = str(bgpIntents_expected).replace('u', "")
-        bgpIntents_str_actual = str(bgpIntents_actual)
-        main.log.info("PointToPointIntent intents expected:")
-        main.log.info(bgpIntents_str_expected)
-        main.log.info("PointToPointIntent intents get from ONOS CLI:")
-        main.log.info(bgpIntents_str_actual)
+        bgpIntents_str_expected = str( bgpIntents_expected ).replace( 'u', "" )
+        bgpIntents_str_actual = str( bgpIntents_actual )
+        main.log.info( "PointToPointIntent intents expected:" )
+        main.log.info( bgpIntents_str_expected )
+        main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
+        main.log.info( bgpIntents_str_actual )
 
-        utilities.assert_equals(expect=True, actual=eq(bgpIntents_str_expected, bgpIntents_str_actual),
-                                onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
-                                onfail="***PointToPointIntent Intents in SDN-IP are wrong!***")
+        utilities.assert_equals(
+            expect=True,
+            actual=eq(
+                bgpIntents_str_expected,
+                bgpIntents_str_actual ),
+            onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
+            onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
 
-        if (eq(bgpIntents_str_expected, bgpIntents_str_actual)):
-            main.log.report("***PointToPointIntent Intents in SDN-IP are correct!***")
+        if ( eq( bgpIntents_str_expected, bgpIntents_str_actual ) ):
+            main.log.report(
+                "***PointToPointIntent Intents in SDN-IP are correct!***" )
         else:
-            main.log.report("***PointToPointIntent Intents in SDN-IP are wrong!***")
+            main.log.report(
+                "***PointToPointIntent Intents in SDN-IP are wrong!***" )
 
-
-        allRoutes_str_expected = str(sorted(allRoutes_expected))
-        routeIntents_str_expected = str(sorted(routeIntents_expected))
+        allRoutes_str_expected = str( sorted( allRoutes_expected ) )
+        routeIntents_str_expected = str( sorted( routeIntents_expected ) )
         ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
         # round_num = 0;
-        # while(True):
-        for round_num in range(1, 6):
+        # while( True ):
+        for round_num in range( 1, 6 ):
             # round = round + 1;
-            main.log.report("The Round " + str(round_num) + " test starts........................................")
+            main.log.report(
+                "The Round " +
+                str( round_num ) +
+                " test starts........................................" )
 
-            main.step("Login all BGP peers and add routes into peers")
-            main.log.info("Login Quagga CLI on host3")
-            main.QuaggaCliHost3.loginQuagga("1.168.30.2")
-            main.log.info("Enter configuration model of Quagga CLI on host3")
-            main.QuaggaCliHost3.enter_config(64514)
-            main.log.info("Add routes to Quagga on host3")
-            main.QuaggaCliHost3.add_routes(prefixes_host3, 1)
+            main.step( "Login all BGP peers and add routes into peers" )
+            main.log.info( "Login Quagga CLI on host3" )
+            main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
+            main.log.info( "Enter configuration model of Quagga CLI on host3" )
+            main.QuaggaCliHost3.enter_config( 64514 )
+            main.log.info( "Add routes to Quagga on host3" )
+            main.QuaggaCliHost3.add_routes( prefixes_host3, 1 )
 
-            main.log.info("Login Quagga CLI on host4")
-            main.QuaggaCliHost4.loginQuagga("1.168.30.3")
-            main.log.info("Enter configuration model of Quagga CLI on host4")
-            main.QuaggaCliHost4.enter_config(64516)
-            main.log.info("Add routes to Quagga on host4")
-            main.QuaggaCliHost4.add_routes(prefixes_host4, 1)
-            time.sleep(60)
+            main.log.info( "Login Quagga CLI on host4" )
+            main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
+            main.log.info( "Enter configuration model of Quagga CLI on host4" )
+            main.QuaggaCliHost4.enter_config( 64516 )
+            main.log.info( "Add routes to Quagga on host4" )
+            main.QuaggaCliHost4.add_routes( prefixes_host4, 1 )
+            time.sleep( 60 )
 
             # get all routes inside SDN-IP
-            get_routes_result = main.ONOScli.routes(json_format=True)
+            get_routes_result = main.ONOScli.routes( json_format=True )
 
             # parse routes from ONOS CLI
-            allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
+            allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(
+                get_routes_result )
 
-            # allRoutes_str_expected = str(sorted(allRoutes_expected))
-            allRoutes_str_actual = str(allRoutes_actual).replace('u', "")
-            main.step("Check routes installed")
-            main.log.info("Routes expected:")
-            main.log.info(allRoutes_str_expected)
-            main.log.info("Routes get from ONOS CLI:")
-            main.log.info(allRoutes_str_actual)
-            utilities.assert_equals(expect=allRoutes_str_expected, actual=allRoutes_str_actual,
-                                    onpass="***Routes in SDN-IP are correct!***",
-                                    onfail="***Routes in SDN-IP are wrong!***")
-            if(eq(allRoutes_str_expected, allRoutes_str_actual)):
-                main.log.report("***Routes in SDN-IP after adding correct!***")
+            # allRoutes_str_expected = str( sorted( allRoutes_expected ) )
+            allRoutes_str_actual = str( allRoutes_actual ).replace( 'u', "" )
+            main.step( "Check routes installed" )
+            main.log.info( "Routes expected:" )
+            main.log.info( allRoutes_str_expected )
+            main.log.info( "Routes get from ONOS CLI:" )
+            main.log.info( allRoutes_str_actual )
+            utilities.assert_equals(
+                expect=allRoutes_str_expected,
+                actual=allRoutes_str_actual,
+                onpass="***Routes in SDN-IP are correct!***",
+                onfail="***Routes in SDN-IP are wrong!***" )
+            if( eq( allRoutes_str_expected, allRoutes_str_actual ) ):
+                main.log.report(
+                    "***Routes in SDN-IP after adding correct!***" )
             else:
-                main.log.report("***Routes in SDN-IP after adding wrong!***")
+                main.log.report( "***Routes in SDN-IP after adding wrong!***" )
 
-            time.sleep(20)
-            get_intents_result = main.ONOScli.intents(json_format=True)
+            time.sleep( 20 )
+            get_intents_result = main.ONOScli.intents( json_format=True )
 
-
-            main.step("Check MultiPointToSinglePointIntent intents installed")
+            main.step(
+                "Check MultiPointToSinglePointIntent intents installed" )
             # route_intents_expected are generated when generating routes
             # get route intents from ONOS CLI
-            routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
-            # routeIntents_str_expected = str(sorted(routeIntents_expected))
-            routeIntents_str_actual = str(routeIntents_actual).replace('u', "")
-            main.log.info("MultiPointToSinglePoint intents expected:")
-            main.log.info(routeIntents_str_expected)
-            main.log.info("MultiPointToSinglePoint intents get from ONOS CLI:")
-            main.log.info(routeIntents_str_actual)
-            utilities.assert_equals(expect=True, actual=eq(routeIntents_str_expected, routeIntents_str_actual),
-                                    onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***",
-                                    onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***")
+            routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(
+                get_intents_result )
+            # routeIntents_str_expected = str( sorted( routeIntents_expected ) )
+            routeIntents_str_actual = str(
+                routeIntents_actual ).replace( 'u', "" )
+            main.log.info( "MultiPointToSinglePoint intents expected:" )
+            main.log.info( routeIntents_str_expected )
+            main.log.info(
+                "MultiPointToSinglePoint intents get from ONOS CLI:" )
+            main.log.info( routeIntents_str_actual )
+            utilities.assert_equals(
+                expect=True,
+                actual=eq(
+                    routeIntents_str_expected,
+                    routeIntents_str_actual ),
+                onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***",
+                onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***" )
 
-            if(eq(routeIntents_str_expected, routeIntents_str_actual)):
-                main.log.report("***MultiPointToSinglePoint Intents after adding routes correct!***")
+            if( eq( routeIntents_str_expected, routeIntents_str_actual ) ):
+                main.log.report(
+                    "***MultiPointToSinglePoint Intents after adding routes correct!***" )
             else:
-                main.log.report("***MultiPointToSinglePoint Intents after adding routes wrong!***")
+                main.log.report(
+                    "***MultiPointToSinglePoint Intents after adding routes wrong!***" )
 
             #============================= Ping Test ========================
             # wait until all MultiPointToSinglePoint
-            time.sleep(20)
+            time.sleep( 20 )
             # ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
-            ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + str(round_num) + "-ping-results-before-delete-routes-" + strftime("%Y-%m-%d_%H:%M:%S", localtime()) + ".txt"
-            ping_test_results = main.QuaggaCliHost.ping_test("1.168.30.100", ping_test_script, ping_test_results_file)
-            main.log.info(ping_test_results)
+            ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + \
+                str( round_num ) + "-ping-results-before-delete-routes-" + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+            ping_test_results = main.QuaggaCliHost.ping_test(
+                "1.168.30.100",
+                ping_test_script,
+                ping_test_results_file )
+            main.log.info( ping_test_results )
             # ping test
 
             #============================= Deleting Routes ==================
-            main.step("Check deleting routes installed")
-            main.log.info("Delete routes to Quagga on host3")
-            main.QuaggaCliHost3.delete_routes(prefixes_host3, 1)
-            main.log.info("Delete routes to Quagga on host4")
-            main.QuaggaCliHost4.delete_routes(prefixes_host4, 1)
+            main.step( "Check deleting routes installed" )
+            main.log.info( "Delete routes to Quagga on host3" )
+            main.QuaggaCliHost3.delete_routes( prefixes_host3, 1 )
+            main.log.info( "Delete routes to Quagga on host4" )
+            main.QuaggaCliHost4.delete_routes( prefixes_host4, 1 )
 
-            get_routes_result = main.ONOScli.routes(json_format=True)
-            allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
-            main.log.info("allRoutes_actual = ")
-            main.log.info(allRoutes_actual)
+            get_routes_result = main.ONOScli.routes( json_format=True )
+            allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(
+                get_routes_result )
+            main.log.info( "allRoutes_actual = " )
+            main.log.info( allRoutes_actual )
 
-            utilities.assert_equals(expect="[]", actual=str(allRoutes_actual),
-                                    onpass="***Route number in SDN-IP is 0, correct!***",
-                                    onfail="***Routes number in SDN-IP is not 0, wrong!***")
+            utilities.assert_equals(
+                expect="[]",
+                actual=str( allRoutes_actual ),
+                onpass="***Route number in SDN-IP is 0, correct!***",
+                onfail="***Routes number in SDN-IP is not 0, wrong!***" )
 
-            if(eq(allRoutes_str_expected, allRoutes_str_actual)):
-                main.log.report("***Routes in SDN-IP after deleting correct!***")
+            if( eq( allRoutes_str_expected, allRoutes_str_actual ) ):
+                main.log.report(
+                    "***Routes in SDN-IP after deleting correct!***" )
             else:
-                main.log.report("***Routes in SDN-IP after deleting wrong!***")
+                main.log.report(
+                    "***Routes in SDN-IP after deleting wrong!***" )
 
-            main.step("Check intents after deleting routes")
-            get_intents_result = main.ONOScli.intents(json_format=True)
-            routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
-            main.log.info("main.ONOScli.intents()= ")
-            main.log.info(routeIntents_actual)
-            utilities.assert_equals(expect="[]", actual=str(routeIntents_actual),
-                                    onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, correct!***",
-                                    onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, wrong!***")
+            main.step( "Check intents after deleting routes" )
+            get_intents_result = main.ONOScli.intents( json_format=True )
+            routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(
+                get_intents_result )
+            main.log.info( "main.ONOScli.intents()= " )
+            main.log.info( routeIntents_actual )
+            utilities.assert_equals(
+                expect="[]",
+                actual=str( routeIntents_actual ),
+                onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, correct!***",
+                onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, wrong!***" )
 
-            if(eq(routeIntents_str_expected, routeIntents_str_actual)):
-                main.log.report("***MultiPointToSinglePoint Intents after deleting routes correct!***")
+            if( eq( routeIntents_str_expected, routeIntents_str_actual ) ):
+                main.log.report(
+                    "***MultiPointToSinglePoint Intents after deleting routes correct!***" )
             else:
-                main.log.report("***MultiPointToSinglePoint Intents after deleting routes wrong!***")
+                main.log.report(
+                    "***MultiPointToSinglePoint Intents after deleting routes wrong!***" )
 
-            time.sleep(20)
+            time.sleep( 20 )
             # ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
-            ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + str(round_num) + "-ping-results-after-delete-routes-" + strftime("%Y-%m-%d_%H:%M:%S", localtime()) + ".txt"
-            ping_test_results = main.QuaggaCliHost.ping_test("1.168.30.100", ping_test_script, ping_test_results_file)
-            main.log.info(ping_test_results)
-            time.sleep(30)
-
-
-
+            ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + \
+                str( round_num ) + "-ping-results-after-delete-routes-" + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+            ping_test_results = main.QuaggaCliHost.ping_test(
+                "1.168.30.100",
+                ping_test_script,
+                ping_test_results_file )
+            main.log.info( ping_test_results )
+            time.sleep( 30 )
diff --git a/TestON/tests/TopoConvNext/TopoConvNext.py b/TestON/tests/TopoConvNext/TopoConvNext.py
index 68d7b5d..c114e48 100644
--- a/TestON/tests/TopoConvNext/TopoConvNext.py
+++ b/TestON/tests/TopoConvNext/TopoConvNext.py
@@ -1,153 +1,155 @@
-#TopoPerfNext
+# TopoPerfNext
 #
-#Topology Convergence scale-out test for ONOS-next
-#NOTE: This test supports up to 7 nodes scale-out scenario
+# Topology Convergence scale-out test for ONOS-next
+# NOTE: This test supports up to 7 nodes scale-out scenario
 #
-#NOTE: Ensure that you have 'tablet.json' file 
+# NOTE: Ensure that you have 'tablet.json' file
 #      in the onos/tools/package/config directory
-#NOTE: You must start this test initially with 3 nodes
+# NOTE: You must start this test initially with 3 nodes
 #
-#andrew@onlab.us
+# andrew@onlab.us
 
 import time
 import sys
 import os
 import re
 
+
 class TopoConvNext:
-    def __init__(self):
+
+    def __init__( self ):
         self.default = ''
 
-    def CASE1(self, main):
-        '''
+    def CASE1( self, main ):
+        """
         ONOS startup sequence
-        '''
+        """
         import time
 
         #******
-        #Global cluster count for scale-out purposes
-        global cluster_count 
+        # Global cluster count for scale-out purposes
+        global cluster_count
         global topo_iteration
         topo_iteration = 1
-        cluster_count = 1 
+        cluster_count = 1
         #******
-        cell_name = main.params['ENV']['cellName']
+        cell_name = main.params[ 'ENV' ][ 'cellName' ]
 
-        git_pull = main.params['GIT']['autoPull']
-        checkout_branch = main.params['GIT']['checkout']
+        git_pull = main.params[ 'GIT' ][ 'autoPull' ]
+        checkout_branch = main.params[ 'GIT' ][ 'checkout' ]
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS4_ip = main.params['CTRL']['ip4']
-        ONOS5_ip = main.params['CTRL']['ip5']
-        ONOS6_ip = main.params['CTRL']['ip6']
-        ONOS7_ip = main.params['CTRL']['ip7']
-        MN1_ip = main.params['MN']['ip1']
-        BENCH_ip = main.params['BENCH']['ip']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+        ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+        ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
+        ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
+        MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+        BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
 
-        main.case("Setting up test environment")
-        main.log.info("copying topology event accumulator config file"+\
-                " to ONOS package/etc/ directory")
-        topo_config_name = main.params['TEST']['topo_config_name']
+        main.case( "Setting up test environment" )
+        main.log.info( "copying topology event accumulator config file" +
+                       " to ONOS package/etc/ directory" )
+        topo_config_name = main.params[ 'TEST' ][ 'topo_config_name' ]
         topo_config =\
-                main.params['TEST']['topo_accumulator_config']
-        main.ONOSbench.handle.sendline("cp ~/"+topo_config+\
-            " ~/ONOS/tools/package/etc/"+\
-            topo_config_name)
-        main.ONOSbench.handle.expect("\$")
+            main.params[ 'TEST' ][ 'topo_accumulator_config' ]
+        main.ONOSbench.handle.sendline( "cp ~/" + topo_config +
+                                        " ~/ONOS/tools/package/etc/" +
+                                        topo_config_name )
+        main.ONOSbench.handle.expect( "\$" )
 
-        main.log.info("Uninstalling previous instances")
-        #main.ONOSbench.onos_uninstall(node_ip = ONOS1_ip)
-        main.ONOSbench.onos_uninstall(node_ip = ONOS2_ip)
-        main.ONOSbench.onos_uninstall(node_ip = ONOS3_ip)
-        main.ONOSbench.onos_uninstall(node_ip = ONOS4_ip)
-        main.ONOSbench.onos_uninstall(node_ip = ONOS5_ip)
-        main.ONOSbench.onos_uninstall(node_ip = ONOS6_ip)
-        main.ONOSbench.onos_uninstall(node_ip = ONOS7_ip)
-      
-        main.log.report("Setting up test environment")
+        main.log.info( "Uninstalling previous instances" )
+        #main.ONOSbench.onos_uninstall( node_ip=ONOS1_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS2_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS3_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS4_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS5_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS6_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS7_ip )
 
-        main.step("Creating cell file")
+        main.log.report( "Setting up test environment" )
+
+        main.step( "Creating cell file" )
         cell_file_result = main.ONOSbench.create_cell_file(
-                BENCH_ip, cell_name, MN1_ip, 
-                "onos-core,onos-app-metrics", 
-                #ONOS1_ip, ONOS2_ip, ONOS3_ip)
-                ONOS1_ip)
-                    
-        main.step("Applying cell file to environment")
-        cell_apply_result = main.ONOSbench.set_cell(cell_name)
-        verify_cell_result = main.ONOSbench.verify_cell()
-        
-        main.step("Removing raft logs")
-        main.ONOSbench.onos_remove_raft_logs()
-        time.sleep(10)
+            BENCH_ip, cell_name, MN1_ip,
+            "onos-core,onos-app-metrics",
+            # ONOS1_ip, ONOS2_ip, ONOS3_ip )
+            ONOS1_ip )
 
-        main.step("Git checkout and pull "+checkout_branch)
+        main.step( "Applying cell file to environment" )
+        cell_apply_result = main.ONOSbench.set_cell( cell_name )
+        verify_cell_result = main.ONOSbench.verify_cell()
+
+        main.step( "Removing raft logs" )
+        main.ONOSbench.onos_remove_raft_logs()
+        time.sleep( 10 )
+
+        main.step( "Git checkout and pull " + checkout_branch )
         if git_pull == 'on':
             checkout_result = \
-                    main.ONOSbench.git_checkout(checkout_branch)
+                main.ONOSbench.git_checkout( checkout_branch )
             pull_result = main.ONOSbench.git_pull()
         else:
             checkout_result = main.TRUE
             pull_result = main.TRUE
-            main.log.info("Skipped git checkout and pull")
+            main.log.info( "Skipped git checkout and pull" )
 
-        main.log.report("Commit information - ")
+        main.log.report( "Commit information - " )
         main.ONOSbench.get_version()
 
-        main.step("Using mvn clean & install")
+        main.step( "Using mvn clean & install" )
         #mvn_result = main.ONOSbench.clean_install()
         mvn_result = main.TRUE
 
-        main.step("Set cell for ONOS cli env")
-        main.ONOS1cli.set_cell(cell_name)
-        #main.ONOS2cli.set_cell(cell_name)
-        #main.ONOS3cli.set_cell(cell_name)
-    
-        main.step("Creating ONOS package")
+        main.step( "Set cell for ONOS cli env" )
+        main.ONOS1cli.set_cell( cell_name )
+        # main.ONOS2cli.set_cell( cell_name )
+        # main.ONOS3cli.set_cell( cell_name )
+
+        main.step( "Creating ONOS package" )
         package_result = main.ONOSbench.onos_package()
 
-        #Start test with single node only
-        main.step("Installing ONOS package")
-        install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
-        #install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
-        #install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
+        # Start test with single node only
+        main.step( "Installing ONOS package" )
+        install1_result = main.ONOSbench.onos_install( node=ONOS1_ip )
+        #install2_result = main.ONOSbench.onos_install( node=ONOS2_ip )
+        #install3_result = main.ONOSbench.onos_install( node=ONOS3_ip )
 
-        time.sleep(10)
+        time.sleep( 10 )
 
-        main.step("Start onos cli")
-        cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
-        #cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
-        #cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
+        main.step( "Start onos cli" )
+        cli1 = main.ONOS1cli.start_onos_cli( ONOS1_ip )
+        #cli2 = main.ONOS2cli.start_onos_cli( ONOS2_ip )
+        #cli3 = main.ONOS3cli.start_onos_cli( ONOS3_ip )
 
-        main.step("Enable metrics feature")
-        #main.ONOS1cli.feature_install("onos-app-metrics")
+        main.step( "Enable metrics feature" )
+        # main.ONOS1cli.feature_install( "onos-app-metrics" )
 
-        utilities.assert_equals(expect=main.TRUE,
-                actual= cell_file_result and cell_apply_result and\
-                        verify_cell_result and checkout_result and\
-                        pull_result and mvn_result and\
-                        install1_result, #and install2_result and\
-                        #install3_result,
-                onpass="Test Environment setup successful",
-                onfail="Failed to setup test environment")
-    
-    def CASE2(self, main):
-        '''
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=cell_file_result and cell_apply_result and
+                                 verify_cell_result and checkout_result and
+                                 pull_result and mvn_result and
+                                 install1_result,  # and install2_result and
+                                 # install3_result,
+                                 onpass="Test Environment setup successful",
+                                 onfail="Failed to setup test environment" )
+
+    def CASE2( self, main ):
+        """
         100 Switch discovery latency
 
         Important:
-            This test case can be potentially dangerous if 
+            This test case can be potentially dangerous if
             your machine has previously set iptables rules.
             One of the steps of the test case will flush
             all existing iptables rules.
         Note:
-            You can specify the number of switches in the 
+            You can specify the number of switches in the
             params file to adjust the switch discovery size
-            (and specify the corresponding topology in Mininet1 
-            .topo file)
-        '''
+            ( and specify the corresponding topology in Mininet1
+            .topo file )
+        """
         import time
         import subprocess
         import os
@@ -156,221 +158,241 @@
         import numpy
 
         ONOS_ip_list = []
-        ONOS_ip_list.append('0')
-        ONOS_ip_list.append(main.params['CTRL']['ip1'])
-        ONOS_ip_list.append(main.params['CTRL']['ip2'])
-        ONOS_ip_list.append(main.params['CTRL']['ip3'])
-        ONOS_ip_list.append(main.params['CTRL']['ip4'])
-        ONOS_ip_list.append(main.params['CTRL']['ip5'])
-        ONOS_ip_list.append(main.params['CTRL']['ip6'])
-        ONOS_ip_list.append(main.params['CTRL']['ip7'])
-        MN1_ip = main.params['MN']['ip1']
-        ONOS_user = main.params['CTRL']['user']
+        ONOS_ip_list.append( '0' )
+        ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip1' ] )
+        ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip2' ] )
+        ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip3' ] )
+        ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip4' ] )
+        ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip5' ] )
+        ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip6' ] )
+        ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip7' ] )
+        MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+        ONOS_user = main.params[ 'CTRL' ][ 'user' ]
 
-        default_sw_port = main.params['CTRL']['port1']
-       
-        #Number of iterations of case
-        num_iter = main.params['TEST']['numIter']
-        iter_ignore = int(main.params['TEST']['iterIgnore'])
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
+
+        # Number of iterations of case
+        num_iter = main.params[ 'TEST' ][ 'numIter' ]
+        iter_ignore = int( main.params[ 'TEST' ][ 'iterIgnore' ] )
 
         #***********
-        #Global number of switches that change 
-        #throughout the test
+        # Global number of switches that change
+        # throughout the test
         global num_sw
-        global topo_iteration    
+        global topo_iteration
         global cluster_count
         if topo_iteration == 1:
-            num_sw = main.params['TEST']['numSwitch1']
+            num_sw = main.params[ 'TEST' ][ 'numSwitch1' ]
         elif topo_iteration == 2:
-            num_sw = main.params['TEST']['numSwitch2']
+            num_sw = main.params[ 'TEST' ][ 'numSwitch2' ]
         elif topo_iteration == 3:
-            num_sw = main.params['TEST']['numSwitch3']
+            num_sw = main.params[ 'TEST' ][ 'numSwitch3' ]
         elif topo_iteration == 4:
-            num_sw = main.params['TEST']['numSwitch4']
+            num_sw = main.params[ 'TEST' ][ 'numSwitch4' ]
         #***********
 
-        #Timestamp 'keys' for json metrics output.
-        #These are subject to change, hence moved into params
-        deviceTimestamp = main.params['JSON']['deviceTimestamp']
-        graphTimestamp = main.params['JSON']['graphTimestamp']
-        
-        #Threshold for this test case
-        sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold']
-        sw_disc_threshold_obj = sw_disc_threshold_str.split(",")
-        sw_disc_threshold_min = int(sw_disc_threshold_obj[0])
-        sw_disc_threshold_max = int(sw_disc_threshold_obj[1])
+        # Timestamp 'keys' for json metrics output.
+        # These are subject to change, hence moved into params
+        deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+        graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+        # Threshold for this test case
+        sw_disc_threshold_str = main.params[ 'TEST' ][ 'swDisc100Threshold' ]
+        sw_disc_threshold_obj = sw_disc_threshold_str.split( "," )
+        sw_disc_threshold_min = int( sw_disc_threshold_obj[ 0 ] )
+        sw_disc_threshold_max = int( sw_disc_threshold_obj[ 1 ] )
 
         assertion = main.TRUE
         sw_discovery_lat_list = []
         syn_ack_delta_list = []
 
-        main.case(str(num_sw)+" switches distributed across "+
-                str(cluster_count)+" nodes convergence latency")
-       
-        main.log.report("Large topology convergence and scale-out test")
-        main.log.report("Currently active ONOS node(s): ")
+        main.case( str( num_sw ) + " switches distributed across " +
+                   str( cluster_count ) + " nodes convergence latency" )
+
+        main.log.report( "Large topology convergence and scale-out test" )
+        main.log.report( "Currently active ONOS node(s): " )
         report_str = "Node "
-        for node in range(1, cluster_count+1):
-            report_str += (str(node) + " ") 
-        main.log.report(report_str)
-        main.log.report("Topology size: "+str(num_sw)+" switches")
+        for node in range( 1, cluster_count + 1 ):
+            report_str += ( str( node ) + " " )
+        main.log.report( report_str )
+        main.log.report( "Topology size: " + str( num_sw ) + " switches" )
 
-        main.step("Distributing "+num_sw+" switches to each ONOS")
-        index = 1 
-        for node in range(1, cluster_count+1):
-            for i in range(index, (int(num_sw)/cluster_count)+index):
+        main.step( "Distributing " + num_sw + " switches to each ONOS" )
+        index = 1
+        for node in range( 1, cluster_count + 1 ):
+            for i in range( index, ( int( num_sw ) / cluster_count ) + index ):
                 main.Mininet1.assign_sw_controller(
-                        sw=str(i),
-                        ip1=ONOS_ip_list[node],
-                        port1=default_sw_port)
-            index = i+1 
-        #for i in range(1, int(num_sw)+1):
-            #main.Mininet1.assign_sw_controller(
-                    #sw=str(i),
-                    #ip1="10.128.174.1",
-                    #            port1="6633")
+                    sw=str( i ),
+                    ip1=ONOS_ip_list[ node ],
+                    port1=default_sw_port )
+            index = i + 1
+        # for i in range( 1, int( num_sw )+1 ):
+            # main.Mininet1.assign_sw_controller(
+            # sw=str( i ),
+            # ip1="10.128.174.1",
+            #            port1="6633" )
 
-        main.log.info("Please check ptpd configuration to ensure "+\
-                "all nodes' system times are in sync")
+        main.log.info( "Please check ptpd configuration to ensure " +
+                       "all nodes' system times are in sync" )
 
-        time.sleep(10)
+        time.sleep( 10 )
 
-        for i in range(0, int(num_iter)):
-            main.step("Set iptables rule to block sw connections")
-               
-            #INPUT rules
+        for i in range( 0, int( num_iter ) ):
+            main.step( "Set iptables rule to block sw connections" )
+
+            # INPUT rules
             main.ONOS1.handle.sendline(
-                    "sudo iptables -A INPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
+                "sudo iptables -A INPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
             main.ONOS2.handle.sendline(
-                    "sudo iptables -A INPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
+                "sudo iptables -A INPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
             main.ONOS3.handle.sendline(
-                    "sudo iptables -A INPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
+                "sudo iptables -A INPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
             main.ONOS4.handle.sendline(
-                    "sudo iptables -A INPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
+                "sudo iptables -A INPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
             main.ONOS5.handle.sendline(
-                    "sudo iptables -A INPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
+                "sudo iptables -A INPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
             main.ONOS6.handle.sendline(
-                    "sudo iptables -A INPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
+                "sudo iptables -A INPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
             main.ONOS7.handle.sendline(
-                    "sudo iptables -A INPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
-               
-            #OUTPUT rules
+                "sudo iptables -A INPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
+
+            # OUTPUT rules
             main.ONOS1.handle.sendline(
-                    "sudo iptables -A OUTPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
+                "sudo iptables -A OUTPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
             main.ONOS2.handle.sendline(
-                    "sudo iptables -A OUTPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
+                "sudo iptables -A OUTPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
             main.ONOS3.handle.sendline(
-                    "sudo iptables -A OUTPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
+                "sudo iptables -A OUTPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
             main.ONOS4.handle.sendline(
-                    "sudo iptables -A OUTPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
+                "sudo iptables -A OUTPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
             main.ONOS5.handle.sendline(
-                    "sudo iptables -A OUTPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
+                "sudo iptables -A OUTPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
             main.ONOS6.handle.sendline(
-                    "sudo iptables -A OUTPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
+                "sudo iptables -A OUTPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
             main.ONOS7.handle.sendline(
-                    "sudo iptables -A OUTPUT -p tcp -s "+
-                    MN1_ip+" --dport "+default_sw_port+" -j DROP")
+                "sudo iptables -A OUTPUT -p tcp -s " +
+                MN1_ip + " --dport " + default_sw_port + " -j DROP" )
 
-            main.log.info("Please wait for switch connection to timeout")
-           
+            main.log.info( "Please wait for switch connection to timeout" )
 
-            #time.sleep(60)
-            #if cluster_count >= 3:
-            #    time.sleep(60)
-            #if cluster_count >= 5:
-            #    time.sleep(30)
-            #if cluster_count >= 6:
-            #    time.sleep(30)
+            # time.sleep( 60 )
+            # if cluster_count >= 3:
+            #    time.sleep( 60 )
+            # if cluster_count >= 5:
+            #    time.sleep( 30 )
+            # if cluster_count >= 6:
+            #    time.sleep( 30 )
 
             if cluster_count >= 3:
-                main.ONOS1.handle.sendline("tshark -i eth0 -t e | "+
-                    "grep 'SYN, ACK' | grep '6633' >"+
-                    "/tmp/syn_ack_onos1_iter"+str(i)+".txt &")
-                main.ONOS2.handle.sendline("tshark -i eth0 -t e | "+
-                    "grep 'SYN, ACK' | grep '6633' >"+
-                    "/tmp/syn_ack_onos2_iter"+str(i)+".txt &")
-                main.ONOS3.handle.sendline("tshark -i eth0 -t e | "+
-                    "grep 'SYN, ACK' | grep '6633' >"+
-                    "/tmp/syn_ack_onos3_iter"+str(i)+".txt &")
+                main.ONOS1.handle.sendline(
+                    "tshark -i eth0 -t e | " +
+                    "grep 'SYN, ACK' | grep '6633' >" +
+                    "/tmp/syn_ack_onos1_iter" +
+                    str( i ) +
+                    ".txt &" )
+                main.ONOS2.handle.sendline(
+                    "tshark -i eth0 -t e | " +
+                    "grep 'SYN, ACK' | grep '6633' >" +
+                    "/tmp/syn_ack_onos2_iter" +
+                    str( i ) +
+                    ".txt &" )
+                main.ONOS3.handle.sendline(
+                    "tshark -i eth0 -t e | " +
+                    "grep 'SYN, ACK' | grep '6633' >" +
+                    "/tmp/syn_ack_onos3_iter" +
+                    str( i ) +
+                    ".txt &" )
             if cluster_count >= 4:
-                main.ONOS4.handle.sendline("tshark -i eth0 -t e | "+
-                    "grep 'SYN, ACK' | grep '6633' >"+
-                    "/tmp/syn_ack_onos4_iter"+str(i)+".txt &")
+                main.ONOS4.handle.sendline(
+                    "tshark -i eth0 -t e | " +
+                    "grep 'SYN, ACK' | grep '6633' >" +
+                    "/tmp/syn_ack_onos4_iter" +
+                    str( i ) +
+                    ".txt &" )
             if cluster_count >= 5:
-                main.ONOS5.handle.sendline("tshark -i eth0 -t e | "+
-                    "grep 'SYN, ACK' | grep '6633' >"+
-                    "/tmp/syn_ack_onos5_iter"+str(i)+".txt &")
+                main.ONOS5.handle.sendline(
+                    "tshark -i eth0 -t e | " +
+                    "grep 'SYN, ACK' | grep '6633' >" +
+                    "/tmp/syn_ack_onos5_iter" +
+                    str( i ) +
+                    ".txt &" )
             if cluster_count >= 6:
-                main.ONOS6.handle.sendline("tshark -i eth0 -t e | "+
-                    "grep 'SYN, ACK' | grep '6633' >"+
-                    "/tmp/syn_ack_onos6_iter"+str(i)+".txt &")
+                main.ONOS6.handle.sendline(
+                    "tshark -i eth0 -t e | " +
+                    "grep 'SYN, ACK' | grep '6633' >" +
+                    "/tmp/syn_ack_onos6_iter" +
+                    str( i ) +
+                    ".txt &" )
             if cluster_count == 7:
-                main.ONOS7.handle.sendline("tshark -i eth0 -t e | "+
-                    "grep 'SYN, ACK' | grep '6633' >"+
-                    "/tmp/syn_ack_onos6_iter"+str(i)+".txt &")
-         
-            #NOTE:
-            #       Delay before checking devices to 
+                main.ONOS7.handle.sendline(
+                    "tshark -i eth0 -t e | " +
+                    "grep 'SYN, ACK' | grep '6633' >" +
+                    "/tmp/syn_ack_onos6_iter" +
+                    str( i ) +
+                    ".txt &" )
+
+            # NOTE:
+            #       Delay before checking devices to
             #       help prevent timing out from CLI
-            #       due to multiple command issuing 
-            time.sleep(20)
+            #       due to multiple command issuing
+            time.sleep( 20 )
 
             loop = True
             loop_count = 0
             device_count = 0
-            while loop_count < 60 and loop: 
-                main.log.info("Checking devices for device down")
-                
+            while loop_count < 60 and loop:
+                main.log.info( "Checking devices for device down" )
+
                 temp_len = 0
                 device_str1 = main.ONOS1cli.devices(
-                    node_ip=ONOS_ip_list[1])
-                device_json1 = json.loads(device_str1)
-                json_len = len(device_json1) 
-                
-                #NOTE: May want to check the rest of 
+                    node_ip=ONOS_ip_list[ 1 ] )
+                device_json1 = json.loads( device_str1 )
+                json_len = len( device_json1 )
+
+                # NOTE: May want to check the rest of
                 #      the ONOS instances for device down as well
 
-                for device1 in device_json1: 
+                for device1 in device_json1:
                     temp_len = temp_len + 1
-                    if device1['available'] == True:
+                    if device1[ 'available' ]:
                         loop = True
                         break
-                    #if I'm on the last json object and I still haven't
-                    #broken out of the loop, it means there were
-                    #no available devices
-                    elif temp_len == json_len-1:
-                        main.log.info("Temp length: "+str(temp_len))
-                        main.step("Flushing iptables and obtaining t0")
-                        t0_system = time.time()*1000
-                        
-                        main.ONOS1.handle.sendline("sudo iptables -F")
-                        main.ONOS2.handle.sendline("sudo iptables -F")
-                        main.ONOS3.handle.sendline("sudo iptables -F")
-                        main.ONOS4.handle.sendline("sudo iptables -F")
-                        main.ONOS5.handle.sendline("sudo iptables -F")
-                        main.ONOS6.handle.sendline("sudo iptables -F")
-                        main.ONOS7.handle.sendline("sudo iptables -F")
-                    
+                    # if I'm on the last json object and I still haven't
+                    # broken out of the loop, it means there were
+                    # no available devices
+                    elif temp_len == json_len - 1:
+                        main.log.info( "Temp length: " + str( temp_len ) )
+                        main.step( "Flushing iptables and obtaining t0" )
+                        t0_system = time.time() * 1000
+
+                        main.ONOS1.handle.sendline( "sudo iptables -F" )
+                        main.ONOS2.handle.sendline( "sudo iptables -F" )
+                        main.ONOS3.handle.sendline( "sudo iptables -F" )
+                        main.ONOS4.handle.sendline( "sudo iptables -F" )
+                        main.ONOS5.handle.sendline( "sudo iptables -F" )
+                        main.ONOS6.handle.sendline( "sudo iptables -F" )
+                        main.ONOS7.handle.sendline( "sudo iptables -F" )
+
                         loop = False
                         break
-                
-                loop_count += 1
-                time.sleep(1)
 
-            main.log.info("System time t0: "+str(t0_system))
+                loop_count += 1
+                time.sleep( 1 )
+
+            main.log.info( "System time t0: " + str( t0_system ) )
 
             counter_loop = 0
             counter_avail1 = 0
@@ -388,207 +410,213 @@
             onos6_dev = False
             onos7_dev = False
 
-            #TODO: Think of a more elegant way to check all 
+            # TODO: Think of a more elegant way to check all
             #      switches across all nodes
-            #Goodluck debugging this loop
+            # Goodluck debugging this loop
             while counter_loop < 60:
-                for node in range(1, cluster_count+1):
+                for node in range( 1, cluster_count + 1 ):
                     if node == 1 and not onos1_dev:
-                        main.log.info("Checking node 1 for device "+
-                            "discovery")
+                        main.log.info( "Checking node 1 for device " +
+                                       "discovery" )
                         device_str_obj1 = main.ONOS1cli.devices(
-                            node_ip=ONOS_ip_list[1])
-                        device_json1 = json.loads(device_str_obj1)
+                            node_ip=ONOS_ip_list[ 1 ] )
+                        device_json1 = json.loads( device_str_obj1 )
                         for device1 in device_json1:
-                            if device1['available'] == True:
+                            if device1[ 'available' ]:
                                 counter_avail1 += 1
-                                if counter_avail1 == int(num_sw):
+                                if counter_avail1 == int( num_sw ):
                                     onos1_dev = True
-                                    main.log.info("All devices have been"+
-                                            " discovered on ONOS1")
+                                    main.log.info( "All devices have been" +
+                                                   " discovered on ONOS1" )
                             else:
                                 counter_avail1 = 0
                     if node == 2 and not onos2_dev:
-                        main.log.info("Checking node 2 for device "+
-                            "discovery")
+                        main.log.info( "Checking node 2 for device " +
+                                       "discovery" )
                         device_str_obj2 = main.ONOS2cli.devices(
-                            node_ip=ONOS_ip_list[2])
-                        device_json2 = json.loads(device_str_obj2)
+                            node_ip=ONOS_ip_list[ 2 ] )
+                        device_json2 = json.loads( device_str_obj2 )
                         for device2 in device_json2:
-                            if device2['available'] == True:
+                            if device2[ 'available' ]:
                                 counter_avail2 += 1
-                                if counter_avail2 == int(num_sw):
+                                if counter_avail2 == int( num_sw ):
                                     onos2_dev = True
-                                    main.log.info("All devices have been"+
-                                            " discovered on ONOS2")
+                                    main.log.info( "All devices have been" +
+                                                   " discovered on ONOS2" )
                             else:
                                 counter_avail2 = 0
                     if node == 3 and not onos3_dev:
-                        main.log.info("Checking node 3 for device "+
-                            "discovery")
+                        main.log.info( "Checking node 3 for device " +
+                                       "discovery" )
                         device_str_obj3 = main.ONOS3cli.devices(
-                            node_ip=ONOS_ip_list[3])
-                        device_json3 = json.loads(device_str_obj3)
+                            node_ip=ONOS_ip_list[ 3 ] )
+                        device_json3 = json.loads( device_str_obj3 )
                         for device3 in device_json3:
-                            if device3['available'] == True:
+                            if device3[ 'available' ]:
                                 counter_avail3 += 1
-                                if counter_avail3 == int(num_sw):
+                                if counter_avail3 == int( num_sw ):
                                     onos3_dev = True
-                                    main.log.info("All devices have been"+
-                                            " discovered on ONOS3")
+                                    main.log.info( "All devices have been" +
+                                                   " discovered on ONOS3" )
                             else:
                                 counter_avail3 = 0
                     if node == 4 and not onos4_dev:
-                        main.log.info("Checking node 4 for device "+
-                            "discovery")
+                        main.log.info( "Checking node 4 for device " +
+                                       "discovery" )
                         device_str_obj4 = main.ONOS4cli.devices(
-                            node_ip=ONOS_ip_list[4])
-                        device_json4 = json.loads(device_str_obj4)
+                            node_ip=ONOS_ip_list[ 4 ] )
+                        device_json4 = json.loads( device_str_obj4 )
                         for device4 in device_json4:
-                            if device4['available'] == True:
+                            if device4[ 'available' ]:
                                 counter_avail4 += 1
-                                if counter_avail4 == int(num_sw):
+                                if counter_avail4 == int( num_sw ):
                                     onos4_dev = True
-                                    main.log.info("All devices have been"+
-                                            " discovered on ONOS4")
+                                    main.log.info( "All devices have been" +
+                                                   " discovered on ONOS4" )
                             else:
                                 counter_avail4 = 0
                     if node == 5 and not onos5_dev:
-                        main.log.info("Checking node 5 for device "+
-                            "discovery")
+                        main.log.info( "Checking node 5 for device " +
+                                       "discovery" )
                         device_str_obj5 = main.ONOS5cli.devices(
-                            node_ip=ONOS_ip_list[5])
-                        device_json5 = json.loads(device_str_obj5)
+                            node_ip=ONOS_ip_list[ 5 ] )
+                        device_json5 = json.loads( device_str_obj5 )
                         for device5 in device_json5:
-                            if device5['available'] == True:
+                            if device5[ 'available' ]:
                                 counter_avail5 += 1
-                                if counter_avail5 == int(num_sw):
+                                if counter_avail5 == int( num_sw ):
                                     onos5_dev = True
-                                    main.log.info("All devices have been"+
-                                            " discovered on ONOS5")
+                                    main.log.info( "All devices have been" +
+                                                   " discovered on ONOS5" )
                             else:
                                 counter_avail5 = 0
                     if node == 6 and not onos6_dev:
-                        main.log.info("Checking node 6 for device "+
-                            "discovery")
+                        main.log.info( "Checking node 6 for device " +
+                                       "discovery" )
                         device_str_obj6 = main.ONOS6cli.devices(
-                            node_ip=ONOS_ip_list[6])
-                        device_json6 = json.loads(device_str_obj6)
+                            node_ip=ONOS_ip_list[ 6 ] )
+                        device_json6 = json.loads( device_str_obj6 )
                         for device6 in device_json6:
-                            if device6['available'] == True:
+                            if device6[ 'available' ]:
                                 counter_avail6 += 1
-                                if counter_avail6 == int(num_sw):
+                                if counter_avail6 == int( num_sw ):
                                     onos6_dev = True
-                                    main.log.info("All devices have been"+
-                                            " discovered on ONOS6")
+                                    main.log.info( "All devices have been" +
+                                                   " discovered on ONOS6" )
                             else:
                                 counter_avail6 = 0
                     if node == 7 and not onos7_dev:
-                        main.log.info("Checking node 7 for device "+
-                            "discovery")
+                        main.log.info( "Checking node 7 for device " +
+                                       "discovery" )
                         device_str_obj7 = main.ONOS7cli.devices(
-                            node_ip=ONOS_ip_list[7])
-                        device_json7 = json.loads(device_str_obj7)
+                            node_ip=ONOS_ip_list[ 7 ] )
+                        device_json7 = json.loads( device_str_obj7 )
                         for device7 in device_json7:
-                            if device7['available'] == True:
+                            if device7[ 'available' ]:
                                 counter_avail7 += 1
-                                if counter_avail7 == int(num_sw):
+                                if counter_avail7 == int( num_sw ):
                                     onos7_dev = True
-                                    main.log.info("All devices have been"+
-                                            " discovered on ONOS7")
+                                    main.log.info( "All devices have been" +
+                                                   " discovered on ONOS7" )
                             else:
                                 counter_avail7 = 0
-                    #END node loop
-              
-                #TODO: clean up this mess of an if statements if possible
-                #Treat each if as a separate test case with the given
+                    # END node loop
+
+                # TODO: clean up this mess of an if statements if possible
+                # Treat each if as a separate test case with the given
                 #     cluster count. Hence when the cluster count changes
                 #     the desired calculations will be made
                 if cluster_count == 1:
                     if onos1_dev:
-                        main.log.info("All devices have been discovered"+
-                            " on all ONOS instances")
-                        time.sleep(5)
+                        main.log.info( "All devices have been discovered" +
+                                       " on all ONOS instances" )
+                        time.sleep( 5 )
                         json_str_metrics_1 =\
                             main.ONOS1cli.topology_events_metrics()
-                        json_obj_1 = json.loads(json_str_metrics_1)
+                        json_obj_1 = json.loads( json_str_metrics_1 )
                         graph_timestamp_1 =\
-                            json_obj_1[graphTimestamp]['value']
-                        
+                            json_obj_1[ graphTimestamp ][ 'value' ]
+
                         graph_lat_1 = \
-                            int(graph_timestamp_1) - int(t0_system)
-                       
-                        main.log.info("Graph Timestamp ONOS1: "+
-                            str(graph_timestamp_1))
+                            int( graph_timestamp_1 ) - int( t0_system )
+
+                        main.log.info( "Graph Timestamp ONOS1: " +
+                                       str( graph_timestamp_1 ) )
 
                         if graph_lat_1 > sw_disc_threshold_min\
-                            and graph_lat_1 < sw_disc_threshold_max\
-                            and int(i) > iter_ignore:
+                                and graph_lat_1 < sw_disc_threshold_max\
+                                and int( i ) > iter_ignore:
                             sw_discovery_lat_list.append(
-                                    graph_lat_1)
-                            main.log.info("Sw discovery latency of "+
-                                str(cluster_count)+" node(s): "+
-                                str(graph_lat_1)+" ms")
+                                graph_lat_1 )
+                            main.log.info(
+                                "Sw discovery latency of " +
+                                str( cluster_count ) +
+                                " node(s): " +
+                                str( graph_lat_1 ) +
+                                " ms" )
                         else:
-                            main.log.info("Switch discovery latency "+
-                                "exceeded the threshold.")
-                            main.log.info(str(graph_lat_1)+" ms")
-                        #Break while loop 
+                            main.log.info( "Switch discovery latency " +
+                                           "exceeded the threshold." )
+                            main.log.info( str( graph_lat_1 ) + " ms" )
+                        # Break while loop
                         break
                 if cluster_count == 2:
                     if onos1_dev and onos2_dev:
-                        main.log.info("All devices have been discovered"+
-                            " on all "+str(cluster_count)+
-                            " ONOS instances")
-                        time.sleep(5)
+                        main.log.info( "All devices have been discovered" +
+                                       " on all " + str( cluster_count ) +
+                                       " ONOS instances" )
+                        time.sleep( 5 )
 
                         json_str_metrics_1 =\
                             main.ONOS1cli.topology_events_metrics()
                         json_str_metrics_2 =\
                             main.ONOS2cli.topology_events_metrics()
-                        json_obj_1 = json.loads(json_str_metrics_1)
-                        json_obj_2 = json.loads(json_str_metrics_2)
+                        json_obj_1 = json.loads( json_str_metrics_1 )
+                        json_obj_2 = json.loads( json_str_metrics_2 )
                         graph_timestamp_1 =\
-                            json_obj_1[graphTimestamp]['value']
+                            json_obj_1[ graphTimestamp ][ 'value' ]
                         graph_timestamp_2 =\
-                            json_obj_2[graphTimestamp]['value']
-                        
-                        graph_lat_1 = \
-                            int(graph_timestamp_1) - int(t0_system)
-                        graph_lat_2 = \
-                            int(graph_timestamp_2) - int(t0_system)
-                        
-                        main.log.info("Graph Timestamp ONOS1: "+
-                            str(graph_timestamp_1))
-                        main.log.info("Graph Timestamp ONOS2: "+
-                            str(graph_timestamp_2))
+                            json_obj_2[ graphTimestamp ][ 'value' ]
 
-                        max_graph_lat = max(graph_lat_1, 
-                            graph_lat_2, graph_lat_3)
+                        graph_lat_1 = \
+                            int( graph_timestamp_1 ) - int( t0_system )
+                        graph_lat_2 = \
+                            int( graph_timestamp_2 ) - int( t0_system )
+
+                        main.log.info( "Graph Timestamp ONOS1: " +
+                                       str( graph_timestamp_1 ) )
+                        main.log.info( "Graph Timestamp ONOS2: " +
+                                       str( graph_timestamp_2 ) )
+
+                        max_graph_lat = max( graph_lat_1,
+                                             graph_lat_2, graph_lat_3 )
 
                         if max_graph_lat > sw_disc_threshold_min\
-                            and max_graph_lat < sw_disc_threshold_max\
-                            and int(i) > iter_ignore:
+                                and max_graph_lat < sw_disc_threshold_max\
+                                and int( i ) > iter_ignore:
                             sw_discovery_lat_list.append(
-                                    max_graph_lat)
-                            main.log.info("Sw discovery latency of "+
-                                str(cluster_count)+" node(s): "+
-                                str(max_graph_lat)+" ms")
+                                max_graph_lat )
+                            main.log.info(
+                                "Sw discovery latency of " +
+                                str( cluster_count ) +
+                                " node(s): " +
+                                str( max_graph_lat ) +
+                                " ms" )
                         else:
-                            main.log.info("Switch discovery latency "+
-                                "exceeded the threshold.")
-                            main.log.info(str(max_graph_lat)+" ms")
+                            main.log.info( "Switch discovery latency " +
+                                           "exceeded the threshold." )
+                            main.log.info( str( max_graph_lat ) + " ms" )
                         break
                 if cluster_count == 3:
                     if onos1_dev and onos2_dev and onos3_dev:
-                        main.log.info("All devices have been discovered"+
-                            " on all "+str(cluster_count)+
-                            " ONOS instances")
-                        
-                        #TODO: Investigate this sleep
-                        #      added to 'pad' the results with 
+                        main.log.info( "All devices have been discovered" +
+                                       " on all " + str( cluster_count ) +
+                                       " ONOS instances" )
+
+                        # TODO: Investigate this sleep
+                        #      added to 'pad' the results with
                         #      plenty of time to 'catch up'
-                        time.sleep(5)
+                        time.sleep( 5 )
 
                         json_str_metrics_1 =\
                             main.ONOS1cli.topology_events_metrics()
@@ -596,53 +624,56 @@
                             main.ONOS2cli.topology_events_metrics()
                         json_str_metrics_3 =\
                             main.ONOS3cli.topology_events_metrics()
-                        json_obj_1 = json.loads(json_str_metrics_1)
-                        json_obj_2 = json.loads(json_str_metrics_2)
-                        json_obj_3 = json.loads(json_str_metrics_3)
+                        json_obj_1 = json.loads( json_str_metrics_1 )
+                        json_obj_2 = json.loads( json_str_metrics_2 )
+                        json_obj_3 = json.loads( json_str_metrics_3 )
                         graph_timestamp_1 =\
-                            json_obj_1[graphTimestamp]['value']
+                            json_obj_1[ graphTimestamp ][ 'value' ]
                         graph_timestamp_2 =\
-                            json_obj_2[graphTimestamp]['value']
+                            json_obj_2[ graphTimestamp ][ 'value' ]
                         graph_timestamp_3 =\
-                            json_obj_3[graphTimestamp]['value']
-                        
+                            json_obj_3[ graphTimestamp ][ 'value' ]
+
                         graph_lat_1 = \
-                            int(graph_timestamp_1) - int(t0_system)
+                            int( graph_timestamp_1 ) - int( t0_system )
                         graph_lat_2 = \
-                            int(graph_timestamp_2) - int(t0_system)
+                            int( graph_timestamp_2 ) - int( t0_system )
                         graph_lat_3 = \
-                            int(graph_timestamp_3) - int(t0_system)
+                            int( graph_timestamp_3 ) - int( t0_system )
 
-                        main.log.info("Graph Timestamp ONOS1: "+
-                            str(graph_timestamp_1))
-                        main.log.info("Graph Timestamp ONOS2: "+
-                            str(graph_timestamp_2))
-                        main.log.info("Graph Timestamp ONOS3: "+
-                            str(graph_timestamp_3))
+                        main.log.info( "Graph Timestamp ONOS1: " +
+                                       str( graph_timestamp_1 ) )
+                        main.log.info( "Graph Timestamp ONOS2: " +
+                                       str( graph_timestamp_2 ) )
+                        main.log.info( "Graph Timestamp ONOS3: " +
+                                       str( graph_timestamp_3 ) )
 
-                        max_graph_lat = max(graph_lat_1, 
-                                graph_lat_2,
-                                graph_lat_3)
+                        max_graph_lat = max( graph_lat_1,
+                                             graph_lat_2,
+                                             graph_lat_3 )
 
                         if max_graph_lat > sw_disc_threshold_min\
-                            and max_graph_lat < sw_disc_threshold_max\
-                            and int(i) > iter_ignore:
+                                and max_graph_lat < sw_disc_threshold_max\
+                                and int( i ) > iter_ignore:
                             sw_discovery_lat_list.append(
-                                    max_graph_lat)
-                            main.log.info("Sw discovery latency of "+
-                                str(cluster_count)+" node(s): "+
-                                str(max_graph_lat)+" ms")
+                                max_graph_lat )
+                            main.log.info(
+                                "Sw discovery latency of " +
+                                str( cluster_count ) +
+                                " node(s): " +
+                                str( max_graph_lat ) +
+                                " ms" )
                         else:
-                            main.log.info("Switch discovery latency "+
-                                "exceeded the threshold.")
-                            main.log.info(str(max_graph_lat)+" ms")
-                        
+                            main.log.info( "Switch discovery latency " +
+                                           "exceeded the threshold." )
+                            main.log.info( str( max_graph_lat ) + " ms" )
+
                         break
                 if cluster_count == 4:
                     if onos1_dev and onos2_dev and onos3_dev and\
                        onos4_dev:
-                        main.log.info("All devices have been discovered"+
-                            " on all ONOS instances")
+                        main.log.info( "All devices have been discovered" +
+                                       " on all ONOS instances" )
                         json_str_metrics_1 =\
                             main.ONOS1cli.topology_events_metrics()
                         json_str_metrics_2 =\
@@ -651,67 +682,70 @@
                             main.ONOS3cli.topology_events_metrics()
                         json_str_metrics_4 =\
                             main.ONOS4cli.topology_events_metrics()
-                        json_obj_1 = json.loads(json_str_metrics_1)
-                        json_obj_2 = json.loads(json_str_metrics_2)
-                        json_obj_3 = json.loads(json_str_metrics_3)
-                        json_obj_4 = json.loads(json_str_metrics_4)
+                        json_obj_1 = json.loads( json_str_metrics_1 )
+                        json_obj_2 = json.loads( json_str_metrics_2 )
+                        json_obj_3 = json.loads( json_str_metrics_3 )
+                        json_obj_4 = json.loads( json_str_metrics_4 )
                         graph_timestamp_1 =\
-                            json_obj_1[graphTimestamp]['value']
+                            json_obj_1[ graphTimestamp ][ 'value' ]
                         graph_timestamp_2 =\
-                            json_obj_2[graphTimestamp]['value']
+                            json_obj_2[ graphTimestamp ][ 'value' ]
                         graph_timestamp_3 =\
-                            json_obj_3[graphTimestamp]['value']
+                            json_obj_3[ graphTimestamp ][ 'value' ]
                         graph_timestamp_4 =\
-                            json_obj_4[graphTimestamp]['value']
-                        
-                        graph_lat_1 = \
-                            int(graph_timestamp_1) - int(t0_system)
-                        graph_lat_2 = \
-                            int(graph_timestamp_2) - int(t0_system)
-                        graph_lat_3 = \
-                            int(graph_timestamp_3) - int(t0_system)
-                        graph_lat_4 = \
-                            int(graph_timestamp_4) - int(t0_system)
-                        
-                        main.log.info("Graph Timestamp ONOS1: "+
-                            str(graph_timestamp_1))
-                        main.log.info("Graph Timestamp ONOS2: "+
-                            str(graph_timestamp_2))
-                        main.log.info("Graph Timestamp ONOS3: "+
-                            str(graph_timestamp_3))
-                        main.log.info("Graph Timestamp ONOS4: "+
-                            str(graph_timestamp_4))
+                            json_obj_4[ graphTimestamp ][ 'value' ]
 
-                        max_graph_lat = max(graph_lat_1,
-                                graph_lat_2,
-                                graph_lat_3,
-                                graph_lat_4)
-                        
+                        graph_lat_1 = \
+                            int( graph_timestamp_1 ) - int( t0_system )
+                        graph_lat_2 = \
+                            int( graph_timestamp_2 ) - int( t0_system )
+                        graph_lat_3 = \
+                            int( graph_timestamp_3 ) - int( t0_system )
+                        graph_lat_4 = \
+                            int( graph_timestamp_4 ) - int( t0_system )
+
+                        main.log.info( "Graph Timestamp ONOS1: " +
+                                       str( graph_timestamp_1 ) )
+                        main.log.info( "Graph Timestamp ONOS2: " +
+                                       str( graph_timestamp_2 ) )
+                        main.log.info( "Graph Timestamp ONOS3: " +
+                                       str( graph_timestamp_3 ) )
+                        main.log.info( "Graph Timestamp ONOS4: " +
+                                       str( graph_timestamp_4 ) )
+
+                        max_graph_lat = max( graph_lat_1,
+                                             graph_lat_2,
+                                             graph_lat_3,
+                                             graph_lat_4 )
+
                         if max_graph_lat > sw_disc_threshold_min\
-                            and max_graph_lat < sw_disc_threshold_max\
-                            and int(i) > iter_ignore:
+                                and max_graph_lat < sw_disc_threshold_max\
+                                and int( i ) > iter_ignore:
                             sw_discovery_lat_list.append(
-                                    max_graph_lat)
-                            main.log.info("Sw discovery latency of "+
-                                str(cluster_count)+" node(s): "+
-                                str(max_graph_lat)+" ms")
+                                max_graph_lat )
+                            main.log.info(
+                                "Sw discovery latency of " +
+                                str( cluster_count ) +
+                                " node(s): " +
+                                str( max_graph_lat ) +
+                                " ms" )
                         else:
-                            main.log.info("Switch discovery latency "+
-                                "exceeded the threshold.")
-                            main.log.info(str(max_graph_lat)+" ms")
-                
+                            main.log.info( "Switch discovery latency " +
+                                           "exceeded the threshold." )
+                            main.log.info( str( max_graph_lat ) + " ms" )
+
                         break
                 if cluster_count == 5:
                     if onos1_dev and onos2_dev and onos3_dev and\
                        onos4_dev and onos5_dev:
-                        main.log.info("All devices have been discovered"+
-                            " on all ONOS instances")
-                        
-                        #TODO: Investigate this sleep
-                        #      added to 'pad' the results with 
+                        main.log.info( "All devices have been discovered" +
+                                       " on all ONOS instances" )
+
+                        # TODO: Investigate this sleep
+                        #      added to 'pad' the results with
                         #      plenty of time to 'catch up'
-                        time.sleep(5)
-                        
+                        time.sleep( 5 )
+
                         json_str_metrics_1 =\
                             main.ONOS1cli.topology_events_metrics()
                         json_str_metrics_2 =\
@@ -722,69 +756,72 @@
                             main.ONOS4cli.topology_events_metrics()
                         json_str_metrics_5 =\
                             main.ONOS5cli.topology_events_metrics()
-                        json_obj_1 = json.loads(json_str_metrics_1)
-                        json_obj_2 = json.loads(json_str_metrics_2)
-                        json_obj_3 = json.loads(json_str_metrics_3)
-                        json_obj_4 = json.loads(json_str_metrics_4)
-                        json_obj_5 = json.loads(json_str_metrics_5)
+                        json_obj_1 = json.loads( json_str_metrics_1 )
+                        json_obj_2 = json.loads( json_str_metrics_2 )
+                        json_obj_3 = json.loads( json_str_metrics_3 )
+                        json_obj_4 = json.loads( json_str_metrics_4 )
+                        json_obj_5 = json.loads( json_str_metrics_5 )
                         graph_timestamp_1 =\
-                            json_obj_1[graphTimestamp]['value']
+                            json_obj_1[ graphTimestamp ][ 'value' ]
                         graph_timestamp_2 =\
-                            json_obj_2[graphTimestamp]['value']
+                            json_obj_2[ graphTimestamp ][ 'value' ]
                         graph_timestamp_3 =\
-                            json_obj_3[graphTimestamp]['value']
+                            json_obj_3[ graphTimestamp ][ 'value' ]
                         graph_timestamp_4 =\
-                            json_obj_4[graphTimestamp]['value']
+                            json_obj_4[ graphTimestamp ][ 'value' ]
                         graph_timestamp_5 =\
-                            json_obj_5[graphTimestamp]['value']
-                        
-                        graph_lat_1 = \
-                            int(graph_timestamp_1) - int(t0_system)
-                        graph_lat_2 = \
-                            int(graph_timestamp_2) - int(t0_system)
-                        graph_lat_3 = \
-                            int(graph_timestamp_3) - int(t0_system)
-                        graph_lat_4 = \
-                            int(graph_timestamp_4) - int(t0_system)
-                        graph_lat_5 = \
-                            int(graph_timestamp_5) - int(t0_system)
-                        
-                        main.log.info("Graph Timestamp ONOS1: "+
-                            str(graph_timestamp_1))
-                        main.log.info("Graph Timestamp ONOS2: "+
-                            str(graph_timestamp_2))
-                        main.log.info("Graph Timestamp ONOS3: "+
-                            str(graph_timestamp_3))
-                        main.log.info("Graph Timestamp ONOS4: "+
-                            str(graph_timestamp_4))
-                        main.log.info("Graph Timestamp ONOS5: "+
-                            str(graph_timestamp_5))
+                            json_obj_5[ graphTimestamp ][ 'value' ]
 
-                        max_graph_lat = max(graph_lat_1,
-                                graph_lat_2,
-                                graph_lat_3,
-                                graph_lat_4,
-                                graph_lat_5)
-                        
+                        graph_lat_1 = \
+                            int( graph_timestamp_1 ) - int( t0_system )
+                        graph_lat_2 = \
+                            int( graph_timestamp_2 ) - int( t0_system )
+                        graph_lat_3 = \
+                            int( graph_timestamp_3 ) - int( t0_system )
+                        graph_lat_4 = \
+                            int( graph_timestamp_4 ) - int( t0_system )
+                        graph_lat_5 = \
+                            int( graph_timestamp_5 ) - int( t0_system )
+
+                        main.log.info( "Graph Timestamp ONOS1: " +
+                                       str( graph_timestamp_1 ) )
+                        main.log.info( "Graph Timestamp ONOS2: " +
+                                       str( graph_timestamp_2 ) )
+                        main.log.info( "Graph Timestamp ONOS3: " +
+                                       str( graph_timestamp_3 ) )
+                        main.log.info( "Graph Timestamp ONOS4: " +
+                                       str( graph_timestamp_4 ) )
+                        main.log.info( "Graph Timestamp ONOS5: " +
+                                       str( graph_timestamp_5 ) )
+
+                        max_graph_lat = max( graph_lat_1,
+                                             graph_lat_2,
+                                             graph_lat_3,
+                                             graph_lat_4,
+                                             graph_lat_5 )
+
                         if max_graph_lat > sw_disc_threshold_min\
-                            and max_graph_lat < sw_disc_threshold_max\
-                            and int(i) > iter_ignore:
+                                and max_graph_lat < sw_disc_threshold_max\
+                                and int( i ) > iter_ignore:
                             sw_discovery_lat_list.append(
-                                    max_graph_lat)
-                            main.log.info("Sw discovery latency of "+
-                                str(cluster_count)+" node(s): "+
-                                str(max_graph_lat)+" ms")
+                                max_graph_lat )
+                            main.log.info(
+                                "Sw discovery latency of " +
+                                str( cluster_count ) +
+                                " node(s): " +
+                                str( max_graph_lat ) +
+                                " ms" )
                         else:
-                            main.log.info("Switch discovery latency "+
-                                "exceeded the threshold.")
-                            main.log.info(str(max_graph_lat)+" ms")
-                
+                            main.log.info( "Switch discovery latency " +
+                                           "exceeded the threshold." )
+                            main.log.info( str( max_graph_lat ) + " ms" )
+
                         break
                 if cluster_count == 6:
                     if onos1_dev and onos2_dev and onos3_dev and\
                        onos4_dev and onos5_dev and onos6_dev:
-                        main.log.info("All devices have been discovered"+
-                            " on all ONOS instances")
+                        main.log.info( "All devices have been discovered" +
+                                       " on all ONOS instances" )
                         json_str_metrics_1 =\
                             main.ONOS1cli.topology_events_metrics()
                         json_str_metrics_2 =\
@@ -797,84 +834,87 @@
                             main.ONOS5cli.topology_events_metrics()
                         json_str_metrics_6 =\
                             main.ONOS6cli.topology_events_metrics()
-                        json_obj_1 = json.loads(json_str_metrics_1)
-                        json_obj_2 = json.loads(json_str_metrics_2)
-                        json_obj_3 = json.loads(json_str_metrics_3)
-                        json_obj_4 = json.loads(json_str_metrics_4)
-                        json_obj_5 = json.loads(json_str_metrics_5)
-                        json_obj_6 = json.loads(json_str_metrics_6)
+                        json_obj_1 = json.loads( json_str_metrics_1 )
+                        json_obj_2 = json.loads( json_str_metrics_2 )
+                        json_obj_3 = json.loads( json_str_metrics_3 )
+                        json_obj_4 = json.loads( json_str_metrics_4 )
+                        json_obj_5 = json.loads( json_str_metrics_5 )
+                        json_obj_6 = json.loads( json_str_metrics_6 )
                         graph_timestamp_1 =\
-                            json_obj_1[graphTimestamp]['value']
+                            json_obj_1[ graphTimestamp ][ 'value' ]
                         graph_timestamp_2 =\
-                            json_obj_2[graphTimestamp]['value']
+                            json_obj_2[ graphTimestamp ][ 'value' ]
                         graph_timestamp_3 =\
-                            json_obj_3[graphTimestamp]['value']
+                            json_obj_3[ graphTimestamp ][ 'value' ]
                         graph_timestamp_4 =\
-                            json_obj_4[graphTimestamp]['value']
+                            json_obj_4[ graphTimestamp ][ 'value' ]
                         graph_timestamp_5 =\
-                            json_obj_5[graphTimestamp]['value']
+                            json_obj_5[ graphTimestamp ][ 'value' ]
                         graph_timestamp_6 =\
-                            json_obj_6[graphTimestamp]['value']
-                        
-                        graph_lat_1 = \
-                            int(graph_timestamp_1) - int(t0_system)
-                        graph_lat_2 = \
-                            int(graph_timestamp_2) - int(t0_system)
-                        graph_lat_3 = \
-                            int(graph_timestamp_3) - int(t0_system)
-                        graph_lat_4 = \
-                            int(graph_timestamp_4) - int(t0_system)
-                        graph_lat_5 = \
-                            int(graph_timestamp_5) - int(t0_system)
-                        graph_lat_6 = \
-                            int(graph_timestamp_6) - int(t0_system)
-                        
-                        main.log.info("Graph Timestamp ONOS1: "+
-                            str(graph_timestamp_1))
-                        main.log.info("Graph Timestamp ONOS2: "+
-                            str(graph_timestamp_2))
-                        main.log.info("Graph Timestamp ONOS3: "+
-                            str(graph_timestamp_3))
-                        main.log.info("Graph Timestamp ONOS4: "+
-                            str(graph_timestamp_4))
-                        main.log.info("Graph Timestamp ONOS5: "+
-                            str(graph_timestamp_5))
-                        main.log.info("Graph Timestamp ONOS6: "+
-                            str(graph_timestamp_6))
+                            json_obj_6[ graphTimestamp ][ 'value' ]
 
-                        max_graph_lat = max(graph_lat_1,
-                                graph_lat_2,
-                                graph_lat_3,
-                                graph_lat_4,
-                                graph_lat_5,
-                                graph_lat_6)
-                        
+                        graph_lat_1 = \
+                            int( graph_timestamp_1 ) - int( t0_system )
+                        graph_lat_2 = \
+                            int( graph_timestamp_2 ) - int( t0_system )
+                        graph_lat_3 = \
+                            int( graph_timestamp_3 ) - int( t0_system )
+                        graph_lat_4 = \
+                            int( graph_timestamp_4 ) - int( t0_system )
+                        graph_lat_5 = \
+                            int( graph_timestamp_5 ) - int( t0_system )
+                        graph_lat_6 = \
+                            int( graph_timestamp_6 ) - int( t0_system )
+
+                        main.log.info( "Graph Timestamp ONOS1: " +
+                                       str( graph_timestamp_1 ) )
+                        main.log.info( "Graph Timestamp ONOS2: " +
+                                       str( graph_timestamp_2 ) )
+                        main.log.info( "Graph Timestamp ONOS3: " +
+                                       str( graph_timestamp_3 ) )
+                        main.log.info( "Graph Timestamp ONOS4: " +
+                                       str( graph_timestamp_4 ) )
+                        main.log.info( "Graph Timestamp ONOS5: " +
+                                       str( graph_timestamp_5 ) )
+                        main.log.info( "Graph Timestamp ONOS6: " +
+                                       str( graph_timestamp_6 ) )
+
+                        max_graph_lat = max( graph_lat_1,
+                                             graph_lat_2,
+                                             graph_lat_3,
+                                             graph_lat_4,
+                                             graph_lat_5,
+                                             graph_lat_6 )
+
                         if max_graph_lat > sw_disc_threshold_min\
-                            and max_graph_lat < sw_disc_threshold_max\
-                            and int(i) > iter_ignore:
+                                and max_graph_lat < sw_disc_threshold_max\
+                                and int( i ) > iter_ignore:
                             sw_discovery_lat_list.append(
-                                    max_graph_lat)
-                            main.log.info("Sw discovery latency of "+
-                                str(cluster_count)+" node(s): "+
-                                str(max_graph_lat)+" ms")
+                                max_graph_lat )
+                            main.log.info(
+                                "Sw discovery latency of " +
+                                str( cluster_count ) +
+                                " node(s): " +
+                                str( max_graph_lat ) +
+                                " ms" )
                         else:
-                            main.log.info("Switch discovery latency "+
-                                "exceeded the threshold.")
-                            main.log.info(str(max_graph_lat)+" ms")
-                        
+                            main.log.info( "Switch discovery latency " +
+                                           "exceeded the threshold." )
+                            main.log.info( str( max_graph_lat ) + " ms" )
+
                         break
                 if cluster_count == 7:
                     if onos1_dev and onos2_dev and onos3_dev and\
                        onos4_dev and onos5_dev and onos6_dev and\
                        onos7_dev:
-                        main.log.info("All devices have been discovered"+
-                            " on all ONOS instances")
-                        
-                        #TODO: Investigate this sleep
-                        #      added to 'pad' the results with 
+                        main.log.info( "All devices have been discovered" +
+                                       " on all ONOS instances" )
+
+                        # TODO: Investigate this sleep
+                        #      added to 'pad' the results with
                         #      plenty of time to 'catch up'
-                        time.sleep(5)
-                        
+                        time.sleep( 5 )
+
                         json_str_metrics_1 =\
                             main.ONOS1cli.topology_events_metrics()
                         json_str_metrics_2 =\
@@ -889,390 +929,451 @@
                             main.ONOS6cli.topology_events_metrics()
                         json_str_metrics_7 =\
                             main.ONOS7cli.topology_events_metrics()
-                        json_obj_1 = json.loads(json_str_metrics_1)
-                        json_obj_2 = json.loads(json_str_metrics_2)
-                        json_obj_3 = json.loads(json_str_metrics_3)
-                        json_obj_4 = json.loads(json_str_metrics_4)
-                        json_obj_5 = json.loads(json_str_metrics_5)
-                        json_obj_6 = json.loads(json_str_metrics_6)
-                        json_obj_7 = json.loads(json_str_metrics_7)
+                        json_obj_1 = json.loads( json_str_metrics_1 )
+                        json_obj_2 = json.loads( json_str_metrics_2 )
+                        json_obj_3 = json.loads( json_str_metrics_3 )
+                        json_obj_4 = json.loads( json_str_metrics_4 )
+                        json_obj_5 = json.loads( json_str_metrics_5 )
+                        json_obj_6 = json.loads( json_str_metrics_6 )
+                        json_obj_7 = json.loads( json_str_metrics_7 )
                         graph_timestamp_1 =\
-                            json_obj_1[graphTimestamp]['value']
+                            json_obj_1[ graphTimestamp ][ 'value' ]
                         graph_timestamp_2 =\
-                            json_obj_2[graphTimestamp]['value']
+                            json_obj_2[ graphTimestamp ][ 'value' ]
                         graph_timestamp_3 =\
-                            json_obj_3[graphTimestamp]['value']
+                            json_obj_3[ graphTimestamp ][ 'value' ]
                         graph_timestamp_4 =\
-                            json_obj_4[graphTimestamp]['value']
+                            json_obj_4[ graphTimestamp ][ 'value' ]
                         graph_timestamp_5 =\
-                            json_obj_5[graphTimestamp]['value']
+                            json_obj_5[ graphTimestamp ][ 'value' ]
                         graph_timestamp_6 =\
-                            json_obj_6[graphTimestamp]['value']
+                            json_obj_6[ graphTimestamp ][ 'value' ]
                         graph_timestamp_7 =\
-                            json_obj_7[graphTimestamp]['value']
-                        
+                            json_obj_7[ graphTimestamp ][ 'value' ]
+
                         graph_lat_1 = \
-                            int(graph_timestamp_1) - int(t0_system)
+                            int( graph_timestamp_1 ) - int( t0_system )
                         graph_lat_2 = \
-                            int(graph_timestamp_2) - int(t0_system)
+                            int( graph_timestamp_2 ) - int( t0_system )
                         graph_lat_3 = \
-                            int(graph_timestamp_3) - int(t0_system)
+                            int( graph_timestamp_3 ) - int( t0_system )
                         graph_lat_4 = \
-                            int(graph_timestamp_4) - int(t0_system)
+                            int( graph_timestamp_4 ) - int( t0_system )
                         graph_lat_5 = \
-                            int(graph_timestamp_5) - int(t0_system)
+                            int( graph_timestamp_5 ) - int( t0_system )
                         graph_lat_6 = \
-                            int(graph_timestamp_6) - int(t0_system)
+                            int( graph_timestamp_6 ) - int( t0_system )
                         graph_lat_7 = \
-                            int(graph_timestamp_7) - int(t0_system)
+                            int( graph_timestamp_7 ) - int( t0_system )
 
-                        main.log.info("Graph Timestamp ONOS1: "+
-                            str(graph_timestamp_1))
-                        main.log.info("Graph Timestamp ONOS2: "+
-                            str(graph_timestamp_2))
-                        main.log.info("Graph Timestamp ONOS3: "+
-                            str(graph_timestamp_3))
-                        main.log.info("Graph Timestamp ONOS4: "+
-                            str(graph_timestamp_4))
-                        main.log.info("Graph Timestamp ONOS5: "+
-                            str(graph_timestamp_5))
-                        main.log.info("Graph Timestamp ONOS6: "+
-                            str(graph_timestamp_6))
-                        main.log.info("Graph Timestamp ONOS7: "+
-                            str(graph_timestamp_7))
+                        main.log.info( "Graph Timestamp ONOS1: " +
+                                       str( graph_timestamp_1 ) )
+                        main.log.info( "Graph Timestamp ONOS2: " +
+                                       str( graph_timestamp_2 ) )
+                        main.log.info( "Graph Timestamp ONOS3: " +
+                                       str( graph_timestamp_3 ) )
+                        main.log.info( "Graph Timestamp ONOS4: " +
+                                       str( graph_timestamp_4 ) )
+                        main.log.info( "Graph Timestamp ONOS5: " +
+                                       str( graph_timestamp_5 ) )
+                        main.log.info( "Graph Timestamp ONOS6: " +
+                                       str( graph_timestamp_6 ) )
+                        main.log.info( "Graph Timestamp ONOS7: " +
+                                       str( graph_timestamp_7 ) )
 
-                        max_graph_lat = max(graph_lat_1,
-                                graph_lat_2,
-                                graph_lat_3,
-                                graph_lat_4,
-                                graph_lat_5,
-                                graph_lat_6,
-                                graph_lat_7)
-                        
+                        max_graph_lat = max( graph_lat_1,
+                                             graph_lat_2,
+                                             graph_lat_3,
+                                             graph_lat_4,
+                                             graph_lat_5,
+                                             graph_lat_6,
+                                             graph_lat_7 )
+
                         if max_graph_lat > sw_disc_threshold_min\
-                            and max_graph_lat < sw_disc_threshold_max\
-                            and int(i) > iter_ignore:
+                                and max_graph_lat < sw_disc_threshold_max\
+                                and int( i ) > iter_ignore:
                             sw_discovery_lat_list.append(
-                                    max_graph_lat)
-                            main.log.info("Sw discovery latency of "+
-                                str(cluster_count)+" node(s): "+
-                                str(max_graph_lat)+" ms")
+                                max_graph_lat )
+                            main.log.info(
+                                "Sw discovery latency of " +
+                                str( cluster_count ) +
+                                " node(s): " +
+                                str( max_graph_lat ) +
+                                " ms" )
                         else:
-                            main.log.info("Switch discovery latency "+
-                                "exceeded the threshold.")
-                            main.log.info(str(max_graph_lat)+" ms")
-                        
+                            main.log.info( "Switch discovery latency " +
+                                           "exceeded the threshold." )
+                            main.log.info( str( max_graph_lat ) + " ms" )
+
                         break
-                
+
                 counter_loop += 1
-                time.sleep(3)
-                #END WHILE LOOP            
-          
-            #Below is used for reporting SYN / ACK timing
-            #of all switches 
+                time.sleep( 3 )
+                # END WHILE LOOP
+
+            # Below is used for reporting SYN / ACK timing
+            # of all switches
             main.ONOS1.tshark_stop()
             syn_ack_timestamp_list = []
             if cluster_count < 3:
-                #TODO: capture synack on nodes less than 3
-                syn_ack_timestamp_list.append(0)
+                # TODO: capture synack on nodes less than 3
+                syn_ack_timestamp_list.append( 0 )
 
             if cluster_count >= 3:
-                main.ONOS2.tshark_stop() 
+                main.ONOS2.tshark_stop()
                 main.ONOS3.tshark_stop()
-                time.sleep(5)
-                os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
-                    "/tmp/syn_ack_onos1_iter"+str(i)+".txt /tmp/")
-                os.system("scp "+ONOS_user+"@"+ONOS2_ip+":"+
-                    "/tmp/syn_ack_onos2_iter"+str(i)+".txt /tmp/")
-                os.system("scp "+ONOS_user+"@"+ONOS3_ip+":"+
-                    "/tmp/syn_ack_onos3_iter"+str(i)+".txt /tmp/")
-                time.sleep(5)
-                #Read each of the files and append all
-                #SYN / ACK timestamps to the list
-                with open("/tmp/syn_ack_onos1_iter"+str(i)+".txt") as\
-                     f_onos1:
+                time.sleep( 5 )
+                os.system(
+                    "scp " +
+                    ONOS_user +
+                    "@" +
+                    ONOS1_ip +
+                    ":" +
+                    "/tmp/syn_ack_onos1_iter" +
+                    str( i ) +
+                    ".txt /tmp/" )
+                os.system(
+                    "scp " +
+                    ONOS_user +
+                    "@" +
+                    ONOS2_ip +
+                    ":" +
+                    "/tmp/syn_ack_onos2_iter" +
+                    str( i ) +
+                    ".txt /tmp/" )
+                os.system(
+                    "scp " +
+                    ONOS_user +
+                    "@" +
+                    ONOS3_ip +
+                    ":" +
+                    "/tmp/syn_ack_onos3_iter" +
+                    str( i ) +
+                    ".txt /tmp/" )
+                time.sleep( 5 )
+                # Read each of the files and append all
+                # SYN / ACK timestamps to the list
+                with open( "/tmp/syn_ack_onos1_iter" + str( i ) + ".txt" ) as\
+                        f_onos1:
                     for line in f_onos1:
-                        line = line.split(" ")
+                        line = line.split( " " )
                         try:
-                            float(line[1])
-                            syn_ack_timestamp_list.append(line[1])
+                            float( line[ 1 ] )
+                            syn_ack_timestamp_list.append( line[ 1 ] )
                         except ValueError:
-                            main.log.info("String cannot be converted")
-                with open("/tmp/syn_ack_onos2_iter"+str(i)+".txt") as\
-                     f_onos2:
+                            main.log.info( "String cannot be converted" )
+                with open( "/tmp/syn_ack_onos2_iter" + str( i ) + ".txt" ) as\
+                        f_onos2:
                     for line in f_onos2:
-                        line = line.split(" ")
+                        line = line.split( " " )
                         try:
-                            float(line[1])
-                            syn_ack_timestamp_list.append(line[1])
+                            float( line[ 1 ] )
+                            syn_ack_timestamp_list.append( line[ 1 ] )
                         except ValueError:
-                            main.log.info("String cannot be converted")
-                with open("/tmp/syn_ack_onos3_iter"+str(i)+".txt") as\
-                     f_onos3:
+                            main.log.info( "String cannot be converted" )
+                with open( "/tmp/syn_ack_onos3_iter" + str( i ) + ".txt" ) as\
+                        f_onos3:
                     for line in f_onos3:
-                        line = line.split(" ")
+                        line = line.split( " " )
                         try:
-                            float(line[1])
-                            syn_ack_timestamp_list.append(line[1])
+                            float( line[ 1 ] )
+                            syn_ack_timestamp_list.append( line[ 1 ] )
                         except ValueError:
-                            main.log.info("String cannot be converted")
+                            main.log.info( "String cannot be converted" )
             if cluster_count >= 4:
-                main.ONOS4.tshark_stop() 
-                time.sleep(5)
-                os.system("scp "+ONOS_user+"@"+ONOS4_ip+":"+
-                    "/tmp/syn_ack_onos4_iter"+str(i)+".txt /tmp/")
-                time.sleep(5)
-                with open("/tmp/syn_ack_onos4_iter"+str(i)+".txt") as\
-                     f_onos4:
+                main.ONOS4.tshark_stop()
+                time.sleep( 5 )
+                os.system(
+                    "scp " +
+                    ONOS_user +
+                    "@" +
+                    ONOS4_ip +
+                    ":" +
+                    "/tmp/syn_ack_onos4_iter" +
+                    str( i ) +
+                    ".txt /tmp/" )
+                time.sleep( 5 )
+                with open( "/tmp/syn_ack_onos4_iter" + str( i ) + ".txt" ) as\
+                        f_onos4:
                     for line in f_onos4:
-                        line = line.split(" ")
+                        line = line.split( " " )
                         try:
-                            float(line[1])
-                            syn_ack_timestamp_list.append(line[1])
+                            float( line[ 1 ] )
+                            syn_ack_timestamp_list.append( line[ 1 ] )
                         except ValueError:
-                            main.log.info("String cannot be converted")
+                            main.log.info( "String cannot be converted" )
             if cluster_count >= 5:
                 main.ONOS5.tshark_stop()
-                time.sleep(5)
-                os.system("scp "+ONOS_user+"@"+ONOS5_ip+":"+
-                    "/tmp/syn_ack_onos5_iter"+str(i)+".txt /tmp/")
-                time.sleep(5)
-                with open("/tmp/syn_ack_onos5_iter"+str(i)+".txt") as\
-                     f_onos5:
+                time.sleep( 5 )
+                os.system(
+                    "scp " +
+                    ONOS_user +
+                    "@" +
+                    ONOS5_ip +
+                    ":" +
+                    "/tmp/syn_ack_onos5_iter" +
+                    str( i ) +
+                    ".txt /tmp/" )
+                time.sleep( 5 )
+                with open( "/tmp/syn_ack_onos5_iter" + str( i ) + ".txt" ) as\
+                        f_onos5:
                     for line in f_onos5:
-                        line = line.split(" ")
+                        line = line.split( " " )
                         try:
-                            float(line[1])
-                            syn_ack_timestamp_list.append(line[1])
+                            float( line[ 1 ] )
+                            syn_ack_timestamp_list.append( line[ 1 ] )
                         except ValueError:
-                            main.log.info("String cannot be converted")
+                            main.log.info( "String cannot be converted" )
             if cluster_count >= 6:
                 main.ONOS6.tshark_stop()
-                time.sleep(5)
-                os.system("scp "+ONOS_user+"@"+ONOS6_ip+":"+
-                    "/tmp/syn_ack_onos6_iter"+str(i)+".txt /tmp/")
-                time.sleep(5)
-                with open("/tmp/syn_ack_onos6_iter"+str(i)+".txt") as\
-                     f_onos6:
+                time.sleep( 5 )
+                os.system(
+                    "scp " +
+                    ONOS_user +
+                    "@" +
+                    ONOS6_ip +
+                    ":" +
+                    "/tmp/syn_ack_onos6_iter" +
+                    str( i ) +
+                    ".txt /tmp/" )
+                time.sleep( 5 )
+                with open( "/tmp/syn_ack_onos6_iter" + str( i ) + ".txt" ) as\
+                        f_onos6:
                     for line in f_onos6:
-                        line = line.split(" ")
+                        line = line.split( " " )
                         try:
-                            float(line[1])
-                            syn_ack_timestamp_list.append(line[1])
+                            float( line[ 1 ] )
+                            syn_ack_timestamp_list.append( line[ 1 ] )
                         except ValueError:
-                            main.log.info("String cannot be converted")
+                            main.log.info( "String cannot be converted" )
             if cluster_count == 7:
                 main.ONOS7.tshark_stop()
-                time.sleep(5)
-                os.system("scp "+ONOS_user+"@"+ONOS7_ip+":"+
-                    "/tmp/syn_ack_onos7_iter"+str(i)+".txt /tmp/")
-                time.sleep(5)
-                with open("/tmp/syn_ack_onos7_iter"+str(i)+".txt") as\
-                     f_onos7:
+                time.sleep( 5 )
+                os.system(
+                    "scp " +
+                    ONOS_user +
+                    "@" +
+                    ONOS7_ip +
+                    ":" +
+                    "/tmp/syn_ack_onos7_iter" +
+                    str( i ) +
+                    ".txt /tmp/" )
+                time.sleep( 5 )
+                with open( "/tmp/syn_ack_onos7_iter" + str( i ) + ".txt" ) as\
+                        f_onos7:
                     for line in f_onos7:
-                        line = line.split(" ")
+                        line = line.split( " " )
                         try:
-                            float(line[1])
-                            syn_ack_timestamp_list.append(line[1])
+                            float( line[ 1 ] )
+                            syn_ack_timestamp_list.append( line[ 1 ] )
                         except ValueError:
-                            main.log.info("String cannot be converted")
-          
-            #Sort the list by timestamp
-            syn_ack_timestamp_list = sorted(syn_ack_timestamp_list)
-            print "syn_ack_-1  " + str(syn_ack_timestamp_list)
+                            main.log.info( "String cannot be converted" )
+
+            # Sort the list by timestamp
+            syn_ack_timestamp_list = sorted( syn_ack_timestamp_list )
+            print "syn_ack_-1  " + str( syn_ack_timestamp_list )
 
             syn_ack_delta =\
-                    int(float(syn_ack_timestamp_list[-1])*1000) -\
-                    int(float(syn_ack_timestamp_list[0])*1000) 
+                int( float( syn_ack_timestamp_list[ -1 ] ) * 1000 ) -\
+                int( float( syn_ack_timestamp_list[ 0 ] ) * 1000 )
 
-            main.log.info("Switch connection attempt delta iteration "+
-                    str(i)+": "+str(syn_ack_delta))
-            syn_ack_delta_list.append(syn_ack_delta)
-            #END ITERATION LOOP
-        #REPORT HERE 
+            main.log.info( "Switch connection attempt delta iteration " +
+                           str( i ) + ": " + str( syn_ack_delta ) )
+            syn_ack_delta_list.append( syn_ack_delta )
+            # END ITERATION LOOP
+        # REPORT HERE
 
-        if len(sw_discovery_lat_list) > 0:
-            sw_lat_avg = sum(sw_discovery_lat_list) / \
-                     len(sw_discovery_lat_list)
-            sw_lat_dev = numpy.std(sw_discovery_lat_list)
+        if len( sw_discovery_lat_list ) > 0:
+            sw_lat_avg = sum( sw_discovery_lat_list ) / \
+                len( sw_discovery_lat_list )
+            sw_lat_dev = numpy.std( sw_discovery_lat_list )
         else:
             sw_lat_avg = 0
             sw_lat_dev = 0
             assertion = main.FALSE
-        
-        main.log.report("Switch connection attempt time avg "+
-            "(last sw SYN/ACK time - first sw SYN/ACK time) "+
-            str(sum(syn_ack_delta_list)/len(syn_ack_delta_list)) +
-            " ms")
-        main.log.report(str(num_sw)+" Switch discovery lat for "+\
-            str(cluster_count)+" instance(s): ")
-        main.log.report("Avg: "+str(sw_lat_avg)+" ms  "+
-            "Std Deviation: "+str(round(sw_lat_dev,1))+" ms")
 
-        utilities.assert_equals(expect=main.TRUE, actual=assertion,
-                onpass="Switch discovery convergence latency" +\
-                        " for "+str(cluster_count)+" nodes successful",
-                onfail="Switch discovery convergence latency" +\
-                        " test failed")
-        
-    def CASE3(self, main):
-        '''
+        main.log.report( "Switch connection attempt time avg " +
+                         "(last sw SYN/ACK time - first sw SYN/ACK time) " +
+                         str( sum( syn_ack_delta_list ) /
+                              len( syn_ack_delta_list ) ) +
+                         " ms" )
+        main.log.report( str( num_sw ) + " Switch discovery lat for " +
+                         str( cluster_count ) + " instance(s): " )
+        main.log.report( "Avg: " +
+                         str( sw_lat_avg ) +
+                         " ms  " +
+                         "Std Deviation: " +
+                         str( round( sw_lat_dev, 1 ) ) +
+                         " ms" )
+
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=assertion,
+            onpass="Switch discovery convergence latency" +
+            " for " +
+            str( cluster_count ) +
+            " nodes successful",
+            onfail="Switch discovery convergence latency" +
+            " test failed" )
+
+    def CASE3( self, main ):
+        """
         Increase number of nodes and initiate CLI
-        '''
+        """
         import time
         import subprocess
         import os
         import requests
         import json
-       
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS4_ip = main.params['CTRL']['ip4']
-        ONOS5_ip = main.params['CTRL']['ip5']
-        ONOS6_ip = main.params['CTRL']['ip6']
-        ONOS7_ip = main.params['CTRL']['ip7']
-        
-        cell_name = main.params['ENV']['cellName']
-        
-        MN1_ip = main.params['MN']['ip1']
-        BENCH_ip = main.params['BENCH']['ip']
 
-        #NOTE:We start with cluster_count at 3. The first 
-        #case already initialized ONOS1. Increase the
-        #cluster count and start from 3.
-        #You can optionally change the increment to
-        #test steps of node sizes, such as 3,5,7
-       
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+        ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+        ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
+        ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
+
+        cell_name = main.params[ 'ENV' ][ 'cellName' ]
+
+        MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+        BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
+
+        # NOTE:We start with cluster_count at 3. The first
+        # case already initialized ONOS1. Increase the
+        # cluster count and start from 3.
+        # You can optionally change the increment to
+        # test steps of node sizes, such as 3,5,7
+
         global cluster_count
-        cluster_count += 2 
-        main.log.report("Increasing cluster size to "+
-            str(cluster_count))
+        cluster_count += 2
+        main.log.report( "Increasing cluster size to " +
+                         str( cluster_count ) )
 
         install_result = main.FALSE
-        #Supports up to 7 node configuration
-        #TODO: Cleanup this ridiculous repetitive code 
+        # Supports up to 7 node configuration
+        # TODO: Cleanup this ridiculous repetitive code
         if cluster_count == 3:
             install_result = \
-                main.ONOSbench.onos_install(node=ONOS2_ip)
+                main.ONOSbench.onos_install( node=ONOS2_ip )
             install_result = \
-                main.ONOSbench.onos_install(node=ONOS3_ip)
-            time.sleep(5)
-            main.log.info("Starting CLI")
-            main.ONOS2cli.start_onos_cli(ONOS2_ip)
-            main.ONOS3cli.start_onos_cli(ONOS3_ip)
-            main.ONOS1cli.add_node(ONOS2_ip, ONOS2_ip)
-            main.ONOS1cli.add_node(ONOS3_ip, ONOS3_ip)
-            
+                main.ONOSbench.onos_install( node=ONOS3_ip )
+            time.sleep( 5 )
+            main.log.info( "Starting CLI" )
+            main.ONOS2cli.start_onos_cli( ONOS2_ip )
+            main.ONOS3cli.start_onos_cli( ONOS3_ip )
+            main.ONOS1cli.add_node( ONOS2_ip, ONOS2_ip )
+            main.ONOS1cli.add_node( ONOS3_ip, ONOS3_ip )
+
         if cluster_count == 4:
-            main.log.info("Installing ONOS on node 4")
+            main.log.info( "Installing ONOS on node 4" )
             install_result = \
-                main.ONOSbench.onos_install(node=ONOS4_ip)
-            time.sleep(5)
-            main.log.info("Starting CLI")
-            main.ONOS4cli.start_onos_cli(ONOS4_ip)
-            main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
-        
+                main.ONOSbench.onos_install( node=ONOS4_ip )
+            time.sleep( 5 )
+            main.log.info( "Starting CLI" )
+            main.ONOS4cli.start_onos_cli( ONOS4_ip )
+            main.ONOS1cli.add_node( ONOS4_ip, ONOS4_ip )
+
         elif cluster_count == 5:
-            main.log.info("Installing ONOS on nodes 4 and 5")
+            main.log.info( "Installing ONOS on nodes 4 and 5" )
             install_result2 = \
-                main.ONOSbench.onos_install(options="",node=ONOS4_ip)
+                main.ONOSbench.onos_install( options="", node=ONOS4_ip )
             install_result3 = \
-                main.ONOSbench.onos_install(options="",node=ONOS5_ip)
-            time.sleep(5)
-            main.log.info("Starting CLI")
-            main.ONOS4cli.start_onos_cli(ONOS4_ip)
-            main.ONOS5cli.start_onos_cli(ONOS5_ip)
-            main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
-            main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
+                main.ONOSbench.onos_install( options="", node=ONOS5_ip )
+            time.sleep( 5 )
+            main.log.info( "Starting CLI" )
+            main.ONOS4cli.start_onos_cli( ONOS4_ip )
+            main.ONOS5cli.start_onos_cli( ONOS5_ip )
+            main.ONOS1cli.add_node( ONOS4_ip, ONOS4_ip )
+            main.ONOS1cli.add_node( ONOS5_ip, ONOS5_ip )
             install_result = install_result2 and install_result3
 
         elif cluster_count == 6:
-            main.log.info("Installing ONOS on nodes 4, 5,and 6")
+            main.log.info( "Installing ONOS on nodes 4, 5,and 6" )
             install_result1 = \
-                main.ONOSbench.onos_install(options="",node=ONOS4_ip)
+                main.ONOSbench.onos_install( options="", node=ONOS4_ip )
             install_result2 = \
-                main.ONOSbench.onos_install(options="",node=ONOS5_ip)
+                main.ONOSbench.onos_install( options="", node=ONOS5_ip )
             install_result3 = \
-                main.ONOSbench.onos_install(node=ONOS6_ip)
-            time.sleep(5)
-            main.log.info("Starting CLI")
-            main.ONOS4cli.start_onos_cli(ONOS4_ip)
-            main.ONOS5cli.start_onos_cli(ONOS5_ip)
-            main.ONOS6cli.start_onos_cli(ONOS6_ip)
-            main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
-            main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
-            main.ONOS1cli.add_node(ONOS6_ip, ONOS6_ip)
+                main.ONOSbench.onos_install( node=ONOS6_ip )
+            time.sleep( 5 )
+            main.log.info( "Starting CLI" )
+            main.ONOS4cli.start_onos_cli( ONOS4_ip )
+            main.ONOS5cli.start_onos_cli( ONOS5_ip )
+            main.ONOS6cli.start_onos_cli( ONOS6_ip )
+            main.ONOS1cli.add_node( ONOS4_ip, ONOS4_ip )
+            main.ONOS1cli.add_node( ONOS5_ip, ONOS5_ip )
+            main.ONOS1cli.add_node( ONOS6_ip, ONOS6_ip )
             install_result = install_result1 and install_result2 and\
-                    install_result3
+                install_result3
 
         elif cluster_count == 7:
-            main.log.info("Installing ONOS on nodes 4, 5, 6,and 7")
+            main.log.info( "Installing ONOS on nodes 4, 5, 6,and 7" )
             install_result3 = \
-                main.ONOSbench.onos_install(node=ONOS6_ip)
+                main.ONOSbench.onos_install( node=ONOS6_ip )
             install_result4 = \
-                main.ONOSbench.onos_install(node=ONOS7_ip)
-            main.log.info("Starting CLI")
-            main.ONOS4cli.start_onos_cli(ONOS4_ip)
-            main.ONOS5cli.start_onos_cli(ONOS5_ip)
-            main.ONOS6cli.start_onos_cli(ONOS6_ip)
-            main.ONOS7cli.start_onos_cli(ONOS7_ip) 
-            main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
-            main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
-            main.ONOS1cli.add_node(ONOS6_ip, ONOS6_ip)
-            main.ONOS1cli.add_node(ONOS7_ip, ONOS7_ip)
+                main.ONOSbench.onos_install( node=ONOS7_ip )
+            main.log.info( "Starting CLI" )
+            main.ONOS4cli.start_onos_cli( ONOS4_ip )
+            main.ONOS5cli.start_onos_cli( ONOS5_ip )
+            main.ONOS6cli.start_onos_cli( ONOS6_ip )
+            main.ONOS7cli.start_onos_cli( ONOS7_ip )
+            main.ONOS1cli.add_node( ONOS4_ip, ONOS4_ip )
+            main.ONOS1cli.add_node( ONOS5_ip, ONOS5_ip )
+            main.ONOS1cli.add_node( ONOS6_ip, ONOS6_ip )
+            main.ONOS1cli.add_node( ONOS7_ip, ONOS7_ip )
 
             install_result = \
-                    install_result3 and install_result4
+                install_result3 and install_result4
 
-        time.sleep(5)
+        time.sleep( 5 )
 
         if install_result == main.TRUE:
             assertion = main.TRUE
         else:
             assertion = main.FALSE
-        
-        utilities.assert_equals(expect=main.TRUE, actual=assertion,
-                onpass="Scale out to "+str(cluster_count)+\
-                       " nodes successful",
-                onfail="Scale out to "+str(cluster_count)+\
-                       " nodes failed")
 
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=assertion,
+            onpass="Scale out to " +
+            str( cluster_count ) +
+            " nodes successful",
+            onfail="Scale out to " +
+            str( cluster_count ) +
+            " nodes failed" )
 
-    def CASE4(self, main):
-        '''
+    def CASE4( self, main ):
+        """
         Cleanup ONOS nodes and Increase topology size
-        '''
-        #TODO: use meaningful assertion
-        assertion=main.TRUE
+        """
+        # TODO: use meaningful assertion
+        assertion = main.TRUE
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS4_ip = main.params['CTRL']['ip4']
-        ONOS5_ip = main.params['CTRL']['ip5']
-        ONOS6_ip = main.params['CTRL']['ip6']
-        ONOS7_ip = main.params['CTRL']['ip7']
-        MN1_ip = main.params['MN']['ip1']
-        BENCH_ip = main.params['BENCH']['ip']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+        ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+        ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
+        ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
+        MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+        BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
 
-        main.log.info("Uninstalling previous instances")
-        main.ONOSbench.onos_uninstall(node_ip = ONOS2_ip)
-        main.ONOSbench.onos_uninstall(node_ip = ONOS3_ip)
-        main.ONOSbench.onos_uninstall(node_ip = ONOS4_ip)
-        main.ONOSbench.onos_uninstall(node_ip = ONOS5_ip)
-        main.ONOSbench.onos_uninstall(node_ip = ONOS6_ip)
-        main.ONOSbench.onos_uninstall(node_ip = ONOS7_ip)
-        
+        main.log.info( "Uninstalling previous instances" )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS2_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS3_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS4_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS5_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS6_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS7_ip )
+
         global topo_iteration
         global cluster_count
-        cluster_count = 1  
+        cluster_count = 1
         topo_iteration += 1
 
-        main.log.report("Increasing topology size")
-        utilities.assert_equals(expect=main.TRUE, actual=assertion,
-            onpass="Topology size increased successfully",
-            onfail="Topology size was not increased")
-
-
-
+        main.log.report( "Increasing topology size" )
+        utilities.assert_equals( expect=main.TRUE, actual=assertion,
+                                 onpass="Topology size increased successfully",
+                                 onfail="Topology size was not increased" )
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.py b/TestON/tests/TopoPerfNext/TopoPerfNext.py
index 65bc7a9..87d7378 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.py
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.py
@@ -1,37 +1,39 @@
-#TopoPerfNext
+# TopoPerfNext
 #
-#Topology Performance test for ONOS-next
+# Topology Performance test for ONOS-next
 #
-#andrew@onlab.us
+# andrew@onlab.us
 #
-#If your machine does not come with numpy
-#run the following command:
-#sudo apt-get install python-numpy python-scipy 
+# If your machine does not come with numpy
+# run the following command:
+# sudo apt-get install python-numpy python-scipy
 
 import time
 import sys
 import os
 import re
 
+
 class TopoPerfNext:
-    def __init__(self):
+
+    def __init__( self ):
         self.default = ''
 
-    def CASE1(self, main):
-        '''
+    def CASE1( self, main ):
+        """
         ONOS startup sequence
-        '''
+        """
         import time
-    
-        cell_name = main.params['ENV']['cellName']
 
-        git_pull = main.params['GIT']['autoPull']
-        checkout_branch = main.params['GIT']['checkout']
+        cell_name = main.params[ 'ENV' ][ 'cellName' ]
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        
+        git_pull = main.params[ 'GIT' ][ 'autoPull' ]
+        checkout_branch = main.params[ 'GIT' ][ 'checkout' ]
+
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+
         #### Hardcoded ONOS nodes particular to my env ####
         ONOS4_ip = "10.128.174.4"
         ONOS5_ip = "10.128.174.5"
@@ -39,108 +41,108 @@
         ONOS7_ip = "10.128.174.7"
         #### ####
 
-        MN1_ip = main.params['MN']['ip1']
-        BENCH_ip = main.params['BENCH']['ip']
+        MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+        BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
 
-        topo_cfg_file = main.params['TEST']['topo_config_file']
-        topo_cfg_name = main.params['TEST']['topo_config_name']
-        
-        main.case("Setting up test environment")
-        main.log.info("Copying topology event accumulator config"+\
-            " to ONOS /package/etc")
-        main.ONOSbench.handle.sendline("cp ~/"+\
-            topo_cfg_file+\
-            " ~/ONOS/tools/package/etc/"+\
-            topo_cfg_name)
-        main.ONOSbench.handle.expect("\$")
+        topo_cfg_file = main.params[ 'TEST' ][ 'topo_config_file' ]
+        topo_cfg_name = main.params[ 'TEST' ][ 'topo_config_name' ]
 
-        main.log.report("Setting up test environment")
+        main.case( "Setting up test environment" )
+        main.log.info( "Copying topology event accumulator config" +
+                       " to ONOS /package/etc" )
+        main.ONOSbench.handle.sendline( "cp ~/" +
+                                        topo_cfg_file +
+                                        " ~/ONOS/tools/package/etc/" +
+                                        topo_cfg_name )
+        main.ONOSbench.handle.expect( "\$" )
 
-        main.step("Cleaning previously installed ONOS if any")
-        main.ONOSbench.onos_uninstall(node_ip=ONOS4_ip)
-        main.ONOSbench.onos_uninstall(node_ip=ONOS5_ip)
-        main.ONOSbench.onos_uninstall(node_ip=ONOS6_ip)
-        main.ONOSbench.onos_uninstall(node_ip=ONOS7_ip)
+        main.log.report( "Setting up test environment" )
 
-        main.step("Creating cell file")
+        main.step( "Cleaning previously installed ONOS if any" )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS4_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS5_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS6_ip )
+        main.ONOSbench.onos_uninstall( node_ip=ONOS7_ip )
+
+        main.step( "Creating cell file" )
         cell_file_result = main.ONOSbench.create_cell_file(
-                BENCH_ip, cell_name, MN1_ip, "onos-core,onos-app-metrics",
-                ONOS1_ip, ONOS2_ip, ONOS3_ip)
+            BENCH_ip, cell_name, MN1_ip, "onos-core,onos-app-metrics",
+            ONOS1_ip, ONOS2_ip, ONOS3_ip )
 
-        main.step("Applying cell file to environment")
-        cell_apply_result = main.ONOSbench.set_cell(cell_name)
+        main.step( "Applying cell file to environment" )
+        cell_apply_result = main.ONOSbench.set_cell( cell_name )
         verify_cell_result = main.ONOSbench.verify_cell()
-        
-        #NOTE: This step may be removed after proper 
-        #      copy cat log functionality
-        main.step("Removing raft/copy-cat logs from ONOS nodes")
-        main.ONOSbench.onos_remove_raft_logs()
-        time.sleep(30)
 
-        main.step("Git checkout and pull "+checkout_branch)
+        # NOTE: This step may be removed after proper
+        #      copy cat log functionality
+        main.step( "Removing raft/copy-cat logs from ONOS nodes" )
+        main.ONOSbench.onos_remove_raft_logs()
+        time.sleep( 30 )
+
+        main.step( "Git checkout and pull " + checkout_branch )
         if git_pull == 'on':
             checkout_result = \
-                    main.ONOSbench.git_checkout(checkout_branch)
+                main.ONOSbench.git_checkout( checkout_branch )
             pull_result = main.ONOSbench.git_pull()
         else:
             checkout_result = main.TRUE
             pull_result = main.TRUE
-            main.log.info("Skipped git checkout and pull")
+            main.log.info( "Skipped git checkout and pull" )
 
-        #TODO: Uncomment when wiki posting works
-        #main.log.report("Commit information - ")
-        #main.ONOSbench.get_version(report=True)
+        # TODO: Uncomment when wiki posting works
+        #main.log.report( "Commit information - " )
+        # main.ONOSbench.get_version( report=True )
 
-        main.step("Using mvn clean & install")
+        main.step( "Using mvn clean & install" )
         #mvn_result = main.ONOSbench.clean_install()
         mvn_result = main.TRUE
 
-        main.step("Set cell for ONOS cli env")
-        main.ONOS1cli.set_cell(cell_name)
-        main.ONOS2cli.set_cell(cell_name)
-        main.ONOS3cli.set_cell(cell_name)
+        main.step( "Set cell for ONOS cli env" )
+        main.ONOS1cli.set_cell( cell_name )
+        main.ONOS2cli.set_cell( cell_name )
+        main.ONOS3cli.set_cell( cell_name )
 
-        main.step("Creating ONOS package")
+        main.step( "Creating ONOS package" )
         package_result = main.ONOSbench.onos_package()
 
-        main.step("Installing ONOS package")
-        install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
-        install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
-        install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
+        main.step( "Installing ONOS package" )
+        install1_result = main.ONOSbench.onos_install( node=ONOS1_ip )
+        install2_result = main.ONOSbench.onos_install( node=ONOS2_ip )
+        install3_result = main.ONOSbench.onos_install( node=ONOS3_ip )
 
-        time.sleep(10)
+        time.sleep( 10 )
 
-        main.step("Start onos cli")
-        cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
-        cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
-        cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
+        main.step( "Start onos cli" )
+        cli1 = main.ONOS1cli.start_onos_cli( ONOS1_ip )
+        cli2 = main.ONOS2cli.start_onos_cli( ONOS2_ip )
+        cli3 = main.ONOS3cli.start_onos_cli( ONOS3_ip )
 
-        utilities.assert_equals(expect=main.TRUE,
-                actual= cell_file_result and cell_apply_result and\
-                        verify_cell_result and checkout_result and\
-                        pull_result and mvn_result and\
-                        install1_result and install2_result and\
-                        install3_result,
-                onpass="Test Environment setup successful",
-                onfail="Failed to setup test environment")
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=cell_file_result and cell_apply_result and
+                                 verify_cell_result and checkout_result and
+                                 pull_result and mvn_result and
+                                 install1_result and install2_result and
+                                 install3_result,
+                                 onpass="Test Environment setup successful",
+                                 onfail="Failed to setup test environment" )
 
-    def CASE2(self, main):
-        '''
+    def CASE2( self, main ):
+        """
         Assign s1 to ONOS1 and measure latency
-        
+
         There are 4 levels of latency measurements to this test:
-        1) End-to-end measurement: Complete end-to-end measurement
-           from TCP (SYN/ACK) handshake to Graph change
-        2) OFP-to-graph measurement: 'ONOS processing' snippet of
+        1 ) End-to-end measurement: Complete end-to-end measurement
+           from TCP ( SYN/ACK ) handshake to Graph change
+        2 ) OFP-to-graph measurement: 'ONOS processing' snippet of
            measurement from OFP Vendor message to Graph change
-        3) OFP-to-device measurement: 'ONOS processing without 
+        3 ) OFP-to-device measurement: 'ONOS processing without
            graph change' snippet of measurement from OFP vendor
            message to Device change timestamp
-        4) T0-to-device measurement: Measurement that includes
-           the switch handshake to devices timestamp without 
-           the graph view change. (TCP handshake -> Device 
-           change)
-        '''
+        4 ) T0-to-device measurement: Measurement that includes
+           the switch handshake to devices timestamp without
+           the graph view change. ( TCP handshake -> Device
+           change )
+        """
         import time
         import subprocess
         import json
@@ -148,414 +150,436 @@
         import os
         import numpy
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS_user = main.params['CTRL']['user']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS_user = main.params[ 'CTRL' ][ 'user' ]
 
-        default_sw_port = main.params['CTRL']['port1']
-       
-        #Number of iterations of case
-        num_iter = main.params['TEST']['numIter']
-        #Number of first 'x' iterations to ignore:
-        iter_ignore = int(main.params['TEST']['iterIgnore'])
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
 
-        #Timestamp 'keys' for json metrics output.
-        #These are subject to change, hence moved into params
-        deviceTimestamp = main.params['JSON']['deviceTimestamp']
-        graphTimestamp = main.params['JSON']['graphTimestamp']
+        # Number of iterations of case
+        num_iter = main.params[ 'TEST' ][ 'numIter' ]
+        # Number of first 'x' iterations to ignore:
+        iter_ignore = int( main.params[ 'TEST' ][ 'iterIgnore' ] )
 
-        debug_mode = main.params['TEST']['debugMode']
-        onos_log = main.params['TEST']['onosLogFile']
+        # Timestamp 'keys' for json metrics output.
+        # These are subject to change, hence moved into params
+        deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+        graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
 
-        #Threshold for the test
-        threshold_str = main.params['TEST']['singleSwThreshold']
-        threshold_obj = threshold_str.split(",")
-        threshold_min = int(threshold_obj[0])
-        threshold_max = int(threshold_obj[1])
+        debug_mode = main.params[ 'TEST' ][ 'debugMode' ]
+        onos_log = main.params[ 'TEST' ][ 'onosLogFile' ]
 
-        #List of switch add latency collected from
-        #all iterations
+        # Threshold for the test
+        threshold_str = main.params[ 'TEST' ][ 'singleSwThreshold' ]
+        threshold_obj = threshold_str.split( "," )
+        threshold_min = int( threshold_obj[ 0 ] )
+        threshold_max = int( threshold_obj[ 1 ] )
+
+        # List of switch add latency collected from
+        # all iterations
         latency_end_to_end_list = []
         latency_ofp_to_graph_list = []
         latency_ofp_to_device_list = []
         latency_t0_to_device_list = []
         latency_tcp_to_ofp_list = []
 
-        #Directory/file to store tshark results
+        # Directory/file to store tshark results
         tshark_of_output = "/tmp/tshark_of_topo.txt"
         tshark_tcp_output = "/tmp/tshark_tcp_topo.txt"
 
-        #String to grep in tshark output
-        tshark_tcp_string = "TCP 74 "+default_sw_port
+        # String to grep in tshark output
+        tshark_tcp_string = "TCP 74 " + default_sw_port
         tshark_of_string = "OFP 86 Vendor"
-     
-        #Initialize assertion to TRUE
+
+        # Initialize assertion to TRUE
         assertion = main.TRUE
-      
-        local_time = time.strftime('%x %X')
-        local_time = local_time.replace("/","")
-        local_time = local_time.replace(" ","_")
-        local_time = local_time.replace(":","")
+
+        local_time = time.strftime( '%x %X' )
+        local_time = local_time.replace( "/", "" )
+        local_time = local_time.replace( " ", "_" )
+        local_time = local_time.replace( ":", "" )
         if debug_mode == 'on':
-            main.ONOS1.tshark_pcap("eth0",
-                    "/tmp/single_sw_lat_pcap_"+local_time) 
+            main.ONOS1.tshark_pcap( "eth0",
+                                    "/tmp/single_sw_lat_pcap_" + local_time )
 
-            main.log.info("TEST")
+            main.log.info( "TEST" )
 
-        main.log.report("Latency of adding one switch to controller")
-        main.log.report("First "+str(iter_ignore)+" iterations ignored"+
-                " for jvm warmup time")
-        main.log.report("Total iterations of test: "+str(num_iter))
+        main.log.report( "Latency of adding one switch to controller" )
+        main.log.report(
+            "First " +
+            str( iter_ignore ) +
+            " iterations ignored" +
+            " for jvm warmup time" )
+        main.log.report( "Total iterations of test: " + str( num_iter ) )
 
-        for i in range(0, int(num_iter)):
-            main.log.info("Starting tshark capture")
+        for i in range( 0, int( num_iter ) ):
+            main.log.info( "Starting tshark capture" )
 
-            #* TCP [ACK, SYN] is used as t0_a, the
-            #  very first "exchange" between ONOS and 
+            #* TCP [ ACK, SYN ] is used as t0_a, the
+            #  very first "exchange" between ONOS and
             #  the switch for end-to-end measurement
-            #* OFP [Stats Reply] is used for t0_b
+            #* OFP [ Stats Reply ] is used for t0_b
             #  the very last OFP message between ONOS
             #  and the switch for ONOS measurement
-            main.ONOS1.tshark_grep(tshark_tcp_string,
-                    tshark_tcp_output)
-            main.ONOS1.tshark_grep(tshark_of_string,
-                    tshark_of_output)
+            main.ONOS1.tshark_grep( tshark_tcp_string,
+                                    tshark_tcp_output )
+            main.ONOS1.tshark_grep( tshark_of_string,
+                                    tshark_of_output )
 
-            #Wait and ensure tshark is started and 
-            #capturing
-            time.sleep(10)
+            # Wait and ensure tshark is started and
+            # capturing
+            time.sleep( 10 )
 
-            main.log.info("Assigning s1 to controller")
+            main.log.info( "Assigning s1 to controller" )
 
-            main.Mininet1.assign_sw_controller(sw="1",
-                    ip1=ONOS1_ip, port1=default_sw_port)
+            main.Mininet1.assign_sw_controller(
+                sw="1",
+                ip1=ONOS1_ip,
+                port1=default_sw_port )
 
-            #Wait and ensure switch is assigned
-            #before stopping tshark
-            time.sleep(30)
-   
-            main.log.info("Stopping all Tshark processes")
+            # Wait and ensure switch is assigned
+            # before stopping tshark
+            time.sleep( 30 )
+
+            main.log.info( "Stopping all Tshark processes" )
             main.ONOS1.stop_tshark()
 
-            #tshark output is saved in ONOS. Use subprocess
-            #to copy over files to TestON for parsing
-            main.log.info("Copying over tshark files")
-            
-            #TCP CAPTURE ****
-            #Copy the tshark output from ONOS machine to
-            #TestON machine in tshark_tcp_output directory>file
-            os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
-                    tshark_tcp_output+" /tmp/") 
-            tcp_file = open(tshark_tcp_output, 'r')
-            temp_text = tcp_file.readline()
-            temp_text = temp_text.split(" ")
+            # tshark output is saved in ONOS. Use subprocess
+            # to copy over files to TestON for parsing
+            main.log.info( "Copying over tshark files" )
 
-            main.log.info("Object read in from TCP capture: "+
-                    str(temp_text))
-            if len(temp_text) > 1:
-                t0_tcp = float(temp_text[1])*1000.0
+            # TCP CAPTURE ****
+            # Copy the tshark output from ONOS machine to
+            # TestON machine in tshark_tcp_output directory>file
+            os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+                       tshark_tcp_output + " /tmp/" )
+            tcp_file = open( tshark_tcp_output, 'r' )
+            temp_text = tcp_file.readline()
+            temp_text = temp_text.split( " " )
+
+            main.log.info( "Object read in from TCP capture: " +
+                           str( temp_text ) )
+            if len( temp_text ) > 1:
+                t0_tcp = float( temp_text[ 1 ] ) * 1000.0
             else:
-                main.log.error("Tshark output file for TCP"+
-                        " returned unexpected results")
+                main.log.error( "Tshark output file for TCP" +
+                                " returned unexpected results" )
                 t0_tcp = 0
                 assertion = main.FALSE
-            
+
             tcp_file.close()
             #****************
 
-            #OF CAPTURE ****
-            os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
-                    tshark_of_output+" /tmp/")
-            of_file = open(tshark_of_output, 'r')
-           
+            # OF CAPTURE ****
+            os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+                       tshark_of_output + " /tmp/" )
+            of_file = open( tshark_of_output, 'r' )
+
             line_ofp = ""
-            #Read until last line of file
+            # Read until last line of file
             while True:
                 temp_text = of_file.readline()
-                if temp_text !='':
+                if temp_text != '':
                     line_ofp = temp_text
                 else:
-                    break 
-            obj = line_ofp.split(" ")
-            
-            main.log.info("Object read in from OFP capture: "+
-                    str(line_ofp))
-    
-            if len(line_ofp) > 1:
-                t0_ofp = float(obj[1])*1000.0
+                    break
+            obj = line_ofp.split( " " )
+
+            main.log.info( "Object read in from OFP capture: " +
+                           str( line_ofp ) )
+
+            if len( line_ofp ) > 1:
+                t0_ofp = float( obj[ 1 ] ) * 1000.0
             else:
-                main.log.error("Tshark output file for OFP"+
-                        " returned unexpected results")
+                main.log.error( "Tshark output file for OFP" +
+                                " returned unexpected results" )
                 t0_ofp = 0
                 assertion = main.FALSE
-            
+
             of_file.close()
             #****************
-           
+
             json_str_1 = main.ONOS1cli.topology_events_metrics()
             json_str_2 = main.ONOS2cli.topology_events_metrics()
             json_str_3 = main.ONOS3cli.topology_events_metrics()
 
-            json_obj_1 = json.loads(json_str_1)
-            json_obj_2 = json.loads(json_str_2)
-            json_obj_3 = json.loads(json_str_3)
+            json_obj_1 = json.loads( json_str_1 )
+            json_obj_2 = json.loads( json_str_2 )
+            json_obj_3 = json.loads( json_str_3 )
 
-            #Obtain graph timestamp. This timestsamp captures
-            #the epoch time at which the topology graph was updated.
+            # Obtain graph timestamp. This timestsamp captures
+            # the epoch time at which the topology graph was updated.
             graph_timestamp_1 = \
-                    json_obj_1[graphTimestamp]['value']
+                json_obj_1[ graphTimestamp ][ 'value' ]
             graph_timestamp_2 = \
-                    json_obj_2[graphTimestamp]['value']
+                json_obj_2[ graphTimestamp ][ 'value' ]
             graph_timestamp_3 = \
-                    json_obj_3[graphTimestamp]['value']
+                json_obj_3[ graphTimestamp ][ 'value' ]
 
-            #Obtain device timestamp. This timestamp captures
-            #the epoch time at which the device event happened
+            # Obtain device timestamp. This timestamp captures
+            # the epoch time at which the device event happened
             device_timestamp_1 = \
-                    json_obj_1[deviceTimestamp]['value'] 
+                json_obj_1[ deviceTimestamp ][ 'value' ]
             device_timestamp_2 = \
-                    json_obj_2[deviceTimestamp]['value'] 
+                json_obj_2[ deviceTimestamp ][ 'value' ]
             device_timestamp_3 = \
-                    json_obj_3[deviceTimestamp]['value'] 
+                json_obj_3[ deviceTimestamp ][ 'value' ]
 
-            #t0 to device processing latency 
-            delta_device_1 = int(device_timestamp_1) - int(t0_tcp)
-            delta_device_2 = int(device_timestamp_2) - int(t0_tcp)
-            delta_device_3 = int(device_timestamp_3) - int(t0_tcp)
-        
-            #Get average of delta from all instances
+            # t0 to device processing latency
+            delta_device_1 = int( device_timestamp_1 ) - int( t0_tcp )
+            delta_device_2 = int( device_timestamp_2 ) - int( t0_tcp )
+            delta_device_3 = int( device_timestamp_3 ) - int( t0_tcp )
+
+            # Get average of delta from all instances
             avg_delta_device = \
-                    (int(delta_device_1)+\
-                     int(delta_device_2)+\
-                     int(delta_device_3)) / 3
+                ( int( delta_device_1 ) +
+                  int( delta_device_2 ) +
+                  int( delta_device_3 ) ) / 3
 
-            #Ensure avg delta meets the threshold before appending
+            # Ensure avg delta meets the threshold before appending
             if avg_delta_device > 0.0 and avg_delta_device < 10000\
-                    and int(i) > iter_ignore:
-                latency_t0_to_device_list.append(avg_delta_device)
+                    and int( i ) > iter_ignore:
+                latency_t0_to_device_list.append( avg_delta_device )
             else:
-                main.log.info("Results for t0-to-device ignored"+\
-                        "due to excess in threshold / warmup iteration.")
+                main.log.info(
+                    "Results for t0-to-device ignored" +
+                    "due to excess in threshold / warmup iteration." )
 
-            #t0 to graph processing latency (end-to-end)
-            delta_graph_1 = int(graph_timestamp_1) - int(t0_tcp)
-            delta_graph_2 = int(graph_timestamp_2) - int(t0_tcp)
-            delta_graph_3 = int(graph_timestamp_3) - int(t0_tcp)
-        
-            #Get average of delta from all instances
+            # t0 to graph processing latency ( end-to-end )
+            delta_graph_1 = int( graph_timestamp_1 ) - int( t0_tcp )
+            delta_graph_2 = int( graph_timestamp_2 ) - int( t0_tcp )
+            delta_graph_3 = int( graph_timestamp_3 ) - int( t0_tcp )
+
+            # Get average of delta from all instances
             avg_delta_graph = \
-                    (int(delta_graph_1)+\
-                     int(delta_graph_2)+\
-                     int(delta_graph_3)) / 3
+                ( int( delta_graph_1 ) +
+                  int( delta_graph_2 ) +
+                  int( delta_graph_3 ) ) / 3
 
-            #Ensure avg delta meets the threshold before appending
+            # Ensure avg delta meets the threshold before appending
             if avg_delta_graph > 0.0 and avg_delta_graph < 10000\
-                    and int(i) > iter_ignore:
-                latency_end_to_end_list.append(avg_delta_graph)
+                    and int( i ) > iter_ignore:
+                latency_end_to_end_list.append( avg_delta_graph )
             else:
-                main.log.info("Results for end-to-end ignored"+\
-                        "due to excess in threshold")
+                main.log.info( "Results for end-to-end ignored" +
+                               "due to excess in threshold" )
 
-            #ofp to graph processing latency (ONOS processing)
-            delta_ofp_graph_1 = int(graph_timestamp_1) - int(t0_ofp)
-            delta_ofp_graph_2 = int(graph_timestamp_2) - int(t0_ofp)
-            delta_ofp_graph_3 = int(graph_timestamp_3) - int(t0_ofp)
-            
+            # ofp to graph processing latency ( ONOS processing )
+            delta_ofp_graph_1 = int( graph_timestamp_1 ) - int( t0_ofp )
+            delta_ofp_graph_2 = int( graph_timestamp_2 ) - int( t0_ofp )
+            delta_ofp_graph_3 = int( graph_timestamp_3 ) - int( t0_ofp )
+
             avg_delta_ofp_graph = \
-                    (int(delta_ofp_graph_1)+\
-                     int(delta_ofp_graph_2)+\
-                     int(delta_ofp_graph_3)) / 3
-            
+                ( int( delta_ofp_graph_1 ) +
+                  int( delta_ofp_graph_2 ) +
+                  int( delta_ofp_graph_3 ) ) / 3
+
             if avg_delta_ofp_graph > threshold_min \
                     and avg_delta_ofp_graph < threshold_max\
-                    and int(i) > iter_ignore:
-                latency_ofp_to_graph_list.append(avg_delta_ofp_graph)
-            elif avg_delta_ofp_graph > (-10) and \
+                    and int( i ) > iter_ignore:
+                latency_ofp_to_graph_list.append( avg_delta_ofp_graph )
+            elif avg_delta_ofp_graph > ( -10 ) and \
                     avg_delta_ofp_graph < 0.0 and\
-                    int(i) > iter_ignore:
-                main.log.info("Sub-millisecond result likely; "+
-                    "negative result was rounded to 0")
-                #NOTE: Current metrics framework does not 
-                #support sub-millisecond accuracy. Therefore,
-                #if the result is negative, we can reasonably
-                #conclude sub-millisecond results and just 
-                #append the best rounded effort - 0 ms. 
-                latency_ofp_to_graph_list.append(0)
+                    int( i ) > iter_ignore:
+                main.log.info( "Sub-millisecond result likely; " +
+                               "negative result was rounded to 0" )
+                # NOTE: Current metrics framework does not
+                # support sub-millisecond accuracy. Therefore,
+                # if the result is negative, we can reasonably
+                # conclude sub-millisecond results and just
+                # append the best rounded effort - 0 ms.
+                latency_ofp_to_graph_list.append( 0 )
             else:
-                main.log.info("Results for ofp-to-graph "+\
-                        "ignored due to excess in threshold")
+                main.log.info( "Results for ofp-to-graph " +
+                               "ignored due to excess in threshold" )
 
-            #ofp to device processing latency (ONOS processing)
-            delta_ofp_device_1 = float(device_timestamp_1) - float(t0_ofp)
-            delta_ofp_device_2 = float(device_timestamp_2) - float(t0_ofp)
-            delta_ofp_device_3 = float(device_timestamp_3) - float(t0_ofp)
-            
+            # ofp to device processing latency ( ONOS processing )
+            delta_ofp_device_1 = float( device_timestamp_1 ) - float( t0_ofp )
+            delta_ofp_device_2 = float( device_timestamp_2 ) - float( t0_ofp )
+            delta_ofp_device_3 = float( device_timestamp_3 ) - float( t0_ofp )
+
             avg_delta_ofp_device = \
-                    (float(delta_ofp_device_1)+\
-                     float(delta_ofp_device_2)+\
-                     float(delta_ofp_device_3)) / 3
-            
-            #NOTE: ofp - delta measurements are occasionally negative
-            #      due to system time misalignment.
-            latency_ofp_to_device_list.append(avg_delta_ofp_device)
+                ( float( delta_ofp_device_1 ) +
+                  float( delta_ofp_device_2 ) +
+                  float( delta_ofp_device_3 ) ) / 3
 
-            delta_ofp_tcp = int(t0_ofp) - int(t0_tcp)
+            # NOTE: ofp - delta measurements are occasionally negative
+            #      due to system time misalignment.
+            latency_ofp_to_device_list.append( avg_delta_ofp_device )
+
+            delta_ofp_tcp = int( t0_ofp ) - int( t0_tcp )
             if delta_ofp_tcp > threshold_min \
                     and delta_ofp_tcp < threshold_max and\
-                    int(i) > iter_ignore:
-                latency_tcp_to_ofp_list.append(delta_ofp_tcp)
+                    int( i ) > iter_ignore:
+                latency_tcp_to_ofp_list.append( delta_ofp_tcp )
             else:
-                main.log.info("Results fo tcp-to-ofp "+\
-                        "ignored due to excess in threshold")
+                main.log.info( "Results fo tcp-to-ofp " +
+                               "ignored due to excess in threshold" )
 
-            #TODO:
-            #Fetch logs upon threshold excess
+            # TODO:
+            # Fetch logs upon threshold excess
 
-            main.log.info("ONOS1 delta end-to-end: "+
-                    str(delta_graph_1) + " ms")
-            main.log.info("ONOS2 delta end-to-end: "+
-                    str(delta_graph_2) + " ms")
-            main.log.info("ONOS3 delta end-to-end: "+
-                    str(delta_graph_3) + " ms")
+            main.log.info( "ONOS1 delta end-to-end: " +
+                           str( delta_graph_1 ) + " ms" )
+            main.log.info( "ONOS2 delta end-to-end: " +
+                           str( delta_graph_2 ) + " ms" )
+            main.log.info( "ONOS3 delta end-to-end: " +
+                           str( delta_graph_3 ) + " ms" )
 
-            main.log.info("ONOS1 delta OFP - graph: "+
-                    str(delta_ofp_graph_1) + " ms")
-            main.log.info("ONOS2 delta OFP - graph: "+
-                    str(delta_ofp_graph_2) + " ms")
-            main.log.info("ONOS3 delta OFP - graph: "+
-                    str(delta_ofp_graph_3) + " ms")
-            
-            main.log.info("ONOS1 delta device - t0: "+
-                    str(delta_device_1) + " ms")
-            main.log.info("ONOS2 delta device - t0: "+
-                    str(delta_device_2) + " ms")
-            main.log.info("ONOS3 delta device - t0: "+
-                    str(delta_device_3) + " ms")
-         
-            main.log.info("TCP to OFP delta: "+
-                    str(delta_ofp_tcp) + " ms")
-            #main.log.info("ONOS1 delta OFP - device: "+
-            #        str(delta_ofp_device_1) + " ms")
-            #main.log.info("ONOS2 delta OFP - device: "+
-            #        str(delta_ofp_device_2) + " ms")
-            #main.log.info("ONOS3 delta OFP - device: "+
-            #        str(delta_ofp_device_3) + " ms")
+            main.log.info( "ONOS1 delta OFP - graph: " +
+                           str( delta_ofp_graph_1 ) + " ms" )
+            main.log.info( "ONOS2 delta OFP - graph: " +
+                           str( delta_ofp_graph_2 ) + " ms" )
+            main.log.info( "ONOS3 delta OFP - graph: " +
+                           str( delta_ofp_graph_3 ) + " ms" )
 
-            main.step("Remove switch from controller")
-            main.Mininet1.delete_sw_controller("s1")
+            main.log.info( "ONOS1 delta device - t0: " +
+                           str( delta_device_1 ) + " ms" )
+            main.log.info( "ONOS2 delta device - t0: " +
+                           str( delta_device_2 ) + " ms" )
+            main.log.info( "ONOS3 delta device - t0: " +
+                           str( delta_device_3 ) + " ms" )
 
-            time.sleep(5)
+            main.log.info( "TCP to OFP delta: " +
+                           str( delta_ofp_tcp ) + " ms" )
+            # main.log.info( "ONOS1 delta OFP - device: "+
+            #        str( delta_ofp_device_1 ) + " ms" )
+            # main.log.info( "ONOS2 delta OFP - device: "+
+            #        str( delta_ofp_device_2 ) + " ms" )
+            # main.log.info( "ONOS3 delta OFP - device: "+
+            #        str( delta_ofp_device_3 ) + " ms" )
 
-        #END of for loop iteration
+            main.step( "Remove switch from controller" )
+            main.Mininet1.delete_sw_controller( "s1" )
 
-        #If there is at least 1 element in each list,
-        #pass the test case
-        if len(latency_end_to_end_list) > 0 and\
-           len(latency_ofp_to_graph_list) > 0 and\
-           len(latency_ofp_to_device_list) > 0 and\
-           len(latency_t0_to_device_list) > 0 and\
-           len(latency_tcp_to_ofp_list) > 0:
+            time.sleep( 5 )
+
+        # END of for loop iteration
+
+        # If there is at least 1 element in each list,
+        # pass the test case
+        if len( latency_end_to_end_list ) > 0 and\
+           len( latency_ofp_to_graph_list ) > 0 and\
+           len( latency_ofp_to_device_list ) > 0 and\
+           len( latency_t0_to_device_list ) > 0 and\
+           len( latency_tcp_to_ofp_list ) > 0:
             assertion = main.TRUE
-        elif len(latency_end_to_end_list) == 0:
-            #The appending of 0 here is to prevent 
-            #the min,max,sum functions from failing 
-            #below
-            latency_end_to_end_list.append(0)
+        elif len( latency_end_to_end_list ) == 0:
+            # The appending of 0 here is to prevent
+            # the min,max,sum functions from failing
+            # below
+            latency_end_to_end_list.append( 0 )
             assertion = main.FALSE
-        elif len(latency_ofp_to_graph_list) == 0:
-            latency_ofp_to_graph_list.append(0)
+        elif len( latency_ofp_to_graph_list ) == 0:
+            latency_ofp_to_graph_list.append( 0 )
             assertion = main.FALSE
-        elif len(latency_ofp_to_device_list) == 0:
-            latency_ofp_to_device_list.append(0)
+        elif len( latency_ofp_to_device_list ) == 0:
+            latency_ofp_to_device_list.append( 0 )
             assertion = main.FALSE
-        elif len(latency_t0_to_device_list) == 0:
-            latency_t0_to_device_list.append(0)
+        elif len( latency_t0_to_device_list ) == 0:
+            latency_t0_to_device_list.append( 0 )
             assertion = main.FALSE
-        elif len(latency_tcp_to_ofp_list) == 0:
-            latency_tcp_to_ofp_list.append(0)
+        elif len( latency_tcp_to_ofp_list ) == 0:
+            latency_tcp_to_ofp_list.append( 0 )
             assertion = main.FALSE
 
-        #Calculate min, max, avg of latency lists
+        # Calculate min, max, avg of latency lists
         latency_end_to_end_max = \
-                int(max(latency_end_to_end_list))
+            int( max( latency_end_to_end_list ) )
         latency_end_to_end_min = \
-                int(min(latency_end_to_end_list))
+            int( min( latency_end_to_end_list ) )
         latency_end_to_end_avg = \
-                (int(sum(latency_end_to_end_list)) / \
-                 len(latency_end_to_end_list))
+            ( int( sum( latency_end_to_end_list ) ) /
+              len( latency_end_to_end_list ) )
         latency_end_to_end_std_dev = \
-                str(round(numpy.std(latency_end_to_end_list),1))
+            str( round( numpy.std( latency_end_to_end_list ), 1 ) )
 
         latency_ofp_to_graph_max = \
-                int(max(latency_ofp_to_graph_list))
+            int( max( latency_ofp_to_graph_list ) )
         latency_ofp_to_graph_min = \
-                int(min(latency_ofp_to_graph_list))
+            int( min( latency_ofp_to_graph_list ) )
         latency_ofp_to_graph_avg = \
-                (int(sum(latency_ofp_to_graph_list)) / \
-                 len(latency_ofp_to_graph_list))
+            ( int( sum( latency_ofp_to_graph_list ) ) /
+              len( latency_ofp_to_graph_list ) )
         latency_ofp_to_graph_std_dev = \
-                str(round(numpy.std(latency_ofp_to_graph_list),1))
+            str( round( numpy.std( latency_ofp_to_graph_list ), 1 ) )
 
         latency_ofp_to_device_max = \
-                int(max(latency_ofp_to_device_list))
+            int( max( latency_ofp_to_device_list ) )
         latency_ofp_to_device_min = \
-                int(min(latency_ofp_to_device_list))
+            int( min( latency_ofp_to_device_list ) )
         latency_ofp_to_device_avg = \
-                (int(sum(latency_ofp_to_device_list)) / \
-                 len(latency_ofp_to_device_list))
+            ( int( sum( latency_ofp_to_device_list ) ) /
+              len( latency_ofp_to_device_list ) )
         latency_ofp_to_device_std_dev = \
-                str(round(numpy.std(latency_ofp_to_device_list),1))
+            str( round( numpy.std( latency_ofp_to_device_list ), 1 ) )
 
         latency_t0_to_device_max = \
-                int(max(latency_t0_to_device_list))
+            int( max( latency_t0_to_device_list ) )
         latency_t0_to_device_min = \
-                int(min(latency_t0_to_device_list))
+            int( min( latency_t0_to_device_list ) )
         latency_t0_to_device_avg = \
-                (int(sum(latency_t0_to_device_list)) / \
-                 len(latency_t0_to_device_list))
+            ( int( sum( latency_t0_to_device_list ) ) /
+              len( latency_t0_to_device_list ) )
         latency_ofp_to_device_std_dev = \
-                str(round(numpy.std(latency_t0_to_device_list),1))
+            str( round( numpy.std( latency_t0_to_device_list ), 1 ) )
 
         latency_tcp_to_ofp_max = \
-                int(max(latency_tcp_to_ofp_list))
+            int( max( latency_tcp_to_ofp_list ) )
         latency_tcp_to_ofp_min = \
-                int(min(latency_tcp_to_ofp_list))
+            int( min( latency_tcp_to_ofp_list ) )
         latency_tcp_to_ofp_avg = \
-                (int(sum(latency_tcp_to_ofp_list)) / \
-                 len(latency_tcp_to_ofp_list))
+            ( int( sum( latency_tcp_to_ofp_list ) ) /
+              len( latency_tcp_to_ofp_list ) )
         latency_tcp_to_ofp_std_dev = \
-                str(round(numpy.std(latency_tcp_to_ofp_list),1))
+            str( round( numpy.std( latency_tcp_to_ofp_list ), 1 ) )
 
-        main.log.report("Switch add - End-to-end latency: "+\
-                "Avg: "+str(latency_end_to_end_avg)+" ms "+
-                "Std Deviation: "+latency_end_to_end_std_dev+" ms")
-        main.log.report("Switch add - OFP-to-Graph latency: "+\
-                "Note: results are not accurate to sub-millisecond. "+
-                "Any sub-millisecond results are rounded to 0 ms. ")
-        main.log.report("Avg: "+str(latency_ofp_to_graph_avg)+" ms "+
-                "Std Deviation: "+latency_ofp_to_graph_std_dev+" ms")
-        main.log.report("Switch add - TCP-to-OFP latency: "+\
-                "Avg: "+str(latency_tcp_to_ofp_avg)+" ms "+
-                "Std Deviation: "+latency_tcp_to_ofp_std_dev+" ms")
+        main.log.report(
+            "Switch add - End-to-end latency: " +
+            "Avg: " +
+            str( latency_end_to_end_avg ) +
+            " ms " +
+            "Std Deviation: " +
+            latency_end_to_end_std_dev +
+            " ms" )
+        main.log.report(
+            "Switch add - OFP-to-Graph latency: " +
+            "Note: results are not accurate to sub-millisecond. " +
+            "Any sub-millisecond results are rounded to 0 ms. " )
+        main.log.report(
+            "Avg: " +
+            str( latency_ofp_to_graph_avg ) +
+            " ms " +
+            "Std Deviation: " +
+            latency_ofp_to_graph_std_dev +
+            " ms" )
+        main.log.report(
+            "Switch add - TCP-to-OFP latency: " +
+            "Avg: " +
+            str( latency_tcp_to_ofp_avg ) +
+            " ms " +
+            "Std Deviation: " +
+            latency_tcp_to_ofp_std_dev +
+            " ms" )
 
         if debug_mode == 'on':
-            main.ONOS1.cp_logs_to_dir("/opt/onos/log/karaf.log",
-                    "/tmp/", copy_file_name="sw_lat_karaf")
+            main.ONOS1.cp_logs_to_dir( "/opt/onos/log/karaf.log",
+                                       "/tmp/", copy_file_name="sw_lat_karaf" )
 
-        utilities.assert_equals(expect=main.TRUE, actual=assertion,
-                onpass="Switch latency test successful",
-                onfail="Switch latency test failed")
+        utilities.assert_equals( expect=main.TRUE, actual=assertion,
+                                 onpass="Switch latency test successful",
+                                 onfail="Switch latency test failed" )
 
-    def CASE3(self, main):
-        '''
+    def CASE3( self, main ):
+        """
         Bring port up / down and measure latency.
         Port enable / disable is simulated by ifconfig up / down
-        
-        In ONOS-next, we must ensure that the port we are 
+
+        In ONOS-next, we must ensure that the port we are
         manipulating is connected to another switch with a valid
         connection. Otherwise, graph view will not be updated.
-        '''
+        """
         import time
         import subprocess
         import os
@@ -563,925 +587,961 @@
         import json
         import numpy
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS_user = main.params['CTRL']['user']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS_user = main.params[ 'CTRL' ][ 'user' ]
 
-        default_sw_port = main.params['CTRL']['port1']
-      
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
+
         assertion = main.TRUE
-        #Number of iterations of case
-        num_iter = main.params['TEST']['numIter']
-       
-        #Timestamp 'keys' for json metrics output.
-        #These are subject to change, hence moved into params
-        deviceTimestamp = main.params['JSON']['deviceTimestamp']
-        graphTimestamp = main.params['JSON']['graphTimestamp']
-        
-        debug_mode = main.params['TEST']['debugMode']
+        # Number of iterations of case
+        num_iter = main.params[ 'TEST' ][ 'numIter' ]
 
-        local_time = time.strftime('%x %X')
-        local_time = local_time.replace("/","")
-        local_time = local_time.replace(" ","_")
-        local_time = local_time.replace(":","")
+        # Timestamp 'keys' for json metrics output.
+        # These are subject to change, hence moved into params
+        deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+        graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+        debug_mode = main.params[ 'TEST' ][ 'debugMode' ]
+
+        local_time = time.strftime( '%x %X' )
+        local_time = local_time.replace( "/", "" )
+        local_time = local_time.replace( " ", "_" )
+        local_time = local_time.replace( ":", "" )
         if debug_mode == 'on':
-            main.ONOS1.tshark_pcap("eth0",
-                    "/tmp/port_lat_pcap_"+local_time) 
+            main.ONOS1.tshark_pcap( "eth0",
+                                    "/tmp/port_lat_pcap_" + local_time )
 
-        #Threshold for this test case
-        up_threshold_str = main.params['TEST']['portUpThreshold']
-        down_threshold_str = main.params['TEST']['portDownThreshold']
-        
-        up_threshold_obj = up_threshold_str.split(",")
-        down_threshold_obj = down_threshold_str.split(",")
+        # Threshold for this test case
+        up_threshold_str = main.params[ 'TEST' ][ 'portUpThreshold' ]
+        down_threshold_str = main.params[ 'TEST' ][ 'portDownThreshold' ]
 
-        up_threshold_min = int(up_threshold_obj[0])
-        up_threshold_max = int(up_threshold_obj[1])
+        up_threshold_obj = up_threshold_str.split( "," )
+        down_threshold_obj = down_threshold_str.split( "," )
 
-        down_threshold_min = int(down_threshold_obj[0])
-        down_threshold_max = int(down_threshold_obj[1])
+        up_threshold_min = int( up_threshold_obj[ 0 ] )
+        up_threshold_max = int( up_threshold_obj[ 1 ] )
 
-        #NOTE: Some hardcoded variables you may need to configure
+        down_threshold_min = int( down_threshold_obj[ 0 ] )
+        down_threshold_max = int( down_threshold_obj[ 1 ] )
+
+        # NOTE: Some hardcoded variables you may need to configure
         #      besides the params
-            
+
         tshark_port_status = "OFP 130 Port Status"
 
         tshark_port_up = "/tmp/tshark_port_up.txt"
         tshark_port_down = "/tmp/tshark_port_down.txt"
         interface_config = "s1-eth1"
 
-        main.log.report("Port enable / disable latency")
-        main.log.report("Simulated by ifconfig up / down")
-        main.log.report("Total iterations of test: "+str(num_iter))
+        main.log.report( "Port enable / disable latency" )
+        main.log.report( "Simulated by ifconfig up / down" )
+        main.log.report( "Total iterations of test: " + str( num_iter ) )
 
-        main.step("Assign switches s1 and s2 to controller 1")
-        main.Mininet1.assign_sw_controller(sw="1",ip1=ONOS1_ip,
-                port1=default_sw_port)
-        main.Mininet1.assign_sw_controller(sw="2",ip1=ONOS1_ip,
-                port1=default_sw_port)
+        main.step( "Assign switches s1 and s2 to controller 1" )
+        main.Mininet1.assign_sw_controller( sw="1", ip1=ONOS1_ip,
+                                            port1=default_sw_port )
+        main.Mininet1.assign_sw_controller( sw="2", ip1=ONOS1_ip,
+                                            port1=default_sw_port )
 
-        #Give enough time for metrics to propagate the 
-        #assign controller event. Otherwise, these events may
-        #carry over to our measurements
-        time.sleep(15)
+        # Give enough time for metrics to propagate the
+        # assign controller event. Otherwise, these events may
+        # carry over to our measurements
+        time.sleep( 15 )
 
         port_up_device_to_ofp_list = []
         port_up_graph_to_ofp_list = []
         port_down_device_to_ofp_list = []
         port_down_graph_to_ofp_list = []
 
-        for i in range(0, int(num_iter)):
-            main.step("Starting wireshark capture for port status down")
-            main.ONOS1.tshark_grep(tshark_port_status,
-                    tshark_port_down)
-            
-            time.sleep(5)
+        for i in range( 0, int( num_iter ) ):
+            main.step( "Starting wireshark capture for port status down" )
+            main.ONOS1.tshark_grep( tshark_port_status,
+                                    tshark_port_down )
 
-            #Disable interface that is connected to switch 2
-            main.step("Disable port: "+interface_config)
-            main.Mininet1.handle.sendline("sh ifconfig "+
-                    interface_config+" down")
-            main.Mininet1.handle.expect("mininet>")
+            time.sleep( 5 )
 
-            time.sleep(3)
+            # Disable interface that is connected to switch 2
+            main.step( "Disable port: " + interface_config )
+            main.Mininet1.handle.sendline( "sh ifconfig " +
+                                           interface_config + " down" )
+            main.Mininet1.handle.expect( "mininet>" )
+
+            time.sleep( 3 )
             main.ONOS1.tshark_stop()
-            
-            main.step("Obtain t1 by metrics call")
+
+            main.step( "Obtain t1 by metrics call" )
             json_str_up_1 = main.ONOS1cli.topology_events_metrics()
             json_str_up_2 = main.ONOS2cli.topology_events_metrics()
             json_str_up_3 = main.ONOS3cli.topology_events_metrics()
 
-            json_obj_1 = json.loads(json_str_up_1)
-            json_obj_2 = json.loads(json_str_up_2)
-            json_obj_3 = json.loads(json_str_up_3)
-            
-            #Copy tshark output file from ONOS to TestON instance
-            #/tmp directory
-            os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
-                    tshark_port_down+" /tmp/")
+            json_obj_1 = json.loads( json_str_up_1 )
+            json_obj_2 = json.loads( json_str_up_2 )
+            json_obj_3 = json.loads( json_str_up_3 )
 
-            f_port_down = open(tshark_port_down, 'r')
-            #Get first line of port down event from tshark
+            # Copy tshark output file from ONOS to TestON instance
+            #/tmp directory
+            os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+                       tshark_port_down + " /tmp/" )
+
+            f_port_down = open( tshark_port_down, 'r' )
+            # Get first line of port down event from tshark
             f_line = f_port_down.readline()
-            obj_down = f_line.split(" ")
-            if len(f_line) > 0:
-                timestamp_begin_pt_down = int(float(obj_down[1])*1000)
-                main.log.info("Port down begin timestamp: "+
-                        str(timestamp_begin_pt_down))
+            obj_down = f_line.split( " " )
+            if len( f_line ) > 0:
+                timestamp_begin_pt_down = int( float( obj_down[ 1 ] ) * 1000 )
+                main.log.info( "Port down begin timestamp: " +
+                               str( timestamp_begin_pt_down ) )
             else:
-                main.log.info("Tshark output file returned unexpected"+
-                        " results: "+str(obj_down))
+                main.log.info( "Tshark output file returned unexpected" +
+                               " results: " + str( obj_down ) )
                 timestamp_begin_pt_down = 0
-            
+
             f_port_down.close()
 
-            main.log.info("TEST tshark obj: "+str(obj_down))
+            main.log.info( "TEST tshark obj: " + str( obj_down ) )
 
-            time.sleep(3)
+            time.sleep( 3 )
 
-            #Obtain graph timestamp. This timestsamp captures
-            #the epoch time at which the topology graph was updated.
+            # Obtain graph timestamp. This timestsamp captures
+            # the epoch time at which the topology graph was updated.
             graph_timestamp_1 = \
-                    json_obj_1[graphTimestamp]['value']
+                json_obj_1[ graphTimestamp ][ 'value' ]
             graph_timestamp_2 = \
-                    json_obj_2[graphTimestamp]['value']
+                json_obj_2[ graphTimestamp ][ 'value' ]
             graph_timestamp_3 = \
-                    json_obj_3[graphTimestamp]['value']
+                json_obj_3[ graphTimestamp ][ 'value' ]
 
-            main.log.info("TEST graph timestamp ONOS1: "+
-                    str(graph_timestamp_1))
+            main.log.info( "TEST graph timestamp ONOS1: " +
+                           str( graph_timestamp_1 ) )
 
-            #Obtain device timestamp. This timestamp captures
-            #the epoch time at which the device event happened
+            # Obtain device timestamp. This timestamp captures
+            # the epoch time at which the device event happened
             device_timestamp_1 = \
-                    json_obj_1[deviceTimestamp]['value'] 
+                json_obj_1[ deviceTimestamp ][ 'value' ]
             device_timestamp_2 = \
-                    json_obj_2[deviceTimestamp]['value'] 
+                json_obj_2[ deviceTimestamp ][ 'value' ]
             device_timestamp_3 = \
-                    json_obj_3[deviceTimestamp]['value'] 
+                json_obj_3[ deviceTimestamp ][ 'value' ]
 
-            #Get delta between graph event and OFP 
-            pt_down_graph_to_ofp_1 = int(graph_timestamp_1) -\
-                    int(timestamp_begin_pt_down)
-            pt_down_graph_to_ofp_2 = int(graph_timestamp_2) -\
-                    int(timestamp_begin_pt_down)
-            pt_down_graph_to_ofp_3 = int(graph_timestamp_3) -\
-                    int(timestamp_begin_pt_down)
+            # Get delta between graph event and OFP
+            pt_down_graph_to_ofp_1 = int( graph_timestamp_1 ) -\
+                int( timestamp_begin_pt_down )
+            pt_down_graph_to_ofp_2 = int( graph_timestamp_2 ) -\
+                int( timestamp_begin_pt_down )
+            pt_down_graph_to_ofp_3 = int( graph_timestamp_3 ) -\
+                int( timestamp_begin_pt_down )
 
-            #Get delta between device event and OFP
-            pt_down_device_to_ofp_1 = int(device_timestamp_1) -\
-                    int(timestamp_begin_pt_down)
-            pt_down_device_to_ofp_2 = int(device_timestamp_2) -\
-                    int(timestamp_begin_pt_down)
-            pt_down_device_to_ofp_3 = int(device_timestamp_3) -\
-                    int(timestamp_begin_pt_down)
-       
-            #Caluclate average across clusters
+            # Get delta between device event and OFP
+            pt_down_device_to_ofp_1 = int( device_timestamp_1 ) -\
+                int( timestamp_begin_pt_down )
+            pt_down_device_to_ofp_2 = int( device_timestamp_2 ) -\
+                int( timestamp_begin_pt_down )
+            pt_down_device_to_ofp_3 = int( device_timestamp_3 ) -\
+                int( timestamp_begin_pt_down )
+
+            # Caluclate average across clusters
             pt_down_graph_to_ofp_avg =\
-                    (int(pt_down_graph_to_ofp_1) +
-                     int(pt_down_graph_to_ofp_2) + 
-                     int(pt_down_graph_to_ofp_3)) / 3
+                ( int( pt_down_graph_to_ofp_1 ) +
+                  int( pt_down_graph_to_ofp_2 ) +
+                  int( pt_down_graph_to_ofp_3 ) ) / 3
             pt_down_device_to_ofp_avg = \
-                    (int(pt_down_device_to_ofp_1) + 
-                     int(pt_down_device_to_ofp_2) +
-                     int(pt_down_device_to_ofp_3)) / 3
+                ( int( pt_down_device_to_ofp_1 ) +
+                  int( pt_down_device_to_ofp_2 ) +
+                  int( pt_down_device_to_ofp_3 ) ) / 3
 
             if pt_down_graph_to_ofp_avg > down_threshold_min and \
                     pt_down_graph_to_ofp_avg < down_threshold_max:
                 port_down_graph_to_ofp_list.append(
-                    pt_down_graph_to_ofp_avg)
-                main.log.info("Port down: graph to ofp avg: "+
-                    str(pt_down_graph_to_ofp_avg) + " ms")
+                    pt_down_graph_to_ofp_avg )
+                main.log.info( "Port down: graph to ofp avg: " +
+                               str( pt_down_graph_to_ofp_avg ) + " ms" )
             else:
-                main.log.info("Average port down graph-to-ofp result" +
-                        " exceeded the threshold: "+
-                        str(pt_down_graph_to_ofp_avg))
+                main.log.info( "Average port down graph-to-ofp result" +
+                               " exceeded the threshold: " +
+                               str( pt_down_graph_to_ofp_avg ) )
 
             if pt_down_device_to_ofp_avg > 0 and \
                     pt_down_device_to_ofp_avg < 1000:
                 port_down_device_to_ofp_list.append(
-                    pt_down_device_to_ofp_avg)
-                main.log.info("Port down: device to ofp avg: "+
-                    str(pt_down_device_to_ofp_avg) + " ms")
+                    pt_down_device_to_ofp_avg )
+                main.log.info( "Port down: device to ofp avg: " +
+                               str( pt_down_device_to_ofp_avg ) + " ms" )
             else:
-                main.log.info("Average port down device-to-ofp result" +
-                        " exceeded the threshold: "+
-                        str(pt_down_device_to_ofp_avg))
+                main.log.info( "Average port down device-to-ofp result" +
+                               " exceeded the threshold: " +
+                               str( pt_down_device_to_ofp_avg ) )
 
-            #Port up events 
-            main.step("Enable port and obtain timestamp")
-            main.step("Starting wireshark capture for port status up")
-            main.ONOS1.tshark_grep(tshark_port_status, tshark_port_up)
-            time.sleep(5)
+            # Port up events
+            main.step( "Enable port and obtain timestamp" )
+            main.step( "Starting wireshark capture for port status up" )
+            main.ONOS1.tshark_grep( tshark_port_status, tshark_port_up )
+            time.sleep( 5 )
 
-            main.Mininet1.handle.sendline("sh ifconfig "+
-                    interface_config+" up")
-            main.Mininet1.handle.expect("mininet>")
-            
-            #Allow time for tshark to capture event
-            time.sleep(3)
+            main.Mininet1.handle.sendline( "sh ifconfig " +
+                                           interface_config + " up" )
+            main.Mininet1.handle.expect( "mininet>" )
+
+            # Allow time for tshark to capture event
+            time.sleep( 3 )
             main.ONOS1.tshark_stop()
 
-            #Obtain metrics shortly afterwards
-            #This timestsamp captures
-            #the epoch time at which the topology graph was updated.
-            main.step("Obtain t1 by REST call")
+            # Obtain metrics shortly afterwards
+            # This timestsamp captures
+            # the epoch time at which the topology graph was updated.
+            main.step( "Obtain t1 by REST call" )
             json_str_up_1 = main.ONOS1cli.topology_events_metrics()
             json_str_up_2 = main.ONOS2cli.topology_events_metrics()
             json_str_up_3 = main.ONOS3cli.topology_events_metrics()
-            
-            json_obj_1 = json.loads(json_str_up_1)
-            json_obj_2 = json.loads(json_str_up_2)
-            json_obj_3 = json.loads(json_str_up_3)
 
-            os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
-                    tshark_port_up+" /tmp/")
+            json_obj_1 = json.loads( json_str_up_1 )
+            json_obj_2 = json.loads( json_str_up_2 )
+            json_obj_3 = json.loads( json_str_up_3 )
 
-            f_port_up = open(tshark_port_up, 'r')
+            os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+                       tshark_port_up + " /tmp/" )
+
+            f_port_up = open( tshark_port_up, 'r' )
             f_line = f_port_up.readline()
-            obj_up = f_line.split(" ")
-            if len(f_line) > 0:
-                timestamp_begin_pt_up = int(float(obj_up[1])*1000)
-                main.log.info("Port up begin timestamp: "+
-                        str(timestamp_begin_pt_up))
+            obj_up = f_line.split( " " )
+            if len( f_line ) > 0:
+                timestamp_begin_pt_up = int( float( obj_up[ 1 ] ) * 1000 )
+                main.log.info( "Port up begin timestamp: " +
+                               str( timestamp_begin_pt_up ) )
             else:
-                main.log.info("Tshark output file returned unexpected"+
-                        " results.")
+                main.log.info( "Tshark output file returned unexpected" +
+                               " results." )
                 timestamp_begin_pt_up = 0
-            
+
             f_port_up.close()
 
             graph_timestamp_1 = \
-                    json_obj_1[graphTimestamp]['value']
+                json_obj_1[ graphTimestamp ][ 'value' ]
             graph_timestamp_2 = \
-                    json_obj_2[graphTimestamp]['value']
+                json_obj_2[ graphTimestamp ][ 'value' ]
             graph_timestamp_3 = \
-                    json_obj_3[graphTimestamp]['value']
+                json_obj_3[ graphTimestamp ][ 'value' ]
 
-            #Obtain device timestamp. This timestamp captures
-            #the epoch time at which the device event happened
+            # Obtain device timestamp. This timestamp captures
+            # the epoch time at which the device event happened
             device_timestamp_1 = \
-                    json_obj_1[deviceTimestamp]['value'] 
+                json_obj_1[ deviceTimestamp ][ 'value' ]
             device_timestamp_2 = \
-                    json_obj_2[deviceTimestamp]['value'] 
+                json_obj_2[ deviceTimestamp ][ 'value' ]
             device_timestamp_3 = \
-                    json_obj_3[deviceTimestamp]['value'] 
+                json_obj_3[ deviceTimestamp ][ 'value' ]
 
-            #Get delta between graph event and OFP 
-            pt_up_graph_to_ofp_1 = int(graph_timestamp_1) -\
-                    int(timestamp_begin_pt_up)
-            pt_up_graph_to_ofp_2 = int(graph_timestamp_2) -\
-                    int(timestamp_begin_pt_up)
-            pt_up_graph_to_ofp_3 = int(graph_timestamp_3) -\
-                    int(timestamp_begin_pt_up)
+            # Get delta between graph event and OFP
+            pt_up_graph_to_ofp_1 = int( graph_timestamp_1 ) -\
+                int( timestamp_begin_pt_up )
+            pt_up_graph_to_ofp_2 = int( graph_timestamp_2 ) -\
+                int( timestamp_begin_pt_up )
+            pt_up_graph_to_ofp_3 = int( graph_timestamp_3 ) -\
+                int( timestamp_begin_pt_up )
 
-            #Get delta between device event and OFP
-            pt_up_device_to_ofp_1 = int(device_timestamp_1) -\
-                    int(timestamp_begin_pt_up)
-            pt_up_device_to_ofp_2 = int(device_timestamp_2) -\
-                    int(timestamp_begin_pt_up)
-            pt_up_device_to_ofp_3 = int(device_timestamp_3) -\
-                    int(timestamp_begin_pt_up)
+            # Get delta between device event and OFP
+            pt_up_device_to_ofp_1 = int( device_timestamp_1 ) -\
+                int( timestamp_begin_pt_up )
+            pt_up_device_to_ofp_2 = int( device_timestamp_2 ) -\
+                int( timestamp_begin_pt_up )
+            pt_up_device_to_ofp_3 = int( device_timestamp_3 ) -\
+                int( timestamp_begin_pt_up )
 
-            main.log.info("ONOS1 delta G2O: "+str(pt_up_graph_to_ofp_1))
-            main.log.info("ONOS2 delta G2O: "+str(pt_up_graph_to_ofp_2))
-            main.log.info("ONOS3 delta G2O: "+str(pt_up_graph_to_ofp_3))
+            main.log.info( "ONOS1 delta G2O: " + str( pt_up_graph_to_ofp_1 ) )
+            main.log.info( "ONOS2 delta G2O: " + str( pt_up_graph_to_ofp_2 ) )
+            main.log.info( "ONOS3 delta G2O: " + str( pt_up_graph_to_ofp_3 ) )
 
-            main.log.info("ONOS1 delta D2O: "+str(pt_up_device_to_ofp_1))
-            main.log.info("ONOS2 delta D2O: "+str(pt_up_device_to_ofp_2)) 
-            main.log.info("ONOS3 delta D2O: "+str(pt_up_device_to_ofp_3)) 
+            main.log.info( "ONOS1 delta D2O: " + str( pt_up_device_to_ofp_1 ) )
+            main.log.info( "ONOS2 delta D2O: " + str( pt_up_device_to_ofp_2 ) )
+            main.log.info( "ONOS3 delta D2O: " + str( pt_up_device_to_ofp_3 ) )
 
             pt_up_graph_to_ofp_avg = \
-                    (int(pt_up_graph_to_ofp_1) + 
-                     int(pt_up_graph_to_ofp_2) +
-                     int(pt_up_graph_to_ofp_3)) / 3
+                ( int( pt_up_graph_to_ofp_1 ) +
+                  int( pt_up_graph_to_ofp_2 ) +
+                  int( pt_up_graph_to_ofp_3 ) ) / 3
 
             pt_up_device_to_ofp_avg = \
-                    (int(pt_up_device_to_ofp_1) + 
-                     int(pt_up_device_to_ofp_2) +
-                     int(pt_up_device_to_ofp_3)) / 3
+                ( int( pt_up_device_to_ofp_1 ) +
+                  int( pt_up_device_to_ofp_2 ) +
+                  int( pt_up_device_to_ofp_3 ) ) / 3
 
             if pt_up_graph_to_ofp_avg > up_threshold_min and \
-                    pt_up_graph_to_ofp_avg < up_threshold_max: 
+                    pt_up_graph_to_ofp_avg < up_threshold_max:
                 port_up_graph_to_ofp_list.append(
-                        pt_up_graph_to_ofp_avg)
-                main.log.info("Port down: graph to ofp avg: "+
-                    str(pt_up_graph_to_ofp_avg) + " ms")
+                    pt_up_graph_to_ofp_avg )
+                main.log.info( "Port down: graph to ofp avg: " +
+                               str( pt_up_graph_to_ofp_avg ) + " ms" )
             else:
-                main.log.info("Average port up graph-to-ofp result"+
-                        " exceeded the threshold: "+
-                        str(pt_up_graph_to_ofp_avg))
-            
+                main.log.info( "Average port up graph-to-ofp result" +
+                               " exceeded the threshold: " +
+                               str( pt_up_graph_to_ofp_avg ) )
+
             if pt_up_device_to_ofp_avg > up_threshold_min and \
                     pt_up_device_to_ofp_avg < up_threshold_max:
                 port_up_device_to_ofp_list.append(
-                        pt_up_device_to_ofp_avg)
-                main.log.info("Port up: device to ofp avg: "+
-                    str(pt_up_device_to_ofp_avg) + " ms")
+                    pt_up_device_to_ofp_avg )
+                main.log.info( "Port up: device to ofp avg: " +
+                               str( pt_up_device_to_ofp_avg ) + " ms" )
             else:
-                main.log.info("Average port up device-to-ofp result"+
-                        " exceeded the threshold: "+
-                        str(pt_up_device_to_ofp_avg))
-            
-            #END ITERATION FOR LOOP
-        
-        #Check all list for latency existence and set assertion
-        if (port_down_graph_to_ofp_list and port_down_device_to_ofp_list\
-           and port_up_graph_to_ofp_list and port_up_device_to_ofp_list):
+                main.log.info( "Average port up device-to-ofp result" +
+                               " exceeded the threshold: " +
+                               str( pt_up_device_to_ofp_avg ) )
+
+            # END ITERATION FOR LOOP
+
+        # Check all list for latency existence and set assertion
+        if ( port_down_graph_to_ofp_list and port_down_device_to_ofp_list
+                and port_up_graph_to_ofp_list and port_up_device_to_ofp_list ):
             assertion = main.TRUE
 
-        #Calculate and report latency measurements
-        port_down_graph_to_ofp_min = min(port_down_graph_to_ofp_list)
-        port_down_graph_to_ofp_max = max(port_down_graph_to_ofp_list)
+        # Calculate and report latency measurements
+        port_down_graph_to_ofp_min = min( port_down_graph_to_ofp_list )
+        port_down_graph_to_ofp_max = max( port_down_graph_to_ofp_list )
         port_down_graph_to_ofp_avg = \
-                (sum(port_down_graph_to_ofp_list) / 
-                 len(port_down_graph_to_ofp_list))
+            ( sum( port_down_graph_to_ofp_list ) /
+              len( port_down_graph_to_ofp_list ) )
         port_down_graph_to_ofp_std_dev = \
-                str(round(numpy.std(port_down_graph_to_ofp_list),1))
-        
-        main.log.report("Port down graph-to-ofp "+
-                "Avg: "+str(port_down_graph_to_ofp_avg)+" ms "+
-                "Std Deviation: "+port_down_graph_to_ofp_std_dev+" ms")
-        
-        port_down_device_to_ofp_min = min(port_down_device_to_ofp_list)
-        port_down_device_to_ofp_max = max(port_down_device_to_ofp_list)
+            str( round( numpy.std( port_down_graph_to_ofp_list ), 1 ) )
+
+        main.log.report(
+            "Port down graph-to-ofp " +
+            "Avg: " +
+            str( port_down_graph_to_ofp_avg ) +
+            " ms " +
+            "Std Deviation: " +
+            port_down_graph_to_ofp_std_dev +
+            " ms" )
+
+        port_down_device_to_ofp_min = min( port_down_device_to_ofp_list )
+        port_down_device_to_ofp_max = max( port_down_device_to_ofp_list )
         port_down_device_to_ofp_avg = \
-                (sum(port_down_device_to_ofp_list) /\
-                 len(port_down_device_to_ofp_list))
+            ( sum( port_down_device_to_ofp_list ) /
+              len( port_down_device_to_ofp_list ) )
         port_down_device_to_ofp_std_dev = \
-                str(round(numpy.std(port_down_device_to_ofp_list),1))
-        
-        main.log.report("Port down device-to-ofp "+
-                "Avg: "+str(port_down_device_to_ofp_avg)+" ms "+
-                "Std Deviation: "+port_down_device_to_ofp_std_dev+" ms")
-        
-        port_up_graph_to_ofp_min = min(port_up_graph_to_ofp_list)
-        port_up_graph_to_ofp_max = max(port_up_graph_to_ofp_list)
+            str( round( numpy.std( port_down_device_to_ofp_list ), 1 ) )
+
+        main.log.report(
+            "Port down device-to-ofp " +
+            "Avg: " +
+            str( port_down_device_to_ofp_avg ) +
+            " ms " +
+            "Std Deviation: " +
+            port_down_device_to_ofp_std_dev +
+            " ms" )
+
+        port_up_graph_to_ofp_min = min( port_up_graph_to_ofp_list )
+        port_up_graph_to_ofp_max = max( port_up_graph_to_ofp_list )
         port_up_graph_to_ofp_avg = \
-                (sum(port_up_graph_to_ofp_list) /\
-                 len(port_up_graph_to_ofp_list))
+            ( sum( port_up_graph_to_ofp_list ) /
+              len( port_up_graph_to_ofp_list ) )
         port_up_graph_to_ofp_std_dev = \
-                str(round(numpy.std(port_up_graph_to_ofp_list),1))
-        
-        main.log.report("Port up graph-to-ofp "+
-                "Avg: "+str(port_up_graph_to_ofp_avg)+" ms "+
-                "Std Deviation: "+port_up_graph_to_ofp_std_dev+" ms")
-          
-        port_up_device_to_ofp_min = min(port_up_device_to_ofp_list)
-        port_up_device_to_ofp_max = max(port_up_device_to_ofp_list)
+            str( round( numpy.std( port_up_graph_to_ofp_list ), 1 ) )
+
+        main.log.report(
+            "Port up graph-to-ofp " +
+            "Avg: " +
+            str( port_up_graph_to_ofp_avg ) +
+            " ms " +
+            "Std Deviation: " +
+            port_up_graph_to_ofp_std_dev +
+            " ms" )
+
+        port_up_device_to_ofp_min = min( port_up_device_to_ofp_list )
+        port_up_device_to_ofp_max = max( port_up_device_to_ofp_list )
         port_up_device_to_ofp_avg = \
-                (sum(port_up_device_to_ofp_list) /\
-                 len(port_up_device_to_ofp_list))
+            ( sum( port_up_device_to_ofp_list ) /
+              len( port_up_device_to_ofp_list ) )
         port_up_device_to_ofp_std_dev = \
-                str(round(numpy.std(port_up_device_to_ofp_list),1))
-        
-        main.log.report("Port up device-to-ofp "+
-                "Avg: "+str(port_up_device_to_ofp_avg)+" ms "+
-                "Std Deviation: "+port_up_device_to_ofp_std_dev+" ms")
+            str( round( numpy.std( port_up_device_to_ofp_list ), 1 ) )
 
-        utilities.assert_equals(expect=main.TRUE, actual=assertion,
-                onpass="Port discovery latency calculation successful",
-                onfail="Port discovery test failed")
+        main.log.report(
+            "Port up device-to-ofp " +
+            "Avg: " +
+            str( port_up_device_to_ofp_avg ) +
+            " ms " +
+            "Std Deviation: " +
+            port_up_device_to_ofp_std_dev +
+            " ms" )
 
-    def CASE4(self, main):
-        '''
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=assertion,
+            onpass="Port discovery latency calculation successful",
+            onfail="Port discovery test failed" )
+
+    def CASE4( self, main ):
+        """
         Link down event using loss rate 100%
-        
+
         Important:
             Use a simple 2 switch topology with 1 link between
-            the two switches. Ensure that mac addresses of the 
+            the two switches. Ensure that mac addresses of the
             switches are 1 / 2 respectively
-        '''
+        """
         import time
         import subprocess
         import os
         import requests
         import json
-        import numpy 
-    
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        ONOS_user = main.params['CTRL']['user']
+        import numpy
 
-        default_sw_port = main.params['CTRL']['port1']
-       
-        #Number of iterations of case
-        num_iter = main.params['TEST']['numIter']
-       
-        #Timestamp 'keys' for json metrics output.
-        #These are subject to change, hence moved into params
-        deviceTimestamp = main.params['JSON']['deviceTimestamp']
-        linkTimestamp = main.params['JSON']['linkTimestamp'] 
-        graphTimestamp = main.params['JSON']['graphTimestamp']
-        
-        debug_mode = main.params['TEST']['debugMode']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        ONOS_user = main.params[ 'CTRL' ][ 'user' ]
 
-        local_time = time.strftime('%x %X')
-        local_time = local_time.replace("/","")
-        local_time = local_time.replace(" ","_")
-        local_time = local_time.replace(":","")
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
+
+        # Number of iterations of case
+        num_iter = main.params[ 'TEST' ][ 'numIter' ]
+
+        # Timestamp 'keys' for json metrics output.
+        # These are subject to change, hence moved into params
+        deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+        linkTimestamp = main.params[ 'JSON' ][ 'linkTimestamp' ]
+        graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+        debug_mode = main.params[ 'TEST' ][ 'debugMode' ]
+
+        local_time = time.strftime( '%x %X' )
+        local_time = local_time.replace( "/", "" )
+        local_time = local_time.replace( " ", "_" )
+        local_time = local_time.replace( ":", "" )
         if debug_mode == 'on':
-            main.ONOS1.tshark_pcap("eth0",
-                    "/tmp/link_lat_pcap_"+local_time) 
+            main.ONOS1.tshark_pcap( "eth0",
+                                    "/tmp/link_lat_pcap_" + local_time )
 
-        #Threshold for this test case
-        up_threshold_str = main.params['TEST']['linkUpThreshold']
-        down_threshold_str = main.params['TEST']['linkDownThreshold']
+        # Threshold for this test case
+        up_threshold_str = main.params[ 'TEST' ][ 'linkUpThreshold' ]
+        down_threshold_str = main.params[ 'TEST' ][ 'linkDownThreshold' ]
 
-        up_threshold_obj = up_threshold_str.split(",")
-        down_threshold_obj = down_threshold_str.split(",")
+        up_threshold_obj = up_threshold_str.split( "," )
+        down_threshold_obj = down_threshold_str.split( "," )
 
-        up_threshold_min = int(up_threshold_obj[0])
-        up_threshold_max = int(up_threshold_obj[1])
+        up_threshold_min = int( up_threshold_obj[ 0 ] )
+        up_threshold_max = int( up_threshold_obj[ 1 ] )
 
-        down_threshold_min = int(down_threshold_obj[0])
-        down_threshold_max = int(down_threshold_obj[1])
+        down_threshold_min = int( down_threshold_obj[ 0 ] )
+        down_threshold_max = int( down_threshold_obj[ 1 ] )
 
         assertion = main.TRUE
-        #Link event timestamp to system time list
+        # Link event timestamp to system time list
         link_down_link_to_system_list = []
         link_up_link_to_system_list = []
-        #Graph event timestamp to system time list
+        # Graph event timestamp to system time list
         link_down_graph_to_system_list = []
-        link_up_graph_to_system_list = [] 
+        link_up_graph_to_system_list = []
 
-        main.log.report("Link up / down discovery latency between "+
-                "two switches")
-        main.log.report("Simulated by setting loss-rate 100%")
-        main.log.report("'tc qdisc add dev <intfs> root netem loss 100%'") 
-        main.log.report("Total iterations of test: "+str(num_iter))
+        main.log.report( "Link up / down discovery latency between " +
+                         "two switches" )
+        main.log.report( "Simulated by setting loss-rate 100%" )
+        main.log.report( "'tc qdisc add dev <intfs> root netem loss 100%'" )
+        main.log.report( "Total iterations of test: " + str( num_iter ) )
 
-        main.step("Assign all switches")
-        main.Mininet1.assign_sw_controller(sw="1",
-                ip1=ONOS1_ip, port1=default_sw_port)
-        main.Mininet1.assign_sw_controller(sw="2",
-                ip1=ONOS1_ip, port1=default_sw_port)
+        main.step( "Assign all switches" )
+        main.Mininet1.assign_sw_controller(
+            sw="1",
+            ip1=ONOS1_ip,
+            port1=default_sw_port )
+        main.Mininet1.assign_sw_controller(
+            sw="2",
+            ip1=ONOS1_ip,
+            port1=default_sw_port )
 
-        main.step("Verifying switch assignment")
-        result_s1 = main.Mininet1.get_sw_controller(sw="s1")
-        result_s2 = main.Mininet1.get_sw_controller(sw="s2")
-          
-        #Allow time for events to finish before taking measurements
-        time.sleep(10)
+        main.step( "Verifying switch assignment" )
+        result_s1 = main.Mininet1.get_sw_controller( sw="s1" )
+        result_s2 = main.Mininet1.get_sw_controller( sw="s2" )
+
+        # Allow time for events to finish before taking measurements
+        time.sleep( 10 )
 
         link_down1 = False
         link_down2 = False
         link_down3 = False
-        #Start iteration of link event test
-        for i in range(0, int(num_iter)):
-            main.step("Getting initial system time as t0")
-            
-            timestamp_link_down_t0 = time.time() * 1000
-            #Link down is simulated by 100% loss rate using traffic 
-            #control command
-            main.Mininet1.handle.sendline(
-                    "sh tc qdisc add dev s1-eth1 root netem loss 100%")
+        # Start iteration of link event test
+        for i in range( 0, int( num_iter ) ):
+            main.step( "Getting initial system time as t0" )
 
-            #TODO: Iterate through 'links' command to verify that
-            #      link s1 -> s2 went down (loop timeout 30 seconds) 
+            timestamp_link_down_t0 = time.time() * 1000
+            # Link down is simulated by 100% loss rate using traffic
+            # control command
+            main.Mininet1.handle.sendline(
+                "sh tc qdisc add dev s1-eth1 root netem loss 100%" )
+
+            # TODO: Iterate through 'links' command to verify that
+            #      link s1 -> s2 went down ( loop timeout 30 seconds )
             #      on all 3 ONOS instances
-            main.log.info("Checking ONOS for link update")
+            main.log.info( "Checking ONOS for link update" )
             loop_count = 0
-            while( not (link_down1 and link_down2 and link_down3)\
+            while( not ( link_down1 and link_down2 and link_down3 )
                     and loop_count < 30 ):
                 json_str1 = main.ONOS1cli.links()
                 json_str2 = main.ONOS2cli.links()
                 json_str3 = main.ONOS3cli.links()
-                
-                if not (json_str1 and json_str2 and json_str3):
-                    main.log.error("CLI command returned error ")
+
+                if not ( json_str1 and json_str2 and json_str3 ):
+                    main.log.error( "CLI command returned error " )
                     break
                 else:
-                    json_obj1 = json.loads(json_str1)
-                    json_obj2 = json.loads(json_str2)
-                    json_obj3 = json.loads(json_str3)
+                    json_obj1 = json.loads( json_str1 )
+                    json_obj2 = json.loads( json_str2 )
+                    json_obj3 = json.loads( json_str3 )
                 for obj1 in json_obj1:
-                    if '01' not in obj1['src']['device']:
+                    if '01' not in obj1[ 'src' ][ 'device' ]:
                         link_down1 = True
-                        main.log.info("Link down from "+
-                                "s1 -> s2 on ONOS1 detected")
+                        main.log.info( "Link down from " +
+                                       "s1 -> s2 on ONOS1 detected" )
                 for obj2 in json_obj2:
-                    if '01' not in obj2['src']['device']:
+                    if '01' not in obj2[ 'src' ][ 'device' ]:
                         link_down2 = True
-                        main.log.info("Link down from "+
-                                "s1 -> s2 on ONOS2 detected")
+                        main.log.info( "Link down from " +
+                                       "s1 -> s2 on ONOS2 detected" )
                 for obj3 in json_obj3:
-                    if '01' not in obj3['src']['device']:
+                    if '01' not in obj3[ 'src' ][ 'device' ]:
                         link_down3 = True
-                        main.log.info("Link down from "+
-                                "s1 -> s2 on ONOS3 detected")
-                
+                        main.log.info( "Link down from " +
+                                       "s1 -> s2 on ONOS3 detected" )
+
                 loop_count += 1
-                #If CLI doesn't like the continuous requests
-                #and exits in this loop, increase the sleep here.
-                #Consequently, while loop timeout will increase
-                time.sleep(1)
-    
-            #Give time for metrics measurement to catch up
-            #NOTE: May need to be configured more accurately
-            time.sleep(10)
-            #If we exited the while loop and link down 1,2,3 are still 
-            #false, then ONOS has failed to discover link down event
-            if not (link_down1 and link_down2 and link_down3):
-                main.log.info("Link down discovery failed")
-                
+                # If CLI doesn't like the continuous requests
+                # and exits in this loop, increase the sleep here.
+                # Consequently, while loop timeout will increase
+                time.sleep( 1 )
+
+            # Give time for metrics measurement to catch up
+            # NOTE: May need to be configured more accurately
+            time.sleep( 10 )
+            # If we exited the while loop and link down 1,2,3 are still
+            # false, then ONOS has failed to discover link down event
+            if not ( link_down1 and link_down2 and link_down3 ):
+                main.log.info( "Link down discovery failed" )
+
                 link_down_lat_graph1 = 0
                 link_down_lat_graph2 = 0
                 link_down_lat_graph3 = 0
                 link_down_lat_device1 = 0
                 link_down_lat_device2 = 0
                 link_down_lat_device3 = 0
-                
+
                 assertion = main.FALSE
             else:
                 json_topo_metrics_1 =\
-                        main.ONOS1cli.topology_events_metrics()
+                    main.ONOS1cli.topology_events_metrics()
                 json_topo_metrics_2 =\
-                        main.ONOS2cli.topology_events_metrics()
+                    main.ONOS2cli.topology_events_metrics()
                 json_topo_metrics_3 =\
-                        main.ONOS3cli.topology_events_metrics()
-                json_topo_metrics_1 = json.loads(json_topo_metrics_1)
-                json_topo_metrics_2 = json.loads(json_topo_metrics_2)
-                json_topo_metrics_3 = json.loads(json_topo_metrics_3)
+                    main.ONOS3cli.topology_events_metrics()
+                json_topo_metrics_1 = json.loads( json_topo_metrics_1 )
+                json_topo_metrics_2 = json.loads( json_topo_metrics_2 )
+                json_topo_metrics_3 = json.loads( json_topo_metrics_3 )
 
-                main.log.info("Obtaining graph and device timestamp")
+                main.log.info( "Obtaining graph and device timestamp" )
                 graph_timestamp_1 = \
-                    json_topo_metrics_1[graphTimestamp]['value']
+                    json_topo_metrics_1[ graphTimestamp ][ 'value' ]
                 graph_timestamp_2 = \
-                    json_topo_metrics_2[graphTimestamp]['value']
+                    json_topo_metrics_2[ graphTimestamp ][ 'value' ]
                 graph_timestamp_3 = \
-                    json_topo_metrics_3[graphTimestamp]['value']
+                    json_topo_metrics_3[ graphTimestamp ][ 'value' ]
 
                 link_timestamp_1 = \
-                    json_topo_metrics_1[linkTimestamp]['value']
+                    json_topo_metrics_1[ linkTimestamp ][ 'value' ]
                 link_timestamp_2 = \
-                    json_topo_metrics_2[linkTimestamp]['value']
+                    json_topo_metrics_2[ linkTimestamp ][ 'value' ]
                 link_timestamp_3 = \
-                    json_topo_metrics_3[linkTimestamp]['value']
+                    json_topo_metrics_3[ linkTimestamp ][ 'value' ]
 
                 if graph_timestamp_1 and graph_timestamp_2 and\
                         graph_timestamp_3 and link_timestamp_1 and\
                         link_timestamp_2 and link_timestamp_3:
-                    link_down_lat_graph1 = int(graph_timestamp_1) -\
-                            int(timestamp_link_down_t0)
-                    link_down_lat_graph2 = int(graph_timestamp_2) -\
-                            int(timestamp_link_down_t0)
-                    link_down_lat_graph3 = int(graph_timestamp_3) -\
-                            int(timestamp_link_down_t0)
-                
-                    link_down_lat_link1 = int(link_timestamp_1) -\
-                            int(timestamp_link_down_t0)
-                    link_down_lat_link2 = int(link_timestamp_2) -\
-                            int(timestamp_link_down_t0)
-                    link_down_lat_link3 = int(link_timestamp_3) -\
-                            int(timestamp_link_down_t0)
+                    link_down_lat_graph1 = int( graph_timestamp_1 ) -\
+                        int( timestamp_link_down_t0 )
+                    link_down_lat_graph2 = int( graph_timestamp_2 ) -\
+                        int( timestamp_link_down_t0 )
+                    link_down_lat_graph3 = int( graph_timestamp_3 ) -\
+                        int( timestamp_link_down_t0 )
+
+                    link_down_lat_link1 = int( link_timestamp_1 ) -\
+                        int( timestamp_link_down_t0 )
+                    link_down_lat_link2 = int( link_timestamp_2 ) -\
+                        int( timestamp_link_down_t0 )
+                    link_down_lat_link3 = int( link_timestamp_3 ) -\
+                        int( timestamp_link_down_t0 )
                 else:
-                    main.log.error("There was an error calculating"+
-                        " the delta for link down event")
+                    main.log.error( "There was an error calculating" +
+                                    " the delta for link down event" )
                     link_down_lat_graph1 = 0
                     link_down_lat_graph2 = 0
                     link_down_lat_graph3 = 0
-                    
+
                     link_down_lat_device1 = 0
                     link_down_lat_device2 = 0
                     link_down_lat_device3 = 0
-        
-            main.log.info("Link down latency ONOS1 iteration "+
-                    str(i)+" (end-to-end): "+
-                    str(link_down_lat_graph1)+" ms")
-            main.log.info("Link down latency ONOS2 iteration "+
-                    str(i)+" (end-to-end): "+
-                    str(link_down_lat_graph2)+" ms")
-            main.log.info("Link down latency ONOS3 iteration "+
-                    str(i)+" (end-to-end): "+
-                    str(link_down_lat_graph3)+" ms")
-            
-            main.log.info("Link down latency ONOS1 iteration "+
-                    str(i)+" (link-event-to-system-timestamp): "+
-                    str(link_down_lat_link1)+" ms")
-            main.log.info("Link down latency ONOS2 iteration "+
-                    str(i)+" (link-event-to-system-timestamp): "+
-                    str(link_down_lat_link2)+" ms")
-            main.log.info("Link down latency ONOS3 iteration "+
-                    str(i)+" (link-event-to-system-timestamp): "+
-                    str(link_down_lat_link3))
-      
-            #Calculate avg of node calculations
-            link_down_lat_graph_avg =\
-                    (link_down_lat_graph1 +
-                     link_down_lat_graph2 +
-                     link_down_lat_graph3) / 3
-            link_down_lat_link_avg =\
-                    (link_down_lat_link1 +
-                     link_down_lat_link2 +
-                     link_down_lat_link3) / 3
 
-            #Set threshold and append latency to list
+            main.log.info( "Link down latency ONOS1 iteration " +
+                           str( i ) + " (end-to-end): " +
+                           str( link_down_lat_graph1 ) + " ms" )
+            main.log.info( "Link down latency ONOS2 iteration " +
+                           str( i ) + " (end-to-end): " +
+                           str( link_down_lat_graph2 ) + " ms" )
+            main.log.info( "Link down latency ONOS3 iteration " +
+                           str( i ) + " (end-to-end): " +
+                           str( link_down_lat_graph3 ) + " ms" )
+
+            main.log.info( "Link down latency ONOS1 iteration " +
+                           str( i ) + " (link-event-to-system-timestamp): " +
+                           str( link_down_lat_link1 ) + " ms" )
+            main.log.info( "Link down latency ONOS2 iteration " +
+                           str( i ) + " (link-event-to-system-timestamp): " +
+                           str( link_down_lat_link2 ) + " ms" )
+            main.log.info( "Link down latency ONOS3 iteration " +
+                           str( i ) + " (link-event-to-system-timestamp): " +
+                           str( link_down_lat_link3 ) )
+
+            # Calculate avg of node calculations
+            link_down_lat_graph_avg =\
+                ( link_down_lat_graph1 +
+                  link_down_lat_graph2 +
+                  link_down_lat_graph3 ) / 3
+            link_down_lat_link_avg =\
+                ( link_down_lat_link1 +
+                  link_down_lat_link2 +
+                  link_down_lat_link3 ) / 3
+
+            # Set threshold and append latency to list
             if link_down_lat_graph_avg > down_threshold_min and\
                link_down_lat_graph_avg < down_threshold_max:
                 link_down_graph_to_system_list.append(
-                        link_down_lat_graph_avg)
+                    link_down_lat_graph_avg )
             else:
-                main.log.info("Link down latency exceeded threshold")
-                main.log.info("Results for iteration "+str(i)+
-                        "have been omitted")
+                main.log.info( "Link down latency exceeded threshold" )
+                main.log.info( "Results for iteration " + str( i ) +
+                               "have been omitted" )
             if link_down_lat_link_avg > down_threshold_min and\
                link_down_lat_link_avg < down_threshold_max:
                 link_down_link_to_system_list.append(
-                        link_down_lat_link_avg)
+                    link_down_lat_link_avg )
             else:
-                main.log.info("Link down latency exceeded threshold")
-                main.log.info("Results for iteration "+str(i)+
-                        "have been omitted")
+                main.log.info( "Link down latency exceeded threshold" )
+                main.log.info( "Results for iteration " + str( i ) +
+                               "have been omitted" )
 
-            #NOTE: To remove loss rate and measure latency:
+            # NOTE: To remove loss rate and measure latency:
             #       'sh tc qdisc del dev s1-eth1 root'
             timestamp_link_up_t0 = time.time() * 1000
-            main.Mininet1.handle.sendline("sh tc qdisc del dev "+
-                    "s1-eth1 root")
-            main.Mininet1.handle.expect("mininet>")
-            
-            main.log.info("Checking ONOS for link update")
-            
+            main.Mininet1.handle.sendline( "sh tc qdisc del dev " +
+                                           "s1-eth1 root" )
+            main.Mininet1.handle.expect( "mininet>" )
+
+            main.log.info( "Checking ONOS for link update" )
+
             link_down1 = True
             link_down2 = True
             link_down3 = True
             loop_count = 0
-            while( (link_down1 and link_down2 and link_down3)\
+            while( ( link_down1 and link_down2 and link_down3 )
                     and loop_count < 30 ):
                 json_str1 = main.ONOS1cli.links()
                 json_str2 = main.ONOS2cli.links()
                 json_str3 = main.ONOS3cli.links()
-                if not (json_str1 and json_str2 and json_str3):
-                    main.log.error("CLI command returned error ")
+                if not ( json_str1 and json_str2 and json_str3 ):
+                    main.log.error( "CLI command returned error " )
                     break
                 else:
-                    json_obj1 = json.loads(json_str1)
-                    json_obj2 = json.loads(json_str2)
-                    json_obj3 = json.loads(json_str3)
-                
+                    json_obj1 = json.loads( json_str1 )
+                    json_obj2 = json.loads( json_str2 )
+                    json_obj3 = json.loads( json_str3 )
+
                 for obj1 in json_obj1:
-                    if '01' in obj1['src']['device']:
-                        link_down1 = False 
-                        main.log.info("Link up from "+
-                            "s1 -> s2 on ONOS1 detected")
+                    if '01' in obj1[ 'src' ][ 'device' ]:
+                        link_down1 = False
+                        main.log.info( "Link up from " +
+                                       "s1 -> s2 on ONOS1 detected" )
                 for obj2 in json_obj2:
-                    if '01' in obj2['src']['device']:
-                        link_down2 = False 
-                        main.log.info("Link up from "+
-                            "s1 -> s2 on ONOS2 detected")
+                    if '01' in obj2[ 'src' ][ 'device' ]:
+                        link_down2 = False
+                        main.log.info( "Link up from " +
+                                       "s1 -> s2 on ONOS2 detected" )
                 for obj3 in json_obj3:
-                    if '01' in obj3['src']['device']:
-                        link_down3 = False 
-                        main.log.info("Link up from "+
-                            "s1 -> s2 on ONOS3 detected")
-                
+                    if '01' in obj3[ 'src' ][ 'device' ]:
+                        link_down3 = False
+                        main.log.info( "Link up from " +
+                                       "s1 -> s2 on ONOS3 detected" )
+
                 loop_count += 1
-                time.sleep(1)
-            
-            if (link_down1 and link_down2 and link_down3):
-                main.log.info("Link up discovery failed")
-                
+                time.sleep( 1 )
+
+            if ( link_down1 and link_down2 and link_down3 ):
+                main.log.info( "Link up discovery failed" )
+
                 link_up_lat_graph1 = 0
                 link_up_lat_graph2 = 0
                 link_up_lat_graph3 = 0
                 link_up_lat_device1 = 0
                 link_up_lat_device2 = 0
                 link_up_lat_device3 = 0
-                
+
                 assertion = main.FALSE
             else:
                 json_topo_metrics_1 =\
-                        main.ONOS1cli.topology_events_metrics()
+                    main.ONOS1cli.topology_events_metrics()
                 json_topo_metrics_2 =\
-                        main.ONOS2cli.topology_events_metrics()
+                    main.ONOS2cli.topology_events_metrics()
                 json_topo_metrics_3 =\
-                        main.ONOS3cli.topology_events_metrics()
-                json_topo_metrics_1 = json.loads(json_topo_metrics_1)
-                json_topo_metrics_2 = json.loads(json_topo_metrics_2)
-                json_topo_metrics_3 = json.loads(json_topo_metrics_3)
+                    main.ONOS3cli.topology_events_metrics()
+                json_topo_metrics_1 = json.loads( json_topo_metrics_1 )
+                json_topo_metrics_2 = json.loads( json_topo_metrics_2 )
+                json_topo_metrics_3 = json.loads( json_topo_metrics_3 )
 
-                main.log.info("Obtaining graph and device timestamp")
+                main.log.info( "Obtaining graph and device timestamp" )
                 graph_timestamp_1 = \
-                    json_topo_metrics_1[graphTimestamp]['value']
+                    json_topo_metrics_1[ graphTimestamp ][ 'value' ]
                 graph_timestamp_2 = \
-                    json_topo_metrics_2[graphTimestamp]['value']
+                    json_topo_metrics_2[ graphTimestamp ][ 'value' ]
                 graph_timestamp_3 = \
-                    json_topo_metrics_3[graphTimestamp]['value']
+                    json_topo_metrics_3[ graphTimestamp ][ 'value' ]
 
                 link_timestamp_1 = \
-                    json_topo_metrics_1[linkTimestamp]['value']
+                    json_topo_metrics_1[ linkTimestamp ][ 'value' ]
                 link_timestamp_2 = \
-                    json_topo_metrics_2[linkTimestamp]['value']
+                    json_topo_metrics_2[ linkTimestamp ][ 'value' ]
                 link_timestamp_3 = \
-                    json_topo_metrics_3[linkTimestamp]['value']
+                    json_topo_metrics_3[ linkTimestamp ][ 'value' ]
 
                 if graph_timestamp_1 and graph_timestamp_2 and\
                         graph_timestamp_3 and link_timestamp_1 and\
                         link_timestamp_2 and link_timestamp_3:
-                    link_up_lat_graph1 = int(graph_timestamp_1) -\
-                            int(timestamp_link_up_t0)
-                    link_up_lat_graph2 = int(graph_timestamp_2) -\
-                            int(timestamp_link_up_t0)
-                    link_up_lat_graph3 = int(graph_timestamp_3) -\
-                            int(timestamp_link_up_t0)
-                
-                    link_up_lat_link1 = int(link_timestamp_1) -\
-                            int(timestamp_link_up_t0)
-                    link_up_lat_link2 = int(link_timestamp_2) -\
-                            int(timestamp_link_up_t0)
-                    link_up_lat_link3 = int(link_timestamp_3) -\
-                            int(timestamp_link_up_t0)
+                    link_up_lat_graph1 = int( graph_timestamp_1 ) -\
+                        int( timestamp_link_up_t0 )
+                    link_up_lat_graph2 = int( graph_timestamp_2 ) -\
+                        int( timestamp_link_up_t0 )
+                    link_up_lat_graph3 = int( graph_timestamp_3 ) -\
+                        int( timestamp_link_up_t0 )
+
+                    link_up_lat_link1 = int( link_timestamp_1 ) -\
+                        int( timestamp_link_up_t0 )
+                    link_up_lat_link2 = int( link_timestamp_2 ) -\
+                        int( timestamp_link_up_t0 )
+                    link_up_lat_link3 = int( link_timestamp_3 ) -\
+                        int( timestamp_link_up_t0 )
                 else:
-                    main.log.error("There was an error calculating"+
-                        " the delta for link down event")
+                    main.log.error( "There was an error calculating" +
+                                    " the delta for link down event" )
                     link_up_lat_graph1 = 0
                     link_up_lat_graph2 = 0
                     link_up_lat_graph3 = 0
-                    
+
                     link_up_lat_device1 = 0
                     link_up_lat_device2 = 0
                     link_up_lat_device3 = 0
-       
-            if debug_mode == 'on':
-                main.log.info("Link up latency ONOS1 iteration "+
-                    str(i)+" (end-to-end): "+
-                    str(link_up_lat_graph1)+" ms")
-                main.log.info("Link up latency ONOS2 iteration "+
-                    str(i)+" (end-to-end): "+
-                    str(link_up_lat_graph2)+" ms")
-                main.log.info("Link up latency ONOS3 iteration "+
-                    str(i)+" (end-to-end): "+
-                    str(link_up_lat_graph3)+" ms")
-            
-                main.log.info("Link up latency ONOS1 iteration "+
-                    str(i)+" (link-event-to-system-timestamp): "+
-                    str(link_up_lat_link1)+" ms")
-                main.log.info("Link up latency ONOS2 iteration "+
-                    str(i)+" (link-event-to-system-timestamp): "+
-                    str(link_up_lat_link2)+" ms")
-                main.log.info("Link up latency ONOS3 iteration "+
-                    str(i)+" (link-event-to-system-timestamp): "+
-                    str(link_up_lat_link3))
-      
-            #Calculate avg of node calculations
-            link_up_lat_graph_avg =\
-                    (link_up_lat_graph1 +
-                     link_up_lat_graph2 +
-                     link_up_lat_graph3) / 3
-            link_up_lat_link_avg =\
-                    (link_up_lat_link1 +
-                     link_up_lat_link2 +
-                     link_up_lat_link3) / 3
 
-            #Set threshold and append latency to list
+            if debug_mode == 'on':
+                main.log.info( "Link up latency ONOS1 iteration " +
+                               str( i ) + " (end-to-end): " +
+                               str( link_up_lat_graph1 ) + " ms" )
+                main.log.info( "Link up latency ONOS2 iteration " +
+                               str( i ) + " (end-to-end): " +
+                               str( link_up_lat_graph2 ) + " ms" )
+                main.log.info( "Link up latency ONOS3 iteration " +
+                               str( i ) + " (end-to-end): " +
+                               str( link_up_lat_graph3 ) + " ms" )
+
+                main.log.info(
+                    "Link up latency ONOS1 iteration " +
+                    str( i ) +
+                    " (link-event-to-system-timestamp): " +
+                    str( link_up_lat_link1 ) +
+                    " ms" )
+                main.log.info(
+                    "Link up latency ONOS2 iteration " +
+                    str( i ) +
+                    " (link-event-to-system-timestamp): " +
+                    str( link_up_lat_link2 ) +
+                    " ms" )
+                main.log.info(
+                    "Link up latency ONOS3 iteration " +
+                    str( i ) +
+                    " (link-event-to-system-timestamp): " +
+                    str( link_up_lat_link3 ) )
+
+            # Calculate avg of node calculations
+            link_up_lat_graph_avg =\
+                ( link_up_lat_graph1 +
+                  link_up_lat_graph2 +
+                  link_up_lat_graph3 ) / 3
+            link_up_lat_link_avg =\
+                ( link_up_lat_link1 +
+                  link_up_lat_link2 +
+                  link_up_lat_link3 ) / 3
+
+            # Set threshold and append latency to list
             if link_up_lat_graph_avg > up_threshold_min and\
                link_up_lat_graph_avg < up_threshold_max:
                 link_up_graph_to_system_list.append(
-                        link_up_lat_graph_avg)
+                    link_up_lat_graph_avg )
             else:
-                main.log.info("Link up latency exceeded threshold")
-                main.log.info("Results for iteration "+str(i)+
-                        "have been omitted")
+                main.log.info( "Link up latency exceeded threshold" )
+                main.log.info( "Results for iteration " + str( i ) +
+                               "have been omitted" )
             if link_up_lat_link_avg > up_threshold_min and\
                link_up_lat_link_avg < up_threshold_max:
                 link_up_link_to_system_list.append(
-                        link_up_lat_link_avg)
+                    link_up_lat_link_avg )
             else:
-                main.log.info("Link up latency exceeded threshold")
-                main.log.info("Results for iteration "+str(i)+
-                        "have been omitted")
+                main.log.info( "Link up latency exceeded threshold" )
+                main.log.info( "Results for iteration " + str( i ) +
+                               "have been omitted" )
 
-        #Calculate min, max, avg of list and report
-        link_down_min = min(link_down_graph_to_system_list)
-        link_down_max = max(link_down_graph_to_system_list)
-        link_down_avg = sum(link_down_graph_to_system_list) / \
-                        len(link_down_graph_to_system_list)
-        link_up_min = min(link_up_graph_to_system_list)
-        link_up_max = max(link_up_graph_to_system_list)
-        link_up_avg = sum(link_up_graph_to_system_list) / \
-                        len(link_up_graph_to_system_list)
+        # Calculate min, max, avg of list and report
+        link_down_min = min( link_down_graph_to_system_list )
+        link_down_max = max( link_down_graph_to_system_list )
+        link_down_avg = sum( link_down_graph_to_system_list ) / \
+            len( link_down_graph_to_system_list )
+        link_up_min = min( link_up_graph_to_system_list )
+        link_up_max = max( link_up_graph_to_system_list )
+        link_up_avg = sum( link_up_graph_to_system_list ) / \
+            len( link_up_graph_to_system_list )
         link_down_std_dev = \
-                str(round(numpy.std(link_down_graph_to_system_list),1))
+            str( round( numpy.std( link_down_graph_to_system_list ), 1 ) )
         link_up_std_dev = \
-                str(round(numpy.std(link_up_graph_to_system_list),1))
+            str( round( numpy.std( link_up_graph_to_system_list ), 1 ) )
 
-        main.log.report("Link down latency " +
-                "Avg: "+str(link_down_avg)+" ms "+
-                "Std Deviation: "+link_down_std_dev+" ms")
-        main.log.report("Link up latency "+
-                "Avg: "+str(link_up_avg)+" ms "+
-                "Std Deviation: "+link_up_std_dev+" ms")
+        main.log.report( "Link down latency " +
+                         "Avg: " + str( link_down_avg ) + " ms " +
+                         "Std Deviation: " + link_down_std_dev + " ms" )
+        main.log.report( "Link up latency " +
+                         "Avg: " + str( link_up_avg ) + " ms " +
+                         "Std Deviation: " + link_up_std_dev + " ms" )
 
-        utilities.assert_equals(expect=main.TRUE, actual=assertion,
-                onpass="Link discovery latency calculation successful",
-                onfail="Link discovery latency case failed")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=assertion,
+            onpass="Link discovery latency calculation successful",
+            onfail="Link discovery latency case failed" )
 
-    def CASE5(self, main):
-        '''
+    def CASE5( self, main ):
+        """
         100 Switch discovery latency
 
         Important:
-            This test case can be potentially dangerous if 
+            This test case can be potentially dangerous if
             your machine has previously set iptables rules.
             One of the steps of the test case will flush
             all existing iptables rules.
         Note:
-            You can specify the number of switches in the 
+            You can specify the number of switches in the
             params file to adjust the switch discovery size
-            (and specify the corresponding topology in Mininet1 
-            .topo file)
-        '''
+            ( and specify the corresponding topology in Mininet1
+            .topo file )
+        """
         import time
         import subprocess
         import os
         import requests
         import json
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS2_ip = main.params['CTRL']['ip2']
-        ONOS3_ip = main.params['CTRL']['ip3']
-        MN1_ip = main.params['MN']['ip1']
-        ONOS_user = main.params['CTRL']['user']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+        ONOS_user = main.params[ 'CTRL' ][ 'user' ]
 
-        default_sw_port = main.params['CTRL']['port1']
-       
-        #Number of iterations of case
-        num_iter = main.params['TEST']['numIter']
-        num_sw = main.params['TEST']['numSwitch']
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
 
-        #Timestamp 'keys' for json metrics output.
-        #These are subject to change, hence moved into params
-        deviceTimestamp = main.params['JSON']['deviceTimestamp']
-        graphTimestamp = main.params['JSON']['graphTimestamp']
-        
-        debug_mode = main.params['TEST']['debugMode']
+        # Number of iterations of case
+        num_iter = main.params[ 'TEST' ][ 'numIter' ]
+        num_sw = main.params[ 'TEST' ][ 'numSwitch' ]
 
-        local_time = time.strftime('%X')
-        local_time = local_time.replace("/","")
-        local_time = local_time.replace(" ","_")
-        local_time = local_time.replace(":","")
+        # Timestamp 'keys' for json metrics output.
+        # These are subject to change, hence moved into params
+        deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+        graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+        debug_mode = main.params[ 'TEST' ][ 'debugMode' ]
+
+        local_time = time.strftime( '%X' )
+        local_time = local_time.replace( "/", "" )
+        local_time = local_time.replace( " ", "_" )
+        local_time = local_time.replace( ":", "" )
         if debug_mode == 'on':
-            main.ONOS1.tshark_pcap("eth0",
-                    "/tmp/100_sw_lat_pcap_"+local_time) 
- 
-        #Threshold for this test case
-        sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold']
-        sw_disc_threshold_obj = sw_disc_threshold_str.split(",")
-        sw_disc_threshold_min = int(sw_disc_threshold_obj[0])
-        sw_disc_threshold_max = int(sw_disc_threshold_obj[1])
+            main.ONOS1.tshark_pcap( "eth0",
+                                    "/tmp/100_sw_lat_pcap_" + local_time )
 
-        tshark_ofp_output = "/tmp/tshark_ofp_"+num_sw+"sw.txt"
-        tshark_tcp_output = "/tmp/tshark_tcp_"+num_sw+"sw.txt"
+        # Threshold for this test case
+        sw_disc_threshold_str = main.params[ 'TEST' ][ 'swDisc100Threshold' ]
+        sw_disc_threshold_obj = sw_disc_threshold_str.split( "," )
+        sw_disc_threshold_min = int( sw_disc_threshold_obj[ 0 ] )
+        sw_disc_threshold_max = int( sw_disc_threshold_obj[ 1 ] )
+
+        tshark_ofp_output = "/tmp/tshark_ofp_" + num_sw + "sw.txt"
+        tshark_tcp_output = "/tmp/tshark_tcp_" + num_sw + "sw.txt"
 
         tshark_ofp_result_list = []
         tshark_tcp_result_list = []
 
         sw_discovery_lat_list = []
 
-        main.case(num_sw+" Switch discovery latency")
-        main.step("Assigning all switches to ONOS1")
-        for i in range(1, int(num_sw)+1):
+        main.case( num_sw + " Switch discovery latency" )
+        main.step( "Assigning all switches to ONOS1" )
+        for i in range( 1, int( num_sw ) + 1 ):
             main.Mininet1.assign_sw_controller(
-                    sw=str(i),
-                    ip1=ONOS1_ip,
-                    port1=default_sw_port)
-        
-        #Ensure that nodes are configured with ptpd
-        #Just a warning message
-        main.log.info("Please check ptpd configuration to ensure"+\
-                " All nodes' system times are in sync")
-        time.sleep(5)
+                sw=str( i ),
+                ip1=ONOS1_ip,
+                port1=default_sw_port )
 
-        for i in range(0, int(num_iter)):
-            
-            main.step("Set iptables rule to block incoming sw connections")
-            #Set iptables rule to block incoming switch connections
-            #The rule description is as follows:
+        # Ensure that nodes are configured with ptpd
+        # Just a warning message
+        main.log.info( "Please check ptpd configuration to ensure" +
+                       " All nodes' system times are in sync" )
+        time.sleep( 5 )
+
+        for i in range( 0, int( num_iter ) ):
+
+            main.step( "Set iptables rule to block incoming sw connections" )
+            # Set iptables rule to block incoming switch connections
+            # The rule description is as follows:
             #   Append to INPUT rule,
             #   behavior DROP that matches following:
             #       * packet type: tcp
             #       * source IP: MN1_ip
             #       * destination PORT: 6633
             main.ONOS1.handle.sendline(
-                    "sudo iptables -A INPUT -p tcp -s "+MN1_ip+
-                    " --dport "+default_sw_port+" -j DROP")
-            main.ONOS1.handle.expect("\$") 
-            #   Append to OUTPUT rule, 
+                "sudo iptables -A INPUT -p tcp -s " + MN1_ip +
+                " --dport " + default_sw_port + " -j DROP" )
+            main.ONOS1.handle.expect( "\$" )
+            #   Append to OUTPUT rule,
             #   behavior DROP that matches following:
             #       * packet type: tcp
             #       * source IP: MN1_ip
             #       * destination PORT: 6633
             main.ONOS1.handle.sendline(
-                    "sudo iptables -A OUTPUT -p tcp -s "+MN1_ip+
-                    " --dport "+default_sw_port+" -j DROP")
-            main.ONOS1.handle.expect("\$")
-            #Give time to allow rule to take effect
-            #NOTE: Sleep period may need to be configured 
+                "sudo iptables -A OUTPUT -p tcp -s " + MN1_ip +
+                " --dport " + default_sw_port + " -j DROP" )
+            main.ONOS1.handle.expect( "\$" )
+            # Give time to allow rule to take effect
+            # NOTE: Sleep period may need to be configured
             #      based on the number of switches in the topology
-            main.log.info("Please wait for switch connection to "+
-                    "time out")
-            time.sleep(60)
-            
-            #Gather vendor OFP with tshark
-            main.ONOS1.tshark_grep("OFP 86 Vendor", 
-                    tshark_ofp_output)
-            main.ONOS1.tshark_grep("TCP 74 ",
-                    tshark_tcp_output)
+            main.log.info( "Please wait for switch connection to " +
+                           "time out" )
+            time.sleep( 60 )
 
-            #NOTE: Remove all iptables rule quickly (flush)
-            #      Before removal, obtain TestON timestamp at which 
+            # Gather vendor OFP with tshark
+            main.ONOS1.tshark_grep( "OFP 86 Vendor",
+                                    tshark_ofp_output )
+            main.ONOS1.tshark_grep( "TCP 74 ",
+                                    tshark_tcp_output )
+
+            # NOTE: Remove all iptables rule quickly ( flush )
+            #      Before removal, obtain TestON timestamp at which
             #      removal took place
-            #      (ensuring nodes are configured via ptp)
+            #      ( ensuring nodes are configured via ptp )
             #      sudo iptables -F
-            
+
             t0_system = time.time() * 1000
             main.ONOS1.handle.sendline(
-                    "sudo iptables -F")
+                "sudo iptables -F" )
 
-            #Counter to track loop count
+            # Counter to track loop count
             counter_loop = 0
             counter_avail1 = 0
             counter_avail2 = 0
@@ -1490,126 +1550,124 @@
             onos2_dev = False
             onos3_dev = False
             while counter_loop < 60:
-                #Continue to check devices for all device 
-                #availability. When all devices in all 3
-                #ONOS instances indicate that devices are available
-                #obtain graph event timestamp for t1.
+                # Continue to check devices for all device
+                # availability. When all devices in all 3
+                # ONOS instances indicate that devices are available
+                # obtain graph event timestamp for t1.
                 device_str_obj1 = main.ONOS1cli.devices()
                 device_str_obj2 = main.ONOS2cli.devices()
                 device_str_obj3 = main.ONOS3cli.devices()
 
-                device_json1 = json.loads(device_str_obj1)                
-                device_json2 = json.loads(device_str_obj2)                
-                device_json3 = json.loads(device_str_obj3)           
-                
+                device_json1 = json.loads( device_str_obj1 )
+                device_json2 = json.loads( device_str_obj2 )
+                device_json3 = json.loads( device_str_obj3 )
+
                 for device1 in device_json1:
-                    if device1['available'] == True:
+                    if device1[ 'available' ]:
                         counter_avail1 += 1
-                        if counter_avail1 == int(num_sw):
+                        if counter_avail1 == int( num_sw ):
                             onos1_dev = True
-                            main.log.info("All devices have been "+
-                                    "discovered on ONOS1")
+                            main.log.info( "All devices have been " +
+                                           "discovered on ONOS1" )
                     else:
                         counter_avail1 = 0
                 for device2 in device_json2:
-                    if device2['available'] == True:
+                    if device2[ 'available' ]:
                         counter_avail2 += 1
-                        if counter_avail2 == int(num_sw):
+                        if counter_avail2 == int( num_sw ):
                             onos2_dev = True
-                            main.log.info("All devices have been "+
-                                    "discovered on ONOS2")
+                            main.log.info( "All devices have been " +
+                                           "discovered on ONOS2" )
                     else:
                         counter_avail2 = 0
                 for device3 in device_json3:
-                    if device3['available'] == True:
+                    if device3[ 'available' ]:
                         counter_avail3 += 1
-                        if counter_avail3 == int(num_sw):
+                        if counter_avail3 == int( num_sw ):
                             onos3_dev = True
-                            main.log.info("All devices have been "+
-                                    "discovered on ONOS3")
+                            main.log.info( "All devices have been " +
+                                           "discovered on ONOS3" )
                     else:
                         counter_avail3 = 0
 
                 if onos1_dev and onos2_dev and onos3_dev:
-                    main.log.info("All devices have been discovered "+
-                            "on all ONOS instances")
+                    main.log.info( "All devices have been discovered " +
+                                   "on all ONOS instances" )
                     json_str_topology_metrics_1 =\
                         main.ONOS1cli.topology_events_metrics()
                     json_str_topology_metrics_2 =\
                         main.ONOS2cli.topology_events_metrics()
                     json_str_topology_metrics_3 =\
                         main.ONOS3cli.topology_events_metrics()
-                   
-                    #Exit while loop if all devices discovered
-                    break 
-                
+
+                    # Exit while loop if all devices discovered
+                    break
+
                 counter_loop += 1
-                #Give some time in between CLI calls
-                #(will not affect measurement)
-                time.sleep(3)
+                # Give some time in between CLI calls
+                #( will not affect measurement )
+                time.sleep( 3 )
 
             main.ONOS1.tshark_stop()
-            
-            os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
-                    tshark_ofp_output+" /tmp/") 
-            os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
-                    tshark_tcp_output+" /tmp/")
 
-            #TODO: Automate OFP output analysis
-            #Debug mode - print out packets captured at runtime     
-            if debug_mode == 'on': 
-                ofp_file = open(tshark_ofp_output, 'r')
-                main.log.info("Tshark OFP Vendor output: ")
+            os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+                       tshark_ofp_output + " /tmp/" )
+            os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+                       tshark_tcp_output + " /tmp/" )
+
+            # TODO: Automate OFP output analysis
+            # Debug mode - print out packets captured at runtime
+            if debug_mode == 'on':
+                ofp_file = open( tshark_ofp_output, 'r' )
+                main.log.info( "Tshark OFP Vendor output: " )
                 for line in ofp_file:
-                    tshark_ofp_result_list.append(line)
-                    main.log.info(line)
+                    tshark_ofp_result_list.append( line )
+                    main.log.info( line )
                 ofp_file.close()
 
-                tcp_file = open(tshark_tcp_output, 'r')
-                main.log.info("Tshark TCP 74 output: ")
+                tcp_file = open( tshark_tcp_output, 'r' )
+                main.log.info( "Tshark TCP 74 output: " )
                 for line in tcp_file:
-                    tshark_tcp_result_list.append(line)
-                    main.log.info(line)
+                    tshark_tcp_result_list.append( line )
+                    main.log.info( line )
                 tcp_file.close()
 
-            json_obj_1 = json.loads(json_str_topology_metrics_1)
-            json_obj_2 = json.loads(json_str_topology_metrics_2)
-            json_obj_3 = json.loads(json_str_topology_metrics_3)
+            json_obj_1 = json.loads( json_str_topology_metrics_1 )
+            json_obj_2 = json.loads( json_str_topology_metrics_2 )
+            json_obj_3 = json.loads( json_str_topology_metrics_3 )
 
             graph_timestamp_1 = \
-                    json_obj_1[graphTimestamp]['value']
+                json_obj_1[ graphTimestamp ][ 'value' ]
             graph_timestamp_2 = \
-                    json_obj_2[graphTimestamp]['value']
+                json_obj_2[ graphTimestamp ][ 'value' ]
             graph_timestamp_3 = \
-                    json_obj_3[graphTimestamp]['value']
+                json_obj_3[ graphTimestamp ][ 'value' ]
 
-            graph_lat_1 = int(graph_timestamp_1) - int(t0_system)
-            graph_lat_2 = int(graph_timestamp_2) - int(t0_system)
-            graph_lat_3 = int(graph_timestamp_3) - int(t0_system)
+            graph_lat_1 = int( graph_timestamp_1 ) - int( t0_system )
+            graph_lat_2 = int( graph_timestamp_2 ) - int( t0_system )
+            graph_lat_3 = int( graph_timestamp_3 ) - int( t0_system )
 
             avg_graph_lat = \
-                    (int(graph_lat_1) +\
-                     int(graph_lat_2) +\
-                     int(graph_lat_3)) / 3
-    
+                ( int( graph_lat_1 ) +
+                  int( graph_lat_2 ) +
+                  int( graph_lat_3 ) ) / 3
+
             if avg_graph_lat > sw_disc_threshold_min \
                     and avg_graph_lat < sw_disc_threshold_max:
                 sw_discovery_lat_list.append(
-                        avg_graph_lat)
+                    avg_graph_lat )
             else:
-                main.log.info("100 Switch discovery latency "+
-                        "exceeded the threshold.")
-            
-            #END ITERATION FOR LOOP
+                main.log.info( "100 Switch discovery latency " +
+                               "exceeded the threshold." )
 
-        sw_lat_min = min(sw_discovery_lat_list)
-        sw_lat_max = max(sw_discovery_lat_list)
-        sw_lat_avg = sum(sw_discovery_lat_list) /\
-                     len(sw_discovery_lat_list)
+            # END ITERATION FOR LOOP
 
-        main.log.report("100 Switch discovery lat "+\
-                "Min: "+str(sw_lat_min)+" ms"+\
-                "Max: "+str(sw_lat_max)+" ms"+\
-                "Avg: "+str(sw_lat_avg)+" ms")
+        sw_lat_min = min( sw_discovery_lat_list )
+        sw_lat_max = max( sw_discovery_lat_list )
+        sw_lat_avg = sum( sw_discovery_lat_list ) /\
+            len( sw_discovery_lat_list )
 
-
+        main.log.report( "100 Switch discovery lat " +
+                         "Min: " + str( sw_lat_min ) + " ms" +
+                         "Max: " + str( sw_lat_max ) + " ms" +
+                         "Avg: " + str( sw_lat_avg ) + " ms" )
diff --git a/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.py b/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.py
index d10c0ee..e81d905 100644
--- a/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.py
+++ b/TestON/tests/TopoPerfNextSingleNode/TopoPerfNextSingleNode.py
@@ -1,1108 +1,1113 @@
-#TopoPerfNext
+# TopoPerfNext
 #
-#Topology Performance test for ONOS-next
+# Topology Performance test for ONOS-next
 #*** Revised for single node operation ***
 #
-#andrew@onlab.us
+# andrew@onlab.us
 
 import time
 import sys
 import os
 import re
 
+
 class TopoPerfNextSingleNode:
-    def __init__(self):
+
+    def __init__( self ):
         self.default = ''
 
-    def CASE1(self, main):
-        '''
+    def CASE1( self, main ):
+        """
         ONOS startup sequence
-        '''
+        """
         import time
-    
-        cell_name = main.params['ENV']['cellName']
 
-        git_pull = main.params['GIT']['autoPull']
-        checkout_branch = main.params['GIT']['checkout']
+        cell_name = main.params[ 'ENV' ][ 'cellName' ]
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        MN1_ip = main.params['MN']['ip1']
-        BENCH_ip = main.params['BENCH']['ip']
+        git_pull = main.params[ 'GIT' ][ 'autoPull' ]
+        checkout_branch = main.params[ 'GIT' ][ 'checkout' ]
 
-        main.case("Setting up test environment")
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+        BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
 
-        main.step("Creating cell file")
+        main.case( "Setting up test environment" )
+
+        main.step( "Creating cell file" )
         cell_file_result = main.ONOSbench.create_cell_file(
-                BENCH_ip, cell_name, MN1_ip, "onos-core",
-                ONOS1_ip)
+            BENCH_ip, cell_name, MN1_ip, "onos-core",
+            ONOS1_ip )
 
-        main.step("Applying cell file to environment")
-        cell_apply_result = main.ONOSbench.set_cell(cell_name)
+        main.step( "Applying cell file to environment" )
+        cell_apply_result = main.ONOSbench.set_cell( cell_name )
         verify_cell_result = main.ONOSbench.verify_cell()
-        
-        main.step("Git checkout and pull "+checkout_branch)
+
+        main.step( "Git checkout and pull " + checkout_branch )
         if git_pull == 'on':
             checkout_result = \
-                    main.ONOSbench.git_checkout(checkout_branch)
+                main.ONOSbench.git_checkout( checkout_branch )
             pull_result = main.ONOSbench.git_pull()
         else:
             checkout_result = main.TRUE
             pull_result = main.TRUE
-            main.log.info("Skipped git checkout and pull")
+            main.log.info( "Skipped git checkout and pull" )
 
-        main.step("Using mvn clean & install")
+        main.step( "Using mvn clean & install" )
         #mvn_result = main.ONOSbench.clean_install()
         mvn_result = main.TRUE
 
-        main.step("Creating ONOS package")
+        main.step( "Creating ONOS package" )
         package_result = main.ONOSbench.onos_package()
 
-        main.step("Installing ONOS package")
-        install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
+        main.step( "Installing ONOS package" )
+        install1_result = main.ONOSbench.onos_install( node=ONOS1_ip )
 
-        #NOTE: This step may be unnecessary
-        #main.step("Starting ONOS service")
-        #start_result = main.ONOSbench.onos_start(ONOS1_ip)
+        # NOTE: This step may be unnecessary
+        #main.step( "Starting ONOS service" )
+        #start_result = main.ONOSbench.onos_start( ONOS1_ip )
 
-        main.step("Set cell for ONOS cli env")
-        main.ONOS1cli.set_cell(cell_name)
+        main.step( "Set cell for ONOS cli env" )
+        main.ONOS1cli.set_cell( cell_name )
 
-        time.sleep(10)
+        time.sleep( 10 )
 
-        main.step("Start onos cli")
-        cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
+        main.step( "Start onos cli" )
+        cli1 = main.ONOS1cli.start_onos_cli( ONOS1_ip )
 
-        main.step("Enable metrics feature")
-        main.ONOS1cli.feature_install("onos-app-metrics")
+        main.step( "Enable metrics feature" )
+        main.ONOS1cli.feature_install( "onos-app-metrics" )
 
-        utilities.assert_equals(expect=main.TRUE,
-                actual= cell_file_result and cell_apply_result and\
-                        verify_cell_result and checkout_result and\
-                        pull_result and mvn_result and\
-                        install1_result, 
-                onpass="ONOS started successfully",
-                onfail="Failed to start ONOS")
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=cell_file_result and cell_apply_result and
+                                 verify_cell_result and checkout_result and
+                                 pull_result and mvn_result and
+                                 install1_result,
+                                 onpass="ONOS started successfully",
+                                 onfail="Failed to start ONOS" )
 
-    def CASE2(self, main):
-        '''
+    def CASE2( self, main ):
+        """
         Assign s1 to ONOS1 and measure latency
-        
+
         There are 4 levels of latency measurements to this test:
-        1) End-to-end measurement: Complete end-to-end measurement
-           from TCP (SYN/ACK) handshake to Graph change
-        2) OFP-to-graph measurement: 'ONOS processing' snippet of
+        1 ) End-to-end measurement: Complete end-to-end measurement
+           from TCP ( SYN/ACK ) handshake to Graph change
+        2 ) OFP-to-graph measurement: 'ONOS processing' snippet of
            measurement from OFP Vendor message to Graph change
-        3) OFP-to-device measurement: 'ONOS processing without 
+        3 ) OFP-to-device measurement: 'ONOS processing without
            graph change' snippet of measurement from OFP vendor
            message to Device change timestamp
-        4) T0-to-device measurement: Measurement that includes
-           the switch handshake to devices timestamp without 
-           the graph view change. (TCP handshake -> Device 
-           change)
-        '''
+        4 ) T0-to-device measurement: Measurement that includes
+           the switch handshake to devices timestamp without
+           the graph view change. ( TCP handshake -> Device
+           change )
+        """
         import time
         import subprocess
         import json
         import requests
         import os
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS_user = main.params['CTRL']['user']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS_user = main.params[ 'CTRL' ][ 'user' ]
 
-        default_sw_port = main.params['CTRL']['port1']
-       
-        #Number of iterations of case
-        num_iter = main.params['TEST']['numIter']
-       
-        #Timestamp 'keys' for json metrics output.
-        #These are subject to change, hence moved into params
-        deviceTimestamp = main.params['JSON']['deviceTimestamp']
-        graphTimestamp = main.params['JSON']['graphTimestamp']
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
 
-        #List of switch add latency collected from
-        #all iterations
+        # Number of iterations of case
+        num_iter = main.params[ 'TEST' ][ 'numIter' ]
+
+        # Timestamp 'keys' for json metrics output.
+        # These are subject to change, hence moved into params
+        deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+        graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+        # List of switch add latency collected from
+        # all iterations
         latency_end_to_end_list = []
         latency_ofp_to_graph_list = []
         latency_ofp_to_device_list = []
         latency_t0_to_device_list = []
 
-        #Directory/file to store tshark results
+        # Directory/file to store tshark results
         tshark_of_output = "/tmp/tshark_of_topo.txt"
         tshark_tcp_output = "/tmp/tshark_tcp_topo.txt"
 
-        #String to grep in tshark output
-        tshark_tcp_string = "TCP 74 "+default_sw_port
+        # String to grep in tshark output
+        tshark_tcp_string = "TCP 74 " + default_sw_port
         tshark_of_string = "OFP 86 Vendor"
-     
-        #Initialize assertion to TRUE
+
+        # Initialize assertion to TRUE
         assertion = main.TRUE
-        
-        main.log.report("Latency of adding one switch")
 
-        for i in range(0, int(num_iter)):
-            main.log.info("Starting tshark capture")
+        main.log.report( "Latency of adding one switch" )
 
-            #* TCP [ACK, SYN] is used as t0_a, the
-            #  very first "exchange" between ONOS and 
+        for i in range( 0, int( num_iter ) ):
+            main.log.info( "Starting tshark capture" )
+
+            #* TCP [ ACK, SYN ] is used as t0_a, the
+            #  very first "exchange" between ONOS and
             #  the switch for end-to-end measurement
-            #* OFP [Stats Reply] is used for t0_b
+            #* OFP [ Stats Reply ] is used for t0_b
             #  the very last OFP message between ONOS
             #  and the switch for ONOS measurement
-            main.ONOS1.tshark_grep(tshark_tcp_string,
-                    tshark_tcp_output)
-            main.ONOS1.tshark_grep(tshark_of_string,
-                    tshark_of_output)
+            main.ONOS1.tshark_grep( tshark_tcp_string,
+                                    tshark_tcp_output )
+            main.ONOS1.tshark_grep( tshark_of_string,
+                                    tshark_of_output )
 
-            #Wait and ensure tshark is started and 
-            #capturing
-            time.sleep(10)
+            # Wait and ensure tshark is started and
+            # capturing
+            time.sleep( 10 )
 
-            main.log.info("Assigning s1 to controller")
+            main.log.info( "Assigning s1 to controller" )
 
-            main.Mininet1.assign_sw_controller(sw="1",
-                    ip1=ONOS1_ip, port1=default_sw_port)
+            main.Mininet1.assign_sw_controller(
+                sw="1",
+                ip1=ONOS1_ip,
+                port1=default_sw_port )
 
-            #Wait and ensure switch is assigned
-            #before stopping tshark
-            time.sleep(30)
-   
-            main.log.info("Stopping all Tshark processes")
+            # Wait and ensure switch is assigned
+            # before stopping tshark
+            time.sleep( 30 )
+
+            main.log.info( "Stopping all Tshark processes" )
             main.ONOS1.stop_tshark()
 
-            #tshark output is saved in ONOS. Use subprocess
-            #to copy over files to TestON for parsing
-            main.log.info("Copying over tshark files")
-            
-            #TCP CAPTURE ****
-            #Copy the tshark output from ONOS machine to
-            #TestON machine in tshark_tcp_output directory>file
-            os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
-                    tshark_tcp_output+" /tmp/") 
-            tcp_file = open(tshark_tcp_output, 'r')
-            temp_text = tcp_file.readline()
-            temp_text = temp_text.split(" ")
+            # tshark output is saved in ONOS. Use subprocess
+            # to copy over files to TestON for parsing
+            main.log.info( "Copying over tshark files" )
 
-            main.log.info("Object read in from TCP capture: "+
-                    str(temp_text))
-            if len(temp_text) > 1:
-                t0_tcp = float(temp_text[1])*1000.0
+            # TCP CAPTURE ****
+            # Copy the tshark output from ONOS machine to
+            # TestON machine in tshark_tcp_output directory>file
+            os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+                       tshark_tcp_output + " /tmp/" )
+            tcp_file = open( tshark_tcp_output, 'r' )
+            temp_text = tcp_file.readline()
+            temp_text = temp_text.split( " " )
+
+            main.log.info( "Object read in from TCP capture: " +
+                           str( temp_text ) )
+            if len( temp_text ) > 1:
+                t0_tcp = float( temp_text[ 1 ] ) * 1000.0
             else:
-                main.log.error("Tshark output file for TCP"+
-                        " returned unexpected results")
+                main.log.error( "Tshark output file for TCP" +
+                                " returned unexpected results" )
                 t0_tcp = 0
                 assertion = main.FALSE
-            
+
             tcp_file.close()
             #****************
 
-            #OF CAPTURE ****
-            os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
-                    tshark_of_output+" /tmp/")
-            of_file = open(tshark_of_output, 'r')
-           
+            # OF CAPTURE ****
+            os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+                       tshark_of_output + " /tmp/" )
+            of_file = open( tshark_of_output, 'r' )
+
             line_ofp = ""
-            #Read until last line of file
+            # Read until last line of file
             while True:
                 temp_text = of_file.readline()
-                if temp_text !='':
+                if temp_text != '':
                     line_ofp = temp_text
                 else:
-                    break 
-            obj = line_ofp.split(" ")
-            
-            main.log.info("Object read in from OFP capture: "+
-                    str(line_ofp))
-    
-            if len(line_ofp) > 1:
-                t0_ofp = float(obj[1])*1000.0
+                    break
+            obj = line_ofp.split( " " )
+
+            main.log.info( "Object read in from OFP capture: " +
+                           str( line_ofp ) )
+
+            if len( line_ofp ) > 1:
+                t0_ofp = float( obj[ 1 ] ) * 1000.0
             else:
-                main.log.error("Tshark output file for OFP"+
-                        " returned unexpected results")
+                main.log.error( "Tshark output file for OFP" +
+                                " returned unexpected results" )
                 t0_ofp = 0
                 assertion = main.FALSE
-            
+
             of_file.close()
             #****************
-           
+
             json_str_1 = main.ONOS1cli.topology_events_metrics()
 
-            json_obj_1 = json.loads(json_str_1)
+            json_obj_1 = json.loads( json_str_1 )
 
-            #Obtain graph timestamp. This timestsamp captures
-            #the epoch time at which the topology graph was updated.
+            # Obtain graph timestamp. This timestsamp captures
+            # the epoch time at which the topology graph was updated.
             graph_timestamp_1 = \
-                    json_obj_1[graphTimestamp]['value']
+                json_obj_1[ graphTimestamp ][ 'value' ]
 
-            #Obtain device timestamp. This timestamp captures
-            #the epoch time at which the device event happened
+            # Obtain device timestamp. This timestamp captures
+            # the epoch time at which the device event happened
             device_timestamp_1 = \
-                    json_obj_1[deviceTimestamp]['value'] 
-            
-            #t0 to device processing latency 
-            delta_device_1 = int(device_timestamp_1) - int(t0_tcp)
-        
-            #Get average of delta from all instances
-            avg_delta_device = (int(delta_device_1))
+                json_obj_1[ deviceTimestamp ][ 'value' ]
 
-            #Ensure avg delta meets the threshold before appending
+            # t0 to device processing latency
+            delta_device_1 = int( device_timestamp_1 ) - int( t0_tcp )
+
+            # Get average of delta from all instances
+            avg_delta_device = ( int( delta_device_1 ) )
+
+            # Ensure avg delta meets the threshold before appending
             if avg_delta_device > 0.0 and avg_delta_device < 10000:
-                latency_t0_to_device_list.append(avg_delta_device)
+                latency_t0_to_device_list.append( avg_delta_device )
             else:
-                main.log.info("Results for t0-to-device ignored"+\
-                        "due to excess in threshold")
+                main.log.info( "Results for t0-to-device ignored" +
+                               "due to excess in threshold" )
 
-            #t0 to graph processing latency (end-to-end)
-            delta_graph_1 = int(graph_timestamp_1) - int(t0_tcp)
-        
-            #Get average of delta from all instances
-            avg_delta_graph = int(delta_graph_1)
+            # t0 to graph processing latency ( end-to-end )
+            delta_graph_1 = int( graph_timestamp_1 ) - int( t0_tcp )
 
-            #Ensure avg delta meets the threshold before appending
+            # Get average of delta from all instances
+            avg_delta_graph = int( delta_graph_1 )
+
+            # Ensure avg delta meets the threshold before appending
             if avg_delta_graph > 0.0 and avg_delta_graph < 10000:
-                latency_end_to_end_list.append(avg_delta_graph)
+                latency_end_to_end_list.append( avg_delta_graph )
             else:
-                main.log.info("Results for end-to-end ignored"+\
-                        "due to excess in threshold")
+                main.log.info( "Results for end-to-end ignored" +
+                               "due to excess in threshold" )
 
-            #ofp to graph processing latency (ONOS processing)
-            delta_ofp_graph_1 = int(graph_timestamp_1) - int(t0_ofp)
-            
-            avg_delta_ofp_graph = int(delta_ofp_graph_1)
-            
+            # ofp to graph processing latency ( ONOS processing )
+            delta_ofp_graph_1 = int( graph_timestamp_1 ) - int( t0_ofp )
+
+            avg_delta_ofp_graph = int( delta_ofp_graph_1 )
+
             if avg_delta_ofp_graph > 0.0 and avg_delta_ofp_graph < 10000:
-                latency_ofp_to_graph_list.append(avg_delta_ofp_graph)
+                latency_ofp_to_graph_list.append( avg_delta_ofp_graph )
             else:
-                main.log.info("Results for ofp-to-graph "+\
-                        "ignored due to excess in threshold")
+                main.log.info( "Results for ofp-to-graph " +
+                               "ignored due to excess in threshold" )
 
-            #ofp to device processing latency (ONOS processing)
-            delta_ofp_device_1 = float(device_timestamp_1) - float(t0_ofp)
-            
-            avg_delta_ofp_device = float(delta_ofp_device_1)
-            
-            #NOTE: ofp - delta measurements are occasionally negative
+            # ofp to device processing latency ( ONOS processing )
+            delta_ofp_device_1 = float( device_timestamp_1 ) - float( t0_ofp )
+
+            avg_delta_ofp_device = float( delta_ofp_device_1 )
+
+            # NOTE: ofp - delta measurements are occasionally negative
             #      due to system time misalignment.
-            latency_ofp_to_device_list.append(avg_delta_ofp_device)
+            latency_ofp_to_device_list.append( avg_delta_ofp_device )
 
-            #TODO:
-            #Fetch logs upon threshold excess
+            # TODO:
+            # Fetch logs upon threshold excess
 
-            main.log.info("ONOS1 delta end-to-end: "+
-                    str(delta_graph_1) + " ms")
+            main.log.info( "ONOS1 delta end-to-end: " +
+                           str( delta_graph_1 ) + " ms" )
 
-            main.log.info("ONOS1 delta OFP - graph: "+
-                    str(delta_ofp_graph_1) + " ms")
-            
-            main.log.info("ONOS1 delta device - t0: "+
-                    str(delta_device_1) + " ms")
-          
-            main.step("Remove switch from controller")
-            main.Mininet1.delete_sw_controller("s1")
+            main.log.info( "ONOS1 delta OFP - graph: " +
+                           str( delta_ofp_graph_1 ) + " ms" )
 
-            time.sleep(5)
+            main.log.info( "ONOS1 delta device - t0: " +
+                           str( delta_device_1 ) + " ms" )
 
-        #END of for loop iteration
+            main.step( "Remove switch from controller" )
+            main.Mininet1.delete_sw_controller( "s1" )
 
-        #If there is at least 1 element in each list,
-        #pass the test case
-        if len(latency_end_to_end_list) > 0 and\
-           len(latency_ofp_to_graph_list) > 0 and\
-           len(latency_ofp_to_device_list) > 0 and\
-           len(latency_t0_to_device_list) > 0:
+            time.sleep( 5 )
+
+        # END of for loop iteration
+
+        # If there is at least 1 element in each list,
+        # pass the test case
+        if len( latency_end_to_end_list ) > 0 and\
+           len( latency_ofp_to_graph_list ) > 0 and\
+           len( latency_ofp_to_device_list ) > 0 and\
+           len( latency_t0_to_device_list ) > 0:
             assertion = main.TRUE
-        elif len(latency_end_to_end_list) == 0:
-            #The appending of 0 here is to prevent 
-            #the min,max,sum functions from failing 
-            #below
-            latency_end_to_end_list.append(0)
+        elif len( latency_end_to_end_list ) == 0:
+            # The appending of 0 here is to prevent
+            # the min,max,sum functions from failing
+            # below
+            latency_end_to_end_list.append( 0 )
             assertion = main.FALSE
-        elif len(latency_ofp_to_graph_list) == 0:
-            latency_ofp_to_graph_list.append(0)
+        elif len( latency_ofp_to_graph_list ) == 0:
+            latency_ofp_to_graph_list.append( 0 )
             assertion = main.FALSE
-        elif len(latency_ofp_to_device_list) == 0:
-            latency_ofp_to_device_list.append(0)
+        elif len( latency_ofp_to_device_list ) == 0:
+            latency_ofp_to_device_list.append( 0 )
             assertion = main.FALSE
-        elif len(latency_t0_to_device_list) == 0:
-            latency_t0_to_device_list.append(0)
+        elif len( latency_t0_to_device_list ) == 0:
+            latency_t0_to_device_list.append( 0 )
             assertion = main.FALSE
 
-        #Calculate min, max, avg of latency lists
+        # Calculate min, max, avg of latency lists
         latency_end_to_end_max = \
-                int(max(latency_end_to_end_list))
+            int( max( latency_end_to_end_list ) )
         latency_end_to_end_min = \
-                int(min(latency_end_to_end_list))
+            int( min( latency_end_to_end_list ) )
         latency_end_to_end_avg = \
-                (int(sum(latency_end_to_end_list)) / \
-                 len(latency_end_to_end_list))
-   
+            ( int( sum( latency_end_to_end_list ) ) /
+              len( latency_end_to_end_list ) )
+
         latency_ofp_to_graph_max = \
-                int(max(latency_ofp_to_graph_list))
+            int( max( latency_ofp_to_graph_list ) )
         latency_ofp_to_graph_min = \
-                int(min(latency_ofp_to_graph_list))
+            int( min( latency_ofp_to_graph_list ) )
         latency_ofp_to_graph_avg = \
-                (int(sum(latency_ofp_to_graph_list)) / \
-                 len(latency_ofp_to_graph_list))
+            ( int( sum( latency_ofp_to_graph_list ) ) /
+              len( latency_ofp_to_graph_list ) )
 
         latency_ofp_to_device_max = \
-                int(max(latency_ofp_to_device_list))
+            int( max( latency_ofp_to_device_list ) )
         latency_ofp_to_device_min = \
-                int(min(latency_ofp_to_device_list))
+            int( min( latency_ofp_to_device_list ) )
         latency_ofp_to_device_avg = \
-                (int(sum(latency_ofp_to_device_list)) / \
-                 len(latency_ofp_to_device_list))
+            ( int( sum( latency_ofp_to_device_list ) ) /
+              len( latency_ofp_to_device_list ) )
 
         latency_t0_to_device_max = \
-                float(max(latency_t0_to_device_list))
+            float( max( latency_t0_to_device_list ) )
         latency_t0_to_device_min = \
-                float(min(latency_t0_to_device_list))
+            float( min( latency_t0_to_device_list ) )
         latency_t0_to_device_avg = \
-                (float(sum(latency_t0_to_device_list)) / \
-                 len(latency_ofp_to_device_list))
+            ( float( sum( latency_t0_to_device_list ) ) /
+              len( latency_ofp_to_device_list ) )
 
-        main.log.report("Switch add - End-to-end latency: \n"+\
-                "Min: "+str(latency_end_to_end_min)+"\n"+\
-                "Max: "+str(latency_end_to_end_max)+"\n"+\
-                "Avg: "+str(latency_end_to_end_avg))
-        main.log.report("Switch add - OFP-to-Graph latency: \n"+\
-                "Min: "+str(latency_ofp_to_graph_min)+"\n"+\
-                "Max: "+str(latency_ofp_to_graph_max)+"\n"+\
-                "Avg: "+str(latency_ofp_to_graph_avg))
-        main.log.report("Switch add - t0-to-Device latency: \n"+\
-                "Min: "+str(latency_t0_to_device_min)+"\n"+\
-                "Max: "+str(latency_t0_to_device_max)+"\n"+\
-                "Avg: "+str(latency_t0_to_device_avg))
+        main.log.report( "Switch add - End-to-end latency: \n" +
+                         "Min: " + str( latency_end_to_end_min ) + "\n" +
+                         "Max: " + str( latency_end_to_end_max ) + "\n" +
+                         "Avg: " + str( latency_end_to_end_avg ) )
+        main.log.report( "Switch add - OFP-to-Graph latency: \n" +
+                         "Min: " + str( latency_ofp_to_graph_min ) + "\n" +
+                         "Max: " + str( latency_ofp_to_graph_max ) + "\n" +
+                         "Avg: " + str( latency_ofp_to_graph_avg ) )
+        main.log.report( "Switch add - t0-to-Device latency: \n" +
+                         "Min: " + str( latency_t0_to_device_min ) + "\n" +
+                         "Max: " + str( latency_t0_to_device_max ) + "\n" +
+                         "Avg: " + str( latency_t0_to_device_avg ) )
 
-        utilities.assert_equals(expect=main.TRUE, actual=assertion,
-                onpass="Switch latency test successful",
-                onfail="Switch latency test failed")
+        utilities.assert_equals( expect=main.TRUE, actual=assertion,
+                                 onpass="Switch latency test successful",
+                                 onfail="Switch latency test failed" )
 
-    def CASE3(self, main):
-        '''
+    def CASE3( self, main ):
+        """
         Bring port up / down and measure latency.
         Port enable / disable is simulated by ifconfig up / down
-        
-        In ONOS-next, we must ensure that the port we are 
+
+        In ONOS-next, we must ensure that the port we are
         manipulating is connected to another switch with a valid
         connection. Otherwise, graph view will not be updated.
-        '''
+        """
         import time
         import subprocess
         import os
         import requests
         import json
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS_user = main.params['CTRL']['user']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS_user = main.params[ 'CTRL' ][ 'user' ]
 
-        default_sw_port = main.params['CTRL']['port1']
-      
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
+
         assertion = main.TRUE
-        #Number of iterations of case
-        num_iter = main.params['TEST']['numIter']
-       
-        #Timestamp 'keys' for json metrics output.
-        #These are subject to change, hence moved into params
-        deviceTimestamp = main.params['JSON']['deviceTimestamp']
-        graphTimestamp = main.params['JSON']['graphTimestamp']
+        # Number of iterations of case
+        num_iter = main.params[ 'TEST' ][ 'numIter' ]
 
-        #NOTE: Some hardcoded variables you may need to configure
+        # Timestamp 'keys' for json metrics output.
+        # These are subject to change, hence moved into params
+        deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+        graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+        # NOTE: Some hardcoded variables you may need to configure
         #      besides the params
-            
+
         tshark_port_status = "OFP 130 Port Status"
 
         tshark_port_up = "/tmp/tshark_port_up.txt"
         tshark_port_down = "/tmp/tshark_port_down.txt"
         interface_config = "s1-eth1"
 
-        main.log.report("Port enable / disable latency")
+        main.log.report( "Port enable / disable latency" )
 
-        main.step("Assign switches s1 and s2 to controller 1")
-        main.Mininet1.assign_sw_controller(sw="1",ip1=ONOS1_ip,
-                port1=default_sw_port)
-        main.Mininet1.assign_sw_controller(sw="2",ip1=ONOS1_ip,
-                port1=default_sw_port)
+        main.step( "Assign switches s1 and s2 to controller 1" )
+        main.Mininet1.assign_sw_controller( sw="1", ip1=ONOS1_ip,
+                                            port1=default_sw_port )
+        main.Mininet1.assign_sw_controller( sw="2", ip1=ONOS1_ip,
+                                            port1=default_sw_port )
 
-        #Give enough time for metrics to propagate the 
-        #assign controller event. Otherwise, these events may
-        #carry over to our measurements
-        time.sleep(10)
+        # Give enough time for metrics to propagate the
+        # assign controller event. Otherwise, these events may
+        # carry over to our measurements
+        time.sleep( 10 )
 
-        main.step("Verify switch is assigned correctly")
-        result_s1 = main.Mininet1.get_sw_controller(sw="s1")
-        result_s2 = main.Mininet1.get_sw_controller(sw="s2")
+        main.step( "Verify switch is assigned correctly" )
+        result_s1 = main.Mininet1.get_sw_controller( sw="s1" )
+        result_s2 = main.Mininet1.get_sw_controller( sw="s2" )
         if result_s1 == main.FALSE or result_s2 == main.FALSE:
-            main.log.info("Switch s1 was not assigned correctly")
+            main.log.info( "Switch s1 was not assigned correctly" )
             assertion = main.FALSE
         else:
-            main.log.info("Switch s1 was assigned correctly")
+            main.log.info( "Switch s1 was assigned correctly" )
 
         port_up_device_to_ofp_list = []
         port_up_graph_to_ofp_list = []
         port_down_device_to_ofp_list = []
         port_down_graph_to_ofp_list = []
 
-        for i in range(0, int(num_iter)):
-            main.step("Starting wireshark capture for port status down")
-            main.ONOS1.tshark_grep(tshark_port_status,
-                    tshark_port_down)
-            
-            time.sleep(10)
+        for i in range( 0, int( num_iter ) ):
+            main.step( "Starting wireshark capture for port status down" )
+            main.ONOS1.tshark_grep( tshark_port_status,
+                                    tshark_port_down )
 
-            #Disable interface that is connected to switch 2
-            main.step("Disable port: "+interface_config)
-            main.Mininet2.handle.sendline("sudo ifconfig "+
-                    interface_config+" down")
-            main.Mininet2.handle.expect("\$")
-            time.sleep(10)
+            time.sleep( 10 )
+
+            # Disable interface that is connected to switch 2
+            main.step( "Disable port: " + interface_config )
+            main.Mininet2.handle.sendline( "sudo ifconfig " +
+                                           interface_config + " down" )
+            main.Mininet2.handle.expect( "\$" )
+            time.sleep( 10 )
 
             main.ONOS1.tshark_stop()
-            time.sleep(5)
-            
-            #Copy tshark output file from ONOS to TestON instance
-            #/tmp directory
-            os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
-                    tshark_port_down+" /tmp/")
+            time.sleep( 5 )
 
-            f_port_down = open(tshark_port_down, 'r')
-            #Get first line of port down event from tshark
+            # Copy tshark output file from ONOS to TestON instance
+            #/tmp directory
+            os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+                       tshark_port_down + " /tmp/" )
+
+            f_port_down = open( tshark_port_down, 'r' )
+            # Get first line of port down event from tshark
             f_line = f_port_down.readline()
-            obj_down = f_line.split(" ")
-            if len(f_line) > 0:
-                timestamp_begin_pt_down = int(float(obj_down[1]))*1000
-                main.log.info("Port down begin timestamp: "+
-                        str(timestamp_begin_pt_down))
+            obj_down = f_line.split( " " )
+            if len( f_line ) > 0:
+                timestamp_begin_pt_down = int( float( obj_down[ 1 ] ) ) * 1000
+                main.log.info( "Port down begin timestamp: " +
+                               str( timestamp_begin_pt_down ) )
             else:
-                main.log.info("Tshark output file returned unexpected"+
-                        " results: "+str(obj_down))
+                main.log.info( "Tshark output file returned unexpected" +
+                               " results: " + str( obj_down ) )
                 timestamp_begin_pt_down = 0
-            
+
             f_port_down.close()
 
-            main.log.info("TEST tshark obj: "+str(obj_down))
+            main.log.info( "TEST tshark obj: " + str( obj_down ) )
 
-            main.step("Obtain t1 by REST call")
+            main.step( "Obtain t1 by REST call" )
             json_str_1 = main.ONOS1cli.topology_events_metrics()
 
-            main.log.info("TEST json_str 1: "+str(json_str_1))
+            main.log.info( "TEST json_str 1: " + str( json_str_1 ) )
 
-            json_obj_1 = json.loads(json_str_1)
-           
-            time.sleep(5)
+            json_obj_1 = json.loads( json_str_1 )
 
-            #Obtain graph timestamp. This timestsamp captures
-            #the epoch time at which the topology graph was updated.
+            time.sleep( 5 )
+
+            # Obtain graph timestamp. This timestsamp captures
+            # the epoch time at which the topology graph was updated.
             graph_timestamp_1 = \
-                    json_obj_1[graphTimestamp]['value']
+                json_obj_1[ graphTimestamp ][ 'value' ]
 
-            #Obtain device timestamp. This timestamp captures
-            #the epoch time at which the device event happened
+            # Obtain device timestamp. This timestamp captures
+            # the epoch time at which the device event happened
             device_timestamp_1 = \
-                    json_obj_1[deviceTimestamp]['value'] 
+                json_obj_1[ deviceTimestamp ][ 'value' ]
 
-            #Get delta between graph event and OFP 
-            pt_down_graph_to_ofp_1 = int(graph_timestamp_1) -\
-                    int(timestamp_begin_pt_down)
+            # Get delta between graph event and OFP
+            pt_down_graph_to_ofp_1 = int( graph_timestamp_1 ) -\
+                int( timestamp_begin_pt_down )
 
-            #Get delta between device event and OFP
-            pt_down_device_to_ofp_1 = int(device_timestamp_1) -\
-                    int(timestamp_begin_pt_down)
-       
-            #Caluclate average across clusters
-            pt_down_graph_to_ofp_avg = int(pt_down_graph_to_ofp_1)
-            pt_down_device_to_ofp_avg = int(pt_down_device_to_ofp_1) 
+            # Get delta between device event and OFP
+            pt_down_device_to_ofp_1 = int( device_timestamp_1 ) -\
+                int( timestamp_begin_pt_down )
+
+            # Caluclate average across clusters
+            pt_down_graph_to_ofp_avg = int( pt_down_graph_to_ofp_1 )
+            pt_down_device_to_ofp_avg = int( pt_down_device_to_ofp_1 )
 
             if pt_down_graph_to_ofp_avg > 0.0 and \
                     pt_down_graph_to_ofp_avg < 1000:
                 port_down_graph_to_ofp_list.append(
-                    pt_down_graph_to_ofp_avg)
-                main.log.info("Port down: graph to ofp avg: "+
-                    str(pt_down_graph_to_ofp_avg) + " ms")
+                    pt_down_graph_to_ofp_avg )
+                main.log.info( "Port down: graph to ofp avg: " +
+                               str( pt_down_graph_to_ofp_avg ) + " ms" )
             else:
-                main.log.info("Average port down graph-to-ofp result" +
-                        " exceeded the threshold: "+
-                        str(pt_down_graph_to_ofp_avg))
+                main.log.info( "Average port down graph-to-ofp result" +
+                               " exceeded the threshold: " +
+                               str( pt_down_graph_to_ofp_avg ) )
 
             if pt_down_device_to_ofp_avg > 0 and \
                     pt_down_device_to_ofp_avg < 1000:
                 port_down_device_to_ofp_list.append(
-                    pt_down_device_to_ofp_avg)
-                main.log.info("Port down: device to ofp avg: "+
-                    str(pt_down_device_to_ofp_avg) + " ms")
+                    pt_down_device_to_ofp_avg )
+                main.log.info( "Port down: device to ofp avg: " +
+                               str( pt_down_device_to_ofp_avg ) + " ms" )
             else:
-                main.log.info("Average port down device-to-ofp result" +
-                        " exceeded the threshold: "+
-                        str(pt_down_device_to_ofp_avg))
+                main.log.info( "Average port down device-to-ofp result" +
+                               " exceeded the threshold: " +
+                               str( pt_down_device_to_ofp_avg ) )
 
-            #Port up events 
-            main.step("Enable port and obtain timestamp")
-            main.step("Starting wireshark capture for port status up")
-            main.ONOS1.tshark_grep("OFP 130 Port Status", tshark_port_up)
-            time.sleep(5)
+            # Port up events
+            main.step( "Enable port and obtain timestamp" )
+            main.step( "Starting wireshark capture for port status up" )
+            main.ONOS1.tshark_grep( "OFP 130 Port Status", tshark_port_up )
+            time.sleep( 5 )
 
-            main.Mininet2.handle.sendline("sudo ifconfig "+
-                    interface_config+" up")
-            main.Mininet2.handle.expect("\$")
-            time.sleep(10)
-            
+            main.Mininet2.handle.sendline( "sudo ifconfig " +
+                                           interface_config + " up" )
+            main.Mininet2.handle.expect( "\$" )
+            time.sleep( 10 )
+
             main.ONOS1.tshark_stop()
 
-            os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
-                    tshark_port_up+" /tmp/")
+            os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+                       tshark_port_up + " /tmp/" )
 
-            f_port_up = open(tshark_port_up, 'r')
+            f_port_up = open( tshark_port_up, 'r' )
             f_line = f_port_up.readline()
-            obj_up = f_line.split(" ")
-            if len(f_line) > 0:
-                timestamp_begin_pt_up = int(float(obj_up[1]))*1000
-                main.log.info("Port up begin timestamp: "+
-                        str(timestamp_begin_pt_up))
+            obj_up = f_line.split( " " )
+            if len( f_line ) > 0:
+                timestamp_begin_pt_up = int( float( obj_up[ 1 ] ) ) * 1000
+                main.log.info( "Port up begin timestamp: " +
+                               str( timestamp_begin_pt_up ) )
             else:
-                main.log.info("Tshark output file returned unexpected"+
-                        " results.")
+                main.log.info( "Tshark output file returned unexpected" +
+                               " results." )
                 timestamp_begin_pt_up = 0
-            
+
             f_port_up.close()
 
-            main.step("Obtain t1 by REST call")
+            main.step( "Obtain t1 by REST call" )
             json_str_1 = main.ONOS1cli.topology_events_metrics()
 
-            json_obj_1 = json.loads(json_str_1)
+            json_obj_1 = json.loads( json_str_1 )
 
-            #Obtain graph timestamp. This timestsamp captures
-            #the epoch time at which the topology graph was updated.
+            # Obtain graph timestamp. This timestsamp captures
+            # the epoch time at which the topology graph was updated.
             graph_timestamp_1 = \
-                    json_obj_1[graphTimestamp]['value']
+                json_obj_1[ graphTimestamp ][ 'value' ]
 
-            #Obtain device timestamp. This timestamp captures
-            #the epoch time at which the device event happened
+            # Obtain device timestamp. This timestamp captures
+            # the epoch time at which the device event happened
             device_timestamp_1 = \
-                    json_obj_1[deviceTimestamp]['value'] 
-            
-            #Get delta between graph event and OFP 
-            pt_up_graph_to_ofp_1 = int(graph_timestamp_1) -\
-                    int(timestamp_begin_pt_up)
+                json_obj_1[ deviceTimestamp ][ 'value' ]
 
-            #Get delta between device event and OFP
-            pt_up_device_to_ofp_1 = int(device_timestamp_1) -\
-                    int(timestamp_begin_pt_up)
+            # Get delta between graph event and OFP
+            pt_up_graph_to_ofp_1 = int( graph_timestamp_1 ) -\
+                int( timestamp_begin_pt_up )
 
-            pt_up_graph_to_ofp_avg = float(pt_up_graph_to_ofp_1) 
+            # Get delta between device event and OFP
+            pt_up_device_to_ofp_1 = int( device_timestamp_1 ) -\
+                int( timestamp_begin_pt_up )
 
-            pt_up_device_to_ofp_avg = float(pt_up_device_to_ofp_1) 
+            pt_up_graph_to_ofp_avg = float( pt_up_graph_to_ofp_1 )
+
+            pt_up_device_to_ofp_avg = float( pt_up_device_to_ofp_1 )
 
             if pt_up_graph_to_ofp_avg > 0 and \
                     pt_up_graph_to_ofp_avg < 1000:
                 port_up_graph_to_ofp_list.append(
-                        pt_up_graph_to_ofp_avg)
-                main.log.info("Port down: graph to ofp avg: "+
-                    str(pt_up_graph_to_ofp_avg) + " ms")
+                    pt_up_graph_to_ofp_avg )
+                main.log.info( "Port down: graph to ofp avg: " +
+                               str( pt_up_graph_to_ofp_avg ) + " ms" )
             else:
-                main.log.info("Average port up graph-to-ofp result"+
-                        " exceeded the threshold: "+
-                        str(pt_up_graph_to_ofp_avg))
-            
+                main.log.info( "Average port up graph-to-ofp result" +
+                               " exceeded the threshold: " +
+                               str( pt_up_graph_to_ofp_avg ) )
+
             if pt_up_device_to_ofp_avg > 0 and \
                     pt_up_device_to_ofp_avg < 1000:
                 port_up_device_to_ofp_list.append(
-                        pt_up_device_to_ofp_avg)
-                main.log.info("Port up: device to ofp avg: "+
-                    str(pt_up_device_to_ofp_avg) + " ms")
+                    pt_up_device_to_ofp_avg )
+                main.log.info( "Port up: device to ofp avg: " +
+                               str( pt_up_device_to_ofp_avg ) + " ms" )
             else:
-                main.log.info("Average port up device-to-ofp result"+
-                        " exceeded the threshold: "+
-                        str(pt_up_device_to_ofp_avg))
-            
-            #END ITERATION FOR LOOP
-        
-        #Check all list for latency existence and set assertion
-        if (port_down_graph_to_ofp_list and port_down_device_to_ofp_list\
-           and port_up_graph_to_ofp_list and port_up_device_to_ofp_list):
+                main.log.info( "Average port up device-to-ofp result" +
+                               " exceeded the threshold: " +
+                               str( pt_up_device_to_ofp_avg ) )
+
+            # END ITERATION FOR LOOP
+
+        # Check all list for latency existence and set assertion
+        if ( port_down_graph_to_ofp_list and port_down_device_to_ofp_list
+                and port_up_graph_to_ofp_list and port_up_device_to_ofp_list ):
             assertion = main.TRUE
 
-        #Calculate and report latency measurements
-        port_down_graph_to_ofp_min = min(port_down_graph_to_ofp_list)
-        port_down_graph_to_ofp_max = max(port_down_graph_to_ofp_list)
+        # Calculate and report latency measurements
+        port_down_graph_to_ofp_min = min( port_down_graph_to_ofp_list )
+        port_down_graph_to_ofp_max = max( port_down_graph_to_ofp_list )
         port_down_graph_to_ofp_avg = \
-                (sum(port_down_graph_to_ofp_list) / 
-                 len(port_down_graph_to_ofp_list))
-        
-        main.log.report("Port down graph-to-ofp Min: "+
-                str(port_down_graph_to_ofp_min)+" ms  Max: "+
-                str(port_down_graph_to_ofp_max)+" ms  Avg: "+
-                str(port_down_graph_to_ofp_avg))
-        
-        port_down_device_to_ofp_min = min(port_down_device_to_ofp_list)
-        port_down_device_to_ofp_max = max(port_down_device_to_ofp_list)
+            ( sum( port_down_graph_to_ofp_list ) /
+              len( port_down_graph_to_ofp_list ) )
+
+        main.log.report( "Port down graph-to-ofp Min: " +
+                         str( port_down_graph_to_ofp_min ) + " ms  Max: " +
+                         str( port_down_graph_to_ofp_max ) + " ms  Avg: " +
+                         str( port_down_graph_to_ofp_avg ) )
+
+        port_down_device_to_ofp_min = min( port_down_device_to_ofp_list )
+        port_down_device_to_ofp_max = max( port_down_device_to_ofp_list )
         port_down_device_to_ofp_avg = \
-                (sum(port_down_device_to_ofp_list) /\
-                 len(port_down_device_to_ofp_list))
-        
-        main.log.report("Port down device-to-ofp Min: "+
-                str(port_down_device_to_ofp_min)+" ms  Max: "+
-                str(port_down_device_to_ofp_max)+" ms  Avg: "+
-                str(port_down_device_to_ofp_avg))
-        
-        port_up_graph_to_ofp_min = min(port_up_graph_to_ofp_list)
-        port_up_graph_to_ofp_max = max(port_up_graph_to_ofp_list)
+            ( sum( port_down_device_to_ofp_list ) /
+              len( port_down_device_to_ofp_list ) )
+
+        main.log.report( "Port down device-to-ofp Min: " +
+                         str( port_down_device_to_ofp_min ) + " ms  Max: " +
+                         str( port_down_device_to_ofp_max ) + " ms  Avg: " +
+                         str( port_down_device_to_ofp_avg ) )
+
+        port_up_graph_to_ofp_min = min( port_up_graph_to_ofp_list )
+        port_up_graph_to_ofp_max = max( port_up_graph_to_ofp_list )
         port_up_graph_to_ofp_avg = \
-                (sum(port_up_graph_to_ofp_list) /\
-                 len(port_up_graph_to_ofp_list))
-        
-        main.log.report("Port up graph-to-ofp Min: "+
-                str(port_up_graph_to_ofp_min)+" ms  Max: "+
-                str(port_up_graph_to_ofp_max)+" ms  Avg: "+
-                str(port_up_graph_to_ofp_avg))
-          
-        port_up_device_to_ofp_min = min(port_up_device_to_ofp_list)
-        port_up_device_to_ofp_max = max(port_up_device_to_ofp_list)
+            ( sum( port_up_graph_to_ofp_list ) /
+              len( port_up_graph_to_ofp_list ) )
+
+        main.log.report( "Port up graph-to-ofp Min: " +
+                         str( port_up_graph_to_ofp_min ) + " ms  Max: " +
+                         str( port_up_graph_to_ofp_max ) + " ms  Avg: " +
+                         str( port_up_graph_to_ofp_avg ) )
+
+        port_up_device_to_ofp_min = min( port_up_device_to_ofp_list )
+        port_up_device_to_ofp_max = max( port_up_device_to_ofp_list )
         port_up_device_to_ofp_avg = \
-                (sum(port_up_device_to_ofp_list) /\
-                 len(port_up_device_to_ofp_list))
-        
-        main.log.report("Port up device-to-ofp Min: "+
-                str(port_up_device_to_ofp_min)+" ms  Max: "+
-                str(port_up_device_to_ofp_max)+" ms  Avg: "+
-                str(port_up_device_to_ofp_avg))
+            ( sum( port_up_device_to_ofp_list ) /
+              len( port_up_device_to_ofp_list ) )
 
-        utilities.assert_equals(expect=main.TRUE, actual=assertion,
-                onpass="Port discovery latency calculation successful",
-                onfail="Port discovery test failed")
+        main.log.report( "Port up device-to-ofp Min: " +
+                         str( port_up_device_to_ofp_min ) + " ms  Max: " +
+                         str( port_up_device_to_ofp_max ) + " ms  Avg: " +
+                         str( port_up_device_to_ofp_avg ) )
 
-    def CASE4(self, main):
-        '''
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=assertion,
+            onpass="Port discovery latency calculation successful",
+            onfail="Port discovery test failed" )
+
+    def CASE4( self, main ):
+        """
         Link down event using loss rate 100%
-        
+
         Important:
             Use a simple 2 switch topology with 1 link between
-            the two switches. Ensure that mac addresses of the 
+            the two switches. Ensure that mac addresses of the
             switches are 1 / 2 respectively
-        '''
+        """
         import time
         import subprocess
         import os
         import requests
         import json
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        ONOS_user = main.params['CTRL']['user']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        ONOS_user = main.params[ 'CTRL' ][ 'user' ]
 
-        default_sw_port = main.params['CTRL']['port1']
-       
-        #Number of iterations of case
-        num_iter = main.params['TEST']['numIter']
-       
-        #Timestamp 'keys' for json metrics output.
-        #These are subject to change, hence moved into params
-        deviceTimestamp = main.params['JSON']['deviceTimestamp']
-        linkTimestamp = main.params['JSON']['linkTimestamp'] 
-        graphTimestamp = main.params['JSON']['graphTimestamp']
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
+
+        # Number of iterations of case
+        num_iter = main.params[ 'TEST' ][ 'numIter' ]
+
+        # Timestamp 'keys' for json metrics output.
+        # These are subject to change, hence moved into params
+        deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+        linkTimestamp = main.params[ 'JSON' ][ 'linkTimestamp' ]
+        graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
 
         assertion = main.TRUE
-        #Link event timestamp to system time list
+        # Link event timestamp to system time list
         link_down_link_to_system_list = []
         link_up_link_to_system_list = []
-        #Graph event timestamp to system time list
+        # Graph event timestamp to system time list
         link_down_graph_to_system_list = []
-        link_up_graph_to_system_list = [] 
+        link_up_graph_to_system_list = []
 
-        main.log.report("Add / remove link latency between "+
-                "two switches")
+        main.log.report( "Add / remove link latency between " +
+                         "two switches" )
 
-        main.step("Assign all switches")
-        main.Mininet1.assign_sw_controller(sw="1",
-                ip1=ONOS1_ip, port1=default_sw_port)
-        main.Mininet1.assign_sw_controller(sw="2",
-                ip1=ONOS1_ip, port1=default_sw_port)
+        main.step( "Assign all switches" )
+        main.Mininet1.assign_sw_controller(
+            sw="1",
+            ip1=ONOS1_ip,
+            port1=default_sw_port )
+        main.Mininet1.assign_sw_controller(
+            sw="2",
+            ip1=ONOS1_ip,
+            port1=default_sw_port )
 
-        main.step("Verifying switch assignment")
-        result_s1 = main.Mininet1.get_sw_controller(sw="s1")
-        result_s2 = main.Mininet1.get_sw_controller(sw="s2")
-          
-        #Allow time for events to finish before taking measurements
-        time.sleep(10)
+        main.step( "Verifying switch assignment" )
+        result_s1 = main.Mininet1.get_sw_controller( sw="s1" )
+        result_s2 = main.Mininet1.get_sw_controller( sw="s2" )
+
+        # Allow time for events to finish before taking measurements
+        time.sleep( 10 )
 
         link_down = False
-        #Start iteration of link event test
-        for i in range(0, int(num_iter)):
-            main.step("Getting initial system time as t0")
-            
-            timestamp_link_down_t0 = time.time() * 1000
-            #Link down is simulated by 100% loss rate using traffic 
-            #control command
-            main.Mininet1.handle.sendline(
-                    "sh tc qdisc add dev s1-eth1 root netem loss 100%")
+        # Start iteration of link event test
+        for i in range( 0, int( num_iter ) ):
+            main.step( "Getting initial system time as t0" )
 
-            #TODO: Iterate through 'links' command to verify that
-            #      link s1 -> s2 went down (loop timeout 30 seconds) 
+            timestamp_link_down_t0 = time.time() * 1000
+            # Link down is simulated by 100% loss rate using traffic
+            # control command
+            main.Mininet1.handle.sendline(
+                "sh tc qdisc add dev s1-eth1 root netem loss 100%" )
+
+            # TODO: Iterate through 'links' command to verify that
+            #      link s1 -> s2 went down ( loop timeout 30 seconds )
             #      on all 3 ONOS instances
-            main.log.info("Checking ONOS for link update")
+            main.log.info( "Checking ONOS for link update" )
             loop_count = 0
             while( not link_down and loop_count < 30 ):
                 json_str = main.ONOS1cli.links()
-                
+
                 if not json_str:
-                    main.log.error("CLI command returned error ")
+                    main.log.error( "CLI command returned error " )
                     break
                 else:
-                    json_obj = json.loads(json_str)
+                    json_obj = json.loads( json_str )
                 for obj in json_obj:
-                    if '01' not in obj['src']['device']:
+                    if '01' not in obj[ 'src' ][ 'device' ]:
                         link_down = True
-                        main.log.report("Link down from "+
-                                "s1 -> s2 on ONOS1 detected")
+                        main.log.report( "Link down from " +
+                                         "s1 -> s2 on ONOS1 detected" )
                 loop_count += 1
-                #If CLI doesn't like the continuous requests
-                #and exits in this loop, increase the sleep here.
-                #Consequently, while loop timeout will increase
-                time.sleep(1)
-    
-            #Give time for metrics measurement to catch up
-            #NOTE: May need to be configured more accurately
-            time.sleep(10)
-            #If we exited the while loop and link down 1,2,3 are still 
-            #false, then ONOS has failed to discover link down event
+                # If CLI doesn't like the continuous requests
+                # and exits in this loop, increase the sleep here.
+                # Consequently, while loop timeout will increase
+                time.sleep( 1 )
+
+            # Give time for metrics measurement to catch up
+            # NOTE: May need to be configured more accurately
+            time.sleep( 10 )
+            # If we exited the while loop and link down 1,2,3 are still
+            # false, then ONOS has failed to discover link down event
             if not link_down:
-                main.log.info("Link down discovery failed")
-                
+                main.log.info( "Link down discovery failed" )
+
                 link_down_lat_graph1 = 0
                 link_down_lat_device1 = 0
                 assertion = main.FALSE
             else:
                 json_topo_metrics_1 =\
-                        main.ONOS1cli.topology_events_metrics()
-                json_topo_metrics_1 = json.loads(json_topo_metrics_1)
-                
-                main.log.info("Obtaining graph and device timestamp")
+                    main.ONOS1cli.topology_events_metrics()
+                json_topo_metrics_1 = json.loads( json_topo_metrics_1 )
+
+                main.log.info( "Obtaining graph and device timestamp" )
                 graph_timestamp_1 = \
-                    json_topo_metrics_1[graphTimestamp]['value']
+                    json_topo_metrics_1[ graphTimestamp ][ 'value' ]
 
                 link_timestamp_1 = \
-                    json_topo_metrics_1[linkTimestamp]['value']
+                    json_topo_metrics_1[ linkTimestamp ][ 'value' ]
 
                 if graph_timestamp_1 and link_timestamp_1:
-                    link_down_lat_graph1 = int(graph_timestamp_1) -\
-                            timestamp_link_down_t0
-                
-                    link_down_lat_link1 = int(link_timestamp_1) -\
-                            timestamp_link_down_t0
+                    link_down_lat_graph1 = int( graph_timestamp_1 ) -\
+                        timestamp_link_down_t0
+
+                    link_down_lat_link1 = int( link_timestamp_1 ) -\
+                        timestamp_link_down_t0
                 else:
-                    main.log.error("There was an error calculating"+
-                        " the delta for link down event")
+                    main.log.error( "There was an error calculating" +
+                                    " the delta for link down event" )
                     link_down_lat_graph1 = 0
-                    
+
                     link_down_lat_device1 = 0
-        
-            main.log.report("Link down latency ONOS1 iteration "+
-                    str(i)+" (end-to-end): "+
-                    str(link_down_lat_graph1)+" ms")
-            
-            main.log.report("Link down latency ONOS1 iteration "+
-                    str(i)+" (link-event-to-system-timestamp): "+
-                    str(link_down_lat_link1)+" ms")
-      
-            #Calculate avg of node calculations
+
+            main.log.report( "Link down latency ONOS1 iteration " +
+                             str( i ) + " (end-to-end): " +
+                             str( link_down_lat_graph1 ) + " ms" )
+
+            main.log.report( "Link down latency ONOS1 iteration " +
+                             str( i ) + " (link-event-to-system-timestamp): " +
+                             str( link_down_lat_link1 ) + " ms" )
+
+            # Calculate avg of node calculations
             link_down_lat_graph_avg = link_down_lat_graph1
             link_down_lat_link_avg = link_down_lat_link1
 
-            #Set threshold and append latency to list
+            # Set threshold and append latency to list
             if link_down_lat_graph_avg > 0.0 and\
                link_down_lat_graph_avg < 30000:
                 link_down_graph_to_system_list.append(
-                        link_down_lat_graph_avg)
+                    link_down_lat_graph_avg )
             else:
-                main.log.info("Link down latency exceeded threshold")
-                main.log.info("Results for iteration "+str(i)+
-                        "have been omitted")
+                main.log.info( "Link down latency exceeded threshold" )
+                main.log.info( "Results for iteration " + str( i ) +
+                               "have been omitted" )
             if link_down_lat_link_avg > 0.0 and\
                link_down_lat_link_avg < 30000:
                 link_down_link_to_system_list.append(
-                        link_down_lat_link_avg)
+                    link_down_lat_link_avg )
             else:
-                main.log.info("Link down latency exceeded threshold")
-                main.log.info("Results for iteration "+str(i)+
-                        "have been omitted")
+                main.log.info( "Link down latency exceeded threshold" )
+                main.log.info( "Results for iteration " + str( i ) +
+                               "have been omitted" )
 
-            #NOTE: To remove loss rate and measure latency:
+            # NOTE: To remove loss rate and measure latency:
             #       'sh tc qdisc del dev s1-eth1 root'
             timestamp_link_up_t0 = time.time() * 1000
-            main.Mininet1.handle.sendline("sh tc qdisc del dev "+
-                    "s1-eth1 root")
-            main.Mininet1.handle.expect("mininet>")
-            
-            main.log.info("Checking ONOS for link update")
-            
+            main.Mininet1.handle.sendline( "sh tc qdisc del dev " +
+                                           "s1-eth1 root" )
+            main.Mininet1.handle.expect( "mininet>" )
+
+            main.log.info( "Checking ONOS for link update" )
+
             link_down1 = True
             loop_count = 0
             while( link_down1 and loop_count < 30 ):
                 json_str1 = main.ONOS1cli.links()
                 if not json_str1:
-                    main.log.error("CLI command returned error ")
+                    main.log.error( "CLI command returned error " )
                     break
                 else:
-                    json_obj1 = json.loads(json_str1)
-                
+                    json_obj1 = json.loads( json_str1 )
+
                 for obj1 in json_obj1:
-                    if '01' in obj1['src']['device']:
-                        link_down1 = False 
-                        main.log.report("Link up from "+
-                            "s1 -> s2 on ONOS1 detected")
+                    if '01' in obj1[ 'src' ][ 'device' ]:
+                        link_down1 = False
+                        main.log.report( "Link up from " +
+                                         "s1 -> s2 on ONOS1 detected" )
                 loop_count += 1
-                time.sleep(1)
-            
+                time.sleep( 1 )
+
             if link_down1:
-                main.log.info("Link up discovery failed")
+                main.log.info( "Link up discovery failed" )
                 link_up_lat_graph1 = 0
                 link_up_lat_device1 = 0
                 assertion = main.FALSE
             else:
                 json_topo_metrics_1 =\
-                        main.ONOS1cli.topology_events_metrics()
-                json_topo_metrics_1 = json.loads(json_topo_metrics_1)
+                    main.ONOS1cli.topology_events_metrics()
+                json_topo_metrics_1 = json.loads( json_topo_metrics_1 )
 
-                main.log.info("Obtaining graph and device timestamp")
+                main.log.info( "Obtaining graph and device timestamp" )
                 graph_timestamp_1 = \
-                    json_topo_metrics_1[graphTimestamp]['value']
-                
+                    json_topo_metrics_1[ graphTimestamp ][ 'value' ]
+
                 link_timestamp_1 = \
-                    json_topo_metrics_1[linkTimestamp]['value']
+                    json_topo_metrics_1[ linkTimestamp ][ 'value' ]
 
                 if graph_timestamp_1 and link_timestamp_1:
-                    link_up_lat_graph1 = int(graph_timestamp_1) -\
-                            timestamp_link_up_t0
-                    link_up_lat_link1 = int(link_timestamp_1) -\
-                            timestamp_link_up_t0
+                    link_up_lat_graph1 = int( graph_timestamp_1 ) -\
+                        timestamp_link_up_t0
+                    link_up_lat_link1 = int( link_timestamp_1 ) -\
+                        timestamp_link_up_t0
                 else:
-                    main.log.error("There was an error calculating"+
-                        " the delta for link down event")
+                    main.log.error( "There was an error calculating" +
+                                    " the delta for link down event" )
                     link_up_lat_graph1 = 0
                     link_up_lat_device1 = 0
-        
-            main.log.info("Link up latency ONOS1 iteration "+
-                    str(i)+" (end-to-end): "+
-                    str(link_up_lat_graph1)+" ms")
-            
-            main.log.info("Link up latency ONOS1 iteration "+
-                    str(i)+" (link-event-to-system-timestamp): "+
-                    str(link_up_lat_link1)+" ms")
-      
-            #Calculate avg of node calculations
+
+            main.log.info( "Link up latency ONOS1 iteration " +
+                           str( i ) + " (end-to-end): " +
+                           str( link_up_lat_graph1 ) + " ms" )
+
+            main.log.info( "Link up latency ONOS1 iteration " +
+                           str( i ) + " (link-event-to-system-timestamp): " +
+                           str( link_up_lat_link1 ) + " ms" )
+
+            # Calculate avg of node calculations
             link_up_lat_graph_avg = link_up_lat_graph1
             link_up_lat_link_avg = link_up_lat_link1
 
-            #Set threshold and append latency to list
+            # Set threshold and append latency to list
             if link_up_lat_graph_avg > 0.0 and\
                link_up_lat_graph_avg < 30000:
                 link_up_graph_to_system_list.append(
-                        link_up_lat_graph_avg)
+                    link_up_lat_graph_avg )
             else:
-                main.log.info("Link up latency exceeded threshold")
-                main.log.info("Results for iteration "+str(i)+
-                        "have been omitted")
+                main.log.info( "Link up latency exceeded threshold" )
+                main.log.info( "Results for iteration " + str( i ) +
+                               "have been omitted" )
             if link_up_lat_link_avg > 0.0 and\
                link_up_lat_link_avg < 30000:
                 link_up_link_to_system_list.append(
-                        link_up_lat_link_avg)
+                    link_up_lat_link_avg )
             else:
-                main.log.info("Link up latency exceeded threshold")
-                main.log.info("Results for iteration "+str(i)+
-                        "have been omitted")
+                main.log.info( "Link up latency exceeded threshold" )
+                main.log.info( "Results for iteration " + str( i ) +
+                               "have been omitted" )
 
-        #Calculate min, max, avg of list and report
-        link_down_min = min(link_down_graph_to_system_list)
-        link_down_max = max(link_down_graph_to_system_list)
-        link_down_avg = sum(link_down_graph_to_system_list) / \
-                        len(link_down_graph_to_system_list)
-        link_up_min = min(link_up_graph_to_system_list)
-        link_up_max = max(link_up_graph_to_system_list)
-        link_up_avg = sum(link_up_graph_to_system_list) / \
-                        len(link_up_graph_to_system_list)
+        # Calculate min, max, avg of list and report
+        link_down_min = min( link_down_graph_to_system_list )
+        link_down_max = max( link_down_graph_to_system_list )
+        link_down_avg = sum( link_down_graph_to_system_list ) / \
+            len( link_down_graph_to_system_list )
+        link_up_min = min( link_up_graph_to_system_list )
+        link_up_max = max( link_up_graph_to_system_list )
+        link_up_avg = sum( link_up_graph_to_system_list ) / \
+            len( link_up_graph_to_system_list )
 
-        main.log.report("Link down latency - Min: "+
-                str(link_down_min)+"ms  Max: "+
-                str(link_down_max)+"ms  Avg: "+
-                str(link_down_avg)+"ms")
-        main.log.report("Link up latency - Min: "+
-                str(link_up_min)+"ms  Max: "+
-                str(link_up_max)+"ms  Avg: "+
-                str(link_up_avg)+"ms")
+        main.log.report( "Link down latency - Min: " +
+                         str( link_down_min ) + "ms  Max: " +
+                         str( link_down_max ) + "ms  Avg: " +
+                         str( link_down_avg ) + "ms" )
+        main.log.report( "Link up latency - Min: " +
+                         str( link_up_min ) + "ms  Max: " +
+                         str( link_up_max ) + "ms  Avg: " +
+                         str( link_up_avg ) + "ms" )
 
-        utilities.assert_equals(expect=main.TRUE, actual=assertion,
-                onpass="Link discovery latency calculation successful",
-                onfail="Link discovery latency case failed")
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=assertion,
+            onpass="Link discovery latency calculation successful",
+            onfail="Link discovery latency case failed" )
 
-    def CASE5(self, main):
-        '''
+    def CASE5( self, main ):
+        """
         100 Switch discovery latency
 
         Important:
-            This test case can be potentially dangerous if 
+            This test case can be potentially dangerous if
             your machine has previously set iptables rules.
             One of the steps of the test case will flush
             all existing iptables rules.
         Note:
-            You can specify the number of switches in the 
+            You can specify the number of switches in the
             params file to adjust the switch discovery size
-            (and specify the corresponding topology in Mininet1 
-            .topo file)
-        '''
+            ( and specify the corresponding topology in Mininet1
+            .topo file )
+        """
         import time
         import subprocess
         import os
         import requests
         import json
 
-        ONOS1_ip = main.params['CTRL']['ip1']
-        MN1_ip = main.params['MN']['ip1']
-        ONOS_user = main.params['CTRL']['user']
+        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        MN1_ip = main.params[ 'MN' ][ 'ip1' ]
+        ONOS_user = main.params[ 'CTRL' ][ 'user' ]
 
-        default_sw_port = main.params['CTRL']['port1']
-       
-        #Number of iterations of case
-        num_iter = main.params['TEST']['numIter']
-        num_sw = main.params['TEST']['numSwitch']
+        default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
 
-        #Timestamp 'keys' for json metrics output.
-        #These are subject to change, hence moved into params
-        deviceTimestamp = main.params['JSON']['deviceTimestamp']
-        graphTimestamp = main.params['JSON']['graphTimestamp']
-   
-        tshark_ofp_output = "/tmp/tshark_ofp_"+num_sw+"sw.txt"
-        tshark_tcp_output = "/tmp/tshark_tcp_"+num_sw+"sw.txt"
+        # Number of iterations of case
+        num_iter = main.params[ 'TEST' ][ 'numIter' ]
+        num_sw = main.params[ 'TEST' ][ 'numSwitch' ]
+
+        # Timestamp 'keys' for json metrics output.
+        # These are subject to change, hence moved into params
+        deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
+        graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
+
+        tshark_ofp_output = "/tmp/tshark_ofp_" + num_sw + "sw.txt"
+        tshark_tcp_output = "/tmp/tshark_tcp_" + num_sw + "sw.txt"
 
         tshark_ofp_result_list = []
         tshark_tcp_result_list = []
 
-        main.case(num_sw+" Switch discovery latency")
-        main.step("Assigning all switches to ONOS1")
-        for i in range(1, int(num_sw)+1):
+        main.case( num_sw + " Switch discovery latency" )
+        main.step( "Assigning all switches to ONOS1" )
+        for i in range( 1, int( num_sw ) + 1 ):
             main.Mininet1.assign_sw_controller(
-                    sw=str(i),
-                    ip1=ONOS1_ip,
-                    port1=default_sw_port)
-        
-        #Ensure that nodes are configured with ptpd
-        #Just a warning message
-        main.log.info("Please check ptpd configuration to ensure"+\
-                " All nodes' system times are in sync")
-        time.sleep(5)
+                sw=str( i ),
+                ip1=ONOS1_ip,
+                port1=default_sw_port )
 
-        for i in range(0, int(num_iter)):
-            
-            main.step("Set iptables rule to block incoming sw connections")
-            #Set iptables rule to block incoming switch connections
-            #The rule description is as follows:
+        # Ensure that nodes are configured with ptpd
+        # Just a warning message
+        main.log.info( "Please check ptpd configuration to ensure" +
+                       " All nodes' system times are in sync" )
+        time.sleep( 5 )
+
+        for i in range( 0, int( num_iter ) ):
+
+            main.step( "Set iptables rule to block incoming sw connections" )
+            # Set iptables rule to block incoming switch connections
+            # The rule description is as follows:
             #   Append to INPUT rule,
             #   behavior DROP that matches following:
             #       * packet type: tcp
             #       * source IP: MN1_ip
             #       * destination PORT: 6633
             main.ONOS1.handle.sendline(
-                    "sudo iptables -A INPUT -p tcp -s "+MN1_ip+
-                    " --dport "+default_sw_port+" -j DROP")
-            main.ONOS1.handle.expect("\$") 
-            #   Append to OUTPUT rule, 
+                "sudo iptables -A INPUT -p tcp -s " + MN1_ip +
+                " --dport " + default_sw_port + " -j DROP" )
+            main.ONOS1.handle.expect( "\$" )
+            #   Append to OUTPUT rule,
             #   behavior DROP that matches following:
             #       * packet type: tcp
             #       * source IP: MN1_ip
             #       * destination PORT: 6633
             main.ONOS1.handle.sendline(
-                    "sudo iptables -A OUTPUT -p tcp -s "+MN1_ip+
-                    " --dport "+default_sw_port+" -j DROP")
-            main.ONOS1.handle.expect("\$")
-            #Give time to allow rule to take effect
-            #NOTE: Sleep period may need to be configured 
+                "sudo iptables -A OUTPUT -p tcp -s " + MN1_ip +
+                " --dport " + default_sw_port + " -j DROP" )
+            main.ONOS1.handle.expect( "\$" )
+            # Give time to allow rule to take effect
+            # NOTE: Sleep period may need to be configured
             #      based on the number of switches in the topology
-            main.log.info("Please wait for switch connection to "+
-                    "time out")
-            time.sleep(60)
-            
-            #Gather vendor OFP with tshark
-            main.ONOS1.tshark_grep("OFP 86 Vendor", 
-                    tshark_ofp_output)
-            main.ONOS1.tshark_grep("TCP 74 ",
-                    tshark_tcp_output)
+            main.log.info( "Please wait for switch connection to " +
+                           "time out" )
+            time.sleep( 60 )
 
-            #NOTE: Remove all iptables rule quickly (flush)
-            #      Before removal, obtain TestON timestamp at which 
+            # Gather vendor OFP with tshark
+            main.ONOS1.tshark_grep( "OFP 86 Vendor",
+                                    tshark_ofp_output )
+            main.ONOS1.tshark_grep( "TCP 74 ",
+                                    tshark_tcp_output )
+
+            # NOTE: Remove all iptables rule quickly ( flush )
+            #      Before removal, obtain TestON timestamp at which
             #      removal took place
-            #      (ensuring nodes are configured via ptp)
+            #      ( ensuring nodes are configured via ptp )
             #      sudo iptables -F
-            
+
             t0_system = time.time() * 1000
             main.ONOS1.handle.sendline(
-                    "sudo iptables -F")
+                "sudo iptables -F" )
 
-            #Counter to track loop count
+            # Counter to track loop count
             counter_loop = 0
             counter_avail1 = 0
             onos1_dev = False
             while counter_loop < 60:
-                #Continue to check devices for all device 
-                #availability. When all devices in all 3
-                #ONOS instances indicate that devices are available
-                #obtain graph event timestamp for t1.
+                # Continue to check devices for all device
+                # availability. When all devices in all 3
+                # ONOS instances indicate that devices are available
+                # obtain graph event timestamp for t1.
                 device_str_obj1 = main.ONOS1cli.devices()
-                device_json1 = json.loads(device_str_obj1)                
-                
+                device_json1 = json.loads( device_str_obj1 )
+
                 for device1 in device_json1:
-                    if device1['available'] == True:
+                    if device1[ 'available' ]:
                         counter_avail1 += 1
-                        if counter_avail1 == int(num_sw):
+                        if counter_avail1 == int( num_sw ):
                             onos1_dev = True
-                            main.log.info("All devices have been "+
-                                    "discovered on ONOS1")
+                            main.log.info( "All devices have been " +
+                                           "discovered on ONOS1" )
                     else:
                         counter_avail1 = 0
 
-                if onos1_dev: 
-                    main.log.info("All devices have been discovered "+
-                            "on all ONOS instances")
+                if onos1_dev:
+                    main.log.info( "All devices have been discovered " +
+                                   "on all ONOS instances" )
                     json_str_topology_metrics_1 =\
                         main.ONOS1cli.topology_events_metrics()
-                    #Exit while loop if all devices discovered
-                    break 
-                
+                    # Exit while loop if all devices discovered
+                    break
+
                 counter_loop += 1
-                #Give some time in between CLI calls
-                #(will not affect measurement)
-                time.sleep(3)
+                # Give some time in between CLI calls
+                #( will not affect measurement )
+                time.sleep( 3 )
 
             main.ONOS1.tshark_stop()
-            
-            os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
-                    tshark_ofp_output+" /tmp/") 
-            os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
-                    tshark_tcp_output+" /tmp/")
-            ofp_file = open(tshark_ofp_output, 'r')
 
-            #The following is for information purpose only.
-            #TODO: Automate OFP output analysis
-            main.log.info("Tshark OFP Vendor output: ")
+            os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+                       tshark_ofp_output + " /tmp/" )
+            os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
+                       tshark_tcp_output + " /tmp/" )
+            ofp_file = open( tshark_ofp_output, 'r' )
+
+            # The following is for information purpose only.
+            # TODO: Automate OFP output analysis
+            main.log.info( "Tshark OFP Vendor output: " )
             for line in ofp_file:
-                tshark_ofp_result_list.append(line)
-                main.log.info(line)
+                tshark_ofp_result_list.append( line )
+                main.log.info( line )
 
             ofp_file.close()
 
-            tcp_file = open(tshark_tcp_output, 'r')
-            main.log.info("Tshark TCP 74 output: ")
+            tcp_file = open( tshark_tcp_output, 'r' )
+            main.log.info( "Tshark TCP 74 output: " )
             for line in tcp_file:
-                tshark_tcp_result_list.append(line)
-                main.log.info(line)
+                tshark_tcp_result_list.append( line )
+                main.log.info( line )
 
             tcp_file.close()
 
-            json_obj_1 = json.loads(json_str_topology_metrics_1)
+            json_obj_1 = json.loads( json_str_topology_metrics_1 )
 
             graph_timestamp_1 = \
-                    json_obj_1[graphTimestamp]['value']
+                json_obj_1[ graphTimestamp ][ 'value' ]
 
             main.log.info(
-                    int(graph_timestamp_1) - int(t0_system))
-
-
-
-
-
-
-
+                int( graph_timestamp_1 ) - int( t0_system ) )
