Port stability fixes to all tests

Change-Id: I1e712ad830a76f80ed9d6f3792786ed9d1ca8194
diff --git a/TestON/tests/HAkillNodes/HAkillNodes.py b/TestON/tests/HAkillNodes/HAkillNodes.py
index aa49941..396e08a 100644
--- a/TestON/tests/HAkillNodes/HAkillNodes.py
+++ b/TestON/tests/HAkillNodes/HAkillNodes.py
@@ -49,6 +49,7 @@
         start tcpdump
         """
         import imp
+        import time
         import pexpect
         main.log.info( "ONOS HA test: Restart minority of ONOS nodes - " +
                          "initialization" )
@@ -281,6 +282,7 @@
                 port=main.params[ 'MNtcpdump' ][ 'port' ] )
 
         main.step( "App Ids check" )
+        time.sleep(60)
         appCheck = main.TRUE
         threads = []
         for i in main.activeNodes:
@@ -1515,7 +1517,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 = []
@@ -1561,7 +1563,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
@@ -1588,11 +1590,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,
@@ -2188,13 +2191,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 = []
@@ -2389,7 +2392,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