More bad input handling

Change-Id: I3509892b187138b725d139a2975746e874cba5bb
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 95e6ee5..21eb959 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -1906,19 +1906,25 @@
             if len(flowTable1) != len(flowTable2):
                 main.log.warn( "Flow table lengths do not match" )
                 return main.FALSE
-
             dFields = ["n_bytes", "cookie", "n_packets", "duration"]
             for flow1, flow2 in zip(flowTable1, flowTable2):
-                map( lambda a: map(a.pop, dFields), [flow1, flow2] )
-
+                for field in dFields:
+                    try:
+                        flow1.pop( field )
+                    except KeyError as e:
+                        main.log.warn( e )
+                        main.log.debug( flow1 )
+                    try:
+                        flow2.pop( field )
+                    except KeyError as e:
+                        main.log.warn( e )
+                        main.log.debug( flow2 )
             for i in range( len(flowTable1) ):
                 if flowTable1[i] not in flowTable2:
                     main.log.warn( "Flow tables do not match:" )
                     main.log.warn( "Old flow:\n{}\n not in new flow table".format( flowTable1[i] ) )
                     return main.FALSE
-
             return main.TRUE
-
         except Exception:
             main.log.exception( "Uncaught exception!" )
             main.cleanup()
diff --git a/TestON/tests/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HAclusterRestart/HAclusterRestart.py
index 234c995..0c3ce16 100644
--- a/TestON/tests/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HAclusterRestart/HAclusterRestart.py
@@ -2197,12 +2197,13 @@
                     hosts.append( None )
             for controller in range( 0, len( hosts ) ):
                 controllerStr = str( controller + 1 )
-                for host in hosts[ controller ]:
-                    if host is None or host.get( 'ipAddresses', [] ) == []:
-                        main.log.error(
-                            "Error with host ipAddresses on controller" +
-                            controllerStr + ": " + str( host ) )
-                        ipResult = main.FALSE
+                if hosts[ controller ]:
+                    for host in hosts[ controller ]:
+                        if host is None or host.get( 'ipAddresses', [] ) == []:
+                            main.log.error(
+                                "Error with host ipAddresses on controller" +
+                                controllerStr + ": " + str( host ) )
+                            ipResult = main.FALSE
             ports = []
             threads = []
             for i in range( main.numCtrls ):
diff --git a/TestON/tests/HAkillNodes/HAkillNodes.py b/TestON/tests/HAkillNodes/HAkillNodes.py
index 396e08a..5768a2d 100644
--- a/TestON/tests/HAkillNodes/HAkillNodes.py
+++ b/TestON/tests/HAkillNodes/HAkillNodes.py
@@ -2194,12 +2194,13 @@
                     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(
-                            "Error with host ipAddresses on controller" +
-                            controllerStr + ": " + str( host ) )
-                        ipResult = main.FALSE
+                if hosts[ controller ]:
+                    for host in hosts[ controller ]:
+                        if host is None or host.get( 'ipAddresses', [] ) == []:
+                            main.log.error(
+                                "Error with host ipAddresses on controller" +
+                                controllerStr + ": " + str( host ) )
+                            ipResult = main.FALSE
             ports = []
             threads = []
             for i in main.activeNodes:
diff --git a/TestON/tests/HAsanity/HAsanity.py b/TestON/tests/HAsanity/HAsanity.py
index 517d53e..5322a9a 100644
--- a/TestON/tests/HAsanity/HAsanity.py
+++ b/TestON/tests/HAsanity/HAsanity.py
@@ -2090,12 +2090,13 @@
                     hosts.append( None )
             for controller in range( 0, len( hosts ) ):
                 controllerStr = str( controller + 1 )
-                for host in hosts[ controller ]:
-                    if host is None or host.get( 'ipAddresses', [] ) == []:
-                        main.log.error(
-                            "Error with host ipAddresses on controller" +
-                            controllerStr + ": " + str( host ) )
-                        ipResult = main.FALSE
+                if hosts[ controller ]:
+                    for host in hosts[ controller ]:
+                        if host is None or host.get( 'ipAddresses', [] ) == []:
+                            main.log.error(
+                                "Error with host ipAddresses on controller" +
+                                controllerStr + ": " + str( host ) )
+                            ipResult = main.FALSE
             ports = []
             threads = []
             for i in range( main.numCtrls ):
diff --git a/TestON/tests/HAstopNodes/HAstopNodes.py b/TestON/tests/HAstopNodes/HAstopNodes.py
index 84b714d..84e7d9c 100644
--- a/TestON/tests/HAstopNodes/HAstopNodes.py
+++ b/TestON/tests/HAstopNodes/HAstopNodes.py
@@ -2183,12 +2183,13 @@
                     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(
-                            "Error with host ipAddresses on controller" +
-                            controllerStr + ": " + str( host ) )
-                        ipResult = main.FALSE
+                if hosts[ controller ]:
+                    for host in hosts[ controller ]:
+                        if host is None or host.get( 'ipAddresses', [] ) == []:
+                            main.log.error(
+                                "Error with host ipAddresses on controller" +
+                                controllerStr + ": " + str( host ) )
+                            ipResult = main.FALSE
             ports = []
             threads = []
             for i in main.activeNodes: