diff --git a/TestON/tests/RCOnosSanity/RCOnosSanity.params b/TestON/tests/RCOnosSanity/RCOnosSanity.params
new file mode 100644
index 0000000..3e236b4
--- /dev/null
+++ b/TestON/tests/RCOnosSanity/RCOnosSanity.params
@@ -0,0 +1,60 @@
+<PARAMS>
+    <testcases>1,2,200,3,4,5,6,7</testcases>
+    <FLOWDEF>/home/onos/ONLabTest/TestON/tests/RCOnosSanity</FLOWDEF>
+    <INTENTS>
+    	<add>pyintents.py</add>
+	<rem>rem_intent_sanity.py</rem>
+    </INTENTS>
+    <RESTTEST>
+        <url>http://127.0.0.1:8080/wm/onos/datagrid/add/intents/json</url>
+        <head>{'Content-type': 'application/json', 'Accept': 'application/json'}</head>
+        <srcMac>00:00:00:00:00:06</srcMac>
+        <dstMac>00:00:00:00:00:10</dstMac>
+        <srcSwitch>00:00:00:00:00:00:10:06</srcSwitch>
+        <dstSwitch>00:00:00:00:00:00:20:31</dstSwitch>
+        <srcPort>1</srcPort>
+        <dstPort>1</dstPort>
+        <intID>6</intID>
+    </RESTTEST>
+    <CASE1>       
+        <destination>h6</destination>
+    </CASE1>       
+    <PING>
+        <source1>h7</source1>
+        <target1>h32</target1>
+        <source2>h8</source2>
+        <target2>h33</target2>
+    </PING>
+    <LINK>
+        <begin>s1</begin>
+        <end>s2</end>
+    </LINK>
+    <YANK>
+        <hostname>h1</hostname>
+        <hostip>10.0.0.1</hostip>
+        <hostmac>00:00:00:00:00:01</hostmac>
+	<sw1>s1</sw1>
+        <sw6>s6</sw6>
+        <intf>s1-eth1</intf>
+    </YANK>
+    <PLUG>
+        <intf>s1-eth1</intf>
+	<sw6>s6</sw6>
+	<sw1>s1</sw1>
+    </PLUG>
+    <CTRL>
+        <ip1>192.168.56.10</ip1>
+        <port1>6633</port1>
+    </CTRL>
+    <RestIP>192.168.56.10</RestIP>
+    <NR_Switches>25</NR_Switches>
+    <NR_Links>50</NR_Links>
+    <RESTCALL>
+	<restIP1>192.168.56.10</restIP1>
+	<restPort>8080</restPort>
+	<restURL>/wm/onos/topology/switches</restURL>
+        <restURL2>/wm/onos/intent/high</restURL2>
+        <restURL3>/wm/onos/topology/hosts</restURL3>
+        <restURL4>/wm/onos/topology/links</restURL4>
+    </RESTCALL>
+</PARAMS>      
diff --git a/TestON/tests/RCOnosSanity/RCOnosSanity.params~ b/TestON/tests/RCOnosSanity/RCOnosSanity.params~
new file mode 100644
index 0000000..c340578
--- /dev/null
+++ b/TestON/tests/RCOnosSanity/RCOnosSanity.params~
@@ -0,0 +1,42 @@
+<PARAMS>
+    <testcases>1,2,21,31,41,4,5,6,7,3,31,41,4,5,6,7</testcases>
+    <FLOWDEF>/home/onos/ONLabTest/TestON/tests/RCOnosSanity</FLOWDEF>
+    <CASE1>       
+        <destination>h6</destination>
+    </CASE1>       
+    <PING>
+        <source1>h7</source1>
+        <target1>h32</target1>
+        <source2>h8</source2>
+        <target2>h33</target2>
+    </PING>
+    <LINK>
+        <begin>s1</begin>
+        <end>s2</end>
+    </LINK>
+    <YANK>
+        <hostname>h1</hostname>
+        <hostip>10.0.0.1</hostip>
+        <hostmac>00:00:00:00:00:01</hostmac>
+	<sw1>s1</sw1>
+        <sw6>s6</sw6>
+        <intf>s1-eth1</intf>
+    </YANK>
+    <PLUG>
+        <intf>s1-eth1</intf>
+	<sw6>s6</sw6>
+	<sw1>s1</sw1>
+    </PLUG>
+    <CTRL>
+        <ip1>192.168.56.10</ip1>
+        <port1>6633</port1>
+    </CTRL>
+    <RestIP>192.168.56.10</RestIP>
+    <NR_Switches>25</NR_Switches>
+    <NR_Links>50</NR_Links>
+    <RESTCALL>
+	<restIP1>192.168.56.10</restIP1>
+	<restPort>8080</restPort>
+	<restURL>/wm/onos/topology/switches</restURL>
+    </RESTCALL>
+</PARAMS>      
diff --git a/TestON/tests/RCOnosSanity/RCOnosSanity.py b/TestON/tests/RCOnosSanity/RCOnosSanity.py
new file mode 100644
index 0000000..b28b2f2
--- /dev/null
+++ b/TestON/tests/RCOnosSanity/RCOnosSanity.py
@@ -0,0 +1,558 @@
+
+class RCOnosSanity :
+
+    def __init__(self) :
+        self.default = ''
+
+#*****************************************************************************************************************************************************************************************
+#Test startup
+#Tests the startup of Zookeeper1, RamCloud1, and ONOS1 to be certain that all started up successfully
+    def CASE1(self,main) :  #Check to be sure ZK, Cass, and ONOS are up, then get ONOS version
+        import time
+        main.ONOS.start()
+        time.sleep(20)
+        main.ONOS.start_rest()
+        test= main.ONOS.rest_status()
+        if test == main.FALSE:
+            main.ONOS.start_rest()
+        main.ONOS.get_version()
+        main.log.report("Started Zookeeper, RamCloud, and ONOS")
+        main.case("Checking if the startup was clean...")
+        main.step("Testing Zookeeper Status")   
+        data =  main.ONOS.zk_status()
+        utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
+        main.step("Testing Ramcloud Coord Status")   
+        data =  main.ONOS.rcc_status()
+        utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Ramcloud Coord is up!",onfail="Ramcloud Coord is down...")
+        main.step("Testing Ramcloud Server Status")   
+        data =  main.ONOS.rcs_status()
+        utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Ramcloud Server is up!",onfail="Ramcloud Server is down...")
+        main.step("Testing ONOS Status")   
+        data =  main.ONOS.status()
+        utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up!",onfail="ONOS is down...")
+        main.step("Testing Rest Status")
+        data =  main.ONOS.rest_status()
+        utilities.assert_equals(expect=main.TRUE,actual=data,onpass="REST is up!",onfail="REST is down...")
+	
+#**********************************************************************************************************************************************************************************************
+#Assign Controllers
+#This test first checks the ip of a mininet host, to be certain that the mininet exists(Host is defined #inParams as <CASE1><destination>).
+#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then #assigns all controllers.    
+
+    def CASE2(self,main) :    #Make sure mininet exists, then assign controllers to switches
+        import time
+        main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
+        main.case("Checking if one MN host exists")
+        main.step("Host IP Checking using checkIP")
+        result = main.Mininet.checkIP(main.params['CASE1']['destination'])
+        main.step("Verifying the result")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
+        main.step("assigning ONOS controller to switches")
+        for i in range(25):
+            if i < 15:
+                j=i+1
+                main.Mininet.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+            else:
+                j=i+16
+                main.Mininet.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+	time.sleep(5)
+        main.Mininet.get_sw_controller("s1")
+
+# **********************************************************************************************************************************************************************************************
+#Add Flows
+#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the #check flow test
+
+    def CASE3(self,main) :    #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
+        main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
+        import time
+        main.case("Taking care of these flows!") 
+        main.step("Cleaning out any leftover flows...")
+        main.ONOS.delete_flow(main.params['INTENTS']['rem'], main.params['FLOWDEF'])
+        strtTime = time.time()
+        main.ONOS.add_flow(main.params['INTENTS']['add'], main.params['FLOWDEF'])
+        main.case("Checking flows")
+        
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            ping = main.Mininet.pingHost(SRC="h"+str(i),TARGET="h"+str(i+25))
+            if ping == main.FALSE and count < 9:
+                count = count + 1
+                i = 6
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                time.sleep(2)
+            elif ping == main.FALSE and count ==9:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time()
+        if result == main.TRUE:
+            main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tFlows failed check")
+
+        result2 = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+        main.step("Verifying the result")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
+
+#*************************************************************************************
+#**************************************************************************************
+#*******************
+#This test case removes Controllers 2,3, and 4 then performs a ping test.
+#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new #controller is #assigned.
+#The ping test performs single pings on hosts from opposite sides of the topology. If 
+#one ping fails, the test waits 5 seconds before trying again.
+#If the ping test fails 6 times, then the test case will return false
+    def CASE41(self,main) :
+        main.log.report("Testing Removal")
+        strtTime = time.time() 
+        result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+        for i in range(10):
+            if result == main.FALSE:
+                time.sleep(5)
+                result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+            else:
+                break
+
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            ping = main.Mininet.pingHost(src="h"+str(i),target="h"+str(i+25))
+            if ping == main.FALSE and count < 6:
+                count = count + 1
+                i = 6
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                time.sleep(2)
+            elif ping == main.FALSE and count ==6:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time() 
+        if result == main.TRUE:
+            main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tPING TEST FAIL")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS,HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+        time.sleep(10)
+
+##########*****************************************************
+    def CASE4(self,main) :
+        main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
+        import time
+        for i in range(25):
+            if i < 15:
+                j=i+1
+                main.Mininet.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+            else:
+                j=i+16
+                main.Mininet.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+        strtTime = time.time()
+        result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+        for i in range(10):
+            if result == main.FALSE:
+                time.sleep(5)
+                result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+            else:
+                break
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            ping = main.Mininet.pingHost(src="h"+str(i),target="h"+str(i+25))
+            if ping == main.FALSE and count < 6:
+                count = count + 1
+                i = 6
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                time.sleep(2)
+            elif ping == main.FALSE and count ==6:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time() 
+        if result == main.TRUE:
+            main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tPING TEST FAIL")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+        time.sleep(10)
+
+# **********************************************************************************************************************************************************************************************
+#This test case restores the controllers removed by Case 4 then performs a ping test.
+
+    def CASE5(self,main) :
+        main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
+        import time
+        for i in range(25):
+            if i < 15:
+                j=i+1
+                main.Mininet.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+            else:
+                j=i+16
+                main.Mininet.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+        strtTime = time.time()
+        result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+        for i in range(2):
+            if result == main.FALSE:
+                time.sleep(5)
+                result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+            else:
+                break
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            ping = main.Mininet.pingHost(src="h"+str(i),target="h"+str(i+25))
+            if ping == main.FALSE and count < 6:
+                count = count + 1
+                i = 6
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                time.sleep(2)
+            elif ping == main.FALSE and count ==6:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time()
+        if result == main.TRUE:
+            main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tPING TEST FAILED")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") 
+# #**********************************************************************************************************************************************************************************************
+#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
+
+    def CASE6(self,main) :
+        main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
+        import time
+        main.case("Bringing Link down... ")
+        result = main.Mininet.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
+       
+        strtTime = time.time() 
+        result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+        for i in range(2):
+            if result == main.FALSE:
+                time.sleep(5)
+                result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+            else:
+                break
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            ping = main.Mininet.pingHost(src="h"+str(i),target="h"+str(i+25))
+            if ping == main.FALSE and count < 10:
+                count = count + 1
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                i = 6
+                time.sleep(2)
+            elif ping == main.FALSE and count == 10:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time()
+        if result == main.TRUE:
+            main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tPING TEST FAILED")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+# #**********************************************************************************************************************************************************************************************
+#Brings the link that Case 6 took down  back up, then runs a ping test to view reroute time
+
+    def CASE7(self,main) :
+        main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
+        import time
+        main.case("Bringing Link up... ")
+        result = main.Mininet.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")      
+        strtTime = time.time()
+        result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+        for i in range(2):
+            if result == main.FALSE:
+                time.sleep(5)
+                result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+            else:
+                break
+        strtTime = time.time()
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            ping = main.Mininet.pingHost(src="h"+str(i),target="h"+str(i+25))
+            if ping == main.FALSE and count < 10:
+                count = count + 1
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                i = 6
+                time.sleep(2)
+            elif ping == main.FALSE and count ==10:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time()
+        if result == main.TRUE:
+            main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tPING TESTS FAILED")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+# #******************************************************************************************************************************************************************
+# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
+
+    def CASE21(self,main) :
+        import json
+        main.log.report("Test device discovery function, by attach, detach, move host h1 from s1->s6->s1. Per mininet naming, switch port the host attaches will remain as 's1-eth1' throughout the test.")
+        main.log.report("Check initially hostMAC/IP exist on the mininet...")
+        host = main.params['YANK']['hostname']
+        mac = main.params['YANK']['hostmac']
+        hostip = main.params['YANK']['hostip']
+        RestIP1 = main.params['RESTCALL']['restIP1']
+        RestPort = main.params['RESTCALL']['restPort']
+        url = main.params['RESTCALL']['restURL']
+       
+        t_topowait = 0
+        t_restwait = 10
+        main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
+        main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
+        #print "host=" + host + ";  RestIP=" + RestIP1 + ";  RestPort=" + str(RestPort)
+        time.sleep(t_topowait) 
+        main.log.info("\n\t\t\t\t ping issue one ping from " + str(host) + " to generate arp to switch. Ping result is not important" )
+        ping = main.Mininet.pingHost(SRC = str(host),TARGET = "10.0.0.254")
+        time.sleep(t_restwait)
+        Reststatus, Switch, Port, MAC = main.ONOS.find_host(RestIP1,RestPort,url, hostip)
+        main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
+        if Reststatus == 1:
+            main.log.report("\t PASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
+            result1 = main.TRUE
+        elif Reststatus > 1:
+            main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+            main.log.report("switches are: " + "; ".join(Switch))
+            main.log.report("Ports are: " + "; ".join(Port))
+            main.log.report("MACs are: " + "; ".join(MAC))
+            result1 = main.FALSE
+        else:
+            main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
+            result1 = main.FALSE
+        ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
+        main.log.report("Yank out s1-eth1")
+        main.step("Yankout s6-eth1 (link to h1) from s1")
+        result = main.Mininet.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
+        time.sleep(t_topowait)
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
+
+        main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
+        ping = main.Mininet.pingHost(SRC = str(host),TARGET = "10.0.0.254")
+        time.sleep(t_restwait)
+        Reststatus, Switch, Port, MAC = main.ONOS.find_host(RestIP1,RestPort,url, hostip)
+
+        main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
+        if Reststatus == 1:
+            main.log.report("\tFAILED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
+            result2 = main.FALSE
+        elif Reststatus > 1:
+            main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+            main.log.report("switches are: " + "; ".join(Switch))
+            main.log.report("Ports are: " + "; ".join(Port))
+            main.log.report("MACs are: " + "; ".join(MAC))
+            result2 = main.FALSE
+        else:
+            main.log.report("\t PASSED - Host " + host + " with MAC:" + str(mac) + " does not exist. PASSED - host is not supposed to be attached to the switch.")
+            result2 = main.TRUE
+         
+        ##### Step to plug "s1-eth1" to s6, which is on autoONOS3  ######
+        main.log.report("Plug s1-eth1 into s6")
+        main.step("Plug s1-eth1 to s6")
+        result = main.Mininet.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
+        time.sleep(t_topowait)
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
+        main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
+
+        ping = main.Mininet.pingHost(src = str(host),target = "10.0.0.254")
+        time.sleep(t_restwait)
+        Reststatus, Switch, Port, MAC = main.ONOS.find_host(RestIP1,RestPort,url, hostip)
+
+        main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
+        if Reststatus == 1:
+            main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
+            result3 = main.TRUE
+        elif Reststatus > 1:
+            main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+            main.log.report("switches are: " + "; ".join(Switch))
+            main.log.report("Ports are: " + "; ".join(Port))
+            main.log.report("MACs are: " + "; ".join(MAC))            
+            result3 = main.FALSE
+        else:
+            main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
+            result3 = main.FALSE
+
+        ###### Step to put interface "s1-eth1" back to s1"#####
+        main.log.report("Move s1-eth1 back on to s1")
+        main.step("Move s1-eth1 back to s1")
+        result = main.Mininet.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
+        time.sleep(t_topowait)
+        result = main.Mininet.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
+        main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
+
+        ping = main.Mininet.pingHost(src = str(host),target = "10.0.0.254")
+        time.sleep(t_restwait)
+        Reststatus, Switch, Port, MAC = main.ONOS.find_host(RestIP1,RestPort,url, hostip)
+
+        main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
+        if Reststatus == 1:
+            main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
+            result4 = main.TRUE
+        elif Reststatus > 1:
+            main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+            main.log.report("switches are: " + "; ".join(Switch))
+            main.log.report("Ports are: " + "; ".join(Port))
+            main.log.report("MACs are: " + "; ".join(MAC))            
+            result4 = main.FALSE
+        else:
+            main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
+            result4 = main.FALSE
+
+        result = result1 and result2 and result3 and result4
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
+
+# Run a pure ping test. 
+
+    def CASE31(self, main):
+        main.log.report("Performing Ping Test")        
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            strtTime = time.time() 
+            ping = main.Mininet.pingHost(src="h"+str(i),target="h"+str(i+25))
+            if ping == main.FALSE and count < 6:
+                count = count + 1
+                i = 6
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                time.sleep(2)
+            elif ping == main.FALSE and count ==6:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time()
+        if result == main.TRUE:
+            main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tPING TEST FAIL")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+
+
+    def CASE200(self, main): 
+        '''
+        POSTS 2 pre-set intents to the REST server and compares the REST server output to expected flows. 
+        '''
+        import time
+        import requests
+        import json
+        import re
+        main.case("Testing Rest Status") 
+
+        #----------------------
+
+        main.log.report("Starting Rest API Only Test")
+        main.log.report("Rest IP used: " + main.params['RestIP'])
+        restcall1 = "http://"+ main.params['RESTCALL']['restIP1'] + ":" + main.params['RESTCALL']['restPort'] + main.params['RESTCALL']['restURL'] 
+        restcall2 = "http://"+ main.params['RESTCALL']['restIP1'] + ":" + main.params['RESTCALL']['restPort'] + main.params['RESTCALL']['restURL2']
+        restcall3 = "http://"+ main.params['RESTCALL']['restIP1'] + ":" + main.params['RESTCALL']['restPort'] + main.params['RESTCALL']['restURL3']
+        restcall4 = "http://"+ main.params['RESTCALL']['restIP1'] + ":" + main.params['RESTCALL']['restPort'] + main.params['RESTCALL']['restURL4']
+
+        main.log.report("Rest Calls used: " + restcall1)
+        main.log.report("Rest Calls used: " + restcall2)
+        main.log.report("Rest Calls used: " + restcall3)
+        main.log.report("Rest Calls used: " + restcall4)
+
+        url = main.params['RESTTEST']['url']
+        #headers = main.params['RESTTEST']['head']
+        headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
+        expSrcMac = main.params['RESTTEST']['srcMac']
+        expDstMac = main.params['RESTTEST']['dstMac']
+        expSrcSwitch = main.params['RESTTEST']['srcSwitch']
+        expDstSwitch = main.params['RESTTEST']['dstSwitch']
+        srcPort = main.params['RESTTEST']['srcPort']
+        dstPort = main.params['RESTTEST']['dstPort']
+        intID = int(main.params['RESTTEST']['intID'])
+
+        intent = [{'intent_id': '%d' %(intID),'intent_type':'shortest_intent_type','intent_op':'add','srcSwitch':expSrcSwitch,'srcPort':int(srcPort),'srcMac':expSrcMac,'dstSwitch':expDstSwitch,'dstPort':int(dstPort),'dstMac':expDstMac}]
+        r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
+
+        intent = [{'intent_id': '%d' %(intID+10),'intent_type':'shortest_intent_type','intent_op':'add','srcSwitch':expDstSwitch,'srcPort':int(dstPort),'srcMac':expDstMac,'dstSwitch':expSrcSwitch,'dstPort':int(srcPort),'dstMac':expSrcMac}]
+        r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
+
+        count = 0
+        main.step("Getting JSON...")
+        #r1 = main.ONOS.get_json_string(restcall1, expSrcSwitch, expDstSwitch, expSrcMac, expDstMac, srcPort, dstPort, intID)
+        r1 = main.ONOS.get_json(restcall1)
+        if re.search(expSrcSwitch, str(r1)) and re.search(expDstSwitch, str(r1)):
+            main.log.report("Restcall: "+restcall1)
+            main.log.report("Expected SrcSwitch "+expSrcSwitch+" found")
+            main.log.report("Expected DstSwitch "+expDstSwitch+" found")
+            count = count+1
+        #r2 = main.ONOS.get_json_string(restcall2, expSrcSwitch, expDstSwitch, expSrcMac, expDstMac, srcPort, dstPort, intID) 
+        r2 = main.ONOS.get_json(restcall2)
+        if re.search("u\'srcMac\': u\'"+expSrcMac+"\'", str(r2)) and re.search("u\'dstMac\': u\'"+expDstMac+"\'", str(r2)):
+            main.log.report("Restcall: "+restcall2)
+            main.log.report("Expected SrcMac "+expSrcMac+" found")
+            main.log.report("Expected DstMac "+expDstMac+" found")
+            if re.search("u\'srcSwitchDpid\': u\'"+expSrcSwitch+"\'", str(r2)) and re.search("u\'dstSwitchDpid\': u\'"+expDstSwitch+"\'", str(r2)):
+                main.log.report("Expected SrcSwitch "+expSrcSwitch+" found")
+                main.log.report("Expected DstSwitch "+expDstSwitch+" found")
+                if re.search("u\'srcPortNumber\': u\'"+srcPort+"\'", str(r2)) and re.search("u\'dstPortNumber\': u\'"+dstPort+"\'", str(r2)):
+                    main.log.report("Expected SrcPort "+srcPort+" found")
+                    main.log.report("Expected DstPort "+dstPort+" found")
+                    count = count+1
+                else:
+                    main.log.report("Expected SrcPort "+srcPort+" NOT found")
+                    main.log.report("Expected DstPort "+dstPort+" NOT found")
+            else:
+                main.log.report("Expected SrcSwitch "+expSrcSwitch+" NOT found")
+                main.log.report("Expected DstSwitch "+expDstSwitch+" NOT found")
+        else:
+            main.log.report("Expected SrcMac "+expSrcMac+" NOT found")
+            main.log.report("Expected DstMac "+expDstMac+" NOT found")
+        if count != 2:
+            main.log.report("Actual data: "+str(r2)) 
+ 
+        #r3 = main.ONOS.get_json_string(restcall3, expSrcSwitch, expDstSwitch, expSrcMac, expDstMac, srcPort, dstPort, intID)
+        r3 = main.ONOS.get_json(restcall3)
+        if re.search("", str(r3)):
+            main.log.report("Restcall: "+restcall3)
+            count = count+1
+  
+        #r4 = main.ONOS.get_json_string(restcall4, expSrcSwitch, expDstSwitch, expSrcMac, expDstMac, srcPort, dstPort, intID)
+        r4 = main.ONOS.get_json(restcall4)
+        if re.search(expSrcSwitch, str(r4)) and re.search(expDstSwitch, str(r4)):
+            main.log.report("Restcall: "+restcall4)
+            main.log.report("Expected SrcSwitch: "+expSrcSwitch+" found")
+            main.log.report("Expected DstSwitch: "+expDstSwitch+" found")
+            count = count+1
+        else:
+            main.log.report("Expected SrcSwitch: "+expSrcSwitch+" NOT found")
+            main.log.report("Expected DstSwitch: "+expDstSwitch+" NOT found")
+
+        utilities.assert_equals(expect=4,actual=count,onpass="REST API test passed!",onfail="REST API test failed...")
+ 
diff --git a/TestON/tests/RCOnosSanity/RCOnosSanity.py~ b/TestON/tests/RCOnosSanity/RCOnosSanity.py~
new file mode 100644
index 0000000..b985f57
--- /dev/null
+++ b/TestON/tests/RCOnosSanity/RCOnosSanity.py~
@@ -0,0 +1,463 @@
+
+class RCOnosSanity :
+
+    def __init__(self) :
+        self.default = ''
+
+#*****************************************************************************************************************************************************************************************
+#Test startup
+#Tests the startup of Zookeeper1, RamCloud1, and ONOS1 to be certain that all started up successfully
+    def CASE1(self,main) :  #Check to be sure ZK, Cass, and ONOS are up, then get ONOS version
+        import time
+        main.ONOS.start()
+        time.sleep(20)
+        main.ONOS.start_rest()
+        time.sleep(4)
+        test= main.ONOS.rest_status()
+        if test == main.FALSE:
+            main.ONOS.start_rest()
+        main.ONOS.get_version()
+        main.log.report("Started Zookeeper, RamCloud, and ONOS")
+        main.case("Checking if the startup was clean...")
+        main.step("Testing Zookeeper Status")   
+        data =  main.ONOS.zk_status()
+        utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
+        main.step("Testing Ramcloud Coord Status")   
+        data =  main.ONOS.rcc_status()
+        utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Ramcloud Coord is up!",onfail="Ramcloud Coord is down...")
+        main.step("Testing Ramcloud Server Status")   
+        data =  main.ONOS.rcs_status()
+        utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Ramcloud Server is up!",onfail="Ramcloud Server is down...")
+        main.step("Testing ONOS Status")   
+        data =  main.ONOS.status()
+        utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up!",onfail="ONOS is down...")
+        main.step("Testing Rest Status")
+        data =  main.ONOS.rest_status()
+        utilities.assert_equals(expect=main.TRUE,actual=data,onpass="REST is up!",onfail="REST is down...")
+	
+#**********************************************************************************************************************************************************************************************
+#Assign Controllers
+#This test first checks the ip of a mininet host, to be certain that the mininet exists(Host is defined #inParams as <CASE1><destination>).
+#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then #assigns all controllers.
+#NOTE: The reason why all four controllers are assigned although one was already assigned as the master is #due to the 'ovs-vsctl set-controller' command erases all present controllers if
+#      the controllers already assigned to the switch are not specified.
+
+    def CASE2(self,main) :    #Make sure mininet exists, then assign controllers to switches
+        import time
+        main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
+        main.case("Checking if one MN host exists")
+        main.step("Host IP Checking using checkIP")
+        result = main.Mininet.checkIP(main.params['CASE1']['destination'])
+        main.step("Verifying the result")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
+        main.step("assigning ONOS controller to switches")
+        for i in range(25):
+            if i < 15:
+                j=i+1
+                main.Mininet.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+            else:
+                j=i+16
+                main.Mininet.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+	main.Mininet.get_sw_controller("s1")
+# **********************************************************************************************************************************************************************************************
+#Add Flows
+#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the #check flow test
+
+    def CASE3(self,main) :    #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
+        main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
+        import time
+        main.case("Taking care of these flows!") 
+        main.step("Cleaning out any leftover flows...")
+        main.ONOS.delete_flow()
+        strtTime = time.time()
+        main.ONOS.add_flow()
+        main.case("Checking flows")
+        
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            ping = main.Mininet.pingHost(SRC="h"+str(i),TARGET="h"+str(i+25))
+            if ping == main.FALSE and count < 9:
+                count = count + 1
+                i = 6
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                time.sleep(2)
+            elif ping == main.FALSE and count ==9:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time()
+        if result == main.TRUE:
+            main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tFlows failed check")
+
+        result2 = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+        main.step("Verifying the result")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
+
+#*************************************************************************************
+#**************************************************************************************
+#*******************
+#This test case removes Controllers 2,3, and 4 then performs a ping test.
+#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new #controller is #assigned.
+#The ping test performs single pings on hosts from opposite sides of the topology. If 
+#one ping fails, the test waits 5 seconds before trying again.
+#If the ping test fails 6 times, then the test case will return false
+    def CASE41(self,main) :
+        main.log.report("Testing Removal")
+        strtTime = time.time() 
+        result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+        for i in range(10):
+            if result == main.FALSE:
+                time.sleep(5)
+                result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+            else:
+                break
+
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            ping = main.Mininet.pingHost(src="h"+str(i),target="h"+str(i+25))
+            if ping == main.FALSE and count < 6:
+                count = count + 1
+                i = 6
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                time.sleep(2)
+            elif ping == main.FALSE and count ==6:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time() 
+        if result == main.TRUE:
+            main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tPING TEST FAIL")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS,HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+        time.sleep(10)
+
+##########*****************************************************
+    def CASE4(self,main) :
+        main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
+        import time
+        for i in range(25):
+            if i < 15:
+                j=i+1
+                main.Mininet.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+            else:
+                j=i+16
+                main.Mininet.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+        strtTime = time.time()
+        result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+        for i in range(10):
+            if result == main.FALSE:
+                time.sleep(5)
+                result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+            else:
+                break
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            ping = main.Mininet.pingHost(src="h"+str(i),target="h"+str(i+25))
+            if ping == main.FALSE and count < 6:
+                count = count + 1
+                i = 6
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                time.sleep(2)
+            elif ping == main.FALSE and count ==6:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time() 
+        if result == main.TRUE:
+            main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tPING TEST FAIL")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+        time.sleep(10)
+
+# **********************************************************************************************************************************************************************************************
+#This test case restores the controllers removed by Case 4 then performs a ping test.
+
+    def CASE5(self,main) :
+        main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
+        import time
+        for i in range(25):
+            if i < 15:
+                j=i+1
+                main.Mininet.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+            else:
+                j=i+16
+                main.Mininet.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
+        strtTime = time.time()
+        result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+        for i in range(2):
+            if result == main.FALSE:
+                time.sleep(5)
+                result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+            else:
+                break
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            ping = main.Mininet.pingHost(src="h"+str(i),target="h"+str(i+25))
+            if ping == main.FALSE and count < 6:
+                count = count + 1
+                i = 6
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                time.sleep(2)
+            elif ping == main.FALSE and count ==6:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time()
+        if result == main.TRUE:
+            main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tPING TEST FAILED")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") 
+# #**********************************************************************************************************************************************************************************************
+#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
+
+    def CASE6(self,main) :
+        main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
+        import time
+        main.case("Bringing Link down... ")
+        result = main.Mininet.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
+       
+        strtTime = time.time() 
+        result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+        for i in range(2):
+            if result == main.FALSE:
+                time.sleep(5)
+                result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
+            else:
+                break
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            ping = main.Mininet.pingHost(src="h"+str(i),target="h"+str(i+25))
+            if ping == main.FALSE and count < 10:
+                count = count + 1
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                i = 6
+                time.sleep(2)
+            elif ping == main.FALSE and count == 10:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time()
+        if result == main.TRUE:
+            main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tPING TEST FAILED")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+# #**********************************************************************************************************************************************************************************************
+#Brings the link that Case 6 took down  back up, then runs a ping test to view reroute time
+
+    def CASE7(self,main) :
+        main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
+        import time
+        main.case("Bringing Link up... ")
+        result = main.Mininet.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")      
+        strtTime = time.time()
+        result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+        for i in range(2):
+            if result == main.FALSE:
+                time.sleep(5)
+                result = main.ONOS.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
+            else:
+                break
+        strtTime = time.time()
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            ping = main.Mininet.pingHost(src="h"+str(i),target="h"+str(i+25))
+            if ping == main.FALSE and count < 10:
+                count = count + 1
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                i = 6
+                time.sleep(2)
+            elif ping == main.FALSE and count ==10:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time()
+        if result == main.TRUE:
+            main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tPING TESTS FAILED")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
+# #******************************************************************************************************************************************************************
+# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
+
+    def CASE21(self,main) :
+        import json
+        main.log.report("Test device discovery function, by attach, detach, move host h1 from s1->s6->s1. Per mininet naming, switch port the host attaches will remain as 's1-eth1' throughout the test.")
+        main.log.report("Check initially hostMAC/IP exist on the mininet...")
+        host = main.params['YANK']['hostname']
+        mac = main.params['YANK']['hostmac']
+        hostip = main.params['YANK']['hostip']
+        RestIP1 = main.params['RESTCALL']['restIP1']
+        RestPort = main.params['RESTCALL']['restPort']
+        url = main.params['RESTCALL']['restURL']
+       
+        t_topowait = 0
+        t_restwait = 10
+        main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
+        main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
+        #print "host=" + host + ";  RestIP=" + RestIP1 + ";  RestPort=" + str(RestPort)
+        time.sleep(t_topowait) 
+        main.log.info("\n\t\t\t\t ping issue one ping from " + str(host) + " to generate arp to switch. Ping result is not important" )
+        ping = main.Mininet.pingHost(SRC = str(host),TARGET = "10.0.0.254")
+        time.sleep(t_restwait)
+        Reststatus, Switch, Port, MAC = main.ONOS.find_host(RestIP1,RestPort,url, hostip)
+        main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
+        if Reststatus == 1:
+            main.log.report("\t PASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
+            result1 = main.TRUE
+        elif Reststatus > 1:
+            main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+            main.log.report("switches are: " + "; ".join(Switch))
+            main.log.report("Ports are: " + "; ".join(Port))
+            main.log.report("MACs are: " + "; ".join(MAC))
+            result1 = main.FALSE
+        else:
+            main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
+            result1 = main.FALSE
+        ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
+        main.log.report("Yank out s1-eth1")
+        main.step("Yankout s6-eth1 (link to h1) from s1")
+        result = main.Mininet.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
+        time.sleep(t_topowait)
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
+
+        main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
+        ping = main.Mininet.pingHost(SRC = str(host),TARGET = "10.0.0.254")
+        time.sleep(t_restwait)
+        Reststatus, Switch, Port, MAC = main.ONOS.find_host(RestIP1,RestPort,url, hostip)
+
+        main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
+        if Reststatus == 1:
+            main.log.report("\tFAILED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
+            result2 = main.FALSE
+        elif Reststatus > 1:
+            main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+            main.log.report("switches are: " + "; ".join(Switch))
+            main.log.report("Ports are: " + "; ".join(Port))
+            main.log.report("MACs are: " + "; ".join(MAC))
+            result2 = main.FALSE
+        else:
+            main.log.report("\t PASSED - Host " + host + " with MAC:" + str(mac) + " does not exist. PASSED - host is not supposed to be attached to the switch.")
+            result2 = main.TRUE
+         
+        ##### Step to plug "s1-eth1" to s6, which is on autoONOS3  ######
+        main.log.report("Plug s1-eth1 into s6")
+        main.step("Plug s1-eth1 to s6")
+        result = main.Mininet.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
+        time.sleep(t_topowait)
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
+        main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
+
+        ping = main.Mininet.pingHost(src = str(host),target = "10.0.0.254")
+        time.sleep(t_restwait)
+        Reststatus, Switch, Port, MAC = main.ONOS.find_host(RestIP1,RestPort,url, hostip)
+
+        main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
+        if Reststatus == 1:
+            main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
+            result3 = main.TRUE
+        elif Reststatus > 1:
+            main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+            main.log.report("switches are: " + "; ".join(Switch))
+            main.log.report("Ports are: " + "; ".join(Port))
+            main.log.report("MACs are: " + "; ".join(MAC))            
+            result3 = main.FALSE
+        else:
+            main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
+            result3 = main.FALSE
+
+        ###### Step to put interface "s1-eth1" back to s1"#####
+        main.log.report("Move s1-eth1 back on to s1")
+        main.step("Move s1-eth1 back to s1")
+        result = main.Mininet.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
+        time.sleep(t_topowait)
+        result = main.Mininet.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
+        main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
+
+        ping = main.Mininet.pingHost(src = str(host),target = "10.0.0.254")
+        time.sleep(t_restwait)
+        Reststatus, Switch, Port, MAC = main.ONOS.find_host(RestIP1,RestPort,url, hostip)
+
+        main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
+        if Reststatus == 1:
+            main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
+            result4 = main.TRUE
+        elif Reststatus > 1:
+            main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+            main.log.report("switches are: " + "; ".join(Switch))
+            main.log.report("Ports are: " + "; ".join(Port))
+            main.log.report("MACs are: " + "; ".join(MAC))            
+            result4 = main.FALSE
+        else:
+            main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
+            result4 = main.FALSE
+
+        result = result1 and result2 and result3 and result4
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
+
+# Run a pure ping test. 
+
+    def CASE31(self, main):
+        main.log.report("Performing Ping Test")        
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            strtTime = time.time() 
+            ping = main.Mininet.pingHost(src="h"+str(i),target="h"+str(i+25))
+            if ping == main.FALSE and count < 6:
+                count = count + 1
+                i = 6
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                time.sleep(2)
+            elif ping == main.FALSE and count ==6:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time()
+        if result == main.TRUE:
+            main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tPING TEST FAIL")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
diff --git a/TestON/tests/RCOnosSanity/RCOnosSanity.topo b/TestON/tests/RCOnosSanity/RCOnosSanity.topo
new file mode 100644
index 0000000..1e1bf8b
--- /dev/null
+++ b/TestON/tests/RCOnosSanity/RCOnosSanity.topo
@@ -0,0 +1,29 @@
+<TOPOLOGY>
+
+    <COMPONENT>
+
+        <ONOS>
+            <host>192.168.56.10</host>
+            <user>onos</user>
+            <password>onos</password>
+            <type>onossanityclidriver</type>
+            <connect_order>1</connect_order>
+            <COMPONENTS>
+             </COMPONENTS>
+        </ONOS>
+
+        <Mininet>
+            <host>192.168.56.10</host>
+            <user>onos</user>
+            <password>onos</password>
+            <type>MininetCliDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS>
+                <arg1> --custom ~/mininet/custom/topo-onos1node.py </arg1>
+                <arg2> --topo mytopo --arp --mac</arg2>
+                <controller>remote</controller>
+             </COMPONENTS>
+        </Mininet>
+
+    </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/RCOnosSanity/RCOnosSanity.topo~ b/TestON/tests/RCOnosSanity/RCOnosSanity.topo~
new file mode 100644
index 0000000..ab4b1b4
--- /dev/null
+++ b/TestON/tests/RCOnosSanity/RCOnosSanity.topo~
@@ -0,0 +1,30 @@
+<TOPOLOGY>
+
+    <COMPONENT>
+
+        <ONOS>
+            <host>192.168.56.10</host>
+            <user>onos</user>
+            <password>onos</password>
+            <type>onossanityclidriver</type>
+            <connect_order>1</connect_order>
+            <COMPONENTS>
+             </COMPONENTS>
+        </ONOS>
+
+        <Mininet>
+            <host>192.168.56.10</host>
+            <user>onos</user>
+            <password>onos</password>
+            <type>MininetCliDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS>
+                # Specify the Option for mininet
+                <arg1> --custom ~/mininet/custom/topo-onos1node.py </arg1>
+                <arg2> --topo mytopo --arp</arg2>
+                <controller> remote </controller>
+             </COMPONENTS>
+        </Mininet>
+
+    </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/RCOnosSanity/README.txt b/TestON/tests/RCOnosSanity/README.txt
new file mode 100644
index 0000000..fe51a93
--- /dev/null
+++ b/TestON/tests/RCOnosSanity/README.txt
@@ -0,0 +1,5 @@
+Please read before proceeding to run test
+- Keep the intent files in the RCOnosSanity directory!
+  Code has been revised to point to FLOWDEF in the params for
+  the intent files. 
+- To use a different intent, modify the .params file.
diff --git a/TestON/tests/RCOnosSanity/__init__.py b/TestON/tests/RCOnosSanity/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/RCOnosSanity/__init__.py
diff --git a/TestON/tests/RCOnosSanity/add_intent_sanity.py b/TestON/tests/RCOnosSanity/add_intent_sanity.py
new file mode 100755
index 0000000..9e8ec99
--- /dev/null
+++ b/TestON/tests/RCOnosSanity/add_intent_sanity.py
@@ -0,0 +1,26 @@
+#! /usr/bin/python
+
+import json
+import requests
+
+
+url = 'http://127.0.0.1:8080/wm/onos/datagrid/add/intents/json'
+headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
+
+
+for i in range(6,16):
+	srcMac = '00:00:00:00:00:'+ str(hex(i)[2:]).zfill(2)
+	dstMac = '00:00:00:00:00:'+ str(hex(i+10)[2:])
+	srcSwitch = '00:00:00:00:00:00:10:'+ str(i).zfill(2)
+	dstSwitch = '00:00:00:00:00:00:20:'+ str(i+25)
+	srcPort = 1
+	dstPort = 1
+	
+	intent = [{'intent_id': '%d' %(i),'intent_type':'shortest_intent_type','intent_op':'add','srcSwitch':srcSwitch,'srcPort':srcPort,'srcMac':srcMac,'dstSwitch':dstSwitch,'dstPort':dstPort,'dstMac':dstMac}]
+	r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
+	#print json.dumps(intent, sort_keys = True)
+	
+	intent = [{'intent_id': '%d' %(i+10),'intent_type':'shortest_intent_type','intent_op':'add','srcSwitch':dstSwitch,'srcPort':dstPort,'srcMac':dstMac,'dstSwitch':srcSwitch,'dstPort':srcPort,'dstMac':srcMac}]
+	#print json.dumps(intent, sort_keys = True)
+	r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
+
diff --git a/TestON/tests/RCOnosSanity/flowdef_20.txt b/TestON/tests/RCOnosSanity/flowdef_20.txt
new file mode 100644
index 0000000..1fd5b40
--- /dev/null
+++ b/TestON/tests/RCOnosSanity/flowdef_20.txt
@@ -0,0 +1,21 @@
+1 ps_1_1 00:00:00:00:00:00:00:06 1 00:00:00:00:00:00:00:1f 1 matchSrcMac 00:00:00:00:00:06 matchDstMac 00:00:00:00:00:10
+2 ps_1_2 00:00:00:00:00:00:00:1f 1 00:00:00:00:00:00:00:06 1 matchSrcMac 00:00:00:00:00:10 matchDstMac 00:00:00:00:00:06
+3 ps_2_1 00:00:00:00:00:00:00:07 1 00:00:00:00:00:00:00:20 1 matchSrcMac 00:00:00:00:00:07 matchDstMac 00:00:00:00:00:11
+4 ps_2_2 00:00:00:00:00:00:00:20 1 00:00:00:00:00:00:00:07 1 matchSrcMac 00:00:00:00:00:11 matchDstMac 00:00:00:00:00:07
+5 ps_3_1 00:00:00:00:00:00:00:08 1 00:00:00:00:00:00:00:21 1 matchSrcMac 00:00:00:00:00:08 matchDstMac 00:00:00:00:00:12
+6 ps_3_2 00:00:00:00:00:00:00:21 1 00:00:00:00:00:00:00:08 1 matchSrcMac 00:00:00:00:00:12 matchDstMac 00:00:00:00:00:08
+7 ps_4_1 00:00:00:00:00:00:00:09 1 00:00:00:00:00:00:00:22 1 matchSrcMac 00:00:00:00:00:09 matchDstMac 00:00:00:00:00:13
+8 ps_4_2 00:00:00:00:00:00:00:22 1 00:00:00:00:00:00:00:09 1 matchSrcMac 00:00:00:00:00:13 matchDstMac 00:00:00:00:00:09
+9 ps_5_1 00:00:00:00:00:00:00:0a 1 00:00:00:00:00:00:00:23 1 matchSrcMac 00:00:00:00:00:0a matchDstMac 00:00:00:00:00:14
+10 ps_5_2 00:00:00:00:00:00:00:23 1 00:00:00:00:00:00:00:0a 1 matchSrcMac 00:00:00:00:00:14 matchDstMac 00:00:00:00:00:0a
+11 ps_6_1 00:00:00:00:00:00:00:0b 1 00:00:00:00:00:00:00:24 1 matchSrcMac 00:00:00:00:00:0b matchDstMac 00:00:00:00:00:15
+12 ps_6_2 00:00:00:00:00:00:00:24 1 00:00:00:00:00:00:00:0b 1 matchSrcMac 00:00:00:00:00:15 matchDstMac 00:00:00:00:00:0b
+13 ps_7_1 00:00:00:00:00:00:00:0c 1 00:00:00:00:00:00:00:25 1 matchSrcMac 00:00:00:00:00:0c matchDstMac 00:00:00:00:00:16
+14 ps_7_2 00:00:00:00:00:00:00:25 1 00:00:00:00:00:00:00:0c 1 matchSrcMac 00:00:00:00:00:16 matchDstMac 00:00:00:00:00:0c
+15 ps_8_1 00:00:00:00:00:00:00:0d 1 00:00:00:00:00:00:00:26 1 matchSrcMac 00:00:00:00:00:0d matchDstMac 00:00:00:00:00:17
+16 ps_8_2 00:00:00:00:00:00:00:26 1 00:00:00:00:00:00:00:0d 1 matchSrcMac 00:00:00:00:00:17 matchDstMac 00:00:00:00:00:0d
+17 ps_9_1 00:00:00:00:00:00:00:0e 1 00:00:00:00:00:00:00:27 1 matchSrcMac 00:00:00:00:00:0e matchDstMac 00:00:00:00:00:18
+18 ps_9_2 00:00:00:00:00:00:00:27 1 00:00:00:00:00:00:00:0e 1 matchSrcMac 00:00:00:00:00:18 matchDstMac 00:00:00:00:00:0e
+19 ps_10_1 00:00:00:00:00:00:00:0f 1 00:00:00:00:00:00:00:28 1 matchSrcMac 00:00:00:00:00:0f matchDstMac 00:00:00:00:00:19
+20 ps_10_2 00:00:00:00:00:00:00:28 1 00:00:00:00:00:00:00:0f 1 matchSrcMac 00:00:00:00:00:19 matchDstMac 00:00:00:00:00:0f
+
diff --git a/TestON/tests/RCOnosSanity/pyintents.py b/TestON/tests/RCOnosSanity/pyintents.py
new file mode 100755
index 0000000..e7902fb
--- /dev/null
+++ b/TestON/tests/RCOnosSanity/pyintents.py
@@ -0,0 +1,56 @@
+#! /usr/bin/env python
+
+import json
+import requests
+
+
+'''
+url = 'http://localhost:8080'
+data = {'sender': 'Alice', 'receiver': 'Bob', 'message': 'We did it!'}
+headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
+r = requests.post(url, data=json.dumps(data), headers=headers)
+'''
+
+url = 'http://127.0.0.1:8080/wm/onos/datagrid/add/intents/json'
+headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
+
+
+'''response
+[{'intent_id':'5','status':'CREATED','log':['created, time:73268214932534']}]
+'''
+
+
+
+for i in range(6,16):
+    #intent = [{'intent_id': '%d' %i,'intent_type':'shortest_intent_type','intent_op':'add','srcSwitch':'8249','srcPort':1,'srcMac':'00:00:00:00:00:01','dstSwitch':'4103','dstPort':1,'dstMac':'00:00:00:00:00:02'}]
+    srcMac = '00:00:00:00:00:'+ str(hex(i)[2:]).zfill(2)
+    dstMac = '00:00:00:00:00:'+ str(hex(i+10)[2:])
+    srcSwitch = '00:00:00:00:00:00:10:'+ str(i).zfill(2)
+    dstSwitch = '00:00:00:00:00:00:20:'+ str(i+25)
+    srcPort = 1 
+    dstPort = 1 
+     
+    print srcMac
+    print dstMac
+    print srcSwitch
+    print dstSwitch
+
+    intent = [{'intent_id': '%d' %(i),'intent_type':'shortest_intent_type','intent_op':'add','srcSwitch':srcSwitch,'srcPort':srcPort,'srcMac':srcMac,'dstSwitch':dstSwitch,'dstPort':dstPort,'dstMac':dstMac}]
+
+
+    print json.dumps(intent, sort_keys = True)
+
+
+    #r = requests.post(url, data=json.dumps(iid, sort_keys=True)+json.dumps(intent, sort_keys=True), headers = headers)
+    r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
+    print r
+    print r.content
+
+
+
+    intent = [{'intent_id': '%d' %(i+10),'intent_type':'shortest_intent_type','intent_op':'add','srcSwitch':dstSwitch,'srcPort':dstPort,'srcMac':dstMac,'dstSwitch':srcSwitch,'dstPort':srcPort,'dstMac':srcMac}]
+    print json.dumps(intent, sort_keys = True)
+    r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
+    print r
+    print r.content
+
diff --git a/TestON/tests/RCOnosSanity/rem_intent_sanity.py b/TestON/tests/RCOnosSanity/rem_intent_sanity.py
new file mode 100755
index 0000000..f841270
--- /dev/null
+++ b/TestON/tests/RCOnosSanity/rem_intent_sanity.py
@@ -0,0 +1,27 @@
+#! /usr/bin/python
+
+import json
+import requests
+
+
+url = 'http://127.0.0.1:8080/wm/onos/datagrid/remove/intents/json'
+headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
+
+for i in range(6,16):
+	srcMac = '00:00:00:00:00:'+ str(hex(i)[2:]).zfill(2)
+	dstMac = '00:00:00:00:00:'+ str(hex(i+10)[2:])
+	srcSwitch = '00:00:00:00:00:00:10:'+ str(i).zfill(2)
+	dstSwitch = '00:00:00:00:00:00:20:'+ str(i+25)
+	srcPort = 1
+	dstPort = 1
+	
+	intent = [{'intent_id': '%d' %(i),'intent_type':'shortest_intent_type','intent_op':'remove','srcSwitch':srcSwitch,'srcPort':srcPort,'srcMac':srcMac,'dstSwitch':dstSwitch,'dstPort':dstPort,'dstMac':dstMac}]
+	r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
+	#print json.dumps(intent, sort_keys = True)
+	
+	intent = [{'intent_id': '%d' %(i+10),'intent_type':'shortest_intent_type','intent_op':'remove','srcSwitch':dstSwitch,'srcPort':dstPort,'srcMac':dstMac,'dstSwitch':srcSwitch,'dstPort':srcPort,'dstMac':srcMac}]
+	#print json.dumps(intent, sort_keys = True)
+	
+#r = requests.post(url, data=json.dumps(add_intent1, sort_keys=True), headers = headers)
+	r = requests.post(url, data=json.dumps(intent, sort_keys=True), headers = headers)
+
