New testcase for changing hosts on the fly and adding p2p intents for hosts on same device
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.py b/TestON/tests/ProdFunc13/ProdFunc13.py
index 13dc26d..e1a0a3f 100644
--- a/TestON/tests/ProdFunc13/ProdFunc13.py
+++ b/TestON/tests/ProdFunc13/ProdFunc13.py
@@ -133,7 +133,7 @@
                                  onpass="Switch down discovery successful",
                                  onfail="Switch down discovery failed" )
 
-    def CASE11( self, main ):
+    def CASE101( self, main ):
         """
         Cleanup sequence:
         onos-service <nodeIp> stop
@@ -528,7 +528,7 @@
         import time
         main.log.report( "This testcase is testing the assignment of" +
                          " all the switches to all the controllers and" +
-                         " discovering the hists in reactive mode" )
+                         " discovering the hosts in reactive mode" )
         main.log.report( "__________________________________" )
         main.case( "Pingall Test" )
         main.step( "Assigning switches to controllers" )
@@ -688,7 +688,86 @@
             onpass="Reactive forwarding app uninstallation successful",
             onfail="Reactive forwarding app uninstallation failed" )
 
+
+    def CASE11( self ):
+        # NOTE: This testcase require reactive forwarding mode enabled
+        # NOTE: in the beginning and then uninstall it before adding 
+        # NOTE: point intents. Again the app is installed so that 
+        # NOTE: testcase 10 can be ran successively
+        import time
+        main.log.report(
+            "This testcase moves a host from one switch to another to add" +
+            "point intents between them and then perform ping" )
+        main.log.report( "__________________________________" )
+        main.log.info( "Moving host from one switch to another" )
+        main.case( "Moving host from a device and attach it to another device" )
+        main.step( "Moving host h9 from device s9 and attach it to s8" )
+        main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
+
+        time.sleep(15) #Time delay to have all the flows ready
+        main.step( "Pingall" )
+        pingResult = main.FALSE
+        time1 = time.time()
+        pingResult = main.Mininet1.pingall()
+        time2 = time.time()
+        print "Time for pingall: %2f seconds" % ( time2 - time1 )
+
+        hosts = main.ONOS2.hosts( jsonFormat = False )
+        main.log.info( hosts )
+        
+        main.case( "Uninstalling reactive forwarding app" )
+        # Unistall onos-app-fwd app to disable reactive forwarding
+        appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
+        main.log.info( "onos-app-fwd uninstalled" )
+
+        main.step( "Add point intents between hosts on the same device")
+        ptpIntentResult = main.ONOS2.addPointIntent(
+            "of:0000000000003008/1",
+            "of:0000000000003008/3" )
+        if ptpIntentResult == main.TRUE:
+            getIntentResult = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( getIntentResult )
+
+        ptpIntentResult = main.ONOS2.addPointIntent(
+            "of:0000000000003008/3",
+            "of:0000000000003008/1" )
+        if ptpIntentResult == main.TRUE:
+            getIntentResult = main.ONOS2.intents()
+            main.log.info( "Point to point intent install successful" )
+            # main.log.info( getIntentResult )
+
+        main.case( "Ping hosts on the same devices" )
+        ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
+
+        '''
+        main.case( "Installing reactive forwarding app" )
+        # Install onos-app-fwd app to enable reactive forwarding
+        appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
+        main.log.info( "onos-app-fwd installed" )
+        '''
+
+        if ping == main.FALSE:
+            main.log.report(
+                "Point intents for hosts on same devices haven't" +
+                " been installed correctly. Cleaning up" )
+        if ping == main.TRUE:
+            main.log.report(
+                "Point intents for hosts on same devices" +
+                "installed correctly. Cleaning up" )
+
+        case11Result = ping and pingResult
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case11Result,
+            onpass= "Point intents for hosts on same devices" +
+                    "Ping Test successful",
+            onfail= "Point intents for hosts on same devices" +
+                    "Ping Test NOT successful" )
+        
+
     def CASE6( self ):
+        import time
         main.log.report( "This testcase is testing the addition of" +
                          " host intents and then does pingall" )
         main.log.report( "__________________________________" )
@@ -740,15 +819,15 @@
             # NOTE: get host can return None
             # TODO: handle this
             host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
+      
             host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
             main.ONOS2.addHostIntent( host1Id, host2Id )
-            hIntents = main.ONOS2.intents( jsonFormat=False )
-            main.log.info( "intents:" + hIntents )
 
         time.sleep( 10 )
         hIntents = main.ONOS2.intents( jsonFormat=False )
         main.log.info( "intents:" + hIntents )
-        main.ONOS2.flows()
+        flows = main.ONOS2.flows()
+        main.log.info( "flows:" + flows )     
 
         count = 1
         i = 8
@@ -1077,14 +1156,11 @@
         intentResult = main.ONOS2.intents( jsonFormat=False )
         main.log.info( "intent_result = " + intentResult )
         intentLinewise = intentResult.split( "\n" )
-        intentList = []
-        for line in intentLinewise:
-            if line.startswith( "id=" ):
-                intentList.append( line )
 
-        intentids = []
-        for line in intentList:
-            intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
+        intentList = [line for line in intentLinewise \
+            if line.startswith( "id=")]
+        intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
+            intentList]
         for id in intentids:
             print "id = ", id
 
@@ -1095,8 +1171,20 @@
 
         intentResult = main.ONOS2.intents( jsonFormat=False )
         main.log.info( "intent_result = " + intentResult )
-
-        case8Result = main.TRUE
+        
+        intentList = [line for line in intentResult.split( "\n" ) \
+            if line.startswith( "id=")]
+        intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
+            intentList]
+        for state in intentState:
+            print state
+        
+        case8Result = main.TRUE        
+        for state in intentState:
+            if state != 'WITHDRAWN':
+                case8Result = main.FALSE
+                break
+                
         if case8Result == main.TRUE:
             main.log.report( "Intent removal successful" )
         else:
@@ -1328,7 +1416,7 @@
         if ptpIntentResult == main.TRUE:
             getIntentResult = main.ONOS2.intents()
             main.log.info( "Point to point intent install successful" )
-            main.log.info( getIntentResult )
+            #main.log.info( getIntentResult )
 
         ptpIntentResult = main.ONOS2.addPointIntent(
             "of:0000000000006027/1",
@@ -1336,7 +1424,7 @@
         if ptpIntentResult == main.TRUE:
             getIntentResult = main.ONOS2.intents()
             main.log.info( "Point to point intent install successful" )
-            main.log.info( getIntentResult )
+            #main.log.info( getIntentResult )
 
         print(
             "___________________________________________________________" )