Port stability fixes to all tests

Change-Id: I1e712ad830a76f80ed9d6f3792786ed9d1ca8194
diff --git a/TestON/tests/HAstopNodes/HAstopNodes.py b/TestON/tests/HAstopNodes/HAstopNodes.py
index 47689af..84b714d 100644
--- a/TestON/tests/HAstopNodes/HAstopNodes.py
+++ b/TestON/tests/HAstopNodes/HAstopNodes.py
@@ -50,6 +50,7 @@
         """
         import imp
         import pexpect
+        import time
         main.log.info( "ONOS HA test: Stop a minority of ONOS nodes - " +
                          "initialization" )
         main.case( "Setting up test environment" )
@@ -274,6 +275,7 @@
                 port=main.params[ 'MNtcpdump' ][ 'port' ] )
 
         main.step( "App Ids check" )
+        time.sleep(60)
         appCheck = main.TRUE
         threads = []
         for i in main.activeNodes:
@@ -1504,7 +1506,7 @@
                 # FIXME: better handling of this, print which node
                 #        Maybe use thread name?
                 main.log.exception( "Error parsing json output of hosts" )
-                # FIXME: should this be an empty json object instead?
+                main.log.warn( repr( t.result ) )
                 hosts.append( None )
 
         ports = []
@@ -1550,7 +1552,7 @@
         consistentHostsResult = main.TRUE
         for controller in range( len( hosts ) ):
             controllerStr = str( main.activeNodes[controller] + 1 )
-            if "Error" not in hosts[ controller ]:
+            if hosts[ controller ] and "Error" not in hosts[ controller ]:
                 if hosts[ controller ] == hosts[ 0 ]:
                     continue
                 else:  # hosts not consistent
@@ -1577,11 +1579,12 @@
         ipResult = main.TRUE
         for controller in range( 0, len( hosts ) ):
             controllerStr = str( main.activeNodes[controller] + 1 )
-            for host in hosts[ controller ]:
-                if not host.get( 'ipAddresses', [ ] ):
-                    main.log.error( "Error with host ips on controller" +
-                                    controllerStr + ": " + str( host ) )
-                    ipResult = main.FALSE
+            if hosts[ controller ]:
+                for host in hosts[ controller ]:
+                    if not host.get( 'ipAddresses', [ ] ):
+                        main.log.error( "Error with host ips on controller" +
+                                        controllerStr + ": " + str( host ) )
+                        ipResult = main.FALSE
         utilities.assert_equals(
             expect=main.TRUE,
             actual=ipResult,
@@ -2177,13 +2180,13 @@
                 except ( ValueError, TypeError ):
                     main.log.exception( "Error parsing hosts results" )
                     main.log.error( repr( t.result ) )
-                    hosts.append( [] )
+                    hosts.append( None )
             for controller in range( 0, len( hosts ) ):
                 controllerStr = str( main.activeNodes[controller] + 1 )
                 for host in hosts[ controller ]:
                     if host is None or host.get( 'ipAddresses', [] ) == []:
                         main.log.error(
-                            "DEBUG:Error with host ipAddresses on controller" +
+                            "Error with host ipAddresses on controller" +
                             controllerStr + ": " + str( host ) )
                         ipResult = main.FALSE
             ports = []
@@ -2378,7 +2381,7 @@
         consistentHostsResult = main.TRUE
         for controller in range( len( hosts ) ):
             controllerStr = str( main.activeNodes[controller] + 1 )
-            if "Error" not in hosts[ controller ]:
+            if hosts[ controller ] or "Error" not in hosts[ controller ]:
                 if hosts[ controller ] == hosts[ 0 ]:
                     continue
                 else:  # hosts not consistent