Fixed quaggadriver and SdnIpTest
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py b/TestON/drivers/common/cli/quaggaclidriver.py
index 8724454..98f83d2 100644
--- a/TestON/drivers/common/cli/quaggaclidriver.py
+++ b/TestON/drivers/common/cli/quaggaclidriver.py
@@ -28,19 +28,14 @@
         # 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(
+        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 ) )
+                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 )
@@ -64,14 +59,9 @@
         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 ) )
+        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( "" )
@@ -85,7 +75,7 @@
             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 ) )
+            main.log.info( "I am in quagga on host " + str( ip_address ) )
 
             return self.handle
         else:
@@ -114,8 +104,7 @@
     def generatePrefixes( self, net, numRoutes ):
         main.log.info( "I am in generate_prefixes method!" )
 
-        # each IP prefix will be composed by
-        #"net" + "." + m + "." + n + "." + x
+        # each IP prefix is composed by "net" + "." + m + "." + n + "." + x
         # the length of each IP prefix is 24
         routes = []
         routesGen = 0
@@ -124,10 +113,8 @@
 
         for i in range( 0, m ):
             for j in range( 0, 256 ):
-                network = str(
-                    net ) + "." + str(
-                        i ) + "." + str(
-                            j ) + ".0/24"
+                network = str( net ) + "." + str( i ) + "." + str( j ) \
+                    + ".0/24"
                 routes.append( network )
                 routesGen = routesGen + 1
 
@@ -144,39 +131,36 @@
 
     # This method generates a multiple to single point intent(
     # MultiPointToSinglePointIntent ) for a given route
-    def generateExpectedSingleRouteIntent(
-            self,
-            prefix,
-            nextHop,
-            nextHopMac,
-            sdnipData ):
+    def generateExpectedSingleRouteIntent( self, prefix, nextHop, nextHopMac,
+                                           sdnipData ):
 
-        ingress = []
+        ingresses = []
         egress = ""
         for peer in sdnipData[ 'bgpPeers' ]:
-            if peer[ 'ip_address' ] == nextHop:
-                egress = "of:" + \
-                    str( peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" +\
-                    str( peer[ 'attachmentPort' ] )
-            else:
-                ingress.append( "of:" +
-                                str( peer[ 'attachmentDpid' ] ).replace( ":",
-                                     "" ) + ":" +
-                                str( peer[ 'attachmentPort' ] ) )
+            if peer[ 'ipAddress' ] == nextHop:
+                egress = "of:" + str(
+                    peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" \
+                    + str( peer[ 'attachmentPort' ] )
+        for peer in sdnipData[ 'bgpPeers' ]:
+            if not peer[ 'ipAddress' ] == nextHop:
+                ingress = "of:" + str(
+                    peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" \
+                    + str( peer[ 'attachmentPort' ] )
+                if not ingress == egress and ingress not in ingresses:
+                    ingresses.append( ingress )
+                    # ingresses.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
+        intent = egress + "/" + str( sorted( ingresses ) ) + "/" + \
+            selector + "/" + treatment
         return intent
 
-    def generateExpectedOnePeerRouteIntents(
-            self,
-            prefixes,
-            nextHop,
-            nextHopMac,
-            sdnipJsonFilePath ):
+    def generateExpectedOnePeerRouteIntents( self, prefixes, nextHop,
+                                             nextHopMac, sdnipJsonFilePath ):
         intents = []
         sdnipJsonFile = open( sdnipJsonFilePath ).read()
 
@@ -185,10 +169,7 @@
         for prefix in prefixes:
             intents.append(
                 self.generateExpectedSingleRouteIntent(
-                    prefix,
-                    nextHop,
-                    nextHopMac,
-                    sdnipData ) )
+                    prefix, nextHop, nextHopMac, sdnipData ) )
         return sorted( intents )
 
     # TODO
@@ -220,14 +201,15 @@
         for intent in intentsJsonObj:
             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' ] ) )
+                    ingress.append(
+                        str( attachmentPoint[ 'device' ] ) + ":"
+                        + str( attachmentPoint[ 'port' ] ) )
 
                 selector = intent[ 'selector' ].replace(
                     "[", "" ).replace( "]", "" ).replace( " ", "" )
@@ -235,8 +217,7 @@
                     str1, str2 = str( selector ).split( "," )
                     selector = str2 + "," + str1
 
-                intent = egress + "/" + \
-                    str( sorted( ingress ) ) + "/" + \
+                intent = egress + "/" + str( sorted( ingress ) ) + "/" + \
                     selector + "/" + intent[ 'treatment' ]
                 intents.append( intent )
         return sorted( intents )
@@ -251,22 +232,16 @@
         for intent in intentsJsonObj:
             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 ) )
+            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 )
@@ -282,73 +257,72 @@
         intents = []
         bgpPeerAttachmentPoint = ""
         bgpSpeakerAttachmentPoint = "of:" + str(
-            sdnipData[ 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ).replace( ":",
-             "" ) + ":" +\
-                     str( sdnipData[ 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] )
+            sdnipData[ 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] )\
+            .replace( ":", "" ) + ":" \
+            + str( sdnipData[ 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] )
         for peer in sdnipData[ 'bgpPeers' ]:
-            bgpPeerAttachmentPoint = "of:" + \
-                str( peer[ 'attachmentDpid' ] ).replace( ":", "" ) +\
-                ":" + str( peer[ 'attachmentPort' ] )
+            bgpPeerAttachmentPoint = "of:" \
+                + str( peer[ 'attachmentDpid' ] ).replace( ":", "" ) \
+                + ":" + str( peer[ 'attachmentPort' ] )
             # find out the BGP speaker IP address for this BGP peer
             bgpSpeakerIpAddress = ""
-            for interfaceAddress in sdnipData[
-                    'bgpSpeakers' ][ 0 ][ 'interfaceAddresses' ]:
+            for interfaceAddress in \
+            sdnipData[ 'bgpSpeakers' ][ 0 ][ 'interfaceAddresses' ]:
                 # if eq( interfaceAddress[ 'interfaceDpid' ],sdnipData[
                 # 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ) and eq(
-                # interfaceAddress[ 'interfacePort' ], sdnipData[
-                # 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] ):
-                if eq(
-                        interfaceAddress[ 'interfaceDpid' ],
-                        peer[ 'attachmentDpid' ] ) and eq(
-                        interfaceAddress[ 'interfacePort' ],
+                # interfaceAddress[ 'interfacePort' ], sdnipData[ 'bgpSpeakers'
+                # ][ 0 ][ 'attachmentPort' ] ):
+                if eq( interfaceAddress[ 'interfaceDpid' ],
+                       peer[ 'attachmentDpid' ] ) \
+                and eq( interfaceAddress[ 'interfacePort' ],
                         peer[ 'attachmentPort' ] ):
-                    bgpSpeakerIpAddress = interfaceAddress[ 'ip_address' ]
+                    bgpSpeakerIpAddress = interfaceAddress[ 'ipAddress' ]
                     break
                 else:
                     continue
 
             # from bgpSpeakerAttachmentPoint to bgpPeerAttachmentPoint
             # direction
-            selectorStr = "IPV4_SRC{ip=" + bgpSpeakerIpAddress +\
-                    "/32}," + "IPV4_DST{ip=" + peer[ 'ip_address' ] + "/32}," +\
-                        "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800},\
-                        TCP_DST{tcpPort=179}"
-            selector = selectorStr.replace( " ", "" ).replace(
-                "[", "" ).replace( "]", "" ).split( "," )
+            selectorStr = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," \
+                + "IPV4_DST{ip=" + peer[ 'ipAddress' ] + "/32}," \
+                + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, \
+                TCP_DST{tcpPort=179}"
+            selector = selectorStr.replace( " ", "" ).replace("[", "" )\
+                .replace( "]", "" ).split( "," )
             intent = bgpSpeakerAttachmentPoint + "/" + \
                 bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
             intents.append( intent )
 
-            selectorStr = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," +\
-                    "IPV4_DST{ip=" + peer[ 'ip_address' ] + "/32}," +\
-                    "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800},\
-                    TCP_SRC{tcpPort=179}"
-            selector = selectorStr.replace( " ", "" ).replace(
-                "[", "" ).replace( "]", "" ).split( "," )
-            intent = bgpSpeakerAttachmentPoint + "/" + \
-                bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
+            selectorStr = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," \
+                + "IPV4_DST{ip=" + peer[ 'ipAddress' ] + "/32}," \
+                + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, \
+                TCP_SRC{tcpPort=179}"
+            selector = selectorStr.replace( " ", "" ).replace("[", "" )\
+                .replace( "]", "" ).split( "," )
+            intent = bgpSpeakerAttachmentPoint + "/" \
+                + bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
             intents.append( intent )
 
             # from bgpPeerAttachmentPoint to bgpSpeakerAttachmentPoint
             # direction
-            selectorStr = "IPV4_SRC{ip=" + peer[ 'ip_address' ] + "/32}," +\
-                    "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," + \
-                    "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800},\
-                    TCP_DST{tcpPort=179}"
-            selector = selectorStr.replace( " ", "" ).replace(
-                "[", "" ).replace( "]", "" ).split( "," )
-            intent = bgpPeerAttachmentPoint + "/" + \
-                bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
+            selectorStr = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," \
+                + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," \
+                + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, \
+                TCP_DST{tcpPort=179}"
+            selector = selectorStr.replace( " ", "" ).replace("[", "" )\
+                .replace( "]", "" ).split( "," )
+            intent = bgpPeerAttachmentPoint + "/" \
+                + bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
             intents.append( intent )
 
-            selectorStr = "IPV4_SRC{ip=" + peer[ 'ip_address' ] + "/32}," +\
-                    "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," +\
-                    "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800},\
-                     TCP_SRC{tcpPort=179}"
-            selector = selectorStr.replace( " ", "" ).replace(
-                "[", "" ).replace( "]", "" ).split( "," )
-            intent = bgpPeerAttachmentPoint + "/" + \
-                bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
+            selectorStr = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," \
+                + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," \
+                + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, \
+                TCP_SRC{tcpPort=179}"
+            selector = selectorStr.replace( " ", "" ).replace( "[", "" )\
+                .replace( "]", "" ).split( "," )
+            intent = bgpPeerAttachmentPoint + "/" \
+                + bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
             intents.append( intent )
 
         return sorted( intents )
@@ -374,8 +348,8 @@
             except:
                 main.log.warn( "Failed to add route" )
                 self.disconnect()
-            waitTimer = 1.00 / routeRate
-            time.sleep( waitTimer )
+            # waitTimer = 1.00 / routeRate
+            # time.sleep( waitTimer )
         if routesAdded == len( routes ):
             main.log.info( "Finished adding routes" )
             return main.TRUE
@@ -400,10 +374,10 @@
                 self.handle.sendline( routeCmd )
                 self.handle.expect( "bgpd", timeout=5 )
             except:
-                main.log.warn( "Failed to add route" )
+                main.log.warn( "Failed to delete route" )
                 self.disconnect()
-            waitTimer = 1.00 / routeRate
-            time.sleep( waitTimer )
+            # waitTimer = 1.00 / routeRate
+            # time.sleep( waitTimer )
         if routesAdded == len( routes ):
             main.log.info( "Finished deleting routes" )
             return main.TRUE
@@ -416,24 +390,15 @@
         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 ) )
+        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(
-                pingTestFile +
-                " > " +
-                pingTestResultFile +
-                " &" )
+            main.log.info( pingTestFile + " > " + pingTestResultFile + " &" )
             self.handle.sendline(
                 pingTestFile +
                 " > " +
@@ -447,7 +412,7 @@
             main.log.info( "NO HANDLE" )
             return main.FALSE
 
-    # Please use the generateRoutes plus addRoutes instead of this one
+    # Please use the generateRoutes plus addRoutes instead of this one!
     def addRoute( self, net, numRoutes, routeRate ):
         try:
             self.handle.sendline( "" )
@@ -467,8 +432,8 @@
             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"
+                network = str( net ) + "." + str( m ) + "." + str( n ) \
+                    + ".0/24"
                 routeCmd = "network " + network
                 try:
                     self.handle.sendline( routeCmd )
@@ -481,10 +446,8 @@
                 routesAdded = routesAdded + 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"
+                network = str( net ) + "." + str( d ) + "." + str( e ) \
+                    + ".0/24"
                 routeCmd = "network " + network
                 try:
                     self.handle.sendline( routeCmd )
@@ -498,7 +461,8 @@
         if routesAdded == numRoutes:
             return main.TRUE
         return main.FALSE
-
+    
+    # Please use deleteRoutes method instead of this one!
     def delRoute( self, net, numRoutes, routeRate ):
         try:
             self.handle.sendline( "" )
@@ -518,8 +482,8 @@
             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"
+                network = str( net ) + "." + str( m ) + "." + str( n ) \
+                    + ".0/24"
                 routeCmd = "no network " + network
                 try:
                     self.handle.sendline( routeCmd )
@@ -532,8 +496,8 @@
                 routesDeleted = routesDeleted + 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"
+                network = str( net ) + "." + str( d ) + "." + str( e ) \
+                    + ".0/24"
                 routeCmd = "no network " + network
                 try:
                     self.handle.sendline( routeCmd )
@@ -554,7 +518,7 @@
             child = pexpect.spawn( "telnet " + ip )
             i = child.expect( [ "login:", "CLI#", pexpect.TIMEOUT ] )
             if i == 0:
-                print "Username and password required. Passing login info."
+                print "user_name and password required. Passing login info."
                 child.sendline( user )
                 child.expect( "Password:" )
                 child.sendline( passwd )
@@ -570,10 +534,8 @@
             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 ] )
+                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:
@@ -620,3 +582,4 @@
             main.log.error( "Connection failed to the host" )
             response = main.FALSE
         return response
+
diff --git a/TestON/tests/SdnIpTest/SdnIpTest.py b/TestON/tests/SdnIpTest/SdnIpTest.py
index 53560f3..85ac21e 100644
--- a/TestON/tests/SdnIpTest/SdnIpTest.py
+++ b/TestON/tests/SdnIpTest/SdnIpTest.py
@@ -8,16 +8,26 @@
     def __init__( self ):
         self.default = ''
 
-    def CASE1( self, main ):
+# from cupshelpers.config import prefix
+
+# Testing the basic functionality of SDN-IP
+
+
+class SdnIpTest:
+
+    def __init__( self ):
+        self.default = ''
+
+    def CASE4( self, main ):
         """
         Test the SDN-IP functionality
         allRoutesExpected: all expected routes for all BGP peers
-        routeIntentsExpected: all expected
-        MultiPointToSinglePointIntent intents
+        routeIntentsExpected: all expected MultiPointToSinglePointIntent \
+        intents
         bgpIntentsExpected: expected PointToPointIntent intents
         allRoutesActual: all routes from ONOS LCI
-        routeIntentsActual: actual MultiPointToSinglePointIntent
-        intents from ONOS CLI
+        routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
+        ONOS CLI
         bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
         """
         import time
@@ -26,9 +36,594 @@
         # 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" )
+        # SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
+        SDNIPJSONFILEPATH = \
+            "/home/admin/workspace/onos/tools/package/config/sdnip.json"
+        # all expected routes for all BGP peers
+        allRoutesExpected = []
+        main.step( "Start to generate routes for all BGP peers" )
+        main.log.info( "Generate prefixes for host3" )
+        prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+        main.log.info( prefixesHost3 )
+        # generate route with next hop
+        for prefix in prefixesHost3:
+            allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+        routeIntentsExpectedHost3 = \
+            main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+            prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+            SDNIPJSONFILEPATH )
+
+        main.log.info( "Generate prefixes for host4" )
+        prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+        main.log.info( prefixesHost4 )
+        # generate route with next hop
+        for prefix in prefixesHost4:
+            allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+        routeIntentsExpectedHost4 = \
+            main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+            prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+            SDNIPJSONFILEPATH )
+
+        main.log.info( "Generate prefixes for host5" )
+        prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
+        main.log.info( prefixesHost5 )
+        for prefix in prefixesHost5:
+            allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
+        routeIntentsExpectedHost5 = \
+            main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
+            prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
+            SDNIPJSONFILEPATH )
+
+        routeIntentsExpected = routeIntentsExpectedHost3 + \
+            routeIntentsExpectedHost4 + routeIntentsExpectedHost5
+
+        cellName = main.params[ 'ENV' ][ 'cellName' ]
+        ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+        main.step( "Set cell for ONOS-cli environment" )
+        main.ONOScli.setCell( cellName )
+        verifyResult = main.ONOSbench.verifyCell()
+
+        main.log.report( "Removing raft logs" )
+        main.ONOSbench.onosRemoveRaftLogs()
+        main.log.report( "Uninstalling ONOS" )
+        main.ONOSbench.onosUninstall( ONOS1Ip )
+
+        main.step( "Installing ONOS package" )
+        onos1InstallResult = main.ONOSbench.onosInstall(
+            options="-f", node=ONOS1Ip )
+
+        main.step( "Checking if ONOS is up yet" )
+        time.sleep( 150 )
+        onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+        if not onos1Isup:
+            main.log.report( "ONOS1 didn't start!" )
+
+        main.step( "Start ONOS-cli" )
+
+        main.ONOScli.startOnosCli( ONOS1Ip )
+
+        main.step( "Get devices in the network" )
+        listResult = main.ONOScli.devices( jsonFormat=False )
+        main.log.info( listResult )
+        time.sleep( 10 )
+        main.log.info( "Installing sdn-ip feature" )
+        main.ONOScli.featureInstall( "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.enterConfig( 64514 )
+        main.log.info( "Add routes to Quagga on host3" )
+        main.QuaggaCliHost3.addRoutes( prefixesHost3, 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.enterConfig( 64516 )
+        main.log.info( "Add routes to Quagga on host4" )
+        main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+
+        main.log.info( "Login Quagga CLI on host5" )
+        main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
+        main.log.info( "Enter configuration model of Quagga CLI on host5" )
+        main.QuaggaCliHost5.enterConfig( 64521 )
+        main.log.info( "Add routes to Quagga on host5" )
+        main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
+
+        for i in range( 101, 201 ):
+            prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
+            main.log.info( prefixesHostX )
+            for prefix in prefixesHostX:
+                allRoutesExpected.append(
+                    prefix + "/" + "192.168.40." + str( i - 100 ) )
+
+            routeIntentsExpectedHostX = \
+            main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
+                prefixesHostX, "192.168.40." + str( i - 100 ),
+                "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
+            routeIntentsExpected = routeIntentsExpected + \
+                routeIntentsExpectedHostX
+
+            main.log.info( "Login Quagga CLI on host" + str( i ) )
+            QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
+            QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
+            main.log.info(
+                "Enter configuration model of Quagga CLI on host" + str( i ) )
+            QuaggaCliHostX.enterConfig( 65000 + i - 100 )
+            main.log.info( "Add routes to Quagga on host" + str( i ) )
+            QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
+
+        time.sleep( 60 )
+
+        # get routes inside SDN-IP
+        getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+        # parse routes from ONOS CLI
+        allRoutesActual = \
+            main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+        allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+        allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+        main.step( "Check routes installed" )
+        main.log.info( "Routes expected:" )
+        main.log.info( allRoutesStrExpected )
+        main.log.info( "Routes get from ONOS CLI:" )
+        main.log.info( allRoutesStrActual )
+        utilities.assertEquals(
+            expect=allRoutesStrExpected, actual=allRoutesStrActual,
+            onpass="***Routes in SDN-IP are correct!***",
+            onfail="***Routes in SDN-IP are wrong!***" )
+        if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+            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!***" )
+
+        time.sleep( 20 )
+        getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+
+        main.step( "Check MultiPointToSinglePointIntent intents installed" )
+        # routeIntentsExpected are generated when generating routes
+        # get rpoute intents from ONOS CLI
+        routeIntentsActual = \
+            main.QuaggaCliHost3.extractActualRouteIntents(
+                getIntentsResult )
+        routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
+        routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
+        main.log.info( "MultiPointToSinglePoint intents expected:" )
+        main.log.info( routeIntentsStrExpected )
+        main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
+        main.log.info( routeIntentsStrActual )
+        utilities.assertEquals(
+            expect=True,
+            actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
+            onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
+            correct!***",
+            onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
+            wrong!***" )
+
+        if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
+            main.log.report( "***MultiPointToSinglePoint Intents before \
+            deleting routes correct!***" )
+        else:
+            main.log.report( "***MultiPointToSinglePoint Intents before \
+            deleting routes wrong!***" )
+
+        main.step( "Check BGP PointToPointIntent intents installed" )
+        # bgp intents expected
+        bgpIntentsExpected = \
+            main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH )
+        # get BGP intents from ONOS CLI
+        bgpIntentsActual = \
+            main.QuaggaCliHost3.extractActualBgpIntents( getIntentsResult )
+
+        bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
+        bgpIntentsStrActual = str( bgpIntentsActual )
+        main.log.info( "PointToPointIntent intents expected:" )
+        main.log.info( bgpIntentsStrExpected )
+        main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
+        main.log.info( bgpIntentsStrActual )
+
+        utilities.assertEquals(
+            expect=True,
+            actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
+            onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
+            onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
+
+        if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
+            main.log.report(
+                "***PointToPointIntent Intents in SDN-IP are correct!***" )
+        else:
+            main.log.report(
+                "***PointToPointIntent Intents in SDN-IP are wrong!***" )
+
+        #============================= Ping Test ========================
+        # wait until all MultiPointToSinglePoint
+        time.sleep( 20 )
+        pingTestScript = "~/SDNIP/test-tools/CASE4-ping-as2host.sh"
+        pingTestResultsFile = \
+        "~/SDNIP/SdnIpIntentDemo/log/CASE4-ping-results-before-delete-routes-" \
+            + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+        pingTestResults = main.QuaggaCliHost.pingTest(
+            "1.168.30.100", pingTestScript, pingTestResultsFile )
+        main.log.info( pingTestResults )
+        time.sleep( 20 )
+
+        #============================= Deleting Routes ==================
+        main.step( "Check deleting routes installed" )
+        main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+        main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
+        main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
+
+        for i in range( 101, 201 ):
+            prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
+            main.log.info( prefixesHostX )
+            QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
+            QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
+
+        getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+        allRoutesActual = \
+            main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+        main.log.info( "allRoutes_actual = " )
+        main.log.info( allRoutesActual )
+
+        utilities.assertEquals(
+            expect="[]", actual=str( allRoutesActual ),
+            onpass="***Route number in SDN-IP is 0, correct!***",
+            onfail="***Routes number in SDN-IP is not 0, wrong!***" )
+
+        if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+            main.log.report( "***Routes in SDN-IP after deleting correct!***" )
+        else:
+            main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
+
+        main.step( "Check intents after deleting routes" )
+        getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+        routeIntentsActual = \
+            main.QuaggaCliHost3.extractActualRouteIntents(
+                getIntentsResult )
+        main.log.info( "main.ONOScli.intents()= " )
+        main.log.info( routeIntentsActual )
+        utilities.assertEquals(
+            expect="[]", actual=str( routeIntentsActual ),
+            onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
+            correct!***",
+            onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
+            wrong!***" )
+
+        if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
+            main.log.report( "***MultiPointToSinglePoint Intents after \
+            deleting routes correct!***" )
+        else:
+            main.log.report( "***MultiPointToSinglePoint Intents after \
+            deleting routes wrong!***" )
+
+        time.sleep( 20 )
+        pingTestScript = "~/SDNIP/test-tools/CASE4-ping-as2host.sh"
+        pingTestResultsFile = \
+        "~/SDNIP/SdnIpIntentDemo/log/CASE4-ping-results-after-delete-routes-" \
+            + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+        pingTestResults = main.QuaggaCliHost.pingTest(
+            "1.168.30.100", pingTestScript, pingTestResultsFile )
+        main.log.info( pingTestResults )
+        time.sleep( 100 )
+
+        # main.step( "Test whether Mininet is started" )
+        # main.Mininet2.handle.sendline( "xterm host1" )
+        # main.Mininet2.handle.expect( "mininet>" )
+
+    def CASE3( self, main ):
+        """
+        Test the SDN-IP functionality
+        allRoutesExpected: all expected routes for all BGP peers
+        routeIntentsExpected: all expected MultiPointToSinglePointIntent intents
+        bgpIntentsExpected: expected PointToPointIntent intents
+        allRoutesActual: all routes from ONOS LCI
+        routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
+        ONOS CLI
+        bgpIntentsActual: 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" )
+        # SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
+        SDNIPJSONFILEPATH = \
+            "/home/admin/workspace/onos/tools/package/config/sdnip.json"
+        # all expected routes for all BGP peers
+        allRoutesExpected = []
+        main.step( "Start to generate routes for all BGP peers" )
+        main.log.info( "Generate prefixes for host3" )
+        prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
+        main.log.info( prefixesHost3 )
+        # generate route with next hop
+        for prefix in prefixesHost3:
+            allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
+        routeIntentsExpectedHost3 = \
+            main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+            prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+            SDNIPJSONFILEPATH )
+
+        main.log.info( "Generate prefixes for host4" )
+        prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
+        main.log.info( prefixesHost4 )
+        # generate route with next hop
+        for prefix in prefixesHost4:
+            allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
+        routeIntentsExpectedHost4 = \
+            main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+            prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+            SDNIPJSONFILEPATH )
+
+        routeIntentsExpected = routeIntentsExpectedHost3 + \
+            routeIntentsExpectedHost4
+
+        cellName = main.params[ 'ENV' ][ 'cellName' ]
+        ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+        main.step( "Set cell for ONOS-cli environment" )
+        main.ONOScli.setCell( cellName )
+        verifyResult = main.ONOSbench.verifyCell()
+
+        main.log.report( "Removing raft logs" )
+        main.ONOSbench.onosRemoveRaftLogs()
+        main.log.report( "Uninstalling ONOS" )
+        main.ONOSbench.onosUninstall( ONOS1Ip )
+
+        main.step( "Installing ONOS package" )
+        onos1InstallResult = main.ONOSbench.onosInstall(
+            options="-f", node=ONOS1Ip )
+
+        main.step( "Checking if ONOS is up yet" )
+        time.sleep( 60 )
+        onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+        if not onos1Isup:
+            main.log.report( "ONOS1 didn't start!" )
+
+        main.step( "Start ONOS-cli" )
+
+        main.ONOScli.startOnosCli( ONOS1Ip )
+
+        main.step( "Get devices in the network" )
+        listResult = main.ONOScli.devices( jsonFormat=False )
+        main.log.info( listResult )
+        time.sleep( 10 )
+        main.log.info( "Installing sdn-ip feature" )
+        main.ONOScli.featureInstall( "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.enterConfig( 64514 )
+        main.log.info( "Add routes to Quagga on host3" )
+        main.QuaggaCliHost3.addRoutes( prefixesHost3, 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.enterConfig( 64516 )
+        main.log.info( "Add routes to Quagga on host4" )
+        main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
+
+        for i in range( 101, 201 ):
+            prefixesHostX = \
+                main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
+            main.log.info( prefixesHostX )
+            for prefix in prefixesHostX:
+                allRoutesExpected.append(
+                    prefix + "/" + "192.168.40." + str( i - 100 ) )
+
+            routeIntentsExpectedHostX = \
+                main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
+                prefixesHostX, "192.168.40." + str( i - 100 ),
+                "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
+            routeIntentsExpected = routeIntentsExpected + \
+                routeIntentsExpectedHostX
+
+            main.log.info( "Login Quagga CLI on host" + str( i ) )
+            QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
+            QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
+            main.log.info(
+                "Enter configuration model of Quagga CLI on host" + str( i ) )
+            QuaggaCliHostX.enterConfig( 65000 + i - 100 )
+            main.log.info( "Add routes to Quagga on host" + str( i ) )
+            QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
+
+        time.sleep( 60 )
+
+        # get routes inside SDN-IP
+        getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+
+        # parse routes from ONOS CLI
+        allRoutesActual = \
+            main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
+
+        allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+        allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+        main.step( "Check routes installed" )
+        main.log.info( "Routes expected:" )
+        main.log.info( allRoutesStrExpected )
+        main.log.info( "Routes get from ONOS CLI:" )
+        main.log.info( allRoutesStrActual )
+        utilities.assertEquals(
+            expect=allRoutesStrExpected, actual=allRoutesStrActual,
+            onpass="***Routes in SDN-IP are correct!***",
+            onfail="***Routes in SDN-IP are wrong!***" )
+        if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+            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!***" )
+
+        time.sleep( 20 )
+        getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+
+        main.step( "Check MultiPointToSinglePointIntent intents installed" )
+        # routeIntentsExpected are generated when generating routes
+        # get rpoute intents from ONOS CLI
+        routeIntentsActual = \
+            main.QuaggaCliHost3.extractActualRouteIntents(
+                getIntentsResult )
+        routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
+        routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
+        main.log.info( "MultiPointToSinglePoint intents expected:" )
+        main.log.info( routeIntentsStrExpected )
+        main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
+        main.log.info( routeIntentsStrActual )
+        utilities.assertEquals(
+            expect=True,
+            actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
+            onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
+            correct!***",
+            onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
+            wrong!***" )
+
+        if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
+            main.log.report(
+                "***MultiPointToSinglePoint Intents before deleting routes \
+                correct!***" )
+        else:
+            main.log.report(
+                "***MultiPointToSinglePoint Intents before deleting routes \
+                wrong!***" )
+
+        main.step( "Check BGP PointToPointIntent intents installed" )
+        # bgp intents expected
+        bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents(
+            SDNIPJSONFILEPATH )
+        # get BGP intents from ONOS CLI
+        bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
+            getIntentsResult )
+
+        bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
+        bgpIntentsStrActual = str( bgpIntentsActual )
+        main.log.info( "PointToPointIntent intents expected:" )
+        main.log.info( bgpIntentsStrExpected )
+        main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
+        main.log.info( bgpIntentsStrActual )
+
+        utilities.assertEquals(
+            expect=True,
+            actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
+            onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
+            onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
+
+        if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
+            main.log.report(
+                "***PointToPointIntent Intents in SDN-IP are correct!***" )
+        else:
+            main.log.report(
+                "***PointToPointIntent Intents in SDN-IP are wrong!***" )
+
+        #============================= Ping Test ========================
+        # wait until all MultiPointToSinglePoint
+        time.sleep( 20 )
+        pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh"
+        pingTestResultsFile = \
+        "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-before-delete-routes-" \
+            + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+        pingTestResults = main.QuaggaCliHost.pingTest(
+            "1.168.30.100", pingTestScript, pingTestResultsFile )
+        main.log.info( pingTestResults )
+        time.sleep( 20 )
+
+        #============================= Deleting Routes ==================
+        main.step( "Check deleting routes installed" )
+        main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
+        main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
+        for i in range( 101, 201 ):
+            prefixesHostX = \
+                main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
+            main.log.info( prefixesHostX )
+            QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
+            QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
+
+        getRoutesResult = main.ONOScli.routes( jsonFormat=True )
+        allRoutesActual = main.QuaggaCliHost3.extractActualRoutes(
+            getRoutesResult )
+        main.log.info( "allRoutes_actual = " )
+        main.log.info( allRoutesActual )
+
+        utilities.assertEquals(
+            expect="[]", actual=str( allRoutesActual ),
+            onpass="***Route number in SDN-IP is 0, correct!***",
+            onfail="***Routes number in SDN-IP is not 0, wrong!***" )
+
+        if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
+            main.log.report(
+                "***Routes in SDN-IP after deleting correct!***" )
+        else:
+            main.log.report(
+                "***Routes in SDN-IP after deleting wrong!***" )
+
+        main.step( "Check intents after deleting routes" )
+        getIntentsResult = main.ONOScli.intents( jsonFormat=True )
+        routeIntentsActual = \
+            main.QuaggaCliHost3.extractActualRouteIntents(
+                getIntentsResult )
+        main.log.info( "main.ONOScli.intents()= " )
+        main.log.info( routeIntentsActual )
+        utilities.assertEquals(
+            expect="[]", actual=str( routeIntentsActual ),
+            onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \
+            0, correct!***",
+            onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \
+            0, wrong!***" )
+
+        if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
+            main.log.report(
+                "***MultiPointToSinglePoint Intents after deleting routes \
+                correct!***" )
+        else:
+            main.log.report(
+                "***MultiPointToSinglePoint Intents after deleting routes \
+                wrong!***" )
+
+        time.sleep( 20 )
+        pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh"
+        pingTestResultsFile = \
+        "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-after-delete-routes-" \
+            + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+        pingTestResults = main.QuaggaCliHost.pingTest(
+            "1.168.30.100", pingTestScript, pingTestResultsFile )
+        main.log.info( pingTestResults )
+        time.sleep( 100 )
+
+        # main.step( "Test whether Mininet is started" )
+        # main.Mininet2.handle.sendline( "xterm host1" )
+        # main.Mininet2.handle.expect( "mininet>" )
+
+    def CASE1( self, main ):
+        """
+        Test the SDN-IP functionality
+        allRoutesExpected: all expected routes for all BGP peers
+        routeIntentsExpected: all expected MultiPointToSinglePointIntent \
+        intents
+        bgpIntentsExpected: expected PointToPointIntent intents
+        allRoutesActual: all routes from ONOS LCI
+        routeIntentsActual: actual MultiPointToSinglePointIntent intents \
+        from ONOS CLI
+        bgpIntentsActual: 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" )
         SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
         # all expected routes for all BGP peers
         allRoutesExpected = []
@@ -39,22 +634,21 @@
         # main.log.info( "BGP Peer Hosts are:" + bgpPeerHosts )
 
         # for i in range( 3, 5 ):
-        #   QuaggaCliHost = "QuaggaCliHost" + str( i )
-        #  prefixes = main.QuaggaCliHost.generatePrefixes( 3, 10 )
+         #   QuaggaCliHost = "QuaggaCliHost" + str( i )
+          #  prefixes = main.QuaggaCliHost.generatePrefixes( 3, 10 )
 
-        # main.log.info( prefixes )
-        # allRoutesExpected.append( prefixes )
+           # main.log.info( prefixes )
+            # allRoutesExpected.append( prefixes )
         main.log.info( "Generate prefixes for host3" )
         prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
         main.log.info( prefixesHost3 )
         # generate route with next hop
         for prefix in prefixesHost3:
             allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
-        routeIntentsExpectedHost3 = main.QuaggaCliHost3.\
-                generateExpectedOnePeerRouteIntents( prefixesHost3,
-                                                     "192.168.20.1",
-                                                     "00:00:00:00:02:02",
-                                                     SDNIPJSONFILEPATH )
+        routeIntentsExpectedHost3 = \
+            main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+            prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+            SDNIPJSONFILEPATH )
 
         main.log.info( "Generate prefixes for host4" )
         prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
@@ -62,11 +656,10 @@
         # generate route with next hop
         for prefix in prefixesHost4:
             allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
-        routeIntentsExpectedHost4 = main.QuaggaCliHost4.\
-                generateExpectedOnePeerRouteIntents( prefixesHost4,
-                                                     "192.168.30.1",
-                                                     "00:00:00:00:03:01",
-                                                     SDNIPJSONFILEPATH )
+        routeIntentsExpectedHost4 = \
+            main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+            prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+            SDNIPJSONFILEPATH )
 
         routeIntentsExpected = routeIntentsExpectedHost3 + \
             routeIntentsExpectedHost4
@@ -88,8 +681,7 @@
         # startResult = main.ONOSbench.onosStart( "127.0.0.1" )
         main.step( "Installing ONOS package" )
         onos1InstallResult = main.ONOSbench.onosInstall(
-            options="-f",
-            node=ONOS1Ip )
+            options="-f", node=ONOS1Ip )
 
         main.step( "Checking if ONOS is up yet" )
         time.sleep( 60 )
@@ -129,8 +721,8 @@
         getRoutesResult = main.ONOScli.routes( jsonFormat=True )
 
         # parse routes from ONOS CLI
-        allRoutesActual = main.QuaggaCliHost3.extractActualRoutes(
-            getRoutesResult )
+        allRoutesActual = \
+            main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
 
         allRoutesStrExpected = str( sorted( allRoutesExpected ) )
         allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
@@ -140,8 +732,7 @@
         main.log.info( "Routes get from ONOS CLI:" )
         main.log.info( allRoutesStrActual )
         utilities.assertEquals(
-            expect=allRoutesStrExpected,
-            actual=allRoutesStrActual,
+            expect=allRoutesStrExpected, actual=allRoutesStrActual,
             onpass="***Routes in SDN-IP are correct!***",
             onfail="***Routes in SDN-IP are wrong!***" )
         if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
@@ -157,8 +748,9 @@
         main.step( "Check MultiPointToSinglePointIntent intents installed" )
         # routeIntentsExpected are generated when generating routes
         # get rpoute intents from ONOS CLI
-        routeIntentsActual = main.QuaggaCliHost3.extractActualRouteIntents(
-            getIntentsResult )
+        routeIntentsActual = \
+            main.QuaggaCliHost3.extractActualRouteIntents(
+                getIntentsResult )
         routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
         routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
         main.log.info( "MultiPointToSinglePoint intents expected:" )
@@ -167,27 +759,25 @@
         main.log.info( routeIntentsStrActual )
         utilities.assertEquals(
             expect=True,
-            actual=eq(
-                routeIntentsStrExpected,
-                routeIntentsStrActual ),
-            onpass= "***MultiPointToSinglePoint " +
-                    "Intents in SDN-IP are correct!***",
-            onfail= "***MultiPointToSinglePoint Intents" +
-                    " in SDN-IP are wrong!***" )
+            actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
+            onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
+            correct!***",
+            onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
+            wrong!***" )
 
         if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
             main.log.report(
-                "***MultiPointToSinglePoint Intents " +
-                "before deleting routes correct!***" )
+                "***MultiPointToSinglePoint Intents before deleting routes \
+                correct!***" )
         else:
             main.log.report(
-                "***MultiPointToSinglePoint Intents" +
-                "before deleting routes wrong!***" )
+                "***MultiPointToSinglePoint Intents before deleting routes \
+                wrong!***" )
 
         main.step( "Check BGP PointToPointIntent intents installed" )
         # bgp intents expected
-        bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents(
-            SDNIPJSONFILEPATH )
+        bgpIntentsExpected = \
+            main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH )
         # get BGP intents from ONOS CLI
         bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
             getIntentsResult )
@@ -201,9 +791,7 @@
 
         utilities.assertEquals(
             expect=True,
-            actual=eq(
-                bgpIntentsStrExpected,
-                bgpIntentsStrActual ),
+            actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
             onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
             onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
 
@@ -214,22 +802,20 @@
             main.log.report(
                 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
 
-        # ============================= Ping Test ========================
+        #============================= Ping Test ========================
         # wait until all MultiPointToSinglePoint
         time.sleep( 20 )
         pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
-        pingTestResultsFile = "~/SDNIP/SdnIpIntentDemo/log/" +\
-                "CASE1-ping-results-before-delete-routes-" + \
-                strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+        pingTestResultsFile = \
+        "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-before-delete-routes-" \
+             + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
         pingTestResults = main.QuaggaCliHost.pingTest(
-            "1.168.30.100",
-            pingTestScript,
-            pingTestResultsFile )
+            "1.168.30.100", pingTestScript, pingTestResultsFile )
         main.log.info( pingTestResults )
 
         # ping test
 
-        # ============================= Deleting Routes ==================
+        #============================= Deleting Routes ==================
         main.step( "Check deleting routes installed" )
         main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
         main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
@@ -239,55 +825,53 @@
         # utilities.assertEquals( expect="Total SDN-IP routes = 1", actual=
         # main.ONOScli.getRoutesNum(),
         getRoutesResult = main.ONOScli.routes( jsonFormat=True )
-        allRoutesActual = main.QuaggaCliHost3.extractActualRoutes(
-            getRoutesResult )
+        allRoutesActual = \
+            main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
         main.log.info( "allRoutes_actual = " )
         main.log.info( allRoutesActual )
 
         utilities.assertEquals(
-            expect="[]",
-            actual=str( allRoutesActual ),
+            expect="[]", actual=str( allRoutesActual ),
             onpass="***Route number in SDN-IP is 0, correct!***",
             onfail="***Routes number in SDN-IP is not 0, wrong!***" )
 
         if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
-            main.log.report( "***Routes in SDN-IP after deleting correct!***" )
+            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" )
         getIntentsResult = main.ONOScli.intents( jsonFormat=True )
-        routeIntentsActual = main.QuaggaCliHost3.extractActualRouteIntents(
-            getIntentsResult )
+        routeIntentsActual = \
+            main.QuaggaCliHost3.extractActualRouteIntents(
+                getIntentsResult )
         main.log.info( "main.ONOScli.intents()= " )
         main.log.info( routeIntentsActual )
         utilities.assertEquals(
-            expect="[]",
-            actual=str( routeIntentsActual ),
-            onpass="***MultiPointToSinglePoint Intents" +
-            " number in SDN-IP is 0, correct!***",
-            onfail="***MultiPointToSinglePoint Intents " +
-            "number in SDN-IP is 0, wrong!***" )
+            expect="[]", actual=str( routeIntentsActual ),
+            onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \
+            0, correct!***",
+            onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \
+            0, wrong!***" )
 
         if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
             main.log.report(
-                "***MultiPointToSinglePoint Intents" +
-                " after deleting routes correct!***" )
+                "***MultiPointToSinglePoint Intents after deleting routes \
+                correct!***" )
         else:
             main.log.report(
-                "***MultiPointToSinglePoint Intents " +
-                "after deleting routes wrong!***" )
+                "***MultiPointToSinglePoint Intents after deleting routes \
+                wrong!***" )
 
         time.sleep( 20 )
         pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
-        pingTestResultsFile = "~/SDNIP/SdnIpIntentDemo/log/" +\
-                              "CASE1-ping-results-after-delete-routes-" +\
-                              strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) +\
-                              ".txt"
+        pingTestResultsFile = \
+        "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-after-delete-routes-" \
+             + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
         pingTestResults = main.QuaggaCliHost.pingTest(
-            "1.168.30.100",
-            pingTestScript,
-            pingTestResultsFile )
+            "1.168.30.100", pingTestScript, pingTestResultsFile )
         main.log.info( pingTestResults )
         time.sleep( 30 )
 
@@ -299,12 +883,12 @@
         """
         Test the SDN-IP functionality
         allRoutesExpected: all expected routes for all BGP peers
-        routeIntentsExpected: all expected MultiPointToSinglePointIntent
+        routeIntentsExpected: all expected MultiPointToSinglePointIntent \
         intents
         bgpIntentsExpected: expected PointToPointIntent intents
         allRoutesActual: all routes from ONOS LCI
-        routeIntentsActual: actual MultiPointToSinglePointIntent intents from
-        ONOS CLI
+        routeIntentsActual: actual MultiPointToSinglePointIntent intents \
+        from ONOS CLI
         bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
         """
         import time
@@ -313,8 +897,8 @@
         from time import localtime, strftime
 
         main.case(
-            "The test case is to help to setup the " +
-            "TestON environment and test new drivers" )
+            "The test case is to help to setup the TestON environment and \
+            test new drivers" )
         SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
         # all expected routes for all BGP peers
         allRoutesExpected = []
@@ -326,11 +910,10 @@
         # generate route with next hop
         for prefix in prefixesHost3:
             allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
-        routeIntentsExpectedHost3 = main.QuaggaCliHost3.\
-                generateExpectedOnePeerRouteIntents( prefixesHost3,
-                                                     "192.168.20.1",
-                                                     "00:00:00:00:02:02",
-                                                     SDNIPJSONFILEPATH )
+        routeIntentsExpectedHost3 = \
+            main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
+            prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
+            SDNIPJSONFILEPATH )
 
         main.log.info( "Generate prefixes for host4" )
         prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
@@ -338,11 +921,10 @@
         # generate route with next hop
         for prefix in prefixesHost4:
             allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
-        routeIntentsExpectedHost4 = main.QuaggaCliHost4.\
-                generateExpectedOnePeerRouteIntents( prefixesHost4,
-                                                     "192.168.30.1",
-                                                     "00:00:00:00:03:01",
-                                                     SDNIPJSONFILEPATH )
+        routeIntentsExpectedHost4 = \
+            main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
+            prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
+            SDNIPJSONFILEPATH )
 
         routeIntentsExpected = routeIntentsExpectedHost3 + \
             routeIntentsExpectedHost4
@@ -362,15 +944,14 @@
         # main.log.report( "Uninstalling ONOS" )
         # main.ONOSbench.onosUninstall( ONOS1Ip )
         main.step( "Creating ONOS package" )
-        packageResult = main.ONOSbench.onosPackage()
+        # packageResult = main.ONOSbench.onosPackage()
 
         main.step( "Installing ONOS package" )
-        onos1InstallResult = main.ONOSbench.onosInstall(
-            options="-f",
-            node=ONOS1Ip )
+        # onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
+        # node=ONOS1Ip )
 
         main.step( "Checking if ONOS is up yet" )
-        time.sleep( 60 )
+        # time.sleep( 60 )
         onos1Isup = main.ONOSbench.isup( ONOS1Ip )
         if not onos1Isup:
             main.log.report( "ONOS1 didn't start!" )
@@ -404,9 +985,7 @@
 
         utilities.assertEquals(
             expect=True,
-            actual=eq(
-                bgpIntentsStrExpected,
-                bgpIntentsStrActual ),
+            actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
             onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
             onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
 
@@ -424,22 +1003,22 @@
         # while( True ):
         for roundNum in range( 1, 6 ):
             # round = round + 1;
-            main.log.report(
-                "The Round " +
-                str( roundNum ) +
-                " test starts........................................" )
+            main.log.report( "The Round " + str( roundNum ) +
+                             " 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.log.info(
+                "Enter configuration model of Quagga CLI on host3" )
             main.QuaggaCliHost3.enterConfig( 64514 )
             main.log.info( "Add routes to Quagga on host3" )
             main.QuaggaCliHost3.addRoutes( prefixesHost3, 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.log.info(
+                "Enter configuration model of Quagga CLI on host4" )
             main.QuaggaCliHost4.enterConfig( 64516 )
             main.log.info( "Add routes to Quagga on host4" )
             main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
@@ -449,8 +1028,8 @@
             getRoutesResult = main.ONOScli.routes( jsonFormat=True )
 
             # parse routes from ONOS CLI
-            allRoutesActual = main.QuaggaCliHost3.extractActualRoutes(
-                getRoutesResult )
+            allRoutesActual = \
+                main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
 
             # allRoutesStrExpected = str( sorted( allRoutesExpected ) )
             allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
@@ -460,15 +1039,15 @@
             main.log.info( "Routes get from ONOS CLI:" )
             main.log.info( allRoutesStrActual )
             utilities.assertEquals(
-                expect=allRoutesStrExpected,
-                actual=allRoutesStrActual,
+                expect=allRoutesStrExpected, actual=allRoutesStrActual,
                 onpass="***Routes in SDN-IP are correct!***",
                 onfail="***Routes in SDN-IP are wrong!***" )
             if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
                 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 )
             getIntentsResult = main.ONOScli.intents( jsonFormat=True )
@@ -477,8 +1056,9 @@
                 "Check MultiPointToSinglePointIntent intents installed" )
             # routeIntentsExpected are generated when generating routes
             # get route intents from ONOS CLI
-            routeIntentsActual = main.QuaggaCliHost3.extractActualRouteIntents(
-                getIntentsResult )
+            routeIntentsActual = \
+                main.QuaggaCliHost3.extractActualRouteIntents(
+                    getIntentsResult )
             # routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
             routeIntentsStrActual = str(
                 routeIntentsActual ).replace( 'u', "" )
@@ -489,38 +1069,35 @@
             main.log.info( routeIntentsStrActual )
             utilities.assertEquals(
                 expect=True,
-                actual=eq(
-                    routeIntentsStrExpected,
-                    routeIntentsStrActual ),
-                onpass= "***MultiPointToSinglePoint " +
-                        "Intents in SDN-IP are correct!***",
-                onfail= "***MultiPointToSinglePoint Intents " +
-                        "in SDN-IP are wrong!***" )
+                actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
+                onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
+                correct!***",
+                onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
+                wrong!***" )
 
             if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
                 main.log.report(
-                    "***MultiPointToSinglePoint Intents" +
-                    " after adding routes correct!***" )
+                    "***MultiPointToSinglePoint Intents after adding routes \
+                    correct!***" )
             else:
                 main.log.report(
-                    "***MultiPointToSinglePoint Intents" +
-                    " after adding routes wrong!***" )
+                    "***MultiPointToSinglePoint Intents after adding routes \
+                    wrong!***" )
 
-            # ============================= Ping Test ========================
+            #============================= Ping Test ========================
             # wait until all MultiPointToSinglePoint
             time.sleep( 20 )
             # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
-            pingTestResultsFile = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + \
-                str( roundNum ) + "-ping-results-before-delete-routes-" +\
-                strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+            pingTestResultsFile = \
+                "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \
+                + str( roundNum ) + "-ping-results-before-delete-routes-" \
+                + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
             pingTestResults = main.QuaggaCliHost.pingTest(
-                "1.168.30.100",
-                pingTestScript,
-                pingTestResultsFile )
+                "1.168.30.100", pingTestScript, pingTestResultsFile )
             main.log.info( pingTestResults )
             # ping test
 
-            # ============================= Deleting Routes ==================
+            #============================= Deleting Routes ==================
             main.step( "Check deleting routes installed" )
             main.log.info( "Delete routes to Quagga on host3" )
             main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
@@ -528,14 +1105,13 @@
             main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
 
             getRoutesResult = main.ONOScli.routes( jsonFormat=True )
-            allRoutesActual = main.QuaggaCliHost3.extractActualRoutes(
-                getRoutesResult )
+            allRoutesActual = \
+                main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
             main.log.info( "allRoutes_actual = " )
             main.log.info( allRoutesActual )
 
             utilities.assertEquals(
-                expect="[]",
-                actual=str( allRoutesActual ),
+                expect="[]", actual=str( allRoutesActual ),
                 onpass="***Route number in SDN-IP is 0, correct!***",
                 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
 
@@ -548,35 +1124,36 @@
 
             main.step( "Check intents after deleting routes" )
             getIntentsResult = main.ONOScli.intents( jsonFormat=True )
-            routeIntentsActual = main.QuaggaCliHost3.extractActualRouteIntents(
-                getIntentsResult )
+            routeIntentsActual = \
+                main.QuaggaCliHost3.extractActualRouteIntents(
+                    getIntentsResult )
             main.log.info( "main.ONOScli.intents()= " )
             main.log.info( routeIntentsActual )
             utilities.assertEquals(
-                expect="[]",
-                actual=str( routeIntentsActual ),
-                onpass="***MultiPointToSinglePoint Intents " +
-                "number in SDN-IP is 0, correct!***",
-                onfail="***MultiPointToSinglePoint Intents " +
-                "number in SDN-IP is 0, wrong!***" )
+                expect="[]", actual=str( routeIntentsActual ),
+                onpass=
+                "***MultiPointToSinglePoint Intents number in SDN-IP \
+                is 0, correct!***",
+                onfail="***MultiPointToSinglePoint Intents number in SDN-IP \
+                is 0, wrong!***" )
 
             if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
                 main.log.report(
-                    "***MultiPointToSinglePoint Intents " +
-                    "after deleting routes correct!***" )
+                    "***MultiPointToSinglePoint Intents after deleting \
+                    routes correct!***" )
             else:
                 main.log.report(
-                    "***MultiPointToSinglePoint Intents " +
-                    "after deleting routes wrong!***" )
+                    "***MultiPointToSinglePoint Intents after deleting \
+                    routes wrong!***" )
 
             time.sleep( 20 )
             # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
-            pingTestResultsFile = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + \
-                str( roundNum ) + "-ping-results-after-delete-routes-" +\
-                strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
+            pingTestResultsFile = \
+                "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \
+                + str( roundNum ) + "-ping-results-after-delete-routes-" \
+                + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
             pingTestResults = main.QuaggaCliHost.pingTest(
-                "1.168.30.100",
-                pingTestScript,
-                pingTestResultsFile )
+                "1.168.30.100", pingTestScript, pingTestResultsFile )
             main.log.info( pingTestResults )
             time.sleep( 30 )
+