Merge "Changes made so that PLATdockertest pulls all images from onos dockerhub"
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 2d75c39..4052db2 100755
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -676,6 +676,7 @@
         try:
             cmdStr = "topology -j"
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             main.log.info( cmdStr + " returned: " + str( handle ) )
             return handle
@@ -704,6 +705,7 @@
         try:
             cmdStr = "device-remove " + str( deviceId )
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             if re.search( "Error", handle ):
                 main.log.error( "Error in removing device" )
@@ -738,6 +740,7 @@
             if jsonFormat:
                 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:
@@ -765,6 +768,7 @@
         try:
             cmdStr = "onos:balance-masters"
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             if re.search( "Error", handle ):
                 main.log.error( "Error in balancing masters" )
@@ -874,6 +878,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             handle = self.sendline( cmdStr, timeout=timeout )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             return handle
         except AssertionError:
@@ -903,6 +908,7 @@
             if jsonFormat:
                 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:
@@ -932,6 +938,7 @@
             if jsonFormat:
                 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:
@@ -1023,6 +1030,7 @@
         try:
             cmdStr = "onos:paths " + str( srcId ) + " " + str( dstId )
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             if re.search( "Error", handle ):
                 main.log.error( "Error in getting paths" )
@@ -1187,6 +1195,7 @@
                 cmdStr += "--encapsulation " + str( encap ) + " "
             cmdStr += str( hostIdOne ) + " " + str( hostIdTwo )
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             if re.search( "Error", handle ):
                 main.log.error( "Error in adding Host intent" )
@@ -1235,6 +1244,7 @@
             cmdStr = "add-optical-intent " + str( ingressDevice ) +\
                 " " + str( egressDevice )
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             # If error, return error message
             if re.search( "Error", handle ):
@@ -1375,6 +1385,7 @@
                     str( portEgress )
 
             handle = self.sendline( cmd )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             # If error, return error message
             if re.search( "Error", handle ):
@@ -1537,6 +1548,7 @@
                     str( egressDevice ) + "/" +\
                     str( portEgress )
             handle = self.sendline( cmd )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             # If error, return error message
             if re.search( "Error", handle ):
@@ -1697,6 +1709,7 @@
                                     "have the same length" )
                     return main.FALSE
             handle = self.sendline( cmd )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             # If error, return error message
             if re.search( "Error", handle ):
@@ -1828,6 +1841,7 @@
                     str( egressPort )
 
             handle = self.sendline( cmd )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             # If error, return error message
             if re.search( "Error", handle ):
@@ -1881,6 +1895,7 @@
 
             cmdStr += " " + app + " " + str( intentId )
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             if re.search( "Error", handle ):
                 main.log.error( "Error in removing intent" )
@@ -1924,6 +1939,7 @@
 
             cmdStr += " " + app
             handle = self.sendline( cmdStr, timeout=timeout )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             if re.search( "Error", handle ):
                 main.log.error( "Error in removing intent" )
@@ -1953,6 +1969,7 @@
         try:
             cmdStr = "purge-intents"
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             if re.search( "Error", handle ):
                 main.log.error( "Error in purging intents" )
@@ -1989,6 +2006,7 @@
             if jsonFormat:
                 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:
@@ -2017,6 +2035,7 @@
         try:
             cmdStr = "routes -s -j"
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             jsonResult = json.loads( handle )
             return jsonResult['totalRoutes4']
@@ -2053,6 +2072,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             args = utilities.parse_args( [ "TYPE" ], **intentargs )
             if "TYPE" in args.keys():
@@ -2332,6 +2352,7 @@
                 cmdStr += " -n "
             cmdStr += state
             handle = self.sendline( cmdStr, timeout=timeout, noExit=noExit )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             if re.search( "Error:", handle ):
                 main.log.error( self.name + ": flows() response: " +
@@ -2458,11 +2479,9 @@
                                                                 offset,
                                                                 back )
             response = self.sendline( cmd, timeout=timeout, noExit=noExit )
+            assert response is not None, "Error in sendline"
             assert "Command not found:" not in response, response
             main.log.info( response )
-            if response == None:
-                return None
-
             if getResponse:
                 return response
 
@@ -2577,6 +2596,7 @@
             if jsonFormat:
                 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:
@@ -2606,6 +2626,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             if handle:
                 return handle
@@ -2679,6 +2700,7 @@
                 cmdStr = "flows any " + str( deviceId ) + " | " +\
                          "grep 'state=ADDED' | wc -l"
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             return handle
         except AssertionError:
@@ -2920,6 +2942,7 @@
                     str( onosNode ) + " " +\
                     str( role )
                 handle = self.sendline( cmdStr )
+                assert handle is not None, "Error in sendline"
                 assert "Command not found:" not in handle, handle
                 if re.search( "Error", handle ):
                     # end color output to escape any colours
@@ -2959,6 +2982,7 @@
             if jsonFormat:
                 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:
@@ -2988,6 +3012,7 @@
         try:
             cmdStr = "election-test-leader"
             response = self.sendline( cmdStr )
+            assert response is not None, "Error in sendline"
             assert "Command not found:" not in response, response
             # Leader
             leaderPattern = "The\scurrent\sleader\sfor\sthe\sElection\s" +\
@@ -3037,6 +3062,7 @@
         try:
             cmdStr = "election-test-run"
             response = self.sendline( cmdStr )
+            assert response is not None, "Error in sendline"
             assert "Command not found:" not in response, response
             # success
             successPattern = "Entering\sleadership\selections\sfor\sthe\s" +\
@@ -3078,6 +3104,7 @@
         try:
             cmdStr = "election-test-withdraw"
             response = self.sendline( cmdStr )
+            assert response is not None, "Error in sendline"
             assert "Command not found:" not in response, response
             # success
             successPattern = "Withdrawing\sfrom\sleadership\selections\sfor" +\
@@ -3503,6 +3530,8 @@
                 return main.FALSE
             cmdStr = "onos:app " + option + " " + appName
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
+            assert "Command not found:" not in output, output
             if "Error executing command" in output:
                 main.log.error( "Error in processing onos:app command: " +
                                 str( output ) )
@@ -3522,6 +3551,9 @@
             # else: Command was successful
             # main.log.debug( "app response: " + repr( output ) )
             return main.TRUE
+        except AssertionError:
+            main.log.exception( self.name + ": AssertionError exception found" )
+            return main.ERROR
         except TypeError:
             main.log.exception( self.name + ": Object not as expected" )
             return main.ERROR
@@ -4988,6 +5020,8 @@
         cmd = "intent-perf -s"
         respDic = {}
         resp = self.sendline( cmd )
+        assert resp is not None, "Error in sendline"
+        assert "Command not found:" not in resp, resp
         try:
             # Generate the dictionary to return
             for l in resp.split( "\n" ):
diff --git a/TestON/tests/CHOTestMonkey/CHOTestMonkey.py b/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
index 78bed55..9d8e0d6 100644
--- a/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
+++ b/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
@@ -44,9 +44,12 @@
         main.enableIPv6 = main.params[ 'TEST' ][ 'IPv6' ]
         main.enableIPv6 = True if main.enableIPv6 == "on" else False
         main.caseSleep = int( main.params[ 'TEST' ][ 'caseSleep' ] )
-        main.numCtrls = main.params[ 'TEST' ][ 'numCtrl' ]
+        main.numCtrls = int( main.params[ 'TEST' ][ 'numCtrl' ] )
+        main.ONOSip = []
+        main.AllONOSip = main.ONOSbench.getOnosIps()
         main.controllers = []
-        for i in range( 1, int( main.numCtrls ) + 1 ):
+        for i in range( 1, main.numCtrls + 1 ):
+            main.ONOSip.append( main.AllONOSip[ i-1 ] )
             newController = Controller( i )
             newController.setCLI( getattr( main, 'ONOScli' + str( i ) ) )
             main.controllers.append( newController )
@@ -127,9 +130,9 @@
 
         main.step( "Uninstall ONOS package on all Nodes" )
         uninstallResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "Uninstalling package on ONOS Node IP: " + main.onosIPs[i] )
-            uResult = main.ONOSbench.onosUninstall( main.onosIPs[i] )
+        for i in range( main.numCtrls ):
+            main.log.info( "Uninstalling package on ONOS Node IP: " + main.ONOSip[i] )
+            uResult = main.ONOSbench.onosUninstall( main.ONOSip[i] )
             utilities.assert_equals( expect=main.TRUE,
                                      actual=uResult,
                                      onpass="Test step PASS",
@@ -138,9 +141,9 @@
 
         main.step( "Install ONOS package on all Nodes" )
         installResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "Installing package on ONOS Node IP: " + main.onosIPs[i] )
-            iResult = main.ONOSbench.onosInstall( node=main.onosIPs[i] )
+        for i in range( main.numCtrls ):
+            main.log.info( "Installing package on ONOS Node IP: " + main.ONOSip[i] )
+            iResult = main.ONOSbench.onosInstall( node=main.ONOSip[i] )
             utilities.assert_equals( expect=main.TRUE,
                                      actual=iResult,
                                      onpass="Test step PASS",
@@ -149,8 +152,8 @@
 
         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.onosIPs[i] )
+        for i in range( 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" )
@@ -289,10 +292,10 @@
         main.step( "Assign switches to controllers" )
         switchMastership = main.TRUE
         for switchName in main.mininetSwitches.keys():
-            main.Mininet1.assignSwController( sw=switchName, ip=main.onosIPs )
+            main.Mininet1.assignSwController( sw=switchName, ip=main.ONOSip )
             response = main.Mininet1.getSwController( switchName )
             print( "Response is " + str( response ) )
-            if re.search( "tcp:" + main.onosIPs[ 0 ], response ):
+            if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
                 switchMastership = switchMastership and main.TRUE
             else:
                 switchMastership = main.FALSE
diff --git a/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py b/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
index e9dff29..aa3a7a3 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
@@ -8,7 +8,7 @@
     def __init__( self, index ):
         self.default = ''
         self.index = index
-        self.ip = main.onosIPs[ index - 1 ]
+        self.ip = main.ONOSip[ index - 1 ]
         self.CLI = None
         self.CLILock = Lock()
         self.status = 'up'
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
index ccab8a1..f6e13cc 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
@@ -273,7 +273,7 @@
                             intent.setInstalled()
         # Re-assign mastership for the device
         with main.mininetLock:
-            main.Mininet1.assignSwController( sw=self.device.name, ip=main.onosIPs )
+            main.Mininet1.assignSwController( sw=self.device.name, ip=main.ONOSip )
         # Re-discover hosts
         for host in self.device.hosts:
             correspondent = None