Fixes for new jenkins environment and other tweeks

    - Fix ERROR message if there are no traffic components to cleanup
    - Use full path for "sudo ip" command
    - Fix missing testcase declarations
    - Make sure we creat dst host components in topology.ping()

Change-Id: Ie01ed72f26fa4c3187f61fefa63f4a791d77b88d
diff --git a/TestON/drivers/common/cli/hostdriver.py b/TestON/drivers/common/cli/hostdriver.py
index a4ab31c..5bfe274 100644
--- a/TestON/drivers/common/cli/hostdriver.py
+++ b/TestON/drivers/common/cli/hostdriver.py
@@ -248,7 +248,7 @@
             main.log.error( self.name + ":     " + self.handle.before )
             return main.FALSE
 
-    def addRouteToHost( self, route, gw, interface=None, sudoRequired=True, purgeOnDisconnect=True ):
+    def addRouteToHost( self, route, gw, interface=None, sudoRequired=True, purgeOnDisconnect=True, cmdPath='/sbin/ip' ):
         """
         Adds a static route to the host
         Arguments:
@@ -260,7 +260,11 @@
         * purgeOnDisconnect - Boolean, remove this route before disconnecting from component
         """
         try:
-            cmd = "ip route add %s via %s" % ( route, gw )
+            if cmdPath:
+                cmd = cmdPath
+            else:
+                cmd = "ip"
+            cmd += " route add %s via %s" % ( route, gw )
             if sudoRequired:
                 cmd = "sudo %s" % cmd
             if interface:
@@ -300,7 +304,7 @@
             main.log.error( self.name + ":     " + self.handle.before )
             return main.FALSE
 
-    def deleteRoute( self, route, gw, interface=None, sudoRequired=True ):
+    def deleteRoute( self, route, gw, interface=None, sudoRequired=True, cmdPath='/sbin/ip'  ):
         """
         Deletess a static route from the host
         Arguments:
@@ -311,7 +315,11 @@
         * sudoRequired - Boolean, whether sudo is needed for this command, defaults to True
         """
         try:
-            cmd = "ip route del %s via %s" % ( route, gw )
+            if cmdPath:
+                cmd = cmdPath
+            else:
+                cmd = "ip"
+            cmd += " route del %s via %s" % ( route, gw )
             if sudoRequired:
                 cmd = "sudo %s" % cmd
             if interface:
diff --git a/TestON/drivers/common/clidriver.py b/TestON/drivers/common/clidriver.py
index 7d306b9..ce32128 100644
--- a/TestON/drivers/common/clidriver.py
+++ b/TestON/drivers/common/clidriver.py
@@ -91,6 +91,7 @@
                                       'Permission denied, please try again.',
                                       self.prompt ],
                                     120 )
+            self.log( str( self.handle.before ) + str( self.handle.after ) )
             if i == 0:  # Accept key, then expect either a password prompt or access
                 main.log.info( self.name + ": ssh key confirmation received, send yes" )
                 self.handle.sendline( 'yes' )
diff --git a/TestON/tests/USECASE/SegmentRouting/SRStaging/SRStaging.topo b/TestON/tests/USECASE/SegmentRouting/SRStaging/SRStaging.topo
index 2f4c8f2..b9d705e 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRStaging/SRStaging.topo
+++ b/TestON/tests/USECASE/SegmentRouting/SRStaging/SRStaging.topo
@@ -183,7 +183,7 @@
         </Host3>
 
         <ng40vm>
-            <host>192.168.122.102</host>
+            <host>10.92.1.95</host>
             <user>ng40</user>
             <password>ng40</password>
             <type>HostDriver</type>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRStaging/SRpairedLeaves/SRpairedLeaves.py b/TestON/tests/USECASE/SegmentRouting/SRStaging/SRpairedLeaves/SRpairedLeaves.py
index 077df04..5911832 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRStaging/SRpairedLeaves/SRpairedLeaves.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRStaging/SRpairedLeaves/SRpairedLeaves.py
@@ -48,6 +48,7 @@
         """
         try:
             from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest
+            from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
             import json
         except ImportError:
             main.log.error( "SRStagingTest not found. Exiting the test" )
@@ -63,6 +64,7 @@
                               topology='0x2',
                               onosNodes=3,
                               description="%s tests on the %s pod" % ( descPrefix, pod ) )
+        hosts = [ 'h1', 'h2', 'h3', 'mgmt' ]
         run.pingAllFabricIntfs( main, hosts, dumpFlows=False )
         main.funcs.cleanup( main )
 
diff --git a/TestON/tests/USECASE/SegmentRouting/SRStaging/dependencies/SRStagingTest.py b/TestON/tests/USECASE/SegmentRouting/SRStaging/dependencies/SRStagingTest.py
index a3ab6ba..5da933b 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRStaging/dependencies/SRStagingTest.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRStaging/dependencies/SRStagingTest.py
@@ -1353,8 +1353,9 @@
 
     def cleanup( self, main, headerOrder=None ):
         try:
-            for component in main.trafficComponents:
-                main.Network.removeComponent( component.name )
+            if getattr( main, "trafficComponents" ):
+                for component in main.trafficComponents:
+                    main.Network.removeComponent( component.name )
             main.trafficComponents = []
         except Exception:
             main.log.exception( "Error cleaning up traffic components" )
diff --git a/TestON/tests/dependencies/topology.py b/TestON/tests/dependencies/topology.py
index 9d20cda..56a29a9 100644
--- a/TestON/tests/dependencies/topology.py
+++ b/TestON/tests/dependencies/topology.py
@@ -263,6 +263,15 @@
             srcIpList[ src ] = main.Network.getIPAddress( src, proto='IPV6' if ipv6 else 'IPV4', iface=hostHandle.interfaces[0].get("name") )
         unexpectedPings = []
         for dst in dstList:
+            if not hasattr( main, dst ):
+                main.log.info( "Creating component for host {}".format( dst ) )
+                main.Network.createHostComponent( dst )
+                hostHandle = getattr( main, dst )
+                if hasattr( main, 'Mininet1' ):
+                    main.log.info( "Starting CLI on host {}".format( dst ) )
+                    hostHandle.startHostCli()
+                else:
+                    hostHandle.connectInband()
             hostHandle = getattr( main, dst )
             dstIp = main.Network.getIPAddress( dst, proto='IPV6' if ipv6 else 'IPV4', iface=hostHandle.interfaces[0].get("name") )
             # Start pings from src hosts in parallel