Fixed some key error and added more documentation

Change-Id: I0001feb28258baa3f125dd034ccc2e3005f1fa9c
diff --git a/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py b/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py
index 11ca425..db9f0cf 100644
--- a/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py
+++ b/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py
@@ -62,6 +62,9 @@
             expectedLink - Expected link when the switches are down, it should
                            be two links lower than the links before the two
                            switches are down
+        Return:
+            Returns main.TRUE if all verification passed, otherwise return
+            main.FALSE; returns main.FALSE if there is a key error
     """
 
     # Assert variables
@@ -89,50 +92,44 @@
     linkUpResult = main.TRUE
     onosNode = int( onosNode )
 
-    if main.hostsData:
-        if not h1Mac:
-            h1Mac = main.hostsData[ host1 ][ 'mac' ]
-        if not h2Mac:
-            h2Mac = main.hostsData[ host2 ][ 'mac' ]
-        if main.hostsData[ host1 ][ 'vlan' ] != '-1':
-            vlan1 = main.hostsData[ host1 ][ 'vlan' ]
-        if main.hostsData[ host2 ][ 'vlan' ] != '-1':
-            vlan2 = main.hostsData[ host2 ][ 'vlan' ]
-        if not h1Id:
-            h1Id = main.hostsData[ host1 ][ 'id' ]
-        if not h2Id:
-            h2Id = main.hostsData[ host2 ][ 'id' ]
+    try:
+        if main.hostsData:
+            if not h1Mac:
+                h1Mac = main.hostsData[ host1 ][ 'mac' ]
+            if not h2Mac:
+                h2Mac = main.hostsData[ host2 ][ 'mac' ]
+            if main.hostsData[ host1 ].get( 'vlan' ):
+                vlan1 = main.hostsData[ host1 ][ 'vlan' ]
+            if main.hostsData[ host1 ].get( 'vlan' ):
+                vlan2 = main.hostsData[ host2 ][ 'vlan' ]
+            if not h1Id:
+                h1Id = main.hostsData[ host1 ][ 'id' ]
+            if not h2Id:
+                h2Id = main.hostsData[ host2 ][ 'id' ]
 
-    assert h1Id and h2Id, "You must specify host IDs"
-    if not ( h1Id and h2Id ):
-        main.log.info( "There are no host IDs" )
+        assert h1Id and h2Id, "You must specify host IDs"
+        if not ( h1Id and h2Id ):
+            main.log.info( "There are no host IDs" )
+            return main.FALSE
+
+        # Discover hosts using arping
+        if not main.hostsData:
+            main.log.info( itemName + ": Discover host using arping" )
+            main.Mininet1.arping( host=host1 )
+            main.Mininet1.arping( host=host2 )
+            host1 = main.CLIs[ 0 ].getHost( mac=h1Mac )
+            host2 = main.CLIs[ 0 ].getHost( mac=h2Mac )
+    except KeyError:
+        main.log.error( itemName + ": Key error Exception" )
         return main.FALSE
 
-    # Discover hosts using arping
-    if not main.hostsData:
-        main.log.info( itemName + ": Discover host using arping" )
-        main.Mininet1.arping( host=host1 )
-        main.Mininet1.arping( host=host2 )
-        host1 = main.CLIs[ 0 ].getHost( mac=h1Mac )
-        host2 = main.CLIs[ 0 ].getHost( mac=h2Mac )
-
     # Check flows count in each node
     checkFlowsCount( main )
 
-    # Checking connectivity before installing intents
-    main.log.info( itemName + ": Check hosts connection before adding intents" )
-    checkPing = pingallHosts( main, hostNames )
-    if not checkPing:
-        main.log.info( itemName + ": Ping did not go through " +
-                       "before adding intents" )
-    else:
-        main.log.debug( itemName + ": Pinged successful before adding " +
-                        "intents,please check fwd app if it is activated" )
-
     # Adding host intents
     main.log.info( itemName + ": Adding host intents" )
     intent1 = main.CLIs[ onosNode ].addHostIntent( hostIdOne=h1Id,
-                                           hostIdTwo=h2Id )
+                                                   hostIdTwo=h2Id )
     intentsId.append( intent1 )
 
     # Check intents state
@@ -307,16 +304,6 @@
     linkUpResult = main.TRUE
     onosNode = int( onosNode )
 
-    # Checking connectivity before installing intents
-    main.log.info( itemName + ": Check hosts connection before adding intents" )
-    checkPing = pingallHosts( main, hostNames )
-    if not checkPing:
-        main.log.info( itemName + ": Ping did not go through " +
-                       "before adding intents" )
-    else:
-        main.log.debug( itemName + ": Pinged successful before adding " +
-                        "intents,please check fwd app if it is activated" )
-
     # Adding bidirectional point  intents
     main.log.info( itemName + ": Adding point intents" )
     intent1 = main.CLIs[ onosNode ].addPointIntent( ingressDevice=deviceId1,
@@ -564,16 +551,6 @@
     # Check flows count in each node
     checkFlowsCount( main )
 
-    # Checking connectivity before installing intents
-    main.log.info( itemName + ": Check hosts connection before adding intents" )
-    checkPing = pingallHosts( main, hostNames )
-    if not checkPing:
-        main.log.info( itemName + ": Ping did not go through " +
-                       "before adding intents" )
-    else:
-        main.log.debug( itemName + ": Pinged successful before adding " +
-                        "intents,please check fwd app if it is activated" )
-
     # Adding bidirectional point  intents
     for i in range( len( devices ) ):
         ingressDevice = devicesCopy[ i ]
@@ -815,16 +792,6 @@
     # Check flows count in each node
     checkFlowsCount( main )
 
-    # Checking connectivity before installing intents
-    main.log.info( itemName + ": Check hosts connection before adding intents" )
-    checkPing = pingallHosts( main, hostNames )
-    if not checkPing:
-        main.log.info( itemName + ": Ping did not go through " +
-                       "before adding intents" )
-    else:
-        main.log.debug( itemName + ": Pinged successful before adding " +
-                        "intents,please check fwd app if it is activated" )
-
     # Adding bidirectional point  intents
     for i in range( len( devices ) ):
         egressDevice = devicesCopy[ i ]
@@ -1115,7 +1082,7 @@
         else:
             for i in range( main.numCtrls ):
                 main.log.debug( itemName + ": ONOS node " + str( i ) + " has " +
-                                flowsCount[ i ] + " flows" )
+                                str( flowsCount[ i ] ) + " flows" )
     else:
         main.log.error( "Checking flows count failed, check summary command" )
         return main.FALSE
diff --git a/TestON/tests/FUNCintent/FUNCintent.py b/TestON/tests/FUNCintent/FUNCintent.py
index d3202c3..ab1902f 100644
--- a/TestON/tests/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNCintent/FUNCintent.py
@@ -26,6 +26,9 @@
 
         main.case( "Constructing test variables and building ONOS package" )
         main.step( "Constructing test variables" )
+        main.caseExplaination = "This test case is mainly for loading " +\
+                               "from params file, and pull and build the " +\
+                               " latest ONOS package"
         stepResult = main.FALSE
 
         # Test variables
@@ -117,6 +120,10 @@
 
         main.case( "Starting up " + str( main.numCtrls ) +
                    " node(s) ONOS cluster" )
+        main.caseExplaination = "Set up ONOS with " + str( main.numCtrls ) +\
+                                " node(s) ONOS cluster"
+
+
 
         #kill off all onos processes
         main.log.info( "Safety check, killing all ONOS processes" +
@@ -228,10 +235,14 @@
         """
             Start Mininet topology with OF 1.0 switches
         """
+        main.OFProtocol = "1.0"
         main.log.report( "Start Mininet topology with OF 1.0 switches" )
-        main.log.case( "Start Mininet topology with OF 1.0 switches" )
+        main.case( "Start Mininet topology with OF 1.0 switches" )
+        main.caseExplaination = "Start mininet topology with OF 1.0 " +\
+                                "switches to test intents, exits out if " +\
+                                "topology did not start correctly"
 
-        main.step( "Start Mininet topology with OF 1.0 switches" )
+        main.step( "Starting Mininet topology with OF 1.0 switches" )
         args = "--switch ovs,protocols=OpenFlow10"
         topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
                                                       main.topology,
@@ -250,10 +261,14 @@
         """
             Start Mininet topology with OF 1.3 switches
         """
+        main.OFProtocol = "1.3"
         main.log.report( "Start Mininet topology with OF 1.3 switches" )
-        main.log.case( "Start Mininet topology with OF 1.3 switches" )
+        main.case( "Start Mininet topology with OF 1.3 switches" )
+        main.caseExplaination = "Start mininet topology with OF 1.3 " +\
+                                "switches to test intents, exits out if " +\
+                                "topology did not start correctly"
 
-        main.step( "Start Mininet topology with OF 1.3 switches" )
+        main.step( "Starting Mininet topology with OF 1.3 switches" )
         args = "--switch ovs,protocols=OpenFlow13"
         topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
                                                       main.topology,
@@ -276,6 +291,9 @@
 
         main.case( "Assign switches to controllers" )
         main.step( "Assigning switches to controllers" )
+        main.caseExplaination = "Assign OF " + main.OFProtocol +\
+                                " switches to ONOS nodes"
+
         assignResult = main.TRUE
         switchList = []
 
@@ -327,7 +345,9 @@
             Stop mininet
         """
         main.log.report( "Stop Mininet topology" )
-        main.log.case( "Stop Mininet topology" )
+        main.case( "Stop Mininet topology" )
+        main.caseExplaination = "Stopping the current mininet topology " +\
+                                "to start up fresh"
 
         main.step( "Stopping Mininet Topology" )
         topoResult = main.Mininet1.stopNet( )
@@ -374,7 +394,13 @@
 
         intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
 
-        main.case( "Add host intents between 2 host" )
+        main.case( "TESTING HOST INTENTS" )
+        main.caseExplaination = "This test case tests Host intents using " +\
+                                str( main.numCtrls ) + " node(s) cluster;\n" +\
+                                "Different type of hosts will be tested in " +\
+                                "each step such as IPV4, Dual stack, VLAN " +\
+                                "etc;\nThe test will use OF " + main.OFProtocol\
+                                + "OVS running in Mininet"
 
         main.step( "IPV4: Add host intents between h1 and h9" )
         stepResult = main.TRUE
@@ -509,7 +535,14 @@
         assert main.numSwitch, "Placed the total number of switch topology in \
                                 main.numSwitch"
 
-        main.case( "Add point intents between 2 devices" )
+        main.case( "TESTING POINT INTENTS" )
+        main.caseExplaination = "This test case will test point to point" +\
+                               " intents using " + str( main.numCtrls ) +\
+                               " node(s) cluster;\n" +\
+                               "Different type of hosts will be tested in " +\
+                               "each step such as IPV4, Dual stack, VLAN etc" +\
+                               ";\nThe test will use OF " + main.OFProtocol +\
+                               "OVS running in Mininet"
 
         # No option point intents
         main.step( "NOOPTION: Add point intents between h1 and h9" )
@@ -740,7 +773,14 @@
         assert main.numSwitch, "Placed the total number of switch topology in \
                                 main.numSwitch"
 
-        main.case( "Add single point to multi point intents between devices" )
+        main.case( "TESTING SINGLE TO MULTI POINT INTENTS" )
+        main.caseExplaination = "This test case will test single point to" +\
+                               " multi point intents using " +\
+                               str( main.numCtrls ) + " node(s) cluster;\n" +\
+                               "Different type of hosts will be tested in " +\
+                               "each step such as IPV4, Dual stack, VLAN etc" +\
+                               ";\nThe test will use OF " + main.OFProtocol +\
+                               "OVS running in Mininet"
 
         main.step( "NOOPTION: Add single point to multi point intents" )
         stepResult = main.TRUE
@@ -862,7 +902,14 @@
         assert main.numSwitch, "Placed the total number of switch topology in \
                                 main.numSwitch"
 
-        main.case( "Add multi point to single point intents between devices" )
+        main.case( "TESTING MULTI TO SINGLE POINT INTENTS" )
+        main.caseExplaination = "This test case will test single point to" +\
+                               " multi point intents using " +\
+                               str( main.numCtrls ) + " node(s) cluster;\n" +\
+                               "Different type of hosts will be tested in " +\
+                               "each step such as IPV4, Dual stack, VLAN etc" +\
+                               ";\nThe test will use OF " + main.OFProtocol +\
+                               "OVS running in Mininet"
 
         main.step( "NOOPTION: Add multi point to single point intents" )
         stepResult = main.TRUE