Merge "Add 4 new intent test case with FlowObj     - SCPFintentEventTpWithFlowObj     - SCPFintentInstallWithdrawLatWithFlowObj     - SCPFintentRerouteLatWithFlowObj     - SCPFscalingMaxIntentsWithFlowObj"
diff --git a/TestON/bin/cleanup.sh b/TestON/bin/cleanup.sh
index 3f82161..f931eca 100755
--- a/TestON/bin/cleanup.sh
+++ b/TestON/bin/cleanup.sh
@@ -29,6 +29,5 @@
         echo "Restoring iptables rules on ${i}"
         ssh sdn@$i "sudo iptables -F"
         ssh sdn@$i "sudo iptables-restore < /etc/iptables/rules.v4"
-        exit 0
     done
 fi
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index ba2b37c..93f98b8 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -2508,7 +2508,7 @@
             nodesStr = self.nodes( jsonFormat=True )
             idList = []
             # Sample nodesStr output
-            # id=local, address=127.0.0.1:9876, state=ACTIVE *
+            # id=local, address=127.0.0.1:9876, state=READY *
             if not nodesStr:
                 main.log.info( "There are no nodes to get id from" )
                 return idList
@@ -3283,7 +3283,6 @@
                 response = self.app( appName, "activate" )
                 if check and response == main.TRUE:
                     for i in range(10):  # try 10 times then give up
-                        # TODO: Check with Thomas about this delay
                         status = self.appStatus( appName )
                         if status == "ACTIVE":
                             return main.TRUE
diff --git a/TestON/tests/FUNCintent/FUNCintent.params b/TestON/tests/FUNCintent/FUNCintent.params
index 26ee48d..59db14d 100644
--- a/TestON/tests/FUNCintent/FUNCintent.params
+++ b/TestON/tests/FUNCintent/FUNCintent.params
@@ -11,7 +11,8 @@
     # 14 - Discover hosts with Mininet Pingall
     # 15 - Discover hosts with Scapy arping ( only discovers scapy hosts )
     # 16 - Balance ownership of switches
-    # 17 - Stop Mininet
+    # 17 - Activate Flow Objectives
+    # 18 - Stop Mininet
     # 1000 - Test host intents
     # 2000 - Test point intents
     # 3000 - Test single to multi point intents
@@ -19,10 +20,10 @@
     # 5000 - Test host mobility
     # 6000 - Test Multi Point intent End Point Failure
 
-    <testcases>1,[2,10,12,13,15,16,1000,2000,3000,4000,5000,6000,17]*2,[2,11,12,13,15,16,1000,2000,3000,4000,5000,6000,17]*2</testcases>
+    <testcases>1,[2,10,12,13,15,16,1000,2000,3000,4000,5000,6000,18]*2,[2,10,12,13,15,16,17,1000,2000,3000,4000,5000,6000,18]*2,[2,11,12,13,15,16,1000,2000,3000,4000,5000,6000,18]*2,[2,11,12,13,15,16,17,1000,2000,3000,4000,5000,6000,18]*2</testcases>
 
     <SCALE>
-        <size>1,3,1,3</size>
+        <size>1,3,1,3,1,3,1,3</size>
     </SCALE>
 
     <DEPENDENCY>
diff --git a/TestON/tests/FUNCintent/FUNCintent.py b/TestON/tests/FUNCintent/FUNCintent.py
index ba4e8dd..ac72b6b 100644
--- a/TestON/tests/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNCintent/FUNCintent.py
@@ -134,6 +134,7 @@
 
         # main.scale[ 0 ] determines the current number of ONOS controller
         main.numCtrls = int( main.scale[ 0 ] )
+        main.flowCompiler = "Flow Rules"
 
         main.case( "Starting up " + str( main.numCtrls ) +
                    " node(s) ONOS cluster" )
@@ -548,12 +549,31 @@
         balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
 
         utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
+                                 actual=balanceResult,
                                  onpass="Successfully balanced mastership of switches",
                                  onfail="Failed to balance mastership of switches" )
 
     def CASE17( self, main ):
         """
+            Use Flow Objectives
+        """
+        main.case( "Enable intent compilation using Flow Objectives" )
+        main.step( "Enabling Flow Objectives" )
+
+        main.flowCompiler = "Flow Objectives"
+
+        cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
+
+        stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
+                                            propName="useFlowObjectives", value="true" )
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully activated Flow Objectives",
+                                 onfail="Failed to activate Flow Objectives" )
+
+    def CASE18( self, main ):
+        """
             Stop mininet and remove scapy host
         """
         main.log.report( "Stop Mininet and Scapy" )
@@ -626,13 +646,14 @@
 
         main.testName = "Host Intents"
         main.case( main.testName + " Test - " + str( main.numCtrls ) +
-                   " NODE(S) - OF " + main.OFProtocol )
+                   " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
         main.caseExplanation = "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"
+                                + " OVS running in Mininet and compile intents" +\
+                               " using " + main.flowCompiler
 
         main.step( "IPV4: Add host intents between h1 and h9" )
         main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
@@ -856,14 +877,15 @@
 
         main.testName = "Point Intents"
         main.case( main.testName + " Test - " + str( main.numCtrls ) +
-                   " NODE(S) - OF " + main.OFProtocol )
+                   " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
         main.caseExplanation = "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"
+                               " OVS running in Mininet and compile intents" +\
+                               " using " + main.flowCompiler
 
         # No option point intents
         main.step( "NOOPTION: Add point intents between h1 and h9" )
@@ -1177,14 +1199,15 @@
 
         main.testName = "Single to Multi Point Intents"
         main.case( main.testName + " Test - " + str( main.numCtrls ) +
-                   " NODE(S) - OF " + main.OFProtocol )
+                   " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
         main.caseExplanation = "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"
+                               " OVS running in Mininet and compile intents" +\
+                               " using " + main.flowCompiler
 
         main.step( "NOOPTION: Install and test single point to multi point intents" )
         main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
@@ -1382,14 +1405,15 @@
 
         main.testName = "Multi To Single Point Intents"
         main.case( main.testName + " Test - " + str( main.numCtrls ) +
-                   " NODE(S) - OF " + main.OFProtocol )
+                   " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
         main.caseExplanation = "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"
+                               " OVS running in Mininet and compile intents" +\
+                               " using " + main.flowCompiler
 
         main.step( "NOOPTION: Add multi point to single point intents" )
         main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
diff --git a/TestON/tests/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HAclusterRestart/HAclusterRestart.py
index 850a93f..f903f95 100644
--- a/TestON/tests/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HAclusterRestart/HAclusterRestart.py
@@ -2533,7 +2533,7 @@
                 activeIps = []
                 currentResult = main.FALSE
                 for node in current:
-                    if node['state'] == 'ACTIVE':
+                    if node['state'] == 'READY':
                         activeIps.append( node['ip'] )
                 activeIps.sort()
                 if ips == activeIps:
diff --git a/TestON/tests/HAfullNetPartition/HAfullNetPartition.py b/TestON/tests/HAfullNetPartition/HAfullNetPartition.py
index 5c342f3..5a6de1a 100644
--- a/TestON/tests/HAfullNetPartition/HAfullNetPartition.py
+++ b/TestON/tests/HAfullNetPartition/HAfullNetPartition.py
@@ -2537,7 +2537,7 @@
                 activeIps = []
                 currentResult = main.FALSE
                 for node in current:
-                    if node['state'] == 'ACTIVE':
+                    if node['state'] == 'READY':
                         activeIps.append( node['ip'] )
                 activeIps.sort()
                 if ips == activeIps:
diff --git a/TestON/tests/HAkillNodes/HAkillNodes.py b/TestON/tests/HAkillNodes/HAkillNodes.py
index 16b8a8b..7654097 100644
--- a/TestON/tests/HAkillNodes/HAkillNodes.py
+++ b/TestON/tests/HAkillNodes/HAkillNodes.py
@@ -2547,7 +2547,7 @@
                 activeIps = []
                 currentResult = main.FALSE
                 for node in current:
-                    if node['state'] == 'ACTIVE':
+                    if node['state'] == 'READY':
                         activeIps.append( node['ip'] )
                 activeIps.sort()
                 if ips == activeIps:
diff --git a/TestON/tests/HAsanity/HAsanity.py b/TestON/tests/HAsanity/HAsanity.py
index 205e6d2..624b720 100644
--- a/TestON/tests/HAsanity/HAsanity.py
+++ b/TestON/tests/HAsanity/HAsanity.py
@@ -2434,7 +2434,7 @@
                 activeIps = []
                 currentResult = main.FALSE
                 for node in current:
-                    if node['state'] == 'ACTIVE':
+                    if node['state'] == 'READY':
                         activeIps.append( node['ip'] )
                 activeIps.sort()
                 if ips == activeIps:
diff --git a/TestON/tests/HAstopNodes/HAstopNodes.py b/TestON/tests/HAstopNodes/HAstopNodes.py
index 1ebf34a..21ec7f3 100644
--- a/TestON/tests/HAstopNodes/HAstopNodes.py
+++ b/TestON/tests/HAstopNodes/HAstopNodes.py
@@ -2536,7 +2536,7 @@
                 activeIps = []
                 currentResult = main.FALSE
                 for node in current:
-                    if node['state'] == 'ACTIVE':
+                    if node['state'] == 'READY':
                         activeIps.append( node['ip'] )
                 activeIps.sort()
                 if ips == activeIps:
diff --git a/TestON/tests/PLATdockertest/PLATdockertest.py b/TestON/tests/PLATdockertest/PLATdockertest.py
index f56ae70..2e743f3 100755
--- a/TestON/tests/PLATdockertest/PLATdockertest.py
+++ b/TestON/tests/PLATdockertest/PLATdockertest.py
@@ -167,7 +167,7 @@
         main.log.debug("Rest call response: " + str(status) + " - " + response)
         if status == 200:
             jrsp = json.loads(response)
-            clusterIP = [item["ip"]for item in jrsp["nodes"] if item["status"]== "ACTIVE"]
+            clusterIP = [item["ip"]for item in jrsp["nodes"] if item["status"]== "READY"]
             main.log.debug(" IPlist is:" + ",".join(IPlist))
             main.log.debug("cluster IP is" + ",".join(clusterIP) )
             if set(IPlist) == set(clusterIP): stepResult = main.TRUE
diff --git a/TestON/tests/USECASE_SegmentRouting/2x2.json b/TestON/tests/USECASE_SegmentRouting/2x2.json
index c6c2eb8..31b2cc8 100644
--- a/TestON/tests/USECASE_SegmentRouting/2x2.json
+++ b/TestON/tests/USECASE_SegmentRouting/2x2.json
@@ -76,25 +76,25 @@
         }
     },
     "hosts" : {
-        "00:00:00:00:00:01/4093" : {
+        "00:00:00:00:00:01/-1" : {
             "basic": {
                 "ips": ["10.0.1.1"],
                 "location": "of:0000000000000001/3"
             }
         },
-        "00:00:00:00:00:02/4093" : {
+        "00:00:00:00:00:02/-1" : {
             "basic": {
                 "ips": ["10.0.1.2"],
                 "location": "of:0000000000000001/4"
             }
         },
-        "00:00:00:00:00:03/4093" : {
+        "00:00:00:00:00:03/-1" : {
             "basic": {
                 "ips": ["10.0.2.1"],
                 "location": "of:0000000000000002/3"
             }
         },
-        "00:00:00:00:00:04/4093" : {
+        "00:00:00:00:00:04/-1" : {
             "basic": {
                 "ips": ["10.0.2.2"],
                 "location": "of:0000000000000002/4"
diff --git a/TestON/tests/USECASE_SegmentRouting/Dependency/cord_fabric.py b/TestON/tests/USECASE_SegmentRouting/Dependency/cord_fabric.py
index b710b12..a2a8a8e 100755
--- a/TestON/tests/USECASE_SegmentRouting/Dependency/cord_fabric.py
+++ b/TestON/tests/USECASE_SegmentRouting/Dependency/cord_fabric.py
@@ -39,7 +39,7 @@
         for s in range(spine):
             spines[s] = self.addSwitch('spine10%s' % (s + 1), dpid="00000000010%s" % (s + 1))
         # Set link speeds to 100Mb/s
-        linkopts = dict(bw=10)
+        linkopts = dict(bw=100)
 
         # Add Leaf switches
         for ls in range(leaf):
diff --git a/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.params b/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.params
index 93c957f..dfa3d5f 100755
--- a/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.params
+++ b/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.params
@@ -1,6 +1,6 @@
 <PARAMS>
 
-    <testcases>1,2,11,9</testcases>
+    <testcases>1,2,11,9, 2,11,9</testcases>
 
     <SCALE>
         <size>1</size>
@@ -15,7 +15,8 @@
 
     <ENV>
         <cellName>productionCell</cellName>
-        <cellApps>drivers,openflow-base,netcfghostprovider,netcfglinksprovider,segmentrouting,vrouter,hostprovider</cellApps>
+        <cellApps>drivers,segmentrouting</cellApps>
+        <diffApps>openflow-base,netcfghostprovider,netcfglinksprovider;openflow</diffApps>
         <cellUser>sdn</cellUser>
     </ENV>
 
@@ -29,7 +30,7 @@
     </CTRL>
 
     <SLEEP>
-        <startup>15</startup>
+        <startup>10</startup>
     </SLEEP>
 
 </PARAMS>
diff --git a/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.py b/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.py
index 292f990..8635b79 100644
--- a/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.py
+++ b/TestON/tests/USECASE_SegmentRouting/USECASE_SegmentRouting.py
@@ -22,7 +22,7 @@
             - Build ONOS package
         """
 
-        main.case( "Constructing test variables and building ONOS package" )
+        main.case( "Constructing test variables and building ONOS" )
         main.step( "Constructing test variables" )
         stepResult = main.FALSE
 
@@ -30,10 +30,15 @@
         main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
         main.cellName = main.params[ 'ENV' ][ 'cellName' ]
         main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+        main.diff = ( main.params[ 'ENV' ][ 'diffApps' ] ).split(";")
         gitBranch = main.params[ 'GIT' ][ 'branch' ]
         main.dependencyPath = main.testOnDirectory + \
                               main.params[ 'DEPENDENCY' ][ 'path' ]
         main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
+        #main.json = ["4x4"]
+        main.json = ["2x2", "2x2"]
+        main.args = [" ", " "]
+        #main.args = [" --spine 4 --leaf 4 "]
         main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
         main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
         main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
@@ -86,7 +91,7 @@
         else:
             main.log.warn( "Did not pull new code so skipping mvn " +
                            "clean install" )
-
+         
     def CASE2( self, main ):
         """
         - Set up cell
@@ -103,8 +108,7 @@
         # main.scale[ 0 ] determines the current number of ONOS controller
         main.numCtrls = int( main.scale[ 0 ] )
 
-        main.case( "Starting up " + str( main.numCtrls ) +
-                   " node(s) ONOS cluster" )
+        main.case( "Package and start ONOS")
 
         #kill off all onos processes
         main.log.info( "Safety check, killing all ONOS processes" +
@@ -118,14 +122,17 @@
         tempOnosIp = []
         for i in range( main.numCtrls ):
             tempOnosIp.append( main.ONOSip[i] )
-
+        apps=main.apps
+        if main.diff:
+            apps = main.apps+","+main.diff.pop(0)
+        else: main.log.error( "App list is empty" )
         onosUser = main.params[ 'ENV' ][ 'cellUser' ]
         main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
                                        "temp",
                                        main.Mininet1.ip_address,
-                                       main.apps,
+                                       apps,
                                        tempOnosIp,
-                                       onosUser)
+                                       main.ONOSbench.user_name)
 
         main.step( "Apply cell to environment" )
         cellResult = main.ONOSbench.setCell( "temp" )
@@ -138,7 +145,7 @@
                                  onfail="Failed to apply cell to environment " )
 
         main.step( "Creating ONOS package" )
-        main.ONOSbench.handle.sendline( "cp ~/OnosSystemTest/TestON/tests/USECASE_SegmentRouting/2x2.json ~/onos/tools/package/config/network-cfg.json")
+        main.ONOSbench.handle.sendline( "cp ~/OnosSystemTest/TestON/tests/USECASE_SegmentRouting/"+main.json.pop(0)+".json ~/onos/tools/package/config/network-cfg.json")
         packageResult = main.ONOSbench.onosPackage()
         stepResult = packageResult
         utilities.assert_equals( expect=main.TRUE,
@@ -147,6 +154,7 @@
                                  onfail="Failed to create ONOS package" )
 
         time.sleep( main.startUpSleep )
+
         main.step( "Installing ONOS package" )
         onosInstallResult = main.TRUE
         for i in range( main.numCtrls ):
@@ -181,12 +189,13 @@
                                  actual=stepResult,
                                  onpass="ONOS service is ready",
                                  onfail="ONOS service did not start properly" )
-        time.sleep( main.startUpSleep )
+        time.sleep( 2*main.startUpSleep )
 
     def CASE9( self, main ):
         '''
             Report errors/warnings/exceptions
         '''
+        main.log.case( "Logging test" )
         #main.ONOSbench.logReport( main.ONOSip[ 0 ],
         #                          [ "INFO" ],
         #                          "a" )
@@ -200,16 +209,23 @@
                                     "Except" ],
                                   "s" )
 
-
     def CASE11( self, main ):
         """
             Start mininet
         """
+        main.log.case( "Start Leaf-Spine 2x2 Mininet Topology" )
         main.log.report( "Start Mininet topology" )
-        main.log.case( "Start Mininet topology" )
 
         main.step( "Starting Mininet Topology" )
-        topoResult = main.Mininet1.startNet( topoFile= main.dependencyPath + main.topology, args="--onos 1" )
+        args,topo=" "," "
+        #if main.topology:
+        #    topo = main.topology.pop(0)
+        #else: main.log.error( "Topo list is empty" )
+        if main.args:
+            args = "--onos 1 " + main.args.pop(0)
+        else: main.log.error( "Argument list is empty" )
+
+        topoResult = main.Mininet1.startNet( topoFile= main.dependencyPath + main.topology, args=args )
         stepResult = topoResult
         utilities.assert_equals( expect=main.TRUE,
                                  actual=stepResult,
@@ -220,16 +236,14 @@
             main.cleanup()
             main.exit()
         main.step("Waiting for switch initialization and configuration")
-        time.sleep( main.startUpSleep )
+        time.sleep( 3*main.startUpSleep)
         pa = main.Mininet1.pingall()
         utilities.assert_equals( expect=main.TRUE, actual=pa,
                                  onpass="Full connectivity successfully tested",
                                  onfail="Full connectivity failed" )
         # cleanup mininet
-        main.CLIs[0].logout()
         main.ONOSbench.onosStop( main.ONOSip[0] )
         main.Mininet1.stopNet()
-        main.Mininet1.disconnect()