Merge "[ONOS-5514] add vlan interfaces in SDNIPClusterTest"
diff --git a/TestON/drivers/common/api/controller/onosrestdriver.py b/TestON/drivers/common/api/controller/onosrestdriver.py
index 15e1e88..5cf3274 100755
--- a/TestON/drivers/common/api/controller/onosrestdriver.py
+++ b/TestON/drivers/common/api/controller/onosrestdriver.py
@@ -474,6 +474,7 @@
                         ethSrc="",
                         ethDst="",
                         bandwidth="",
+                        protected=False,
                         lambdaAlloc=False,
                         ipProto="",
                         ipSrc="",
@@ -543,6 +544,9 @@
                                              "types": [ "OPTICAL" ],
                                              "inclusive": "false" } ] }
 
+            # if protected:
+            #     intentJson['constraints'].append( { "type": "Protection", "types": ["Protection"], "inclusive": "true" } )
+
             if ethType == "IPV4":
                 intentJson[ 'selector' ][ 'criteria' ].append( {
                                                          "type":"ETH_TYPE",
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index e6e8cf9..90f79a9 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -587,11 +587,10 @@
                 main.log.info( self.name + ": no packets lost, host is reachable" )
                 return main.TRUE
             else:
-                main.log.info(
+                main.log.warn(
                     self.name +
                     ": PACKET LOST, HOST IS NOT REACHABLE" )
                 return main.FALSE
-
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
             main.log.error( self.name + ":     " + self.handle.before )
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 08f8a5b..e9cf2b1 100755
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1276,6 +1276,7 @@
             ethDst="",
             bandwidth="",
             lambdaAlloc=False,
+            protected=False,
             ipProto="",
             ipSrc="",
             ipDst="",
@@ -1342,6 +1343,8 @@
                 cmd += " --setVlan " + str( setVlan )
             if encap:
                 cmd += " --encapsulation " + str( encap )
+            if protected:
+                cmd += " --protect "
 
             # Check whether the user appended the port
             # or provided it as an input
@@ -3347,7 +3350,7 @@
             main.cleanup()
             main.exit()
 
-    def partitions( self, jsonFormat=True ):
+    def partitions( self, candidates=False, jsonFormat=True ):
         """
         Returns the output of the raft partitions command for ONOS.
         """
@@ -3364,6 +3367,8 @@
         # },
         try:
             cmdStr = "onos:partitions"
+            if candidates:
+                cmdStr += " -c"
             if jsonFormat:
                 cmdStr += " -j"
             output = self.sendline( cmdStr )
@@ -4704,7 +4709,7 @@
             return main.TRUE
         except AssertionError:
             main.log.exception( "" )
-            return None
+            return main.FALSE
         except TypeError:
             main.log.exception( self.name + ": Object not as expected" )
             return main.FALSE
@@ -4788,7 +4793,7 @@
             return main.TRUE
         except AssertionError:
             main.log.exception( "" )
-            return None
+            return main.FALSE
         except TypeError:
             main.log.exception( self.name + ": Object not as expected" )
             return main.FALSE
@@ -4824,7 +4829,7 @@
             return main.TRUE
         except AssertionError:
             main.log.exception( "" )
-            return None
+            return main.FALSE
         except TypeError:
             main.log.exception( self.name + ": Object not as expected" )
             return main.FALSE
@@ -4838,20 +4843,22 @@
             main.cleanup()
             main.exit()
 
-    def portstate(self, dpid='of:0000000000000102', port='2', state='enable'):
+    def portstate( self, dpid, port, state ):
         '''
         Description:
              Changes the state of port in an OF switch by means of the
              PORTSTATUS OF messages.
         params:
-            dpid - (string) Datapath ID of the device
-            port - (string) target port in the device
-            state - (string) target state (enable or disabled)
+            dpid - (string) Datapath ID of the device. Ex: 'of:0000000000000102'
+            port - (string) target port in the device. Ex: '2'
+            state - (string) target state (enable or disable)
         returns:
             main.TRUE if no exceptions were thrown and no Errors are
             present in the resoponse. Otherwise, returns main.FALSE
         '''
         try:
+            state = state.lower()
+            assert state == 'enable' or state == 'disable', "Unknown state"
             cmd =  "portstate {} {} {}".format( dpid, port, state )
             response = self.sendline( cmd, showResponse=True )
             assert response is not None, "Error in sendline"
@@ -4862,7 +4869,7 @@
             return main.TRUE
         except AssertionError:
             main.log.exception( "" )
-            return None
+            return main.FALSE
         except TypeError:
             main.log.exception( self.name + ": Object not as expected" )
             return main.FALSE
@@ -5011,30 +5018,54 @@
             return None
         return respDic
 
-    def logSearch( self, searchTerm, mode='all' ):
+    def logSearch( self, mode='all', searchTerm='', startLine='', logNum=1 ):
         """
         Searches the latest ONOS log file for the given search term and
         return a list that contains all the lines that have the search term.
 
         Arguments:
-            searchTerm - A string to grep for in the ONOS log.
+            searchTerm:
+                The string to grep from the ONOS log.
+            startLine:
+                The term that decides which line is the start to search the searchTerm in
+                the karaf log. For now, startTerm only works in 'first' mode.
+            logNum:
+                In some extreme cases, one karaf log is not big enough to contain all the
+                information.Because of this, search mutiply logs is necessary to capture
+                the right result. logNum is the number of karaf logs that we need to search
+                the searchTerm.
             mode:
                 all: return all the strings that contain the search term
                 last: return the last string that contains the search term
                 first: return the first string that contains the search term
-                num: return the number that the searchTerm appears in the log
+                num: return the number of times that the searchTerm appears in the log
+                total: return how many lines in karaf log
         """
         try:
             assert type( searchTerm ) is str
-            cmd = "cat /opt/onos/log/karaf.log | grep \'" + searchTerm + "\'"
+            #Build the log paths string
+            logPath = '/opt/onos/log/karaf.log.'
+            logPaths = '/opt/onos/log/karaf.log'
+            for i in range( 1, logNum ):
+                logPaths = logPath + str( i ) + " " + logPaths
+            cmd = "cat " + logPaths
+            if mode == 'all':
+                cmd = cmd + " | grep \'" + searchTerm + "\'"
             if mode == 'last':
-                cmd = cmd + " | tail -n 1"
+                cmd = cmd + " | grep \'" + searchTerm + "\'" + " | tail -n 1"
             if mode == 'first':
-                cmd = cmd + " | head -n 1"
+                if startLine != '':
+                    # 100000000 is just a extreme large number to make sure this function can grep all the lines after startLine
+                    cmd = cmd + " | grep -A 100000000 \'" + startLine + "\' | grep \'" + searchTerm + "\'" + "| head -n 1"
+                else:
+                    cmd = cmd + " | grep \'" + searchTerm + "\'" + " | head -n 1"
             if mode == 'num':
-                cmd = "cat /opt/onos/log/karaf.log | grep -c \'" + searchTerm + "\'"
+                cmd = cmd + " | grep -c \'" + searchTerm + "\'"
                 num = self.sendline( cmd )
                 return num
+            if mode == 'total':
+                totalLines = self.sendline( "cat /opt/onos/log/karaf.log | wc -l" )
+                return int(totalLines)
             before = self.sendline( cmd )
             before = before.splitlines()
             # make sure the returned list only contains the search term
@@ -5057,3 +5088,385 @@
             main.log.exception( self.name + ": Uncaught exception!" )
             main.cleanup()
             main.exit()
+
+    def vplsShow( self, jsonFormat=True ):
+        """
+        Description: Returns result of onos:vpls show, which should list the
+                     configured VPLS networks and the assigned interfaces.
+        Optional:
+            * jsonFormat: enable json formatting of output
+        Returns:
+            The output of the command or None on error.
+        """
+        try:
+            cmdStr = "vpls show"
+            if jsonFormat:
+                raise NotImplementedError
+                cmdStr += " -j"
+            handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
+            assert "Command not found:" not in handle, handle
+            return handle
+        except AssertionError:
+            main.log.exception( "" )
+            return None
+        except TypeError:
+            main.log.exception( self.name + ": Object not as expected" )
+            return None
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except NotImplementedError:
+            main.log.exception( self.name + ": Json output not supported")
+            return None
+        except Exception:
+            main.log.exception( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
+
+    def parseVplsShow( self ):
+        """
+        Parse the cli output of 'vpls show' into json output. This is required
+        as there is currently no json output available.
+        """
+        try:
+            output = []
+            raw = self.vplsShow( jsonFormat=False )
+            namePat = "VPLS name: (?P<name>\w+)"
+            interfacesPat = "Associated interfaces: \[(?P<interfaces>.*)\]"
+            encapPat = "Encapsulation: (?P<encap>\w+)"
+            pattern = "\s+".join( [ namePat, interfacesPat, encapPat ] )
+            mIter = re.finditer( pattern, raw )
+            for match in mIter:
+                item = {}
+                item[ 'name' ] = match.group( 'name' )
+                ifaces = match.group( 'interfaces' ).split( ', ')
+                if ifaces == [ "" ]:
+                    ifaces = []
+                item[ 'interfaces' ] = ifaces
+                encap = match.group( 'encap' )
+                if encap != 'NONE':
+                    item[ 'encapsulation' ] = encap.lower()
+                output.append( item )
+            return output
+        except Exception:
+            main.log.exception( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
+
+    def vplsList( self, jsonFormat=True ):
+        """
+        Description: Returns result of onos:vpls list, which should list the
+                     configured VPLS networks.
+        Optional:
+            * jsonFormat: enable json formatting of output
+        """
+        try:
+            cmdStr = "vpls list"
+            if jsonFormat:
+                raise NotImplementedError
+                cmdStr += " -j"
+            handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
+            assert "Command not found:" not in handle, handle
+            return handle
+        except AssertionError:
+            main.log.exception( "" )
+            return None
+        except TypeError:
+            main.log.exception( self.name + ": Object not as expected" )
+            return None
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except NotImplementedError:
+            main.log.exception( self.name + ": Json output not supported")
+            return None
+        except Exception:
+            main.log.exception( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
+
+    def vplsCreate( self, network ):
+        """
+        CLI command to create a new VPLS network.
+        Required arguments:
+            network - String name of the network to create.
+        returns:
+            main.TRUE on success and main.FALSE on failure
+        """
+        try:
+            network = str( network )
+            cmdStr = "vpls create "
+            cmdStr += network
+            output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
+            assert "Command not found:" not in output, output
+            assert "Error executing command" not in output, output
+            assert "VPLS already exists:" not in output, output
+            return main.TRUE
+        except AssertionError:
+            main.log.exception( "" )
+            return main.FALSE
+        except TypeError:
+            main.log.exception( self.name + ": Object not as expected" )
+            return main.FALSE
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except Exception:
+            main.log.exception( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
+
+    def vplsDelete( self, network ):
+        """
+        CLI command to delete a VPLS network.
+        Required arguments:
+            network - Name of the network to delete.
+        returns:
+            main.TRUE on success and main.FALSE on failure
+        """
+        try:
+            network = str( network )
+            cmdStr = "vpls delete "
+            cmdStr += network
+            output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
+            assert "Command not found:" not in output, output
+            assert "Error executing command" not in output, output
+            assert " not found" not in output, output
+            return main.TRUE
+        except AssertionError:
+            main.log.exception( "" )
+            return main.FALSE
+        except TypeError:
+            main.log.exception( self.name + ": Object not as expected" )
+            return main.FALSE
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except Exception:
+            main.log.exception( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
+
+    def vplsAddIface( self, network, iface ):
+        """
+        CLI command to add an interface to a VPLS network.
+        Required arguments:
+            network - Name of the network to add the interface to.
+            iface - The ONOS name for an interface.
+        returns:
+            main.TRUE on success and main.FALSE on failure
+        """
+        try:
+            network = str( network )
+            iface = str( iface )
+            cmdStr = "vpls add-if "
+            cmdStr += network + " " + iface
+            output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
+            assert "Command not found:" not in output, output
+            assert "Error executing command" not in output, output
+            assert "already associated to network" not in output, output
+            assert "Interface cannot be added." not in output, output
+            return main.TRUE
+        except AssertionError:
+            main.log.exception( "" )
+            return main.FALSE
+        except TypeError:
+            main.log.exception( self.name + ": Object not as expected" )
+            return main.FALSE
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except Exception:
+            main.log.exception( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
+
+    def vplsRemIface( self, network, iface ):
+        """
+        CLI command to remove an interface from a VPLS network.
+        Required arguments:
+            network - Name of the network to remove the interface from.
+            iface - Name of the interface to remove.
+        returns:
+            main.TRUE on success and main.FALSE on failure
+        """
+        try:
+            iface = str( iface )
+            cmdStr = "vpls rem-if "
+            cmdStr += network + " " + iface
+            output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
+            assert "Command not found:" not in output, output
+            assert "Error executing command" not in output, output
+            assert "is not configured" not in output, output
+            return main.TRUE
+        except AssertionError:
+            main.log.exception( "" )
+            return main.FALSE
+        except TypeError:
+            main.log.exception( self.name + ": Object not as expected" )
+            return main.FALSE
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except Exception:
+            main.log.exception( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
+
+    def vplsClean( self ):
+        """
+        Description: Clears the VPLS app configuration.
+        Returns: main.TRUE on success and main.FALSE on failure
+        """
+        try:
+            cmdStr = "vpls clean"
+            handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
+            assert "Command not found:" not in handle, handle
+            return handle
+        except AssertionError:
+            main.log.exception( "" )
+            return main.FALSE
+        except TypeError:
+            main.log.exception( self.name + ": Object not as expected" )
+            return main.FALSE
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except Exception:
+            main.log.exception( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
+
+    def vplsSetEncap( self, network, encapType ):
+        """
+        CLI command to add an interface to a VPLS network.
+        Required arguments:
+            network - Name of the network to create.
+            encapType - Type of encapsulation.
+        returns:
+            main.TRUE on success and main.FALSE on failure
+        """
+        try:
+            network = str( network )
+            encapType = str( encapType ).upper()
+            assert encapType in [ "MPLS", "VLAN", "NONE" ], "Incorrect type"
+            cmdStr = "vpls set-encap "
+            cmdStr += network + " " + encapType
+            output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
+            assert "Command not found:" not in output, output
+            assert "Error executing command" not in output, output
+            assert "already associated to network" not in output, output
+            assert "Encapsulation type " not in output, output
+            return main.TRUE
+        except AssertionError:
+            main.log.exception( "" )
+            return main.FALSE
+        except TypeError:
+            main.log.exception( self.name + ": Object not as expected" )
+            return main.FALSE
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except Exception:
+            main.log.exception( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
+
+    def interfaces( self, jsonFormat=True ):
+        """
+        Description: Returns result of interfaces command.
+        Optional:
+            * jsonFormat: enable json formatting of output
+        Returns:
+            The output of the command or None on error.
+        """
+        try:
+            cmdStr = "interfaces"
+            if jsonFormat:
+                #raise NotImplementedError
+                cmdStr += " -j"
+            handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
+            assert "Command not found:" not in handle, handle
+            return handle
+        except AssertionError:
+            main.log.exception( "" )
+            return None
+        except TypeError:
+            main.log.exception( self.name + ": Object not as expected" )
+            return None
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except NotImplementedError:
+            main.log.exception( self.name + ": Json output not supported")
+            return None
+        except Exception:
+            main.log.exception( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
+
+    def getTimeStampFromLog( self, mode, searchTerm, splitTerm_before, splitTerm_after, startLine='', logNum=1 ):
+        '''
+        Get the timestamp of searchTerm from karaf log.
+
+        Arguments:
+            splitTerm_before and splitTerm_after:
+
+                The terms that split the string that contains the timeStamp of
+                searchTerm. For example, if that string is "xxxxxxxcreationTime =
+                1419510501xxxxxx", then the splitTerm_before is "CreationTime = "
+                and the splitTerm_after is "x"
+
+            others:
+
+                plz look at the "logsearch" Function in onosclidriver.py
+
+
+        '''
+        if logNum < 0:
+            main.log.error("Get wrong log number ")
+            return main.ERROR
+        lines = self.logSearch( mode=mode, searchTerm=searchTerm, startLine=startLine, logNum=logNum )
+        if len(lines) == 0:
+            main.log.warn( "Captured timestamp string is empty" )
+            return main.ERROR
+        lines = lines[ 0 ]
+        try:
+            assert type(lines) is str
+            # get the target value
+            line = lines.split( splitTerm_before )
+            key = line[ 1 ].split( splitTerm_after )
+            return int( key[ 0 ] )
+        except IndexError:
+            main.log.warn( "Index Error!" )
+            return main.ERROR
+        except AssertionError:
+            main.log.warn( "Search Term Not Found " )
+            return main.ERROR
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 655f17e..ecf1b03 100755
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -745,43 +745,43 @@
         NOTE: Assumes cells are located at:
             ~/<self.home>/tools/test/cells/
         """
-        # Variable initialization
-        cellDirectory = 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
-        tempDirectory = "/tmp/"
-        # Create the cell file in the directory for writing ( w+ )
-        cellFile = open( tempDirectory + fileName, 'w+' )
-        if isinstance( onosIpAddrs, types.StringType ):
-            onosIpAddrs = [ onosIpAddrs ]
-
-        # App string is hardcoded environment variables
-        # That you may wish to use by default on startup.
-        # Note that you  may not want certain apps listed
-        # on here.
-        appString = "export ONOS_APPS=" + appString
-        onosGroup = "export ONOS_GROUP=" + onosUser
-        onosUser = "export ONOS_USER=" + onosUser
-        if useSSH:
-            onosUseSSH = "export ONOS_USE_SSH=true"
-        mnString = "export OCN="
-        if mnIpAddrs == "":
-            mnString = ""
-        onosString = "export OC"
-        tempCount = 1
-
-        # Create ONOSNIC ip address prefix
-        tempOnosIp = str( onosIpAddrs[ 0 ] )
-        tempList = []
-        tempList = tempOnosIp.split( "." )
-        # Omit last element of list to format for NIC
-        tempList = tempList[ :-1 ]
-        # Structure the nic string ip
-        nicAddr = ".".join( tempList ) + ".*"
-        self.nicAddr = nicAddr
-        onosNicString = "export ONOS_NIC=" + nicAddr
-
         try:
+            # Variable initialization
+            cellDirectory = 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
+            tempDirectory = "/tmp/"
+            # Create the cell file in the directory for writing ( w+ )
+            cellFile = open( tempDirectory + fileName, 'w+' )
+            if isinstance( onosIpAddrs, types.StringType ):
+                onosIpAddrs = [ onosIpAddrs ]
+
+            # App string is hardcoded environment variables
+            # That you may wish to use by default on startup.
+            # Note that you  may not want certain apps listed
+            # on here.
+            appString = "export ONOS_APPS=" + appString
+            onosGroup = "export ONOS_GROUP=" + onosUser
+            onosUser = "export ONOS_USER=" + onosUser
+            if useSSH:
+                onosUseSSH = "export ONOS_USE_SSH=true"
+            mnString = "export OCN="
+            if mnIpAddrs == "":
+                mnString = ""
+            onosString = "export OC"
+            tempCount = 1
+
+            # Create ONOSNIC ip address prefix
+            tempOnosIp = str( onosIpAddrs[ 0 ] )
+            tempList = []
+            tempList = tempOnosIp.split( "." )
+            # Omit last element of list to format for NIC
+            tempList = tempList[ :-1 ]
+            # Structure the nic string ip
+            nicAddr = ".".join( tempList ) + ".*"
+            self.nicAddr = nicAddr
+            onosNicString = "export ONOS_NIC=" + nicAddr
+
             # Start writing to file
             cellFile.write( onosNicString + "\n" )
 
@@ -2123,6 +2123,35 @@
 
         return sorted( self.onosIps.values() )
 
+    def listLog( self, nodeIp ):
+        """
+            Get a list of all the karaf log names
+        """
+        try:
+            cmd = "onos-ssh " + nodeIp + " ls -tr /opt/onos/log"
+            self.handle.sendline( cmd )
+            self.handle.expect( ":~" )
+            before = self.handle.before.splitlines()
+            logNames = []
+            for word in before:
+                if 'karaf.log' in word:
+                    logNames.append( word )
+            return logNames
+        except pexpect.EOF:
+            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.cleanup()
+            main.exit()
+        except Exception:
+            main.log.exception( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
+
     def logReport( self, nodeIp, searchTerms, outputMode="s" ):
         """
         Searches the latest ONOS log file for the given search terms and
diff --git a/TestON/requirements.txt b/TestON/requirements.txt
index 86c8741..28f7503 100644
--- a/TestON/requirements.txt
+++ b/TestON/requirements.txt
@@ -11,3 +11,4 @@
 pylint==1.1.0
 requests==2.2.1
 scapy==2.3.1
+ipaddress==1.0.16
diff --git a/TestON/tests/CHO/CHOtest/CHOtest.py b/TestON/tests/CHO/CHOtest/CHOtest.py
index 411035d..41f1693 100644
--- a/TestON/tests/CHO/CHOtest/CHOtest.py
+++ b/TestON/tests/CHO/CHOtest/CHOtest.py
@@ -134,16 +134,6 @@
                                      onfail="Test step FAIL" )
             installResult = ( installResult and i_result )
 
-        main.step( "Verify ONOS nodes UP status" )
-        statusResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "ONOS Node " + main.onosIPs[i] + " status:" )
-            onos_status = main.ONOSbench.onosStatus( node=main.onosIPs[i] )
-            utilities.assert_equals( expect=main.TRUE, actual=onos_status,
-                                     onpass="Test step PASS",
-                                     onfail="Test step FAIL" )
-            statusResult = ( statusResult and onos_status )
-
         main.step( "Set up ONOS secure SSH" )
         secureSshResult = main.TRUE
         for i in range( int( main.numCtrls ) ):
@@ -152,6 +142,30 @@
                                  onpass="Test step PASS",
                                  onfail="Test step FAIL" )
 
+        time.sleep( 5 )
+        main.step( "Starting ONOS service" )
+        stopResult = main.TRUE
+        startResult = main.TRUE
+        onosIsUp = main.TRUE
+        for i in range( main.numCtrls ):
+            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+        if onosIsUp == main.TRUE:
+            main.log.report( "ONOS instance is up and ready" )
+        else:
+            main.log.report( "ONOS instance may not be up, stop and " +
+                             "start ONOS again " )
+            for i in range( main.numCtrls ):
+                stopResult = stopResult and \
+                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
+            for i in range( main.numCtrls ):
+                startResult = startResult and \
+                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
+        stepResult = onosIsUp and stopResult and startResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ONOS service is ready",
+                                 onfail="ONOS service did not start properly" )
+
         main.step( "Start ONOS CLI on all nodes" )
         cliResult = main.TRUE
         main.step(" Start ONOS cli using thread ")
diff --git a/TestON/tests/CHOTestMonkey/CHOTestMonkey.py b/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
index ec64601..78bed55 100644
--- a/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
+++ b/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
@@ -147,16 +147,6 @@
                                      onfail="Test step FAIL" )
             installResult = ( installResult and iResult )
 
-        main.step( "Verify ONOS nodes UP status" )
-        statusResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "ONOS Node " + main.onosIPs[i] + " status:" )
-            onos_status = main.ONOSbench.onosStatus( node=main.onosIPs[i] )
-            utilities.assert_equals( expect=main.TRUE, actual=onos_status,
-                                     onpass="Test step PASS",
-                                     onfail="Test step FAIL" )
-            statusResult = ( statusResult and onos_status )
-
         main.step( "Set up ONOS secure SSH" )
         secureSshResult = main.TRUE
         for i in range( int( main.numCtrls ) ):
@@ -165,6 +155,30 @@
                                  onpass="Test step PASS",
                                  onfail="Test step FAIL" )
 
+        time.sleep( 5 )
+        main.step( "Starting ONOS service" )
+        stopResult = main.TRUE
+        startResult = main.TRUE
+        onosIsUp = main.TRUE
+        for i in range( main.numCtrls ):
+            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+        if onosIsUp == main.TRUE:
+            main.log.report( "ONOS instance is up and ready" )
+        else:
+            main.log.report( "ONOS instance may not be up, stop and " +
+                             "start ONOS again " )
+            for i in range( main.numCtrls ):
+                stopResult = stopResult and \
+                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
+            for i in range( main.numCtrls ):
+                startResult = startResult and \
+                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
+        stepResult = onosIsUp and stopResult and startResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ONOS service is ready",
+                                 onfail="ONOS service did not start properly" )
+
         main.step( "Start ONOS CLI on all nodes" )
         cliResult = main.TRUE
         startCliResult  = main.TRUE
diff --git a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py
index f799854..800a864 100755
--- a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py
+++ b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py
@@ -133,6 +133,12 @@
                                  onpass="ONOS install successful",
                                  onfail="ONOS install failed" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.ONOSbench.onosSecureSSH( node=main.nodes[ 0 ].ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                     onpass="Test step PASS",
+                                     onfail="Test step FAIL" )
+
         main.step( "Checking if ONOS is up yet" )
         print main.nodes[0].ip_address
         for i in range( 2 ):
@@ -143,12 +149,6 @@
                                  onpass="ONOS startup successful",
                                  onfail="ONOS startup failed" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.ONOSbench.onosSecureSSH( node=main.nodes[ 0 ].ip_address )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                     onpass="Test step PASS",
-                                     onfail="Test step FAIL" )
-
         main.step( "Starting ONOS CLI sessions" )
         print main.nodes[ 0 ].ip_address
         cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address )
diff --git a/TestON/tests/FUNC/FUNCflow/FUNCflow.py b/TestON/tests/FUNC/FUNCflow/FUNCflow.py
index 1acc76a..df64bb4 100644
--- a/TestON/tests/FUNC/FUNCflow/FUNCflow.py
+++ b/TestON/tests/FUNC/FUNCflow/FUNCflow.py
@@ -175,6 +175,14 @@
                                  onpass="Successfully installed ONOS package",
                                  onfail="Failed to install ONOS package" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for i in range( int( main.numCtrls ) ):
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         time.sleep( main.startUpSleep )
         main.step( "Starting ONOS service" )
         stopResult = main.TRUE
@@ -200,14 +208,6 @@
                                  onpass="ONOS service is ready",
                                  onfail="ONOS service did not start properly" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Start ONOS cli" )
         cliResult = main.TRUE
         for i in range( main.numCtrls ):
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.py b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
index 1371453..6297464 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
@@ -205,6 +205,14 @@
                                  onpass="Successfully installed ONOS package",
                                  onfail="Failed to install ONOS package" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for i in range( int( main.numCtrls ) ):
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         time.sleep( main.startUpSleep )
         main.step( "Starting ONOS service" )
         stopResult = main.TRUE
@@ -229,14 +237,6 @@
                                  onpass="ONOS service is ready on all nodes",
                                  onfail="ONOS service did not start properly on all nodes" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Start ONOS cli" )
         cliResult = main.TRUE
         for i in range( main.numCtrls ):
@@ -1119,6 +1119,42 @@
                                  actual=testResult,
                                  onpass=main.assertReturnString,
                                  onfail=main.assertReturnString )
+
+        main.step("Protected: Add point intents between h1 and h9")
+        main.assertReturnString = "Assertion Result for protected point intent\n"
+        senders = [
+            {"name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01"}
+        ]
+        recipients = [
+            {"name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09"}
+        ]
+        testResult = main.FALSE
+        installResult = main.intentFunction.installPointIntent(
+            main,
+            name="Protected",
+            senders=senders,
+            recipients=recipients,
+            protected=True )
+
+        if installResult:
+            testResult = main.intentFunction.testPointIntent(
+                main,
+                name="Protected",
+                intentId=installResult,
+                senders=senders,
+                recipients=recipients,
+                sw1="s5",
+                sw2="s2",
+                protected=True,
+                expectedLink=18 )
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=testResult,
+                                 onpass=main.assertReturnString,
+                                 onfail=main.assertReturnString )
+
         main.step( "IPV4_2: Add point intents between h1 and h9" )
         main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
         senders = [
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
index 1760324..d8a0e36 100755
--- a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
@@ -309,6 +309,7 @@
                         ethType="",
                         bandwidth="",
                         lambdaAlloc=False,
+                        protected=False,
                         ipProto="",
                         ipSrc="",
                         ipDst="",
@@ -397,6 +398,7 @@
                                             ethDst=dstMac,
                                             bandwidth=bandwidth,
                                             lambdaAlloc=lambdaAlloc,
+                                            protected=protected,
                                             ipProto=ipProto,
                                             ipSrc=ipSrc,
                                             ipDst=ipDst,
@@ -423,6 +425,7 @@
                 main.assertReturnString += 'Encapsulation intents check Passed\n'
             else:
                 main.assertReturnString += 'Encapsulation intents check failed\n'
+
         if flowDuration( main ):
             main.assertReturnString += 'Flow duration check Passed\n'
             return intentId
@@ -972,6 +975,7 @@
                      ethType="",
                      bandwidth="",
                      lambdaAlloc=False,
+                     protected=False,
                      ipProto="",
                      ipAddresses="",
                      tcp="",
@@ -1109,6 +1113,21 @@
             main.assertReturnString += 'Link Down Failed\n'
             testResult = main.FALSE
 
+        if protected:
+            # Check Connection
+            if utilities.retry(f=scapyCheckConnection, retValue=main.FALSE,
+                               args=(main, senderNames, recipientNames, vlanId, useTCP) ):
+                main.assertReturnString += 'Link down Scapy Packet Received Passed\n'
+            else:
+                main.assertReturnString += 'Link down Scapy Packet Recieved Failed\n'
+                testResult = main.FALSE
+
+            if ProtectedIntentCheck( main ):
+                main.assertReturnString += 'Protected Intent Check Passed\n'
+            else:
+                main.assertReturnString += 'Protected Intent Check Failed\n'
+                testResult = main.FALSE
+
         # Check intent state
         if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
             main.assertReturnString += 'Link Down Intent State Passed\n'
@@ -1996,4 +2015,11 @@
     if pop == totalflows and push == totalflows:
         return main.TRUE
     else:
-        return main.FALSE
\ No newline at end of file
+        return main.FALSE
+
+def ProtectedIntentCheck( main ):
+    import json
+    intent = main.CLIs[ 0 ].intents( jsonFormat=False )
+    if "Protection" in intent:
+        return main.TRUE
+    return main.FALSE
\ No newline at end of file
diff --git a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
index dc8df66..71bf286 100644
--- a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
+++ b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
@@ -230,6 +230,14 @@
                                  onpass="Successfully installed ONOS package",
                                  onfail="Failed to install ONOS package" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for i in range( int( main.numCtrls ) ):
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         time.sleep( main.startUpSleep )
         main.step( "Starting ONOS service" )
         stopResult = main.TRUE
@@ -259,14 +267,6 @@
         # supported by the Rest API remove this when Leader Checking is supported
         # by the REST API
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Start ONOS cli" )
         cliResult = main.TRUE
         for i in range( main.numCtrls ):
@@ -1173,6 +1173,39 @@
                                  onpass=main.assertReturnString,
                                  onfail=main.assertReturnString )
 
+        # main.step( "Protected: Add point intents between h1 and h9" )
+        # main.assertReturnString = "Assertion Result for protected point intent\n"
+        # senders = [
+        #     { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
+        # ]
+        # recipients = [
+        #     { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
+        # ]
+        # testResult = main.FALSE
+        # installResult = main.intentFunction.installPointIntent(
+        #     main,
+        #     name="Protected",
+        #     senders=senders,
+        #     recipients=recipients,
+        #     protected=True )
+        # 
+        # if installResult:
+        #     testResult = main.intentFunction.testPointIntent(
+        #         main,
+        #         name="Protected",
+        #         intentId=installResult,
+        #         senders=senders,
+        #         recipients=recipients,
+        #         sw1="s5",
+        #         sw2="s2",
+        #         protected=True,
+        #         expectedLink=18 )
+        #
+        # utilities.assert_equals( expect=main.TRUE,
+        #                          actual=testResult,
+        #                          onpass=main.assertReturnString,
+        #                          onfail=main.assertReturnString )
+
         main.step( "IPV4_2: Add point intents between h1 and h9" )
         main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
         senders = [
diff --git a/TestON/tests/FUNC/FUNCintentRest/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintentRest/dependencies/FuncIntentFunction.py
index 088d38d..8fa65f2 100755
--- a/TestON/tests/FUNC/FUNCintentRest/dependencies/FuncIntentFunction.py
+++ b/TestON/tests/FUNC/FUNCintentRest/dependencies/FuncIntentFunction.py
@@ -305,6 +305,7 @@
                         ethType="",
                         bandwidth="",
                         lambdaAlloc=False,
+                        protected=False,
                         ipProto="",
                         ipSrc="",
                         ipDst="",
@@ -394,6 +395,7 @@
                                             ethDst=dstMac,
                                             bandwidth=bandwidth,
                                             lambdaAlloc=lambdaAlloc,
+                                            protected=protected,
                                             ipProto=ipProto,
                                             ipSrc=ipSrc,
                                             ipDst=ipDst,
@@ -436,6 +438,7 @@
                      ethType="",
                      bandwidth="",
                      lambdaAlloc=False,
+                     protected=False,
                      ipProto="",
                      ipAddresses="",
                      tcp="",
@@ -575,6 +578,21 @@
             main.assertReturnString += 'Link Down Failed\n'
             testResult = main.FALSE
 
+        if protected:
+            # Check Connection
+            if utilities.retry(f=scapyCheckConnection, retValue=main.FALSE,
+                               args=(main, senderNames, recipientNames, vlanId, useTCP)):
+                main.assertReturnString += 'Link down Scapy Packet Received Passed\n'
+            else:
+                main.assertReturnString += 'Link down Scapy Packet Recieved Failed\n'
+                testResult = main.FALSE
+
+            if ProtectedIntentCheck(main):
+                main.assertReturnString += 'Protected Intent Check Passed\n'
+            else:
+                main.assertReturnString += 'Protected Intent Check Failed\n'
+                testResult = main.FALSE
+
         # Check intent state
         if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, intentId ), sleep=main.checkIntentSleep ):
             main.assertReturnString += 'Link Down Intent State Passed\n'
@@ -1731,3 +1749,11 @@
     else:
         return main.FALSE
     return main.TRUE
+
+def ProtectedIntentCheck( main ):
+    intent = main.RESTs[ 0 ].intents()
+    main.log.debug(intent)
+    main.stop()
+    if "Protection" in intent:
+        return main.TRUE
+    return main.FALSE
diff --git a/TestON/tests/FUNC/FUNCipv6Intent/FUNCipv6Intent.py b/TestON/tests/FUNC/FUNCipv6Intent/FUNCipv6Intent.py
index 6423ff4..d13762e 100755
--- a/TestON/tests/FUNC/FUNCipv6Intent/FUNCipv6Intent.py
+++ b/TestON/tests/FUNC/FUNCipv6Intent/FUNCipv6Intent.py
@@ -196,6 +196,14 @@
                                  onpass="Successfully installed ONOS package",
                                  onfail="Failed to install ONOS package" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for i in range( int( main.numCtrls ) ):
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         time.sleep( main.startUpSleep )
         main.step( "Starting ONOS service" )
         stopResult = main.TRUE
@@ -222,14 +230,6 @@
                                  onpass="ONOS service is ready",
                                  onfail="ONOS service did not start properly" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Start ONOS cli" )
         cliResult = main.TRUE
         for i in range( main.numCtrls ):
diff --git a/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py b/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py
index 8b145ab..7154a28 100644
--- a/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py
+++ b/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py
@@ -214,6 +214,14 @@
                                  onpass="Successfully installed ONOS package",
                                  onfail="Failed to install ONOS package" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for i in range( int( main.numCtrls ) ):
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         time.sleep( main.startUpSleep )
         main.step( "Starting ONOS service" )
         stopResult = main.TRUE
@@ -243,14 +251,6 @@
         # supported by the Rest API remove this when Leader Checking is supported
         # by the REST API
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Start ONOS cli" )
         cliResult = main.TRUE
         for i in range( main.numCtrls ):
diff --git a/TestON/tests/FUNC/FUNCoptical/FUNCoptical.py b/TestON/tests/FUNC/FUNCoptical/FUNCoptical.py
index c85d39e..08c0aaa 100644
--- a/TestON/tests/FUNC/FUNCoptical/FUNCoptical.py
+++ b/TestON/tests/FUNC/FUNCoptical/FUNCoptical.py
@@ -185,6 +185,14 @@
                                  onpass="Successfully installed ONOS package",
                                  onfail="Failed to install ONOS package" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for i in range( int( main.numCtrls ) ):
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         time.sleep( main.startUpSleep )
         main.step( "Starting ONOS service" )
         stopResult = main.TRUE
@@ -209,14 +217,6 @@
                                  onpass="ONOS service is ready on all nodes",
                                  onfail="ONOS service did not start properly on all nodes" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Start ONOS cli" )
         cliResult = main.TRUE
         for i in range( main.numCtrls ):
diff --git a/TestON/tests/FUNC/FUNCovsdbtest/FUNCovsdbtest.py b/TestON/tests/FUNC/FUNCovsdbtest/FUNCovsdbtest.py
index 894b96b..3563efb 100644
--- a/TestON/tests/FUNC/FUNCovsdbtest/FUNCovsdbtest.py
+++ b/TestON/tests/FUNC/FUNCovsdbtest/FUNCovsdbtest.py
@@ -130,6 +130,14 @@
                                  onpass="Successfully installed ONOS package",
                                  onfail="Failed to install ONOS package" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for i in range( int( main.numCtrls ) ):
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.nodes[ i ].ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         time.sleep( main.startUpSleep )
         main.step("Starting ONOS service")
         stopResult = main.TRUE
@@ -152,14 +160,6 @@
                                  onpass="ONOS service is ready on all nodes",
                                  onfail="ONOS service did not start properly on all nodes" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.nodes[ i ].ip_address )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Starting ONOS CLI sessions" )
         cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address )
         utilities.assert_equals( expect=main.TRUE, actual=cliResults,
diff --git a/TestON/tests/FUNC/FUNCvirNetNB/FUNCvirNetNB.py b/TestON/tests/FUNC/FUNCvirNetNB/FUNCvirNetNB.py
index 9545a4e..81eb698 100644
--- a/TestON/tests/FUNC/FUNCvirNetNB/FUNCvirNetNB.py
+++ b/TestON/tests/FUNC/FUNCvirNetNB/FUNCvirNetNB.py
@@ -144,6 +144,12 @@
                                 onfail="ONOS install failed" )
         time.sleep( main.startUpSleep )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.ONOSbench.onosSecureSSH( node=main.nodes[0].ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         main.step( "Checking if ONOS is up yet" )
 
         for i in range( 2 ):
@@ -155,12 +161,6 @@
                      onfail="ONOS startup failed" )
         time.sleep( main.startUpSleep )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.ONOSbench.onosSecureSSH( node=main.nodes[0].ip_address )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Starting ONOS CLI sessions" )
 
         print main.nodes[0].ip_address
diff --git a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
index fba0007..afd3f78 100644
--- a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
@@ -208,6 +208,14 @@
                                  onpass="ONOS install successful",
                                  onfail="ONOS install failed" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for node in main.nodes:
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         main.step( "Checking if ONOS is up yet" )
         for i in range( 2 ):
             onosIsupResult = main.TRUE
@@ -222,14 +230,6 @@
                                  onpass="ONOS startup successful",
                                  onfail="ONOS startup failed" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for node in main.nodes:
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Starting ONOS CLI sessions" )
         cliResults = main.TRUE
         threads = []
diff --git a/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py b/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
index 6f53489..0bc27d0 100644
--- a/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
+++ b/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
@@ -233,6 +233,14 @@
             main.cleanup()
             main.exit()
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for node in main.nodes:
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         main.step( "Checking if ONOS is up yet" )
         for i in range( 2 ):
             onosIsupResult = main.TRUE
@@ -247,14 +255,6 @@
                                  onpass="ONOS startup successful",
                                  onfail="ONOS startup failed" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for node in main.nodes:
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Starting ONOS CLI sessions" )
         cliResults = main.TRUE
         threads = []
diff --git a/TestON/tests/HA/HAkillNodes/HAkillNodes.py b/TestON/tests/HA/HAkillNodes/HAkillNodes.py
index a579cff..eb9ad75 100644
--- a/TestON/tests/HA/HAkillNodes/HAkillNodes.py
+++ b/TestON/tests/HA/HAkillNodes/HAkillNodes.py
@@ -240,6 +240,14 @@
             main.cleanup()
             main.exit()
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for node in main.nodes:
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         main.step( "Checking if ONOS is up yet" )
         for i in range( 2 ):
             onosIsupResult = main.TRUE
@@ -254,14 +262,6 @@
                                  onpass="ONOS startup successful",
                                  onfail="ONOS startup failed" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for node in main.nodes:
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Starting ONOS CLI sessions" )
         cliResults = main.TRUE
         threads = []
diff --git a/TestON/tests/HA/HAsanity/HAsanity.py b/TestON/tests/HA/HAsanity/HAsanity.py
index feb69bf..151547b 100644
--- a/TestON/tests/HA/HAsanity/HAsanity.py
+++ b/TestON/tests/HA/HAsanity/HAsanity.py
@@ -209,6 +209,14 @@
                                  onpass="ONOS install successful",
                                  onfail="ONOS install failed" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for node in main.nodes:
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         main.step( "Checking if ONOS is up yet" )
         for i in range( 2 ):
             onosIsupResult = main.TRUE
@@ -223,14 +231,6 @@
                                  onpass="ONOS startup successful",
                                  onfail="ONOS startup failed" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for node in main.nodes:
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Starting ONOS CLI sessions" )
         cliResults = main.TRUE
         threads = []
diff --git a/TestON/tests/HA/HAscaling/HAscaling.py b/TestON/tests/HA/HAscaling/HAscaling.py
index 2bc1d13..d4cf53d 100644
--- a/TestON/tests/HA/HAscaling/HAscaling.py
+++ b/TestON/tests/HA/HAscaling/HAscaling.py
@@ -273,6 +273,14 @@
                             path,
                             direction="to" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for node in main.nodes:
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         main.step( "Checking if ONOS is up yet" )
         for i in range( 2 ):
             onosIsupResult = main.TRUE
@@ -288,14 +296,6 @@
                                  onpass="ONOS startup successful",
                                  onfail="ONOS startup failed" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for node in main.nodes:
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Starting ONOS CLI sessions" )
         cliResults = main.TRUE
         threads = []
diff --git a/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py b/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
index 702b09e..9037002 100644
--- a/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
+++ b/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
@@ -198,6 +198,14 @@
                                  onpass="ONOS install successful",
                                  onfail="ONOS install failed" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for node in main.nodes:
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         main.step( "Checking if ONOS is up yet" )
         for i in range( 2 ):
             onosIsupResult = main.TRUE
@@ -212,14 +220,6 @@
                                  onpass="ONOS startup successful",
                                  onfail="ONOS startup failed" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for node in main.nodes:
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Starting ONOS CLI sessions" )
         cliResults = main.TRUE
         threads = []
diff --git a/TestON/tests/HA/HAstopNodes/HAstopNodes.py b/TestON/tests/HA/HAstopNodes/HAstopNodes.py
index ddf9b2a..ce38887 100644
--- a/TestON/tests/HA/HAstopNodes/HAstopNodes.py
+++ b/TestON/tests/HA/HAstopNodes/HAstopNodes.py
@@ -233,6 +233,14 @@
             main.cleanup()
             main.exit()
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for node in main.nodes:
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         main.step( "Checking if ONOS is up yet" )
         for i in range( 2 ):
             onosIsupResult = main.TRUE
@@ -247,14 +255,6 @@
                                  onpass="ONOS startup successful",
                                  onfail="ONOS startup failed" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for node in main.nodes:
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Starting ONOS CLI sessions" )
         cliResults = main.TRUE
         threads = []
diff --git a/TestON/tests/HA/HAswapNodes/HAswapNodes.py b/TestON/tests/HA/HAswapNodes/HAswapNodes.py
index 60dff34..082f831 100644
--- a/TestON/tests/HA/HAswapNodes/HAswapNodes.py
+++ b/TestON/tests/HA/HAswapNodes/HAswapNodes.py
@@ -267,6 +267,14 @@
                             path,
                             direction="to" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for node in main.nodes:
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         main.step( "Checking if ONOS is up yet" )
         for i in range( 2 ):
             onosIsupResult = main.TRUE
@@ -282,14 +290,6 @@
                                  onpass="ONOS startup successful",
                                  onfail="ONOS startup failed" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for node in main.nodes:
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Starting ONOS CLI sessions" )
         cliResults = main.TRUE
         threads = []
diff --git a/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py b/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py
index 50ca811..2915864 100644
--- a/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py
+++ b/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py
@@ -120,6 +120,9 @@
             main.ONOSbench.onosInstall( ONOSIp[node])
 
         for node in range(1, clusterCount + 1):
+            secureSshResult = main.ONOSbench.onosSecureSSH( ONOSIp[node] )
+
+        for node in range(1, clusterCount + 1):
             for i in range( 2 ):
                 isup = main.ONOSbench.isup( ONOSIp[node] )
                 if isup:
@@ -129,7 +132,6 @@
                 main.log.report( "ONOS " + str(node) + " didn't start!" )
 
         for node in range(1, clusterCount + 1):
-            secureSshResult = main.ONOSbench.onosSecureSSH( ONOSIp[node] )
             exec "a = main.ONOS%scli.startOnosCli" %str(node)
             a(ONOSIp[node])
 
diff --git a/TestON/tests/SCPF/SCPFhostLat/SCPFhostLat.py b/TestON/tests/SCPF/SCPFhostLat/SCPFhostLat.py
index 42159b4..6c382e4 100644
--- a/TestON/tests/SCPF/SCPFhostLat/SCPFhostLat.py
+++ b/TestON/tests/SCPF/SCPFhostLat/SCPFhostLat.py
@@ -167,16 +167,6 @@
                                      onpass="Test step PASS",
                                      onfail="Test step FAIL" )
             installResult = installResult and i_result
-        time.sleep( main.startUpSleep )
-        main.step( "Verify ONOS nodes UP status" )
-        statusResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "ONOS Node " + main.ONOSip[i] + " status:" )
-            onos_status = main.ONOSbench.onosStatus( node=main.ONOSip[i] )
-            utilities.assert_equals( expect=main.TRUE, actual=onos_status,
-                                     onpass="Test step PASS",
-                                     onfail="Test step FAIL" )
-            statusResult = ( statusResult and onos_status )
 
         main.step( "Set up ONOS secure SSH" )
         secureSshResult = main.TRUE
@@ -186,6 +176,31 @@
                                  onpass="Test step PASS",
                                  onfail="Test step FAIL" )
 
+        time.sleep( main.startUpSleep )
+        main.step( "Starting ONOS service" )
+        stopResult = main.TRUE
+        startResult = main.TRUE
+        onosIsUp = main.TRUE
+
+        for i in range( main.numCtrls ):
+            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+        if onosIsUp == main.TRUE:
+            main.log.report( "ONOS instance is up and ready" )
+        else:
+            main.log.report( "ONOS instance may not be up, stop and " +
+                             "start ONOS again " )
+            for i in range( main.numCtrls ):
+                stopResult = stopResult and \
+                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
+            for i in range( main.numCtrls ):
+                startResult = startResult and \
+                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
+        stepResult = onosIsUp and stopResult and startResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ONOS service is ready",
+                                 onfail="ONOS service did not start properly" )
+
         main.step( "Start ONOS CLI on all nodes" )
         cliResult = main.TRUE
         main.step(" Start ONOS cli using thread ")
diff --git a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py
index 42c3522..3e221a5 100644
--- a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py
+++ b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py
@@ -166,17 +166,6 @@
                                     onfail="Test step FAIL")
             installResult = installResult and i_result
 
-        main.step( "Verify ONOS nodes UP status" )
-        statusResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "ONOS Node " + main.ONOSip[i] + " status:" )
-            onos_status = main.ONOSbench.onosStatus(node=main.ONOSip[i])
-            utilities.assert_equals(expect=main.TRUE, actual=onos_status,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            statusResult = (statusResult and onos_status)
-        time.sleep(2)
-
         main.step( "Set up ONOS secure SSH" )
         secureSshResult = main.TRUE
         for i in range( int( main.numCtrls ) ):
@@ -185,6 +174,30 @@
                                  onpass="Test step PASS",
                                  onfail="Test step FAIL" )
 
+        time.sleep( main.startUpSleep )
+        main.step( "Starting ONOS service" )
+        stopResult = main.TRUE
+        startResult = main.TRUE
+        onosIsUp = main.TRUE
+        for i in range( main.numCtrls ):
+            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+        if onosIsUp == main.TRUE:
+            main.log.report( "ONOS instance is up and ready" )
+        else:
+            main.log.report( "ONOS instance may not be up, stop and " +
+                             "start ONOS again " )
+            for i in range( main.numCtrls ):
+                stopResult = stopResult and \
+                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
+            for i in range( main.numCtrls ):
+                startResult = startResult and \
+                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
+        stepResult = onosIsUp and stopResult and startResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ONOS service is ready",
+                                 onfail="ONOS service did not start properly" )
+
         main.step( "Start ONOS cli using thread" )
         startCliResult = main.TRUE
         pool = []
diff --git a/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.py b/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.py
index 1c04fd1..412ef29 100644
--- a/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.py
+++ b/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.py
@@ -164,16 +164,6 @@
                                     onfail="Test step FAIL")
             installResult = installResult and i_result
 
-        main.step("Verify ONOS nodes UP status")
-        statusResult = main.TRUE
-        for i in range(int(main.numCtrls)):
-            main.log.info("ONOS Node " + main.ONOSip[i] + " status:")
-            onos_status = main.ONOSbench.onosStatus(node=main.ONOSip[i])
-            utilities.assert_equals(expect=main.TRUE, actual=onos_status,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            statusResult = (statusResult and onos_status)
-
         main.step( "Set up ONOS secure SSH" )
         secureSshResult = main.TRUE
         for i in range( int( main.numCtrls ) ):
@@ -182,6 +172,30 @@
                                  onpass="Test step PASS",
                                  onfail="Test step FAIL" )
 
+        time.sleep( main.startUpSleep )
+        main.step( "Starting ONOS service" )
+        stopResult = main.TRUE
+        startResult = main.TRUE
+        onosIsUp = main.TRUE
+        for i in range( main.numCtrls ):
+            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+        if onosIsUp == main.TRUE:
+            main.log.report( "ONOS instance is up and ready" )
+        else:
+            main.log.report( "ONOS instance may not be up, stop and " +
+                             "start ONOS again " )
+            for i in range( main.numCtrls ):
+                stopResult = stopResult and \
+                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
+            for i in range( main.numCtrls ):
+                startResult = startResult and \
+                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
+        stepResult = onosIsUp and stopResult and startResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ONOS service is ready",
+                                 onfail="ONOS service did not start properly" )
+
         time.sleep(2)
         main.step("Start ONOS CLI on all nodes")
         cliResult = main.TRUE
diff --git a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.params b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.params
index 19d9806..2edd9a1 100644
--- a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.params
+++ b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.params
@@ -10,6 +10,16 @@
         <cellApps>drivers,null,intentperf,metrics</cellApps>
     </ENV>
 
+    <DEPENDENCY>
+        <FILE1>intentRerouteLatFuncs</FILE1>
+        <PATH>/tests/SCPF/SCPFintentRerouteLat/dependencies/</PATH>
+    </DEPENDENCY>
+
+    <SEARCHTERM>
+        <TopologyTime>TopologyManager</TopologyTime>
+        <InstallTime>INSTALLED</InstallTime>
+    </SEARCHTERM>
+
     <TEST>
         <skipCleanInstall>yes</skipCleanInstall>
         <warmUp>5</warmUp>
@@ -30,6 +40,7 @@
             <port>0000000000000003/2</port>>
         </end2>
     </TEST>
+
     <DATABASE>
         <dbName>/tmp/IntentRerouteLatDB</dbName>
         <dbFlowObj>/tmp/IntentRerouteLatDBWithFlowObj</dbFlowObj>
diff --git a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py
index e861f0c..5138950 100644
--- a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py
+++ b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py
@@ -14,11 +14,14 @@
     - The unit of the latency result is milliseconds
 """
 
+
 class SCPFintentRerouteLat:
     def __init__(self):
         self.default = ''
 
     def CASE0( self, main ):
+        import imp
+        import os
         '''
         - GIT
         - BUILDING ONOS
@@ -40,7 +43,8 @@
                                     actual=stepResult,
                                     onpass="Successfully checkout onos branch.",
                                     onfail="Failed to checkout onos branch. Exiting test...")
-            if not stepResult: main.exit()
+            if not stepResult:
+                main.exit()
 
             main.step("Git Pull on ONOS branch:" + gitBranch)
             stepResult = main.ONOSbench.gitPull()
@@ -56,11 +60,12 @@
                                     actual=stepResult,
                                     onpass="Successfully build onos.",
                                     onfail="Failed to build onos. Exiting test...")
-            if not stepResult: main.exit()
+            if not stepResult:
+                main.exit()
 
         else:
             main.log.warn("Skipped pulling onos and Skipped building ONOS")
-
+        main.onosIp = main.ONOSbench.getOnosIps()
         main.apps = main.params['ENV']['cellApps']
         main.BENCHUser = main.params['BENCH']['user']
         main.BENCHIp = main.params['BENCH']['ip1']
@@ -84,7 +89,7 @@
         main.deviceCount = int(main.params['TEST']['deviceCount'])
         main.end1 = main.params['TEST']['end1']
         main.end2 = main.params['TEST']['end2']
-
+        main.searchTerm = main.params['SEARCHTERM']
         if main.flowObj == "True":
             main.flowObj = True
             main.dbFileName = main.params['DATABASE']['dbFlowObj']
@@ -100,6 +105,11 @@
         main.log.info("Create Database file " + main.dbFileName)
         resultsDB = open(main.dbFileName, "w+")
         resultsDB.close()
+        file1 = main.params[ "DEPENDENCY" ][ "FILE1" ]
+        main.dependencyPath = os.path.dirname( os.getcwd() ) + main.params[ "DEPENDENCY" ][ "PATH" ]
+        main.intentRerouteLatFuncs = imp.load_source(file1, main.dependencyPath + file1 + ".py")
+
+        main.record = 0
 
     def CASE1( self, main ):
         '''
@@ -179,21 +189,35 @@
                                     onfail="Test step FAIL")
             installResult = installResult and i_result
 
-        main.step("Verify ONOS nodes UP status")
-        statusResult = main.TRUE
-        for i in range(int(main.numCtrls)):
-            main.log.info("ONOS Node " + main.ONOSip[i] + " status:")
-            onos_status = main.ONOSbench.onosStatus(node=main.ONOSip[i])
-            utilities.assert_equals(expect=main.TRUE, actual=onos_status,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            statusResult = (statusResult and onos_status)
-
         main.step( "Set up ONOS secure SSH" )
         secureSshResult = main.TRUE
         for i in range( int( main.numCtrls ) ):
             secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+            utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                    onpass="Test step PASS",
+                                    onfail="Test step FAIL" )
+
+        main.step( "Starting ONOS service" )
+        stopResult = main.TRUE
+        startResult = main.TRUE
+        onosIsUp = main.TRUE
+
+        for i in range( main.numCtrls ):
+            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+        if onosIsUp == main.TRUE:
+            main.log.report( "ONOS instance is up and ready" )
+        else:
+            main.log.report( "ONOS instance may not be up, stop and " +
+                             "start ONOS again " )
+
+            for i in range( main.numCtrls ):
+                stopResult = stopResult and \
+                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
+            for i in range( main.numCtrls ):
+                startResult = startResult and \
+                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
+        stepResult = onosIsUp and stopResult and startResult
+        utilities.assert_equals( expect=main.TRUE, actual=stepResult,
                                  onpass="Test step PASS",
                                  onfail="Test step FAIL" )
 
@@ -226,8 +250,10 @@
         if main.flowObj:
             main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
                                 "useFlowObjectives", value="true")
-        time.sleep(main.startUpSleep)
-
+        time.sleep( main.startUpSleep )
+        for i in range( int( main.numCtrls ) ):
+            main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.topology" )
+            main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.intent" )
         # Balance Master
         main.CLIs[0].balanceMasters()
         if len(main.ONOSip) > 1:
@@ -247,13 +273,19 @@
         for batchSize in main.intentsList:
             main.log.report("Intent Batch size: " + str(batchSize) + "\n      ")
             main.LatencyList = []
-            validRun = 0
-            invalidRun = 0
-            while validRun <= main.warmUp + main.sampleSize and invalidRun <= 20:
-                if validRun >= main.warmUp:
+            main.LatencyListTopoToFirstInstalled = []
+            main.LatencyListFirstInstalledToLastInstalled = []
+            main.validRun = 0
+            main.invalidRun = 0
+            # initial a variables to record the term of startLine in karaf logs of each node
+            main.totalLines = []
+            for i in range( main.numCtrls ):
+                main.totalLines.append( '' )
+            while main.validRun <= main.warmUp + main.sampleSize and main.invalidRun <= 20:
+                if main.validRun >= main.warmUp:
                     main.log.info("================================================")
-                    main.log.info("Starting test iteration: {} ".format(validRun - main.warmUp))
-                    main.log.info("Total iteration: {}".format(validRun + invalidRun))
+                    main.log.info("Starting test iteration: {} ".format( main.validRun - main.warmUp))
+                    main.log.info("Total iteration: {}".format( main.validRun + main.invalidRun))
                     main.log.info("================================================")
                 else:
                     main.log.info("====================Warm Up=====================")
@@ -264,7 +296,7 @@
 
                 # check links and flows
                 k = 0
-                verify = main.FALSE
+                main.verify = main.FALSE
                 linkCheck = 0
                 flowsCheck = 0
                 while k <= main.verifyAttempts:
@@ -274,31 +306,24 @@
                     flowsCheck = summary.get("flows")
                     if linkCheck == main.deviceCount * 2 and flowsCheck == batchSize * (main.deviceCount - 1 ):
                         main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck))
-                        verify = main.TRUE
+                        main.verify = main.TRUE
                         break
                     k += 1
-                if not verify:
+                if not main.verify:
                     main.log.warn("Links or flows number are not match!")
                     main.log.warn("links: {}, flows: {} ".format(linkCheck, flowsCheck))
                     # bring back topology
-                    main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
-                    time.sleep(1)
-                    main.CLIs[0].purgeWithdrawnIntents()
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0)
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false")
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
-                    if validRun >= main.warmUp:
-                        invalidRun += 1
+                    main.intentRerouteLatFuncs.bringBackTopology( main )
+                    if main.validRun >= main.warmUp:
+                        main.invalidRun += 1
                         continue
                     else:
-                        validRun += 1
+                        main.validRun += 1
                         continue
-
                 # Bring link down
                 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "down",
                                   timeout=main.timeout, showResponse=False)
-                verify = main.FALSE
+                main.verify = main.FALSE
                 k = 0
                 topoManagerLog = ""
                 while k <= main.verifyAttempts:
@@ -308,88 +333,42 @@
                     flowsCheck = summary.get("flows")
                     if linkCheck == (main.deviceCount - 1) * 2:
                         main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck))
-                        verify = main.TRUE
+                        main.verify = main.TRUE
                         break
                     k += 1
-                if not verify:
+                if not main.verify:
                     main.log.warn("Links number are not match in TopologyManager log!")
                     main.log.warn(topoManagerLog)
                     # bring back topology
-                    main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
-                    time.sleep(1)
-                    main.CLIs[0].purgeWithdrawnIntents()
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0)
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false")
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
-                    if validRun >= main.warmUp:
-                        invalidRun += 1
+                    main.intentRerouteLatFuncs.bringBackTopology( main )
+                    if main.validRun >= main.warmUp:
+                        main.invalidRun += 1
                         continue
                     else:
-                        validRun += 1
+                        main.validRun += 1
                         continue
-
-                try:
-                    # expect twice to clean the pexpect buffer
-                    main.ONOSbench.handle.sendline("")
-                    main.ONOSbench.handle.expect("\$")
-                    main.ONOSbench.handle.expect("\$")
-                    # send line by using bench, can't use driver because pexpect buffer problem
-                    cmd = "onos-ssh $OC1 cat /opt/onos/log/karaf.log | grep TopologyManager| tail -1"
-                    main.ONOSbench.handle.sendline(cmd)
-                    time.sleep(1)
-                    main.ONOSbench.handle.expect(":~")
-                    topoManagerLog = main.ONOSbench.handle.before
-                    topoManagerLogTemp = topoManagerLog.splitlines()
-                    # To make sure we get correct topology log
-                    for lines in topoManagerLogTemp:
-                        if "creationTime" in lines:
-                            topoManagerLog = lines
-                    main.log.info("Topology Manager log:")
-                    print(topoManagerLog)
-                    cutTimestamp = float(topoManagerLog.split("creationTime=")[1].split(",")[0])
-                except:
-                    main.log.error("Topology Log is not correct!")
-                    print(topoManagerLog)
-                    # bring back topology
-                    verify = main.FALSE
-                    main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
-                    time.sleep(1)
-                    main.CLIs[0].purgeWithdrawnIntents()
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0)
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false")
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
-                    if validRun >= main.warmUp:
-                        invalidRun += 1
+                # record the link romving time as the startLine
+                for i in range( main.numCtrls ):
+                    logNum = main.intentRerouteLatFuncs.checkLog( main, i )
+                    main.totalLines[i] = str(main.CLIs[ i ].getTimeStampFromLog( "last", "LINK_REMOVED", "time = ", " ", logNum=logNum ))
+                    main.log.info("Node " + str( i+1 ) + ": the start timestamp is " + main.totalLines[i] + " this iteration" )
+                #Calculate values
+                lastTopologyToFirstInstalled, firstInstalledToLastInstalled, totalTime = main.intentRerouteLatFuncs.getValues( main )
+                if totalTime == -1:
+                    if main.validRun >= main.warmUp:
+                        main.invalidRun += 1
                     else:
-                        validRun += 1
-                    # If we got wrong Topology log, we should skip this iteration, and continue for next one
+                        main.validRun += 1
                     continue
-
-                installedTemp = []
-                time.sleep(1)
-                for cli in main.CLIs:
-                    tempJson = json.loads(cli.intentsEventsMetrics())
-                    Installedtime = tempJson.get('intentInstalledTimestamp').get('value')
-                    installedTemp.append(float(Installedtime))
-                for i in range(0, len(installedTemp)):
-                    main.log.info("ONOS Node {} Installed Time stemp: {}".format((i + 1), installedTemp[i]))
-                maxInstallTime = float(max(installedTemp))
-                if validRun >= main.warmUp and verify:
-                    main.log.info("Installed time stemp: {0:f}".format(maxInstallTime))
-                    main.log.info("CutTimestamp: {0:f}".format(cutTimestamp))
-                    # Both timeStemps are milliseconds
-                    main.log.info("Latency: {0:f}".format(float(maxInstallTime - cutTimestamp)))
-                    main.LatencyList.append(float(maxInstallTime - cutTimestamp))
-                # We get valid latency, validRun + 1
-                validRun += 1
+                else:
+                    main.log.info("Get valid latency")
+                    main.validRun += 1
 
                 # Verify Summary after we bring up link, and withdrawn intents
                 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "up",
                                   timeout=main.timeout)
                 k = 0
-                verify = main.FALSE
+                main.verify = main.FALSE
                 linkCheck = 0
                 flowsCheck = 0
                 while k <= main.verifyAttempts:
@@ -403,31 +382,41 @@
                     intentCheck = summary.get("intents")
                     if linkCheck == main.deviceCount * 2 and flowsCheck == 0 and intentCheck == 0:
                         main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck))
-                        verify = main.TRUE
+                        main.verify = main.TRUE
                         break
                     k += 1
-                if not verify:
+                if not main.verify:
                     main.log.error("links, flows, or intents are not correct!")
                     main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck))
                     # bring back topology
-                    main.log.info("Bring back topology...")
-                    main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
-                    time.sleep(1)
-                    main.CLIs[0].purgeWithdrawnIntents()
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0)
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false")
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
-                    main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
+                    main.intentRerouteLatFuncs.bringBackTopology( main )
                     continue
+                main.log.info("total negative results num: " + str( main.record ) )
 
             aveLatency = 0
+            aveLatencyTopoToFirstInstalled = 0
+            aveLatencyFirstInstalledToLastInstalled = 0
+
             stdLatency = 0
-            aveLatency = numpy.average(main.LatencyList)
-            stdLatency = numpy.std(main.LatencyList)
-            main.log.report("Scale: " + str(main.numCtrls) + "  \tIntent batch: " + str(batchSize))
-            main.log.report("Latency average:................" + str(aveLatency))
-            main.log.report("Latency standard deviation:....." + str(stdLatency))
-            main.log.report("________________________________________________________")
+            stdLatencyTopoToFirstInstalled = 0
+            stdLatencyFirstInstalledToLastInstalled = 0
+
+            aveLatency = numpy.average( main.LatencyList )
+            aveLatencyTopoToFirstInstalled = numpy.average( main.LatencyListTopoToFirstInstalled )
+            aveLatencyFirstInstalledToLastInstalled = numpy.average( main.LatencyListFirstInstalledToLastInstalled )
+
+            stdLatency = numpy.std( main.LatencyList )
+            stdLatencyTopoToFirstInstalled = numpy.std( main.LatencyListTopoToFirstInstalled )
+            stdLatencyFirstInstalledToLastInstalled = numpy.std( main.LatencyListFirstInstalledToLastInstalled )
+
+            main.log.report( "Scale: " + str( main.numCtrls ) + "  \tIntent batch: " + str( batchSize ) )
+            main.log.report( "Total Latency average:................" + str( aveLatency ) )
+            main.log.report( "Latency standard deviation:..........." + str( stdLatency ) )
+            main.log.report( "Last Topology to first installed Latency average:................." + str( aveLatencyTopoToFirstInstalled ) )
+            main.log.report( "Last Topology to first installed Latency standard deviation:......" + str( stdLatencyTopoToFirstInstalled ) )
+            main.log.report( "First installed to last installed Latency average:................" + str( aveLatencyFirstInstalledToLastInstalled ) )
+            main.log.report( "First installed to last installed Latency standard deviation:....." + str( stdLatencyFirstInstalledToLastInstalled ) )
+            main.log.report( "________________________________________________________" )
 
             if not (numpy.isnan(aveLatency) or numpy.isnan(stdLatency)):
                 # check if got NaN for result
@@ -436,6 +425,10 @@
                 resultsDB.write(str(main.numCtrls) + ",")
                 resultsDB.write(str(batchSize) + ",")
                 resultsDB.write(str(aveLatency) + ",")
-                resultsDB.write(str(stdLatency) + "\n")
+                resultsDB.write(str(stdLatency) + ",")
+                resultsDB.write(str(aveLatencyTopoToFirstInstalled) + ",")
+                resultsDB.write(str(stdLatencyTopoToFirstInstalled) + ",")
+                resultsDB.write(str(aveLatencyFirstInstalledToLastInstalled) + ",")
+                resultsDB.write(str(stdLatencyFirstInstalledToLastInstalled) + "\n")
                 resultsDB.close()
         del main.scale[0]
diff --git a/TestON/tests/SCPF/SCPFintentRerouteLat/dependencies/intentRerouteLatFuncs.py b/TestON/tests/SCPF/SCPFintentRerouteLat/dependencies/intentRerouteLatFuncs.py
new file mode 100644
index 0000000..fc18cb6
--- /dev/null
+++ b/TestON/tests/SCPF/SCPFintentRerouteLat/dependencies/intentRerouteLatFuncs.py
@@ -0,0 +1,103 @@
+'''
+The functions for intentRerouteLat
+
+'''
+import numpy
+import time
+
+def _init_( self ):
+    self.default = ''
+
+def checkLog( main, nodeId ):
+    try:
+        logNames = main.ONOSbench.listLog( main.onosIp[ nodeId ] )
+        assert logNames is not None
+        if len( logNames ) >= 2:
+            return 2
+        return 1
+    except AssertionError:
+        main.log.error("There is no karaf log")
+        return -1
+
+def bringBackTopology( main ):
+    main.log.info( "Bring back topology " )
+    main.CLIs[ 0 ].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
+    time.sleep( 1 )
+    main.CLIs[ 0 ].purgeWithdrawnIntents()
+    main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "deviceCount", value=0)
+    main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "enabled", value="false")
+    main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
+    main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "enabled", value="true")
+
+def getValues( main ):
+    '''
+    Calculated the wanted values for intentRerouteTest
+
+    1. Get the first "last topology timestamp" from karaf.log in different node
+    2. Get the first "first intent installed timestamp" from  karaf log in different node
+    3. Get the last "last intent installed timestamp" from karaf log in different node
+
+    Return:
+        last_topology_to_first_installed: The time from the last topology to the first intent installed
+        first_installed_to_last_installed: Time time from the first topology to the last intent installed
+        totalTime: The time from the last topology to the last intent installed
+
+    '''
+    lastTopologyTimestamp = compareTimestamp( main, main.searchTerm[ "TopologyTime" ], "creationTime=", ",",  'last',func='min' )
+    firstIntentInstalledTimestamp = compareTimestamp( main, main.searchTerm[ "InstallTime" ], "time = ", " ",  'first',func='min' )
+    lastIntentInstalledTimestamp = compareTimestamp( main, main.searchTerm[ "InstallTime" ], "time = ", " ",  'last',func='max' )
+
+    if lastTopologyTimestamp == -1 or firstIntentInstalledTimestamp == -1 or lastIntentInstalledTimestamp == -1:
+        main.log.warn( "Can't get timestamp from karaf log! " )
+        bringBackTopology( main )
+        return -1, -1, -1
+
+    #calculate values
+    lastTopologyToFirstInstalled = firstIntentInstalledTimestamp - lastTopologyTimestamp
+    if lastTopologyToFirstInstalled < 0:
+        main.record = main.record + 1
+
+    firstInstalledToLastInstalled = lastIntentInstalledTimestamp - firstIntentInstalledTimestamp
+    totalTime = lastIntentInstalledTimestamp - lastTopologyTimestamp
+
+    if main.validRun >= main.warmUp and main.verify:
+        main.log.info( "Last topology time stamp: {0:f}".format( lastTopologyTimestamp ))
+        main.log.info( "First installed time stamp: {0:f}".format( firstIntentInstalledTimestamp ))
+        main.log.info( "Last installed time stamp: {0:f}".format( lastIntentInstalledTimestamp ))
+        main.log.info( "Last topology to first installed latency:{0:f}".format( lastTopologyToFirstInstalled ))
+        main.log.info( "First installed to last installed latency:{0:f}".format( firstInstalledToLastInstalled ))
+        main.log.info( "Overall latency:{0:f}".format( totalTime ))
+        main.LatencyList.append( totalTime )
+        main.LatencyListTopoToFirstInstalled.append( lastTopologyToFirstInstalled )
+        main.LatencyListFirstInstalledToLastInstalled.append( firstInstalledToLastInstalled )
+    return lastTopologyToFirstInstalled, firstInstalledToLastInstalled, totalTime
+
+def compareTimestamp( main, compareTerm, splitTerm_before, splitTerm_after, mode, func='max' ):
+    '''
+    Compare all the timestamps of compareTerm from different node.
+
+    func:
+        max: Compare which one is the biggest and retun it
+        min: Compare which one is the smallest and return it
+
+    return:
+        This function will return the biggest or smallest timestamps of the compareTerm.
+
+    '''
+    compareTermList = []
+    for i in range( main.numCtrls ):
+        timestamp = main.CLIs[ i ].getTimeStampFromLog( mode, compareTerm, splitTerm_before, splitTerm_after, startLine=main.totalLines[ i ], logNum=checkLog( main, i ) )
+        compareTermList.append( timestamp )
+    main.log.info("-----------------------------------------------")
+    for i in range( main.numCtrls ):
+        main.log.info( "ONOS Node {} {} {} time stamp: {}".format((i+1), mode, compareTerm, compareTermList[ i ]))
+    x = min( compareTermList )
+    main.log.info("-----------------------------------------------")
+    if x == -1:
+        main.log.warn( "Can't compare timestamps" )
+        return -1
+    else:
+        if func == 'max':
+            return max( compareTermList )
+        if func == 'min':
+            return min( compareTermList )
diff --git a/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py b/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py
index 59dc3a1..ae38911 100644
--- a/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py
+++ b/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py
@@ -168,17 +168,6 @@
                                     onfail="Test step FAIL")
             installResult = installResult and i_result
 
-        main.step( "Verify ONOS nodes UP status" )
-        statusResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "ONOS Node " + main.ONOSip[i] + " status:" )
-            onos_status = main.ONOSbench.onosStatus( node=main.ONOSip[i] )
-            utilities.assert_equals(expect=main.TRUE, actual=onos_status,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            statusResult = statusResult and onos_status
-        time.sleep(2)
-
         main.step( "Set up ONOS secure SSH" )
         secureSshResult = main.TRUE
         for i in range( int( main.numCtrls ) ):
@@ -187,6 +176,30 @@
                                  onpass="Test step PASS",
                                  onfail="Test step FAIL" )
 
+        time.sleep( main.startUpSleep )
+        main.step( "Starting ONOS service" )
+        stopResult = main.TRUE
+        startResult = main.TRUE
+        onosIsUp = main.TRUE
+        for i in range( main.numCtrls ):
+            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+        if onosIsUp == main.TRUE:
+            main.log.report( "ONOS instance is up and ready" )
+        else:
+            main.log.report( "ONOS instance may not be up, stop and " +
+                             "start ONOS again " )
+            for i in range( main.numCtrls ):
+                stopResult = stopResult and \
+                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
+            for i in range( main.numCtrls ):
+                startResult = startResult and \
+                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
+        stepResult = onosIsUp and stopResult and startResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ONOS service is ready",
+                                 onfail="ONOS service did not start properly" )
+
         main.step( "Start ONOS CLI on all nodes" )
         cliResult = main.TRUE
         main.step( " Start ONOS cli using thread " )
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py b/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py
index 1a1e38f..ea2a6dd 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py
@@ -219,6 +219,14 @@
                                  onpass="Successfully installed ONOS package",
                                  onfail="Failed to install ONOS package" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for i in range( int( main.numCtrls ) ):
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
         time.sleep( main.startUpSleep )
         main.step( "Starting ONOS service" )
         stopResult = main.TRUE
@@ -245,14 +253,6 @@
                                  onpass="ONOS service is ready",
                                  onfail="ONOS service did not start properly" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
         main.step( "Start ONOS cli" )
         cliResult = main.TRUE
         main.activeNodes = []
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py
index b94c292..f7a8782 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py
@@ -56,7 +56,7 @@
 
     '''
     try:
-        termInfo = main.CLIs[ index ].logSearch( term, mode=Mode)
+        termInfo = main.CLIs[ index ].logSearch( mode=Mode, searchTerm=term )
         termTime = getTimestampFromString( main, termInfo[ 0 ] )
         roleRequestTime = getRoleRequestTimeFromTshark( main )
         if termTime == -1 or roleRequestTime == -1:
@@ -87,8 +87,8 @@
 
     '''
     try:
-        termInfo1 = main.CLIs[ index ].logSearch( term1, mode=mode1 )
-        termInfo2 = main.CLIs[ index ].logSearch( term2, mode=mode2 )
+        termInfo1 = main.CLIs[ index ].logSearch( mode=mode1, searchTerm=term1 )
+        termInfo2 = main.CLIs[ index ].logSearch( mode=mode2, searchTerm=term2 )
         if funcMode == 'TD':
             startTime = getTimestampFromString( main, termInfo1[0] )
             endTime = getTimestampFromString ( main, termInfo2[0] )
@@ -449,6 +449,16 @@
         restartResult = main.FALSE
         main.log.error( main.topoName + ": Failed to install ONOS cluster" )
 
+    main.log.info( main.topoName + ": set up ONOS secure SSH" )
+    secureSshResult = []
+    for i in range( int( main.numCtrls ) ):
+        secureSshResult.append( main.onosSecureSSH( node=main.ONOSip[i] ) )
+    if all( result == main.TRUE for result in secureSshResult ):
+        main.log.info( main.topoName + ": Successfully set up ONOS secure SSH" )
+    else:
+        main.log.error( main.topoName + ": Failed to set up ONOS secure SSH" )
+        restartResult = main.FALSE
+
     for i in range( main.numCtrls ):
         onosIsUpResult.append( main.ONOSbench.isup( main.ONOSip[ i ] ) )
 
@@ -473,16 +483,6 @@
         else:
             main.log.error( main.topoName + ": Failed to start ONOS cluster" )
 
-    main.log.info( main.topoName + ": set up ONOS secure SSH" )
-    secureSshResult = []
-    for i in range( int( main.numCtrls ) ):
-        secureSshResult.append( main.onosSecureSSH( node=main.ONOSip[i] ) )
-    if all( result == main.TRUE for result in secureSshResult ):
-        main.log.info( main.topoName + ": Successfully set up ONOS secure SSH" )
-    else:
-        main.log.error( main.topoName + ": Failed to set up ONOS secure SSH" )
-        restartResult = main.FALSE
-
     main.log.info( main.topoName + ": Starting ONOS CLI" )
     cliResult = []
     for i in range( main.numCtrls ):
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
index a7a7bc5..46714ac 100644
--- a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
@@ -192,16 +192,6 @@
                                      onfail="Test step FAIL" )
             installResult = installResult and i_result
 
-        main.step( "Verify ONOS nodes UP status" )
-        statusResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "ONOS Node " + main.ONOSip[i] + " status:" )
-            onos_status = main.ONOSbench.onosStatus( node=main.ONOSip[i] )
-            utilities.assert_equals( expect=main.TRUE, actual=onos_status,
-                                     onpass="Test step PASS",
-                                     onfail="Test step FAIL" )
-            statusResult = ( statusResult and onos_status )
-
         main.step( "Set up ONOS secure SSH" )
         secureSshResult = main.TRUE
         for i in range( int( main.numCtrls ) ):
@@ -210,6 +200,30 @@
                                  onpass="Test step PASS",
                                  onfail="Test step FAIL" )
 
+        time.sleep( main.startUpSleep )
+        main.step( "Starting ONOS service" )
+        stopResult = main.TRUE
+        startResult = main.TRUE
+        onosIsUp = main.TRUE
+        for i in range( main.numCtrls ):
+            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+        if onosIsUp == main.TRUE:
+            main.log.report( "ONOS instance is up and ready" )
+        else:
+            main.log.report( "ONOS instance may not be up, stop and " +
+                             "start ONOS again " )
+            for i in range( main.numCtrls ):
+                stopResult = stopResult and \
+                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
+            for i in range( main.numCtrls ):
+                startResult = startResult and \
+                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
+        stepResult = onosIsUp and stopResult and startResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ONOS service is ready",
+                                 onfail="ONOS service did not start properly" )
+
         main.step( "Start ONOS CLI on all nodes" )
         cliResult = main.TRUE
         main.step(" Start ONOS cli using thread ")
diff --git a/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py b/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py
index 3fef087..46a5f47 100644
--- a/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py
+++ b/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py
@@ -171,16 +171,6 @@
                                     onfail="Test step FAIL")
             installResult = installResult and i_result
 
-        main.step("Verify ONOS nodes UP status")
-        statusResult = main.TRUE
-        for i in range(int(main.numCtrls)):
-            main.log.info("ONOS Node " + main.ONOSip[i] + " status:")
-            onos_status = main.ONOSbench.onosStatus(node=main.ONOSip[i])
-            utilities.assert_equals(expect=main.TRUE, actual=onos_status,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            statusResult = (statusResult and onos_status)
-
         main.step( "Set up ONOS secure SSH" )
         secureSshResult = main.TRUE
         for i in range( int( main.numCtrls ) ):
@@ -189,6 +179,30 @@
                                  onpass="Test step PASS",
                                  onfail="Test step FAIL" )
 
+        time.sleep( main.startUpSleep )
+        main.step( "Starting ONOS service" )
+        stopResult = main.TRUE
+        startResult = main.TRUE
+        onosIsUp = main.TRUE
+        for i in range( main.numCtrls ):
+            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+        if onosIsUp == main.TRUE:
+            main.log.report( "ONOS instance is up and ready" )
+        else:
+            main.log.report( "ONOS instance may not be up, stop and " +
+                             "start ONOS again " )
+            for i in range( main.numCtrls ):
+                stopResult = stopResult and \
+                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
+            for i in range( main.numCtrls ):
+                startResult = startResult and \
+                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
+        stepResult = onosIsUp and stopResult and startResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ONOS service is ready",
+                                 onfail="ONOS service did not start properly" )
+
         time.sleep(2)
         main.step("Start ONOS CLI on all nodes")
         cliResult = main.TRUE
diff --git a/TestON/tests/SCPF/SCPFswitchLat/dependencies/switchFunc.py b/TestON/tests/SCPF/SCPFswitchLat/dependencies/switchFunc.py
index 41a2fc4..78d0d37 100644
--- a/TestON/tests/SCPF/SCPFswitchLat/dependencies/switchFunc.py
+++ b/TestON/tests/SCPF/SCPFswitchLat/dependencies/switchFunc.py
@@ -15,7 +15,7 @@
         searchTerm: the key term of timestamp
 
     '''
-    lines = main.CLIs[ index ].logSearch( searchTerm, mode='last' )
+    lines = main.CLIs[ index ].logSearch( mode='last', searchTerm=searchTerm )
     try:
         assert lines != None
         logString = lines[ len ( lines ) - 1 ]
diff --git a/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.py b/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.py
index 0873626..1c19c30 100644
--- a/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.py
+++ b/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.py
@@ -57,6 +57,9 @@
         onos1InstallResult = main.ONOSbench.onosInstall( options = "-f",
                                                            node = ONOS1Ip )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
+
         main.step( "Checking if ONOS is up yet" )
         for i in range( 2 ):
             onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout = 420 )
@@ -65,9 +68,6 @@
         if not onos1Isup:
             main.log.report( "ONOS1 didn't start!" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
-
         cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
                 commandlineTimeout = 100, onosStartTimeout = 600 )
 
diff --git a/TestON/tests/USECASE/SDNIPperf/SDNIPperf.py b/TestON/tests/USECASE/SDNIPperf/SDNIPperf.py
index 4bfa244..9d6ae4a 100644
--- a/TestON/tests/USECASE/SDNIPperf/SDNIPperf.py
+++ b/TestON/tests/USECASE/SDNIPperf/SDNIPperf.py
@@ -56,6 +56,9 @@
         onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
                                                            node=ONOS1Ip )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
+
         main.step( "Checking if ONOS is up yet" )
         for i in range( 2 ):
             onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
@@ -64,9 +67,6 @@
         if not onos1Isup:
             main.log.report( "ONOS1 didn't start!" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
-
         cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
                 commandlineTimeout=100, onosStartTimeout=600)
 
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index 7ef28e6..08eb9c9 100755
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -8,7 +8,7 @@
 
 class Testcaselib:
 
-    useSSH=False
+    useSSH=True
 
     @staticmethod
     def initTest( main ):
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/cord_fabric.py b/TestON/tests/USECASE/SegmentRouting/dependencies/cord_fabric.py
index 6348632..2c91806 100755
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/cord_fabric.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/cord_fabric.py
@@ -2,8 +2,9 @@
 
 import os
 import re
+import math
 from optparse import OptionParser
-
+from ipaddress import IPv6Network, IPv4Network
 from mininet.net import Mininet
 from mininet.topo import Topo
 from mininet.node import RemoteController, UserSwitch, Host, OVSBridge
@@ -26,12 +27,77 @@
                        help='number of ONOS Instances, default=0, 0 means localhost, 1 will use OC1 and so on' )
     parser.add_option( '--vlan', dest='vlan', type='int', default=-1,
                        help='vid of cross connect, default=-1, -1 means utilize default value' )
+    parser.add_option( '--ipv6', action="store_true", dest='ipv6',
+                       help='hosts are capable to use also ipv6' )
     (options, args) = parser.parse_args( )
     return options, args
 
 
 opts, args = parseOptions( )
 
+IP6_SUBNET_CLASS = 120
+IP4_SUBNET_CLASS = 24
+
+class LeafAndSpine6( Topo ):
+    """
+    Create Leaf and Spine Topology for IPv4/IPv6 tests.
+    """
+    def __init__( self, spine=2, leaf=2, fanout=2, **opts ):
+        Topo.__init__( self, **opts )
+        spines          = {}
+        leafs           = {}
+        """
+        We calculate the offset from /120 and from /24 in order to have
+        a number of /120 and /24 subnets == leaf
+        """
+        offset          = int(math.ceil(math.sqrt( leaf )))
+        """
+        We calculate the subnets to use and set options
+        """
+        ipv6SubnetClass = unicode('2000::/%s' % (IP6_SUBNET_CLASS - offset))
+        ipv6Subnets     = list(IPv6Network(ipv6SubnetClass).subnets( new_prefix = IP6_SUBNET_CLASS ))
+        ipv4SubnetClass = unicode('10.0.0.0/%s' % (IP4_SUBNET_CLASS - offset))
+        ipv4Subnets     = list(IPv4Network(ipv4SubnetClass).subnets( new_prefix = IP4_SUBNET_CLASS ))
+        linkopts        = dict( bw=100 )
+        """
+        We create the spine switches
+        """
+        for s in range( spine ):
+            spines[ s ] = self.addSwitch( 'spine10%s' % (s + 1),
+                                          dpid="00000000010%s" % (s + 1) )
+        """
+        We create the leaf switches
+        """
+        for ls in range( leaf ):
+            leafs[ ls ] = self.addSwitch( 'leaf%s' % (ls + 1),
+                                          dpid="00000000000%s" % (1 + ls) )
+            ipv6Subnet  = ipv6Subnets[ ls ]
+            ipv6Hosts   = list(ipv6Subnet.hosts())
+            ipv4Subnet  = ipv4Subnets[ ls ]
+            ipv4Hosts   = list(ipv4Subnet.hosts())
+            """
+            We add the hosts
+            """
+            for f in range( fanout ):
+                ipv6 = ipv6Hosts[ f ]
+                ipv6Gateway = ipv6Hosts[ len( ipv6Hosts ) - 1 ]
+                ipv4 = ipv4Hosts[ f ]
+                ipv4Gateway = ipv4Hosts[ len( ipv4Hosts ) - 1 ]
+                host = self.addHost(
+                    name='h%s' % (ls * fanout + f + 1),
+                    cls=Ipv6Host,
+                    ip="%s/%s" %(ipv4, IP4_SUBNET_CLASS),
+                    gateway='%s' % ipv4Gateway,
+                    ipv6="%s/%s" %(ipv6, IP6_SUBNET_CLASS),
+                    ipv6Gateway="%s" % ipv6Gateway
+                    )
+                self.addLink( host, leafs[ ls ], **linkopts )
+            """
+            Connect leaf to all spines
+            """
+            for s in range( spine ):
+                switch = spines[ s ]
+                self.addLink( leafs[ ls ], switch, **linkopts )
 
 class LeafAndSpine( Topo ):
     def __init__( self, spine=2, leaf=2, fanout=2, **opts ):
@@ -92,6 +158,22 @@
         self.cmd( mtu )
         self.cmd( 'ip route add default via %s' % self.gateway )
 
+class Ipv6Host( IpHost ):
+    """
+    Abstraction to model an augmented host with a ipv6
+    functionalities as well
+    """
+    def __init__( self, name, *args, **kwargs ):
+        IpHost.__init__(self, name, *args, **kwargs)
+
+    def config( self, **kwargs ):
+        IpHost.config( self, **kwargs )
+        ipv6Cmd         = 'ifconfig %s-eth0 inet6 add %s' % (self.name, kwargs['ipv6'])
+        ipv6GatewayCmd  = 'ip -6 route add default via %s' % kwargs['ipv6Gateway']
+        ipv6MtuCmd      = 'ifconfig %s-eth0 inet6 mtu 1490' % (self.name)
+        self.cmd( ipv6Cmd )
+        self.cmd( ipv6GatewayCmd )
+        self.cmd( ipv6MtuCmd )
 
 class VLANHost( Host ):
     "Host connected to VLAN interface"
@@ -143,15 +225,34 @@
         link = self.mn.addLink( host, switch )
         host.config(**params)
 
+    def do_pingall6( self, line ):
+        "Ping6 between all hosts."
+        self.mn.pingAll6( line )
+
 def config( opts ):
     spine = opts.spine
     leaf = opts.leaf
     fanout = opts.fanout
     vlan = opts.vlan
+    ipv6 = opts.ipv6
     controllers = [ os.environ[ 'OC%s' % i ] for i in
                     range( 1, opts.onos + 1 ) ] if (opts.onos) else [
         '127.0.0.1' ]
-    topo = LeafAndSpine( spine=spine, leaf=leaf, fanout=fanout, vlan=vlan )
+    if not ipv6:
+        topo = LeafAndSpine(
+            spine=spine,
+            leaf=leaf,
+            fanout=fanout,
+            vlan=vlan,
+            )
+    else:
+        topo = LeafAndSpine6(
+            spine=spine,
+            leaf=leaf,
+            fanout=fanout,
+            vlan=vlan,
+            ipv6=ipv6
+            )
     net = Mininet( topo=topo, link=TCLink, build=False,
                    switch=UserSwitch, controller=None, autoSetMacs=True )
     i = 0
@@ -160,12 +261,12 @@
         i += 1;
     net.build( )
     net.start( )
-    out1 = net.get( 'out1' )
-    out1.cmd( "arp -s 10.0.9.254 10:00:00:00:00:01 -i %s " % (out1.intf()) )
-    CLI(net)
+    if not ipv6:
+        out1 = net.get( 'out1' )
+        out1.cmd( "arp -s 10.0.9.254 10:00:00:00:00:01 -i %s " % (out1.intf()) )
+    ExtendedCLI(net)
     net.stop( )
 
-
 if __name__ == '__main__':
     setLogLevel( 'info' )
     config( opts )
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py
index aa7f34a..4ca92c7 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py
@@ -157,13 +157,6 @@
                                  onpass="Install ONOS succeeded",
                                  onfail="Install ONOS failed" )
 
-        main.step( "Checking if ONOS is up yet" )
-        onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=onos1UpResult,
-                                 onpass="ONOS is up",
-                                 onfail="ONOS is NOT up" )
-
         main.step( "Set up ONOS secure SSH" )
         secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
         utilities.assert_equals( expect=main.TRUE,
@@ -171,6 +164,13 @@
                                  onpass="Set up ONOS secure SSH succeeded",
                                  onfail="Set up ONOS secure SSH failed " )
 
+        main.step( "Checking if ONOS is up yet" )
+        onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=onos1UpResult,
+                                 onpass="ONOS is up",
+                                 onfail="ONOS is NOT up" )
+
         main.step( "Checking if ONOS CLI is ready" )
         cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
                 commandlineTimeout=100, onosStartTimeout=600 )
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.py b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.py
index 253f58f..68ed759 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.py
@@ -140,6 +140,15 @@
                                  onpass="Install ONOS to nodes succeeded",
                                  onfail="Install ONOS to nodes failed" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
+        secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS2Ip )
+        secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS3Ip )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=secureSshResult,
+                                 onpass="Set up ONOS secure SSH succeeded",
+                                 onfail="Set up ONOS secure SSH failed " )
+
         main.step( "Checking if ONOS is up yet" )
         onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
         onos2UpResult = main.ONOSbench.isup( ONOS2Ip, timeout=420 )
@@ -150,15 +159,6 @@
                                  onpass="ONOS nodes are up",
                                  onfail="ONOS nodes are NOT up" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
-        secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS2Ip )
-        secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS3Ip )
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=secureSshResult,
-                                 onpass="Set up ONOS secure SSH succeeded",
-                                 onfail="Set up ONOS secure SSH failed " )
-
         main.step( "Checking if ONOS CLI is ready" )
         main.CLIs = []
         cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip,
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster_fsfw/USECASE_SdnipFunctionCluster_fsfw.py b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster_fsfw/USECASE_SdnipFunctionCluster_fsfw.py
index 8458b9a..d7c44c9 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster_fsfw/USECASE_SdnipFunctionCluster_fsfw.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster_fsfw/USECASE_SdnipFunctionCluster_fsfw.py
@@ -145,6 +145,15 @@
                                  onpass="Install ONOS to nodes succeeded",
                                  onfail="Install ONOS to nodes failed" )
 
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
+        secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS2Ip )
+        secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS3Ip )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=secureSshResult,
+                                 onpass="Set up ONOS secure SSH succeeded",
+                                 onfail="Set up ONOS secure SSH failed " )
+
         main.step( "Checking if ONOS is up yet" )
         onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
         onos2UpResult = main.ONOSbench.isup( ONOS2Ip, timeout=420 )
@@ -155,15 +164,6 @@
                                  onpass="ONOS nodes are up",
                                  onfail="ONOS nodes are NOT up" )
 
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
-        secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS2Ip )
-        secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS3Ip )
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=secureSshResult,
-                                 onpass="Set up ONOS secure SSH succeeded",
-                                 onfail="Set up ONOS secure SSH failed " )
-
         main.step( "Checking if ONOS CLI is ready" )
         main.CLIs = []
         cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip,
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.py b/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.py
index ab57821..3601489 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.py
@@ -146,13 +146,6 @@
                                  onpass="Install ONOS succeeded",
                                  onfail="Install ONOS failed" )
 
-        main.step( "Checking if ONOS is up yet" )
-        onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=onos1UpResult,
-                                 onpass="ONOS is up",
-                                 onfail="ONOS is NOT up" )
-
         main.step( "Set up ONOS secure SSH" )
         secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
         utilities.assert_equals( expect=main.TRUE,
@@ -160,6 +153,13 @@
                                  onpass="Set up ONOS secure SSH succeeded",
                                  onfail="Set up ONOS secure SSH failed " )
 
+        main.step( "Checking if ONOS is up yet" )
+        onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=onos1UpResult,
+                                 onpass="ONOS is up",
+                                 onfail="ONOS is NOT up" )
+
         main.step( "Checking if ONOS CLI is ready" )
         cliResult = main.ONOScli1.startOnosCli( ONOS1Ip,
                                                commandlineTimeout=100,
diff --git a/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.params b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.params
new file mode 100755
index 0000000..9d9bab2
--- /dev/null
+++ b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.params
@@ -0,0 +1,32 @@
+<PARAMS>
+
+    <testcases>1,2,3</testcases>
+
+    <num_controllers>3</num_controllers>
+
+    <DEPENDENCY>
+        <wrapper1>startUp</wrapper1>
+        <topology>~/onos/tools/test/topos/vpls.json</topology>
+    </DEPENDENCY>
+
+    <ENV>
+        <cellName>vpls</cellName>
+        <cellApps>drivers,openflow,vpls</cellApps>
+        <cellUser>sdn</cellUser>
+    </ENV>
+
+    <CTRL>
+        <port>6653</port>
+    </CTRL>
+
+    <vpls>
+        <name>org.onosproject.vpls</name>
+        <hosts>6</hosts>
+    </vpls>
+
+    <SLEEP>
+        <startup>10</startup>
+        <netcfg>10</netcfg>
+    </SLEEP>
+
+</PARAMS>
diff --git a/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py
new file mode 100755
index 0000000..d6c0403
--- /dev/null
+++ b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py
@@ -0,0 +1,370 @@
+# CASE1: Startup
+# CASE2: Load vpls topology and configurations from demo script
+# CASE3: Test CLI commands
+
+class VPLSBasic:
+    def __init__( self ):
+        self.default = ''
+
+    def CASE1( self, main ):
+        """
+        CASE1 is to compile ONOS and push it to the test machines
+
+        Startup sequence:
+        cell <name>
+        onos-verify-cell
+        NOTE: temporary - onos-remove-raft-logs
+        onos-uninstall
+        start mininet
+        git pull
+        mvn clean install
+        onos-package
+        onos-install -f
+        onos-wait-for-start
+        start cli sessions
+        start tcpdump
+        """
+        import imp
+        import time
+        import json
+        main.case( "Setting up test environment" )
+        main.caseExplanation = "Setup the test environment including " +\
+                                "installing ONOS, starting Mininet and ONOS" +\
+                                "cli sessions."
+
+        # load some variables from the params file
+        cellName = main.params[ 'ENV' ][ 'cellName' ]
+
+        main.numCtrls = int( main.params[ 'num_controllers' ] )
+
+        ofPort = main.params[ 'CTRL' ][ 'port' ]
+
+        main.CLIs = []
+        main.RESTs = []
+        main.nodes = []
+        ipList = []
+        for i in range( 1, main.numCtrls + 1 ):
+            try:
+                main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+                main.RESTs.append( getattr( main, 'ONOSrest' + str( i ) ) )
+                main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+                ipList.append( main.nodes[ -1 ].ip_address )
+            except AttributeError:
+                break
+
+        main.step( "Create cell file" )
+        cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
+        main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
+                                       main.Mininet1.ip_address,
+                                       cellAppString, ipList )
+        main.step( "Applying cell variable to environment" )
+        cellResult = main.ONOSbench.setCell( cellName )
+        verifyResult = main.ONOSbench.verifyCell()
+
+        main.log.info( "Uninstalling ONOS" )
+        for node in main.nodes:
+            main.ONOSbench.onosUninstall( node.ip_address )
+
+        # Make sure ONOS is DEAD
+        main.log.info( "Killing any ONOS processes" )
+        killResults = main.TRUE
+        for node in main.nodes:
+            killed = main.ONOSbench.onosKill( node.ip_address )
+            killResults = killResults and killed
+
+        cleanInstallResult = main.TRUE
+
+        main.step( "Starting Mininet" )
+        # scp topo file to mininet
+        # TODO: move to params?
+        topoName = "vpls"
+        topoFile = "vpls.py"
+        filePath = main.ONOSbench.home + "/tools/test/topos/"
+        main.ONOSbench.scp( main.Mininet1,
+                            filePath + topoFile,
+                            main.Mininet1.home,
+                            direction="to" )
+        topo = " --custom " + main.Mininet1.home + topoFile + " --topo " + topoName
+        args = " --switch ovs,protocols=OpenFlow13 --controller=remote"
+        for node in main.nodes:
+            args += ",ip=" + node.ip_address
+        mnCmd = "sudo mn" + topo + args
+        mnResult = main.Mininet1.startNet( mnCmd=mnCmd )
+        utilities.assert_equals( expect=main.TRUE, actual=mnResult,
+                                 onpass="Mininet Started",
+                                 onfail="Error starting Mininet" )
+
+        main.ONOSbench.getVersion( report=True )
+
+        main.step( "Creating ONOS package" )
+        packageResult = main.ONOSbench.buckBuild()
+        utilities.assert_equals( expect=main.TRUE, actual=packageResult,
+                                 onpass="ONOS package successful",
+                                 onfail="ONOS package failed" )
+
+        main.step( "Installing ONOS package" )
+        onosInstallResult = main.TRUE
+        for node in main.nodes:
+            tmpResult = main.ONOSbench.onosInstall( options="-f",
+                                                    node=node.ip_address )
+            onosInstallResult = onosInstallResult and tmpResult
+        utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
+                                 onpass="ONOS install successful",
+                                 onfail="ONOS install failed" )
+
+        main.step( "Set up ONOS secure SSH" )
+        secureSshResult = main.TRUE
+        for node in main.nodes:
+            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
+                                 onpass="Test step PASS",
+                                 onfail="Test step FAIL" )
+
+        main.step( "Checking if ONOS is up yet" )
+        for i in range( 2 ):
+            onosIsupResult = main.TRUE
+            for node in main.nodes:
+                started = main.ONOSbench.isup( node.ip_address )
+                if not started:
+                    main.log.error( node.name + " hasn't started" )
+                onosIsupResult = onosIsupResult and started
+            if onosIsupResult == main.TRUE:
+                break
+        utilities.assert_equals( expect=main.TRUE, actual=onosIsupResult,
+                                 onpass="ONOS startup successful",
+                                 onfail="ONOS startup failed" )
+
+        main.step( "Starting ONOS CLI sessions" )
+        cliResults = main.TRUE
+        threads = []
+        for i in range( main.numCtrls ):
+            t = main.Thread( target=main.CLIs[i].startOnosCli,
+                             name="startOnosCli-" + str( i ),
+                             args=[main.nodes[i].ip_address] )
+            threads.append( t )
+            t.start()
+
+        for t in threads:
+            t.join()
+            cliResults = cliResults and t.result
+        utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+                                 onpass="ONOS cli startup successful",
+                                 onfail="ONOS cli startup failed" )
+
+        main.activeNodes = [ i for i in range( 0, len( main.CLIs ) ) ]
+
+        main.step( "Activate apps defined in the params file" )
+        # get data from the params
+        apps = main.params.get( 'apps' )
+        if apps:
+            apps = apps.split(',')
+            main.log.warn( apps )
+            activateResult = True
+            for app in apps:
+                main.CLIs[ 0 ].app( app, "Activate" )
+            # TODO: check this worked
+            time.sleep( SLEEP )  # wait for apps to activate
+            for app in apps:
+                state = main.CLIs[ 0 ].appStatus( app )
+                if state == "ACTIVE":
+                    activateResult = activeResult and True
+                else:
+                    main.log.error( "{} is in {} state".format( app, state ) )
+                    activeResult = False
+            utilities.assert_equals( expect=True,
+                                     actual=activateResult,
+                                     onpass="Successfully activated apps",
+                                     onfail="Failed to activate apps" )
+        else:
+            main.log.warn( "No apps were specified to be loaded after startup" )
+
+        main.step( "Set ONOS configurations" )
+        config = main.params.get( 'ONOS_Configuration' )
+        if config:
+            main.log.debug( config )
+            checkResult = main.TRUE
+            for component in config:
+                for setting in config[component]:
+                    value = config[component][setting]
+                    check = main.CLIs[ 0 ].setCfg( component, setting, value )
+                    main.log.info( "Value was changed? {}".format( main.TRUE == check ) )
+                    checkResult = check and checkResult
+            utilities.assert_equals( expect=main.TRUE,
+                                     actual=checkResult,
+                                     onpass="Successfully set config",
+                                     onfail="Failed to set config" )
+        else:
+            main.log.warn( "No configurations were specified to be changed after startup" )
+
+        main.step( "App Ids check" )
+        appCheck = main.TRUE
+        threads = []
+        for i in main.activeNodes:
+            t = main.Thread( target=main.CLIs[i].appToIDCheck,
+                             name="appToIDCheck-" + str( i ),
+                             args=[] )
+            threads.append( t )
+            t.start()
+
+        for t in threads:
+            t.join()
+            appCheck = appCheck and t.result
+        if appCheck != main.TRUE:
+            main.log.warn( main.CLIs[0].apps() )
+            main.log.warn( main.CLIs[0].appIDs() )
+        utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+                                 onpass="App Ids seem to be correct",
+                                 onfail="Something is wrong with app Ids" )
+
+    def CASE2( self, main ):
+        """
+        Load and test vpls configurations from json configuration file
+        """
+        import os.path
+        from tests.USECASE.VPLS.dependencies import vpls
+
+        pprint = main.ONOSrest1.pprint
+        hosts = int( main.params['vpls']['hosts'] )
+        SLEEP = int( main.params['SLEEP']['netcfg'] )
+
+        main.step( "Discover hosts using pings" )
+        for i in range( 1, hosts + 1 ):
+            src = "h" + str( i )
+            for j in range( 1, hosts + 1 ):
+                if j == i:
+                    continue
+                dst = "h" + str( j )
+            pingResult = main.Mininet1.pingHost( SRC=src, TARGET=dst )
+
+        main.step( "Load VPLS configurations" )
+        # TODO: load from params
+        fileName = main.params['DEPENDENCY']['topology']
+        app = main.params['vpls']['name']
+        # TODO make this a function?
+        main.ONOSbench.handle.sendline( "onos-netcfg $OC1 " + fileName )
+        # Time for netcfg to load data
+        time.sleep( SLEEP )
+        # 'Master' copy of test configuration
+        try:
+            with open( os.path.expanduser( fileName ) ) as dataFile:
+                originalCfg = json.load( dataFile )
+                main.vplsConfig = originalCfg['apps'].get( app ).get( 'vpls' ).get( 'vplsList')
+        except Exception as e:
+            main.log.error( "Error loading config file: {}".format( e ) )
+        if main.vplsConfig:
+            result = True
+        else:
+            result = False
+        utilities.assert_equals( expect=True,
+                                 actual=result,
+                                 onpass="Loaded vpls configuration",
+                                 onfail="Failed to load vpls configuration" )
+
+        main.step( "Check interface configurations" )
+        result = False
+        getPorts = main.ONOSrest1.getNetCfg( subjectClass="ports" )
+        onosCfg = pprint( getPorts )
+        sentCfg = pprint( originalCfg.get( "ports" ) )
+
+        if onosCfg == sentCfg:
+            main.log.info( "ONOS interfaces NetCfg matches what was sent" )
+            result = True
+        else:
+            main.log.error( "ONOS interfaces NetCfg doesn't match what was sent" )
+            main.log.debug( "ONOS config: {}".format( onosCfg ) )
+            main.log.debug( "Sent config: {}".format( sentCfg ) )
+        utilities.assert_equals( expect=True,
+                                 actual=result,
+                                 onpass="Net Cfg added for interfaces",
+                                 onfail="Net Cfg not added for interfaces" )
+
+        # Run a bunch of checks to verify functionality based on configs
+        vpls.verify( main )
+
+    def CASE3( self, main ):
+        """
+        Test VPLS cli commands
+        High level steps:
+            remove interface from a network
+            Clean configs
+            create vpls network
+            add interfaces to a network
+            add encap
+            change encap
+            remove encap
+            list?
+        """
+        from tests.USECASE.VPLS.dependencies import vpls
+        SLEEP = int( main.params['SLEEP']['netcfg'] )
+        pprint = main.ONOSrest1.pprint
+
+        main.step( "Remove an interface from a vpls network" )
+        main.CLIs[0].vplsRemIface( 'VPLS1', 'h1' )
+        time.sleep( SLEEP )
+        #update master config json
+        for network in main.vplsConfig:
+            if network.get( 'name' ) == 'VPLS1':
+                ifaces = network.get( 'interfaces' )
+                ifaces.remove('h1')
+        vpls.verify( main )
+
+        main.step( "Clean all vpls configurations" )
+        main.CLIs[0].vplsClean()
+        time.sleep( SLEEP )
+        main.vplsConfig = []
+        vpls.verify( main )
+
+        main.step( "Create a new vpls network" )
+        name = "Network1"
+        main.CLIs[0].vplsCreate( name )
+        time.sleep( SLEEP )
+        network1 = { 'name': name, 'interfaces': [], 'encapsulation': 'NONE' }
+        main.vplsConfig.append( network1 )
+        vpls.verify( main )
+
+        main.step( "Add interfaces to the network" )
+        main.CLIs[0].vplsAddIface( name, "h1" )
+        main.CLIs[0].vplsAddIface( name, "h5" )
+        main.CLIs[0].vplsAddIface( name, "h4" )
+        time.sleep( SLEEP )
+        for network in main.vplsConfig:
+            if network.get( 'name' ) == name:
+                ifaces = network.get( 'interfaces' )
+                ifaces.append( 'h1' )
+                ifaces.append( 'h4' )
+                ifaces.append( 'h5' )
+                network[ 'interfaces' ] = ifaces
+        vpls.verify( main )
+
+        main.step( "Add MPLS encapsulation to a vpls network" )
+        encapType = "MPLS"
+        main.CLIs[0].vplsSetEncap( name, encapType )
+        for network in main.vplsConfig:
+            if network.get( 'name' ) == name:
+                network['encapsulation'] = encapType
+        time.sleep( SLEEP )
+        vpls.verify( main )
+
+        main.step( "Change an encapsulation type" )
+        encapType = "VLAN"
+        main.CLIs[0].vplsSetEncap( name, encapType )
+        for network in main.vplsConfig:
+            if network.get( 'name' ) == name:
+                network['encapsulation'] = encapType
+        time.sleep( SLEEP )
+        vpls.verify( main )
+
+        main.step( "Remove encapsulation" )
+        encapType = "NONE"
+        main.CLIs[0].vplsSetEncap( name, encapType )
+        for network in main.vplsConfig:
+            if network.get( 'name' ) == name:
+                network['encapsulation'] = encapType
+        time.sleep( SLEEP )
+        vpls.verify( main )
+
+        main.step( "Clean all vpls configurations" )
+        main.CLIs[0].vplsClean()
+        time.sleep( SLEEP )
+        main.vplsConfig = []
+        vpls.verify( main )
diff --git a/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.topo b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.topo
new file mode 100755
index 0000000..e9a1f8e
--- /dev/null
+++ b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.topo
@@ -0,0 +1,115 @@
+<TOPOLOGY>
+    <COMPONENT>
+
+        <ONOSbench>
+            <host>localhost</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>1</connect_order>
+            <COMPONENTS>
+                <nodes>1</nodes>
+            </COMPONENTS>
+        </ONOSbench>
+
+        <ONOScli1>
+            <host>localhost</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosCliDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli1>
+
+        <ONOScli2>
+            <host>localhost</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosCliDriver</type>
+            <connect_order>3</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli2>
+
+        <ONOScli3>
+            <host>localhost</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosCliDriver</type>
+            <connect_order>4</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli3>
+
+        <ONOS1>
+            <host>OC1</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>9</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS1>
+
+        <ONOS2>
+            <host>OC2</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>10</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS2>
+
+        <ONOS3>
+            <host>OC3</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>11</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS3>
+
+        <ONOSrest1>
+            <host>OC1</host>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSrest1>
+
+        <ONOSrest2>
+            <host>OC2</host>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>3</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSrest2>
+
+        <ONOSrest3>
+            <host>OC3</host>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>4</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSrest3>
+
+
+        <Mininet1>
+            <host>OCN</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>MininetCliDriver</type>
+            <connect_order>7</connect_order>
+            <COMPONENTS>
+                <home>~/mininet/custom/</home>
+            </COMPONENTS>
+        </Mininet1>
+
+    </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/USECASE/VPLS/VPLSBasic/__init__.py b/TestON/tests/USECASE/VPLS/VPLSBasic/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/USECASE/VPLS/VPLSBasic/__init__.py
diff --git a/TestON/tests/USECASE/VPLS/VPLSBasic/dependencies/__init__.py b/TestON/tests/USECASE/VPLS/VPLSBasic/dependencies/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/USECASE/VPLS/VPLSBasic/dependencies/__init__.py
diff --git a/TestON/tests/USECASE/VPLS/__init__.py b/TestON/tests/USECASE/VPLS/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/USECASE/VPLS/__init__.py
diff --git a/TestON/tests/USECASE/VPLS/dependencies/__init__.py b/TestON/tests/USECASE/VPLS/dependencies/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/USECASE/VPLS/dependencies/__init__.py
diff --git a/TestON/tests/USECASE/VPLS/dependencies/vpls.py b/TestON/tests/USECASE/VPLS/dependencies/vpls.py
new file mode 100644
index 0000000..8dfdd46
--- /dev/null
+++ b/TestON/tests/USECASE/VPLS/dependencies/vpls.py
@@ -0,0 +1,144 @@
+"""
+Functions for the vpls tests
+"""
+import time
+import json
+
+def sanitizeConfig( config ):
+    """
+    Take a python json object for vpls config and normalize it.
+    Things it does:
+        Converts all strings to the same format
+        Make sure each network has an encapsulation key:value
+        Makes sure encapsulation type is all uppercase
+        Make sure an empty list of interfaces is formated consistently
+        Sorts the list of interfaces
+    """
+    # Convert to same string formats
+    config = json.loads( json.dumps( config ) )
+    for network in config:
+        encap = network.get( 'encapsulation', None )
+        if encap is None:
+            encap = "NONE"
+        network[ 'encapsulation' ] = encap.upper()
+        ifaces = network.get( 'interfaces' )
+        if ifaces == ['']:
+            ifaces = []
+        else:
+            ifaces = sorted( ifaces )
+            network['interfaces'] = ifaces
+    return config
+
+def verify( main ):
+    """
+    Runs some tests to verify the vpls configurations.
+        - Compare sent vpls network configuration to what is stored in each:
+            - ONOS network configuration
+            - ONOS VPLS application configuration
+        - Ping between each pair of hosts to check connectivity
+
+    NOTE: This requires the expected/sent network config json for the vpls
+          application be stored in main.vplsConfig
+    """
+    # Variables
+    app = main.params['vpls']['name']
+    pprint = main.ONOSrest1.pprint
+    SLEEP = int( main.params['SLEEP']['netcfg'] )
+
+    main.step( "Check network configurations for vpls application" )
+    clusterResult = True
+    for node in main.RESTs:
+        result = False
+        getVPLS = node.getNetCfg( subjectClass="apps",
+                                  subjectKey=app )
+        onosCfg = json.loads( getVPLS ).get( 'vpls' ).get( 'vplsList' )
+        onosCfg = pprint( sanitizeConfig( onosCfg ) )
+        sentCfg = pprint( sanitizeConfig( main.vplsConfig ) )
+        result = onosCfg == sentCfg
+        if result:
+            main.log.info( "ONOS NetCfg matches what was sent" )
+        else:
+            clusterResult = False
+            main.log.error( "ONOS NetCfg doesn't match what was sent" )
+            main.log.debug( "ONOS config: {}".format( onosCfg ) )
+            main.log.debug( "Sent config: {}".format( sentCfg ) )
+    utilities.assert_equals( expect=True,
+                             actual=clusterResult,
+                             onpass="Net Cfg added for vpls",
+                             onfail="Net Cfg not added for vpls" )
+
+    main.step( "Check vpls app configurations" )
+    clusterResult = True
+    for node in main.CLIs:
+        result = False
+        #TODO Read from vpls show and match to pushed json
+        vpls = node.parseVplsShow()
+        parsedVpls = pprint( sanitizeConfig( vpls ) )
+        sentVpls = pprint( sanitizeConfig( main.vplsConfig ) )
+        result = parsedVpls == sentVpls
+        if result:
+            main.log.info( "VPLS config matches sent NetCfg" )
+        else:
+            clusterResult = False
+            main.log.error( "VPLS config doesn't match sent NetCfg" )
+            main.log.debug( "ONOS config: {}".format( parsedVpls ) )
+            main.log.debug( "Sent config: {}".format( sentVpls ) )
+    utilities.assert_equals( expect=True,
+                             actual=clusterResult,
+                             onpass="VPLS successfully configured",
+                             onfail="VPLS not configured correctly" )
+
+    # FIXME This doesn't work, some will be withdrawn if interfaces are removed
+    # TODO: if encapsulation is set, look for that
+    # TODO: can we look at the intent keys?
+    """
+    main.step( "Check intent states" )
+    # Print the intent states
+    intents = main.CLIs[0].intents()
+    count = 0
+    while count <= 5:
+        installedCheck = True
+        try:
+            for intent in json.loads( intents ):
+                state = intent.get( 'state', None )
+                if "INSTALLED" not in state:
+                    installedCheck = False
+        except ( ValueError, TypeError ):
+            main.log.exception( "Error parsing intents" )
+        if installedCheck:
+            break
+        count += 1
+    utilities.assert_equals( expect=True,
+                             actual=installedCheck ,
+                             onpass="All Intents in installed state",
+                             onfail="Not all Intents in installed state" )
+    """
+
+    main.step( "Check connectivity" )
+    connectivityCheck = True
+    hosts = int( main.params['vpls']['hosts'] )
+    networks = []
+    for network in main.vplsConfig:
+        nodes = network.get( 'interfaces', None )
+        if nodes:
+            networks.append( nodes )
+    for i in range( 1, hosts + 1 ):
+        src = "h" + str( i )
+        for j in range( 1, hosts + 1 ):
+            if j == i:
+                continue
+            dst = "h" + str( j )
+            pingResult = main.Mininet1.pingHost( SRC=src, TARGET=dst )
+            expected = main.FALSE
+            for network in networks:
+                if src in network and dst in network:
+                    expected = main.TRUE
+                    break
+            if pingResult != expected:
+                connectivityCheck = False
+                main.log.error( "%s <-> %s: %s; Expected: %s" %
+                               ( src, dst, pingResult, expected ) )
+    utilities.assert_equals( expect=True,
+                             actual=connectivityCheck,
+                             onpass="Connectivity is as expected",
+                             onfail="Connectivity is not as expected" )