Merge branch 'ONOS-Next' of https://github.com/OPENNETWORKINGLAB/ONLabTest into ONOS-Next

Conflicts:
	TestON/drivers/common/cli/onosclidriver.py
diff --git a/TestON/core/logger.py b/TestON/core/logger.py
index 44a70b8..3a24008 100644
--- a/TestON/core/logger.py
+++ b/TestON/core/logger.py
@@ -42,7 +42,7 @@
             
         logmsg = logmsg + "\n\tTest Script :" + path + "Tests/" + main.TEST + ".py"+ ""
         logmsg = logmsg + "\n\tTest Params : " + path + "Tests/" + main.TEST + ".params" + ""
-        logmsg = logmsg + "\n\tTopology : " + path + "Tests/" +main.TEST + ".tpl" + ""
+        logmsg = logmsg + "\n\tTopology : " + path + "Tests/" +main.TEST + ".topo" + ""
         logmsg = logmsg + "\n"+" " * 30+"+" +"-" * 18+"+" +"\n" +"-" * 27+"  { Script Exec Params }  "+"-" * 27 +"\n" +" " * 30 +"+"+"-" * 18 +"+\n";
         values = "\n\t" + str(main.params)
         values = re.sub(",", "\n\t", values)
@@ -110,7 +110,8 @@
            
         main.LogFileName = main.logdir + "/" + main.TEST + "_" +str(currentTime) + ".log"
         main.ReportFileName = main.logdir + "/" + main.TEST + "_" + str(currentTime) + ".rpt"
-                
+        main.JenkinsCSV = main.logdir + "/" + main.TEST + ".csv"               
+ 
         #### Add log-level - Report
         logging.addLevelName(9, "REPORT")
         logging.addLevelName(7, "EXACT")
@@ -228,7 +229,17 @@
         #main.log.report(testResult)
         main.testResult = testResult
         main.log.exact(testResult)
-                
+        
+        ##CSV output needed for Jenkin's plot plugin
+        #NOTE: the elements were orded based on the colors assigned to the data
+        logfile = open(main.JenkinsCSV ,"w")
+        logfile.write(",".join( ['Tests Failed', 'Tests Passed', 'Tests Planned'] ) + "\n")
+        logfile.write(",".join( [str(main.TOTAL_TC_FAIL), str(main.TOTAL_TC_PASS), str(main.TOTAL_TC_PLANNED)] ))
+        logfile.close()        
+        
+
+
+
     def updateCaseResults(self,main):
         '''
             Update the case result based on the steps execution and asserting each step in the test-case
diff --git a/TestON/dependencies/rotate.sh b/TestON/dependencies/rotate.sh
new file mode 100755
index 0000000..235d138
--- /dev/null
+++ b/TestON/dependencies/rotate.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+
+# NOTE: Taken fnd modified from onos.sh
+# pack-rotate-log [packname] "[log-filenames]" [max rotations]
+# Note: [packname] and all the log-files specified by [log-filenames]
+#       must reside in same dir
+# Example:
+#  pack="/foo/bar/testlogs"
+#  logfiles="/foo/bar/test1.log /foo/bar/test*.log"
+#  pack-rotate-log $pack "$logfiles" 5
+#   => testlogs.tar.bz2 (will contain test1.log test2.log ...)
+#      testlogs.tar.bz2 -> testlogs.1.tar.bz2
+#      testlogs.1.tar.bz2 -> testlogs.2.tar.bz2
+#      ...
+function pack-rotate-log {
+  local packname=$1
+  local logfiles=$2
+  local nr_max=${3:-10}
+  local suffix=".tar.bz2"
+
+  # rotate
+  for i in `seq $(expr $nr_max - 1) -1 1`; do
+    if [ -f ${packname}.${i}${suffix} ]; then
+      mv -f -- ${packname}.${i}${suffix} ${packname}.`expr $i + 1`${suffix}
+    fi
+  done
+  if [ -f ${packname}${suffix} ]; then
+    mv -- ${packname}${suffix} ${packname}.1${suffix}
+  fi
+
+  # pack
+  local existing_logfiles=$( ls -1 $logfiles  2>/dev/null | xargs -n1  basename 2>/dev/null)
+  if [ ! -z "${existing_logfiles}" ]; then
+    tar cjf ${packname}${suffix} -C `dirname ${packname}` -- ${existing_logfiles}
+    for word in ${existing_logfiles}
+    do
+        rm -- `dirname ${packname}`/${word}
+    done
+   fi
+}
+
+
+
+#Begin script
+#NOTE: This seems to break the TestON summary since it mentions the testname
+#echo "Rotating logs for '${1}' test"
+base_name=$1
+root_dir="/home/admin/packet_captures"
+timestamp=`date +%Y_%B_%d_%H_%M_%S`
+#Maybe this should be an argument? pack-and-rotate supports that
+nr_max=20
+
+pack-rotate-log ${root_dir}'/'${base_name} "${root_dir}/${base_name}*.pcap" ${nr_max}
diff --git a/TestON/drivers/common/cli/emulator/lincoedriver.py b/TestON/drivers/common/cli/emulator/lincoedriver.py
index 4d2cc01..8da1700 100644
--- a/TestON/drivers/common/cli/emulator/lincoedriver.py
+++ b/TestON/drivers/common/cli/emulator/lincoedriver.py
@@ -10,6 +10,7 @@
 list your email here for future contact:
 
     andrew@onlab.us
+    shreya@onlab.us
 
 OCT 20 2014
 '''
@@ -23,6 +24,7 @@
 import re
 import sys
 import core.teston
+import time
 sys.path.append("../")
 from math import pow
 from drivers.common.cli.emulatordriver import Emulator
@@ -60,9 +62,16 @@
         if self.handle :
             main.log.info("Handle successfully created")
             self.home = "~/linc-oe"
+         
             self.handle.sendline("cd "+self.home)
             self.handle.expect("oe$")
-
+          
+            #self.handle.sendline("pgrep -g linc")
+            #self.handle.expect("\$")
+            print "handle = ", self.handle.before            
+            
+            return main.TRUE 
+            ''' 
             main.log.info("Building Linc-OE")
             self.handle.sendline("make rel")
             i = self.handle.expect(["ERROR","linc-oe\$"],timeout=60)
@@ -73,15 +82,15 @@
                 x = self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
                 main.log.info("make rel returned: "+ str(x))
             else: 
-                main.log.info(self.name+": Starting Linc-OE CLI.. This may take a while")
-                time.sleep(30)
-                self.handle.sendline("sudo ./rel/linc/bin/linc console")
-                j = self.handle.expect(["linc@",pexpect.EOF,pexpect.TIMEOUT])
-          
+            
+            main.log.info(self.name+": Starting Linc-OE CLI.. This may take a while")
+            time.sleep(30)
+            self.handle.sendline("sudo ./rel/linc/bin/linc console")
+            j = self.handle.expect(["linc@",pexpect.EOF,pexpect.TIMEOUT])
             if j == 0:
                 main.log.info("Linc-OE CLI started")
                 return main.TRUE
-
+            '''
         else:
             main.log.error(self.name+
                     ": Connection failed to the host "+
@@ -90,6 +99,26 @@
                     ": Failed to connect to Linc-OE")
             return main.FALSE
 
+
+    def start_console(self):
+        import time
+        main.log.info(self.name+": Starting Linc-OE CLI.. This may take a while")
+        time.sleep(30)
+        self.handle.sendline("sudo ./rel/linc/bin/linc console")
+        j = self.handle.expect(["linc@",pexpect.EOF,pexpect.TIMEOUT])
+        start_result = self.handle.before
+        if j == 0:
+            main.log.info("Linc-OE CLI started")
+            return main.TRUE
+        else:
+            main.log.error(self.name+
+            ": Connection failed to the host "+self.user_name+"@"+self.ip_address)
+            main.log.error(self.name+
+            ": Failed to connect to Linc-OE")
+            return main.FALSE
+
+
+
     def build(self):
         '''
         Build Linc-OE with the specified settings
@@ -285,18 +314,42 @@
             main.log.info(self.name+" :::::::")
             main.cleanup()
             main.exit()
+    
+    def stopLincOEConsole(self):
+        '''
+        This function is only used for packet optical testing
+        Send disconnect prompt to Linc-OE CLI
+        (CTRL+C) and kill the linc process
+        '''
+        try:
+            cmd = "pgrep -f linc"
+            self.handle.sendline("pgrep -f linc")
+            self.handle.expect("linc") 
+            print "stophandle = ", self.handle.before
+        except pexpect.EOF:
+            main.log.error(self.name+ ": EOF exception")
+            main.log.error(self.name+ ":    " + self.handle.before) 
 
     def disconnect(self):
         '''
         Send disconnect prompt to Linc-OE CLI
-        (CTRL+C)
+        (CTRL+C) and kill the linc process
         '''
         try:
             #Send CTRL+C twice to exit CLI
-            self.handle.sendline("\x03")
-            self.handle.sendline("\x03")
+            self.handle.send("\x03")
+            self.handle.send("\x03")
             self.handle.expect("\$")
-
+            handle1 = self.handle.before
+            cmd = "pgrep -f linc"
+            self.handle.sendline(cmd)
+            self.handle.expect("\$")
+            handle2 = self.handle.before
+            main.log.info("pid's = "+handle2)
+            cmd = "sudo kill -9 `pgrep -f linc`"
+            self.handle.sendline(cmd)
+            self.handle.expect("\$")
+            
         except pexpect.EOF:
             main.log.error(self.name+ ": EOF exception")
             main.log.error(self.name+ ":    " + self.handle.before)
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index c888e23..92ec312 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -146,14 +146,18 @@
         topoDict = self.num_switches_n_links(*topoArgList)
         return topoDict
 
-    def pingall(self):
+    def pingall(self, timeout=300):
         '''
         Verifies the reachability of the hosts using pingall command.
+        Optional parameter timeout allows you to specify how long to wait for pingall to complete
+        Returns:
+                main.TRUE if pingall completes with no pings dropped
+                otherwise main.FALSE
         '''
         if self.handle :
             main.log.info(self.name+": Checking reachabilty to the hosts using pingall")
             try:
-                response = self.execute(cmd="pingall",prompt="mininet>",timeout=300)
+                response = self.execute(cmd="pingall",prompt="mininet>",timeout=int(timeout))
             except pexpect.EOF:
                 main.log.error(self.name + ": EOF exception found")
                 main.log.error(self.name + ":     " + self.handle.before)
@@ -283,7 +287,47 @@
             return main.FALSE
         else :
             return main.TRUE
+
     
+
+
+    def changeIP(self,host,intf,newIP,newNetmask):
+        '''
+        Changes the ip address of a host on the fly
+        Ex: h2 ifconfig h2-eth0 10.0.1.2 netmask 255.255.255.0
+        '''
+        if self.handle:
+            try:
+                cmd = host+" ifconfig "+intf+" "+newIP+" "+newNetMask
+                self.handle.sendline(cmd)
+                self.handle.expect("mininet>")
+                response = self.handle.before
+                main.log.info("Ip of host "+host+" changed to new IP "+newIP)
+                return main.TRUE
+            except pexpect.EOF:
+                main.log.error(self.name + ": EOF exception found")
+                main.log.error(self.name + ":     " + self.handle.before)
+                return main.FALSE
+
+    def changeDefaultGateway(self,host,newGW):
+        '''
+        Changes the default gateway of a host
+        Ex: h1 route add default gw 10.0.1.2
+        '''
+        if self.handle:
+            try:
+                cmd = host+" route add default gw "+newGW 
+                self.handle.sendline(cmd)
+                self.handle.expect("mininet>")
+                response = self.handle.before
+                main.log.info("Default gateway of host "+host+" changed to "+newGW)
+                return main.TRUE
+            except pexpect.EOF:
+                main.log.error(self.name + ": EOF exception found")
+                main.log.error(self.name + ":     " + self.handle.before)
+                return main.FALSE
+   
+
     def getMacAddress(self,host):
         '''
         Verifies the host's ip configured or not.
@@ -439,17 +483,40 @@
             main.cleanup()
             main.exit()
         return response
-    
-    def iperf(self):
+    '''
+    def iperf(self,host1,host2):
         main.log.info(self.name+": Simple iperf TCP test between two (optionally specified) hosts")
         try:
-            response = self.execute(cmd = 'iperf',prompt = 'mininet>',timeout = 10)
+            if not host1 and not host2:
+                response = self.execute(cmd = 'iperf',prompt = 'mininet>',timeout = 10)
+            else:
+                cmd1 = 'iperf '+ host1 + " " + host2
+                response = self.execute(cmd = cmd1, prompt = '>',timeout = 20)
         except pexpect.EOF:  
             main.log.error(self.name + ": EOF exception found")
             main.log.error(self.name + ":     " + self.handle.before)
             main.cleanup()
             main.exit()
         return response
+     '''
+    def iperf(self,host1,host2):
+        main.log.info(self.name+": Simple iperf TCP test between two hosts")
+        try:
+            cmd1 = 'iperf '+ host1 + " " + host2
+            self.handle.sendline(cmd1)
+            self.handle.expect("mininet>") 
+            response = self.handle.before
+            if re.search('Results:',response):
+                main.log.info(self.name+": iperf test succssful")
+                return main.TRUE
+            else:
+                main.log.error(self.name+": iperf test failed")
+                return main.FALSE 
+        except pexpect.EOF:
+            main.log.error(self.name + ": EOF exception found")
+            main.log.error(self.name + ":     " + self.handle.before)
+            main.cleanup()
+            main.exit()
     
     def iperfudp(self):
         main.log.info(self.name+": Simple iperf TCP test between two (optionally specified) hosts")
@@ -656,6 +723,187 @@
         else:
             main.log.info(response)
 
+    def add_switch( self, sw, **kwargs ):
+        '''
+        adds a switch to the mininet topology
+        NOTE: this uses a custom mn function
+        NOTE: cannot currently specify what type of switch
+        required params:
+            switchname = name of the new switch as a string
+        optional keyvalues:
+            dpid = "dpid"
+        returns: main.FASLE on an error, else main.TRUE
+        '''
+        dpid = kwargs.get('dpid', '')
+        command = "addswitch " + str( sw ) + " " + str( dpid )
+        try:
+            response = self.execute(cmd=command,prompt="mininet>",timeout=10)
+            if re.search("already exists!", response):
+                main.log.warn(response)
+                return main.FALSE
+            elif re.search("Error", response):
+                main.log.warn(response)
+                return main.FALSE
+            elif re.search("usage:", response):
+                main.log.warn(response)
+                return main.FALSE
+            else:
+                return main.TRUE
+        except pexpect.EOF:
+            main.log.error(self.name + ": EOF exception found")
+            main.log.error(self.name + ":     " + self.handle.before)
+            main.cleanup()
+            main.exit()
+
+    def del_switch( self, sw ):
+        '''
+        delete a switch from the mininet topology
+        NOTE: this uses a custom mn function
+        required params:
+            switchname = name of the switch as a string
+        returns: main.FASLE on an error, else main.TRUE
+        '''
+        command = "delswitch " + str( sw )
+        try:
+            response = self.execute(cmd=command,prompt="mininet>",timeout=10)
+            if re.search("no switch named", response):
+                main.log.warn(response)
+                return main.FALSE
+            elif re.search("Error", response):
+                main.log.warn(response)
+                return main.FALSE
+            elif re.search("usage:", response):
+                main.log.warn(response)
+                return main.FALSE
+            else:
+                return main.TRUE
+        except pexpect.EOF:
+            main.log.error(self.name + ": EOF exception found")
+            main.log.error(self.name + ":     " + self.handle.before)
+            main.cleanup()
+            main.exit()
+
+    def add_link( self, node1, node2 ):
+        '''
+        add a link to the mininet topology
+        NOTE: this uses a custom mn function
+        NOTE: cannot currently specify what type of link
+        required params:
+            node1 = the string node name of the first endpoint of the link
+            node2 = the string node name of the second endpoint of the link
+        returns: main.FASLE on an error, else main.TRUE
+        '''
+        command = "addlink " + str( node1 ) + " " + str( node2 )
+        try:
+            response = self.execute(cmd=command,prompt="mininet>",timeout=10)
+            if re.search("doesnt exist!", response):
+                main.log.warn(response)
+                return main.FALSE
+            elif re.search("Error", response):
+                main.log.warn(response)
+                return main.FALSE
+            elif re.search("usage:", response):
+                main.log.warn(response)
+                return main.FALSE
+            else:
+                return main.TRUE
+        except pexpect.EOF:
+            main.log.error(self.name + ": EOF exception found")
+            main.log.error(self.name + ":     " + self.handle.before)
+            main.cleanup()
+            main.exit()
+
+    def del_link( self, node1, node2 ):
+        '''
+        delete a link from the mininet topology
+        NOTE: this uses a custom mn function
+        required params:
+            node1 = the string node name of the first endpoint of the link
+            node2 = the string node name of the second endpoint of the link
+        returns: main.FASLE on an error, else main.TRUE
+        '''
+        command = "dellink " + str( node1 ) + " " + str( node2 )
+        try:
+            response = self.execute(cmd=command,prompt="mininet>",timeout=10)
+            if re.search("no node named", response):
+                main.log.warn(response)
+                return main.FALSE
+            elif re.search("Error", response):
+                main.log.warn(response)
+                return main.FALSE
+            elif re.search("usage:", response):
+                main.log.warn(response)
+                return main.FALSE
+            else:
+                return main.TRUE
+        except pexpect.EOF:
+            main.log.error(self.name + ": EOF exception found")
+            main.log.error(self.name + ":     " + self.handle.before)
+            main.cleanup()
+            main.exit()
+
+    def add_host( self, hostname, **kwargs ):
+        '''
+        Add a host to the mininet topology
+        NOTE: this uses a custom mn function
+        NOTE: cannot currently specify what type of host
+        required params:
+            hostname = the string hostname
+        optional key-value params
+            switch = "switch name"
+            returns: main.FASLE on an error, else main.TRUE
+        '''
+        switch = kwargs.get('switch', '')
+        command = "addhost " + str( hostname ) + " " + str( switch )
+        try:
+            response = self.execute(cmd=command,prompt="mininet>",timeout=10)
+            if re.search("already exists!", response):
+                main.log.warn(response)
+                return main.FALSE
+            elif re.search("doesnt exists!", response):
+                main.log.warn(response)
+                return main.FALSE
+            elif re.search("Error", response):
+                main.log.warn(response)
+                return main.FALSE
+            elif re.search("usage:", response):
+                main.log.warn(response)
+                return main.FALSE
+            else:
+                return main.TRUE
+        except pexpect.EOF:
+            main.log.error(self.name + ": EOF exception found")
+            main.log.error(self.name + ":     " + self.handle.before)
+            main.cleanup()
+            main.exit()
+
+    def del_host( self, hostname ):
+        '''
+        delete a host from the mininet topology
+        NOTE: this uses a custom mn function
+        required params:
+            hostname = the string hostname
+            returns: main.FASLE on an error, else main.TRUE
+        '''
+        command = "delhost " + str( hostname )
+        try:
+            response = self.execute(cmd=command,prompt="mininet>",timeout=10)
+            if re.search("no host named", response):
+                main.log.warn(response)
+                return main.FALSE
+            elif re.search("Error", response):
+                main.log.warn(response)
+                return main.FALSE
+            elif re.search("usage:", response):
+                main.log.warn(response)
+                return main.FALSE
+            else:
+                return main.TRUE
+        except pexpect.EOF:
+            main.log.error(self.name + ": EOF exception found")
+            main.log.error(self.name + ":     " + self.handle.before)
+            main.cleanup()
+            main.exit()
 
     def disconnect(self):
         main.log.info(self.name+": Disconnecting mininet...")
@@ -928,10 +1176,8 @@
             onos_ports = [x for x in onos_ports]
 
             #TODO: handle other reserved port numbers besides LOCAL
-            #NOTE: List of Reserved Ports
-            #   Local port: -2 in unsigned int in Openflow, the size depends on
-            #       openflow version( 1.0 is 16 bit, 1.3 is 32 bit), ONOS shows
-            #       'local', we store as long(uint64(-2))
+            #NOTE: Reserved ports
+            #   Local port: -2 in Openflow, ONOS shows 'local', we store as long(uint64(-2))
             for mn_port in mn_ports_log:
                 if mn_port in onos_ports:
                     #don't set results to true here as this is just one of many checks and it might override a failure
@@ -951,7 +1197,7 @@
                 switch_result = main.FALSE
                 main.log.warn("Ports in ONOS but not MN: " + str(onos_ports) )
             if switch_result == main.FALSE:
-                main.log.report("The list of active ports for switch %s(%s) does not match:" % (mn_switch['name'], mn_switch['dpid']) )
+                main.log.report("The list of ports for switch %s(%s) does not match:" % (mn_switch['name'], mn_switch['dpid']) )
                 main.log.warn("mn_ports[]  =  " + str(mn_ports_log))
                 main.log.warn("onos_ports[] = " + str(onos_ports_log))
             ports_results = ports_results and switch_result
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index 5d2a7a3..1795a16 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -80,9 +80,16 @@
         Returns main.ERROR if "found multiple mininet" is found and
         Returns main.TRUE else
         '''
+        #TODO: maybe we want to return the % loss instead? This way we can set an acceptible loss %.
+        #EX: 393 packets transmitted, 380 received, 3% packet loss, time 78519ms
+        # we may need to return a float to get around rounding errors
+
         import os
         self.handle.sendline("")
         self.handle.expect("\$")
+        #Clear any output waiting in the bg from killing pings
+        self.handle.sendline("")
+        self.handle.expect("\$")
         self.handle.sendline("cat " + pingList)
         self.handle.expect(pingList)
         self.handle.expect("\$")
@@ -162,8 +169,13 @@
         self.handle.sendline("")
         self.handle.expect("\$")
         self.handle.sendline("")
-        self.handle.expect("\$")
-        return main.TRUE
+        i=self.handle.expect(["password","\$"])
+        if i == 0:
+            main.log.error("Error, sudo asking for password")
+            main.log.error(self.handle.before)
+            return main.FALSE
+        else:
+            return main.TRUE
     
     def pingLongKill(self):
         import time
@@ -215,34 +227,6 @@
             main.last_result = main.FALSE
             return main.FALSE
 
-
-    def pingall(self):
-        '''
-        Verifies the reachability of the hosts using pingall command.
-        This function is required by Packey Optical test
-        '''
-        if self.handle :
-            main.log.info(self.name+": Checking reachabilty to the hosts using pingall")
-            try:
-                response = self.execute(cmd="pingall",prompt="mininet>",timeout=120)
-                print "response: " + str(response)
-            except pexpect.EOF:
-                main.log.error(self.name + ": EOF exception found")
-                main.log.error(self.name + ":     " + self.handle.before)
-            pattern = 'Results\:\s0\%\sdropped\s'
-            if re.search(pattern,response):
-                main.log.info(self.name+": All hosts are reachable")
-                return main.TRUE
-            else:
-                main.log.error(self.name+": Unable to reach all the hosts")
-                return main.FALSE
-        else :
-            main.log.error(self.name+": Connection failed to the host")
-            return main.FALSE
-
-
-
- 
     def pingHost(self,**pingParams):
         ''' 
         Pings between two hosts on remote mininet  
@@ -292,154 +276,14 @@
         else :
             main.log.error("Connection failed to the host") 
 
-    def ctrl_none(self):
-        '''
-        Sets all the switches to no controllers. 
-        '''
-        self.execute(cmd="~/ONOS/scripts/test-ctrl-none.sh", prompt="\$",timeout=10)
-
-    def ctrl_one(self, ip):
-        '''
-        Sets all the switches to point to the supplied IP
-        '''
-        self.execute(cmd="~/ONOS/scripts/test-ctrl-one.sh "+ip, prompt="\$",timeout=10)
- 
-    def ctrl_local(self):
-        '''
-        Sets all the switches to point to the Controller on the same machine that they are running on. 
-        '''
-        self.execute(cmd="~/ONOS/scripts/test-ctrl-local.sh ", prompt="\$",timeout=10)
-
- #   def verifySSH(self,**connectargs):
- #       response = self.execute(cmd="h1 /usr/sbin/sshd -D&",prompt="mininet>",timeout=10)
- #       response = self.execute(cmd="h4 /usr/sbin/sshd -D&",prompt="mininet>",timeout=10)
- #       for key in connectargs:
- #           vars(self)[key] = connectargs[key]
- #       response = self.execute(cmd="xterm h1 h4 ",prompt="mininet>",timeout=10)
- #       import time
- #       time.sleep(20)
- #       if self.flag == 0:
- #           self.flag = 1
- #           return main.FALSE
- #       else :
- #           return main.TRUE
- #   
- #   def getMacAddress(self,host):
- #       '''
- #           Verifies the host's ip configured or not.
- #       '''
- #       if self.handle :
- #           response = self.execute(cmd=host+" ifconfig",prompt="mininet>",timeout=10)
-
- #           pattern = "HWaddr\s(((\d|\w)+:)+(\d|\w))"
- #           mac_address_search = re.search(pattern, response)
- #           main.log.info("Mac-Address of Host "+host +" is "+mac_address_search.group(1))
- #           return mac_address_search.group(1)
- #       else :
- #           main.log.error("Connection failed to the host") 
- #   def getIPAddress(self,host):
- #       '''
- #           Verifies the host's ip configured or not.
- #       '''
- #       if self.handle :
- #           response = self.execute(cmd=host+" ifconfig",prompt="mininet>",timeout=10)
-
- #           pattern = "inet\saddr:(\d+\.\d+\.\d+\.\d+)"
- #           ip_address_search = re.search(pattern, response)
- #           main.log.info("IP-Address of Host "+host +" is "+ip_address_search.group(1))
- #           return ip_address_search.group(1)
- #       else :
- #           main.log.error("Connection failed to the host") 
- #       
- #   def dump(self):
- #       main.log.info("Dump node info")
- #       self.execute(cmd = 'dump',prompt = 'mininet>',timeout = 10)
- #       return main.TRUE
- #           
- #   def intfs(self):
- #       main.log.info("List interfaces")
- #       self.execute(cmd = 'intfs',prompt = 'mininet>',timeout = 10)
- #       return main.TRUE
- #   
- #   def net(self):
- #       main.log.info("List network connections")
- #       self.execute(cmd = 'net',prompt = 'mininet>',timeout = 10)
- #       return main.TRUE
- #   
- #   def iperf(self):
- #       main.log.info("Simple iperf TCP test between two (optionally specified) hosts")
- #       self.execute(cmd = 'iperf',prompt = 'mininet>',timeout = 10)
- #       return main.TRUE
- #   
- #   def iperfudp(self):
- #       main.log.info("Simple iperf TCP test between two (optionally specified) hosts")
- #       self.execute(cmd = 'iperfudp',prompt = 'mininet>',timeout = 10)
- #       return main.TRUE
- #   
- #   def nodes(self):
- #       main.log.info("List all nodes.")
- #       self.execute(cmd = 'nodes',prompt = 'mininet>',timeout = 10)    
- #       return main.TRUE
- #   
- #   def pingpair(self):
- #       main.log.infoe("Ping between first two hosts")
- #       self.execute(cmd = 'pingpair',prompt = 'mininet>',timeout = 20)
- #       
- #       if utilities.assert_matches(expect='0% packet loss',actual=response,onpass="No Packet loss",onfail="Hosts not reachable"):
- #           main.log.info("Ping between two hosts SUCCESS")
- #           main.last_result = main.TRUE 
- #           return main.TRUE
- #       else :
- #           main.log.error("PACKET LOST, HOSTS NOT REACHABLE")
- #           main.last_result = main.FALSE
- #           return main.FALSE
- #   
- #   def link(self,**linkargs):
- #       '''
- #       Bring link(s) between two nodes up or down
- #       '''
- #       main.log.info('Bring link(s) between two nodes up or down')
- #       args = utilities.parse_args(["END1","END2","OPTION"],**linkargs)
- #       end1 = args["END1"] if args["END1"] != None else ""
- #       end2 = args["END2"] if args["END2"] != None else ""
- #       option = args["OPTION"] if args["OPTION"] != None else ""
- #       command = "link "+str(end1) + " " + str(end2)+ " " + str(option)
- #       response = self.execute(cmd=command,prompt="mininet>",timeout=10)
- #       return main.TRUE
- #       
-
- #   def dpctl(self,**dpctlargs):
- #       '''
- #        Run dpctl command on all switches.
- #       '''
- #       main.log.info('Run dpctl command on all switches')
- #       args = utilities.parse_args(["CMD","ARGS"],**dpctlargs)
- #       cmd = args["CMD"] if args["CMD"] != None else ""
- #       cmdargs = args["ARGS"] if args["ARGS"] != None else ""
- #       command = "dpctl "+cmd + " " + str(cmdargs)
- #       response = self.execute(cmd=command,prompt="mininet>",timeout=10)
- #       return main.TRUE
- #  
- #       
- #   def get_version(self):
- #       file_input = path+'/lib/Mininet/INSTALL'
- #       version = super(Mininet, self).get_version()
- #       pattern = 'Mininet\s\w\.\w\.\w\w*'
- #       for line in open(file_input,'r').readlines():
- #           result = re.match(pattern, line)
- #           if result:
- #               version = result.group(0)
- #               
- #           
- #       return version    
-    def start_tcpdump(self, filename, intf = "eth0", port = "port 6633"):
+    def start_tcpdump(self, filename, intf = "eth0", port = "port 6633", user="admin"):
         ''' 
         Runs tpdump on an intferface and saves the file
         intf can be specified, or the default eth0 is used
         '''
         try:
             self.handle.sendline("")
-            self.handle.sendline("sudo tcpdump -n -i "+ intf + " " + port + " -w " + filename.strip() + "  &")
+            self.handle.sendline("sudo tcpdump -n -i "+ intf + " " + port + " -w " + filename.strip() + " -Z " + user + "  &")
             self.handle.sendline("")
             self.handle.sendline("")
             i=self.handle.expect(['No\ssuch\device','listening\son',pexpect.TIMEOUT,"\$"],timeout=10)
@@ -508,49 +352,6 @@
             main.log.error(self.name + ": EOF exception found")
             main.log.error(self.name + ":     " + self.handle.before)
             return main.FALSE
-    
-    def del_switch(self,sw):
-        self.handle.sendline("")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl del-br "+sw)
-        self.handle.expect("\$")
-        return main.TRUE
-
-    def add_switch(self,sw):
-        #FIXME: Remove hardcoded number of ports
-        self.handle.sendline("")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-br "+sw)
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth1")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth2")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth3")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth4")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth5")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth6")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth7")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth8")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth9")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth10")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth11")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth12")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth13")
-        self.handle.expect("\$")
-        self.handle.sendline("sudo ovs-vsctl add-port "+sw+" " + sw + "-eth14")
-        self.handle.expect("\$")
-
 
     def disconnect(self):
         '''    
@@ -574,8 +375,6 @@
         #FIXME: clean up print statements and such
         self.handle.sendline("cd")
         self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
-        #print "cd expect status: "
-        #print self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
         #TODO: Write seperate versions of the function for this, possibly a string that tells it which switch is in use?
         #For 1.0 version of OVS
         #command = "sudo ovs-ofctl dump-flows " + sw + " | awk '{OFS=\",\" ; print $1 $6 $7 }' |sort -n -k1"
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 3a33619..2391d3a 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -90,7 +90,7 @@
                 self.handle.expect("Confirm")
                 self.handle.sendline("yes")
                 self.handle.expect("\$")
-            self.handle.sendline("\n")
+            self.handle.sendline("")
             self.handle.expect("\$")
             self.handle.sendline("exit")
             self.handle.expect("closed")
@@ -194,13 +194,7 @@
             else:
                 #If failed, send ctrl+c to process and try again
                 main.log.info("Starting CLI failed. Retrying...")
-                self.handle.sendline("\x03")
-                i = self.handle.expect(["onos>",pexpect.TIMEOUT],
-                        timeout=30)
-                #Send ctrl+d to exit the onos> prompt that was
-                #not successful
-                self.handle.sendline("\x04")
-                self.handle.expect("\$")
+                self.handle.send("\x03")
                 self.handle.sendline("onos -w "+str(ONOS_ip))
                 i = self.handle.expect(["onos>",pexpect.TIMEOUT],
                         timeout=30)
@@ -467,52 +461,21 @@
             main.log.info(self.name+" ::::::")
             main.cleanup()
             main.exit()
-        
-    def devices(self, json_format=True, grep_str="",node_ip=""):
+
+    def devices(self, json_format=True):
         '''
         Lists all infrastructure devices or switches
         Optional argument:
-            * grep_str : pass in a string to grep
-            * node_ip : used to reattempt CLI connection
+            * json_format - boolean indicating if you want output in json
         '''
         try:
             self.handle.sendline("")
             self.handle.expect("onos>")
-            
-            if json_format:
-                if not grep_str:
-                    self.handle.sendline("devices -j")
-                    self.handle.expect("devices -j")
-                    i = self.handle.expect([
-                        "onos>", "\$", pexpect.TIMEOUT])
-                    if (i == 1 or i == 2) and node_ip:
-                        self.handle.sendline("onos -w "+node_ip)
-                        self.handle.expect("onos>")
-                        self.handle.sendline("devices -j")
-                        self.handle.expect("devices -j")
-                    elif not node_ip and i == 2: 
-                        main.log.info("ONOS CLI exited. Please "+
-                            "provide node_ip in the function to "+
-                            "attempt to reconnect")
-                else:
-                    self.handle.sendline("devices -j | grep '"+
-                        str(grep_str)+"'")
-                    self.handle.expect("devices -j | grep '"+str(grep_str)+"'")
-                    i = self.handle.expect([
-                        "onos>","\$", pexpect.TIMEOUT])
 
-                    if (i == 1 or i == 2) and node_ip:
-                        main.log.info("CLI dropped. Logging back into"+
-                            " ONOS")
-                        self.handle.sendline("onos -w "+node_ip)
-                        self.handle.expect("onos>")
-                        self.handle.sendline("devices -j")
-                        self.handle.expect("devices -j")
-                    elif not node_ip and i == 2:
-                        main.log.info("ONOS CLI exited. Please "+
-                            "provide node_ip in the function to "+
-                            "attempt to reconnect")
-                
+            if json_format:
+                self.handle.sendline("devices -j")
+                self.handle.expect("devices -j")
+                self.handle.expect("onos>")
                 handle = self.handle.before
                 '''
                 handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
@@ -528,13 +491,8 @@
                 #print "repr(handle1) = ", repr(handle1)
                 return handle1
             else:
-                if not grep_str:
-                    self.handle.sendline("devices")
-                    self.handle.expect("onos>")
-                else:
-                    self.handle.sendline("devices | grep '"+
-                        str(grep_str)+"'")
-                    self.handle.expect("onos>")
+                self.handle.sendline("devices")
+                self.handle.expect("onos>")
                 handle = self.handle.before
                 #print "handle =",handle
                 return handle
@@ -550,34 +508,28 @@
             main.cleanup()
             main.exit()
 
-    def links(self, json_format=True, grep_str=""):
+    def links(self, json_format=True):
         '''
         Lists all core links
         Optional argument:
-            * grep_str - pass in a string to grep
+            * json_format - boolean indicating if you want output in json
         '''
         try:
             self.handle.sendline("")
             self.handle.expect("onos>")
-            
+
             if json_format:
-                if not grep_str:
-                    self.handle.sendline("links -j")
-                    self.handle.expect("links -j")
-                    self.handle.expect("onos>")
-                else:
-                    self.handle.sendline("links -j | grep '"+
-                        str(grep_str)+"'")
-                    self.handle.expect("links -j | grep '"+str(grep_str)+"'")
-                    self.handle.expect("onos>")
+                self.handle.sendline("links -j")
+                self.handle.expect("links -j")
+                self.handle.expect("onos>")
                 handle = self.handle.before
                 '''
                 handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
                 To make that escape sequence visible, use repr() function. The repr(handle) output when printed shows the ANSI escape sequences.
                 In json.loads(somestring), this somestring variable is actually repr(somestring) and json.loads would fail with the escape sequence.
-                So we take off that escape sequence using 
+                So we take off that escape sequence using
                 ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle) 
+                handle1 = ansi_escape.sub('', handle)
                 '''
                 #print "repr(handle) =", repr(handle)
                 ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
@@ -585,13 +537,8 @@
                 #print "repr(handle1) = ", repr(handle1)
                 return handle1
             else:
-                if not grep_str:
-                    self.handle.sendline("links")
-                    self.handle.expect("onos>")
-                else:
-                    self.handle.sendline("links | grep '"+
-                        str(grep_str)+"'")
-                    self.handle.expect("onos>")
+                self.handle.sendline("links")
+                self.handle.expect("onos>")
                 handle = self.handle.before
                 #print "handle =",handle
                 return handle
@@ -608,34 +555,28 @@
             main.exit()
 
 
-    def ports(self, json_format=True, grep_str=""):
+    def ports(self, json_format=True):
         '''
         Lists all ports
         Optional argument:
-            * grep_str - pass in a string to grep
+            * json_format - boolean indicating if you want output in json
         '''
         try:
             self.handle.sendline("")
             self.handle.expect("onos>")
-            
+
             if json_format:
-                if not grep_str:
-                    self.handle.sendline("ports -j")
-                    self.handle.expect("ports -j")
-                    self.handle.expect("onos>")
-                else:
-                    self.handle.sendline("ports -j | grep '"+
-                        str(grep_str)+"'")
-                    self.handle.expect("ports -j | grep '"+str(grep_str)+"'")
-                    self.handle.expect("onos>")
+                self.handle.sendline("ports -j")
+                self.handle.expect("ports -j")
+                self.handle.expect("onos>")
                 handle = self.handle.before
                 '''
                 handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
                 To make that escape sequence visible, use repr() function. The repr(handle) output when printed shows the ANSI escape sequences.
                 In json.loads(somestring), this somestring variable is actually repr(somestring) and json.loads would fail with the escape sequence.
-                So we take off that escape sequence using the following commads: 
+                So we take off that escape sequence using the following commads:
                 ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle) 
+                handle1 = ansi_escape.sub('', handle)
                 '''
                 #print "repr(handle) =", repr(handle)
                 ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
@@ -644,20 +585,13 @@
                 return handle1
 
             else:
-                if not grep_str:
-                    self.handle.sendline("ports")
-                    self.handle.expect("onos>")
-                    self.handle.sendline("")
-                    self.handle.expect("onos>")
-                else:
-                    self.handle.sendline("ports | grep '"+
-                        str(grep_str)+"'")
-                    self.handle.expect("onos>")
-                    self.handle.sendline("")
-                    self.handle.expect("onos>")
+                self.handle.sendline("ports")
+                self.handle.expect("onos>")
+                self.handle.sendline("")
+                self.handle.expect("onos>")
                 handle = self.handle.before
                 #print "handle =",handle
-                return handle  
+                return handle
         except pexpect.EOF:
             main.log.error(self.name + ": EOF exception found")
             main.log.error(self.name + ":    " + self.handle.before)
@@ -671,34 +605,32 @@
             main.exit()
 
 
-    def roles(self, json_format=True, grep_str=""):
+    def roles(self, json_format=True):
         '''
         Lists all devices and the controllers with roles assigned to them
         Optional argument:
-            * grep_str - pass in a string to grep
+            * json_format - boolean indicating if you want output in json
         '''
         try:
             self.handle.sendline("")
             self.handle.expect("onos>")
-            
+
             if json_format:
-                if not grep_str:
-                    self.handle.sendline("roles -j")
-                    self.handle.expect("roles -j")
-                    self.handle.expect("onos>")
-                else:
-                    self.handle.sendline("roles -j | grep '"+
-                        str(grep_str)+"'")
-                    self.handle.expect("roles -j | grep '"+str(grep_str)+"'")
-                    self.handle.expect("onos>")
+                self.handle.sendline("roles -j")
+                self.handle.expect("roles -j")
+                self.handle.expect("onos>")
                 handle = self.handle.before
                 '''
-                handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
-                To make that escape sequence visible, use repr() function. The repr(handle) output when printed shows the ANSI escape sequences.
-                In json.loads(somestring), this somestring variable is actually repr(somestring) and json.loads would fail with the escape sequence.
-                So we take off that escape sequence using the following commads: 
+                handle variable here contains some ANSI escape color code sequences at the
+                end which are invisible in the print command output. To make that escape
+                sequence visible, use repr() function. The repr(handle) output when printed
+                shows the ANSI escape sequences. In json.loads(somestring), this somestring
+                variable is actually repr(somestring) and json.loads would fail with the escape
+                sequence.
+
+                So we take off that escape sequence using the following commads:
                 ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle) 
+                handle1 = ansi_escape.sub('', handle)
                 '''
                 #print "repr(handle) =", repr(handle)
                 ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
@@ -707,20 +639,13 @@
                 return handle1
 
             else:
-                if not grep_str:
-                    self.handle.sendline("roles")
-                    self.handle.expect("onos>")
-                    self.handle.sendline("")
-                    self.handle.expect("onos>")
-                else:
-                    self.handle.sendline("roles | grep '"+
-                        str(grep_str)+"'")
-                    self.handle.expect("onos>")
-                    self.handle.sendline("")
-                    self.handle.expect("onos>")
+                self.handle.sendline("roles")
+                self.handle.expect("onos>")
+                self.handle.sendline("")
+                self.handle.expect("onos>")
                 handle = self.handle.before
                 #print "handle =",handle
-                return handle  
+                return handle
         except pexpect.EOF:
             main.log.error(self.name + ": EOF exception found")
             main.log.error(self.name + ":    " + self.handle.before)
@@ -808,35 +733,29 @@
             main.log.info(self.name+" ::::::")
             main.cleanup()
             main.exit()
-    
-    def hosts(self, json_format=True, grep_str=""):
+
+    def hosts(self, json_format=True):
         '''
-        Lists all discovered hosts 
+        Lists all discovered hosts
         Optional argument:
-            * grep_str - pass in a string to grep
+            * json_format - boolean indicating if you want output in json
         '''
         try:
             self.handle.sendline("")
             self.handle.expect("onos>")
-            
+
             if json_format:
-                if not grep_str:
-                    self.handle.sendline("hosts -j")
-                    self.handle.expect("hosts -j")
-                    self.handle.expect("onos>")
-                else:
-                    self.handle.sendline("hosts -j | grep '"+
-                        str(grep_str)+"'")
-                    self.handle.expect("hosts -j | grep '"+str(grep_str)+"'")
-                    self.handle.expect("onos>")
+                self.handle.sendline("hosts -j")
+                self.handle.expect("hosts -j")
+                self.handle.expect("onos>")
                 handle = self.handle.before
                 '''
                 handle variable here contains some ANSI escape color code sequences at the end which are invisible in the print command output
                 To make that escape sequence visible, use repr() function. The repr(handle) output when printed shows the ANSI escape sequences.
                 In json.loads(somestring), this somestring variable is actually repr(somestring) and json.loads would fail with the escape sequence.
-                So we take off that escape sequence using 
+                So we take off that escape sequence using
                 ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
-                handle1 = ansi_escape.sub('', handle) 
+                handle1 = ansi_escape.sub('', handle)
                 '''
                 #print "repr(handle) =", repr(handle)
                 ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
@@ -844,13 +763,8 @@
                 #print "repr(handle1) = ", repr(handle1)
                 return handle1
             else:
-                if not grep_str:
-                    self.handle.sendline("hosts")
-                    self.handle.expect("onos>")
-                else:
-                    self.handle.sendline("hosts | grep '"+
-                        str(grep_str)+"'")
-                    self.handle.expect("onos>")
+                self.handle.sendline("hosts")
+                self.handle.expect("onos>")
                 handle = self.handle.before
                 #print "handle =",handle
                 return handle
@@ -948,24 +862,24 @@
             * host_id_two: ONOS host id for host2
         Description:
             Adds a host-to-host intent (bidrectional) by
-            specifying the two hosts. 
+            specifying the two hosts.
         '''
         try:
             self.handle.sendline("")
             self.handle.expect("onos>")
-            
+
             self.handle.sendline("add-host-intent "+
                     str(host_id_one) + " " + str(host_id_two))
             self.handle.expect("onos>")
 
             handle = self.handle.before
-            print "handle =", handle
+            #print "handle =", handle
 
             main.log.info("Intent installed between "+
                     str(host_id_one) + " and " + str(host_id_two))
 
             return handle
-        
+
         except pexpect.EOF:
             main.log.error(self.name + ": EOF exception found")
             main.log.error(self.name + ":    " + self.handle.before)
@@ -1202,7 +1116,7 @@
             main.cleanup()
             main.exit()
 
-    def intents(self, json_format = False):
+    def intents(self, json_format = True):
         '''
         Optional:
             * json_format: enable output formatting in json
@@ -1240,7 +1154,7 @@
             main.cleanup()
             main.exit()
 
-    def flows(self, json_format = False):
+    def flows(self, json_format = True):
         '''
         Optional:
             * json_format: enable output formatting in json
@@ -1253,6 +1167,8 @@
                 self.handle.expect("flows -j")
                 self.handle.expect("onos>")
                 handle = self.handle.before
+                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+                handle = ansi_escape.sub('', handle)
 
             else:
                 self.handle.sendline("")
@@ -1260,6 +1176,8 @@
                 self.handle.sendline("flows")
                 self.handle.expect("onos>")
                 handle = self.handle.before
+            if re.search("Error\sexecuting\scommand:", handle):
+                main.log.error(self.name + ".flows() response: " + str(handle))
 
             return handle
 
@@ -1698,5 +1616,54 @@
             main.cleanup()
             main.exit()
 
+    def clusters(self, json_format=True):
+        '''
+        Lists all clusters
+        Optional argument:
+            * json_format - boolean indicating if you want output in json
+        '''
+        try:
+            self.handle.sendline("")
+            self.handle.expect("onos>")
+
+            if json_format:
+                self.handle.sendline("clusters -j")
+                self.handle.expect("clusters -j")
+                self.handle.expect("onos>")
+                handle = self.handle.before
+                '''
+                handle variable here contains some ANSI escape color code
+                sequences at the end which are invisible in the print command
+                output. To make that escape sequence visible, use repr() function.
+                The repr(handle) output when printed shows the ANSI escape sequences.
+                In json.loads(somestring), this somestring variable is actually
+                repr(somestring) and json.loads would fail with the escape sequence.
+                So we take off that escape sequence using
+                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+                handle1 = ansi_escape.sub('', handle)
+                '''
+                #print "repr(handle) =", repr(handle)
+                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+                handle1 = ansi_escape.sub('', handle)
+                #print "repr(handle1) = ", repr(handle1)
+                return handle1
+            else:
+                self.handle.sendline("clusters")
+                self.handle.expect("onos>")
+                handle = self.handle.before
+                #print "handle =",handle
+                return handle
+        except pexpect.EOF:
+            main.log.error(self.name + ": EOF exception found")
+            main.log.error(self.name + ":    " + self.handle.before)
+            main.cleanup()
+            main.exit()
+        except:
+            main.log.info(self.name+" ::::::")
+            main.log.error( traceback.print_exc())
+            main.log.info(self.name+" ::::::")
+            main.cleanup()
+            main.exit()
+
 
     #***********************************
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 0c01e9f..6bb46a0 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -82,7 +82,7 @@
         '''
         response = ''
         try:
-            self.handle.sendline("\n")
+            self.handle.sendline("")
             self.handle.expect("\$")
             self.handle.sendline("exit")
             self.handle.expect("closed")
@@ -164,7 +164,7 @@
             self.handle.sendline("cd "+ self.home)
             self.handle.expect("\$")
 
-            self.handle.sendline("\n")
+            self.handle.sendline("")
             self.handle.expect("\$")
             self.handle.sendline("mvn clean install")
             self.handle.expect("mvn clean install")
@@ -195,7 +195,7 @@
                     for line in self.handle.before.splitlines():
                         if "Total time:" in line:
                             main.log.info(line)
-                    self.handle.sendline("\n")
+                    self.handle.sendline("")
                     self.handle.expect("\$", timeout=60)
                     return main.TRUE
                 elif i == 4:
@@ -392,11 +392,11 @@
             self.handle.sendline("export TERM=xterm-256color")
             self.handle.expect("xterm-256color")
             self.handle.expect("\$")
-            self.handle.sendline("\n")
+            self.handle.sendline("")
             self.handle.expect("\$")
             self.handle.sendline("cd " + self.home + "; git log -1 --pretty=fuller --decorate=short | grep -A 6 \"commit\" --color=never")
-            #self.handle.expect("--color=never")
-            #self.handle.sendline("")
+            #NOTE: for some reason there are backspaces inserted in this phrase when run from Jenkins on some tests
+            self.handle.expect("never")
             self.handle.expect("\$")
             response=(self.name +": \n"+ str(self.handle.before + self.handle.after))
             self.handle.sendline("cd " + self.home)
@@ -411,13 +411,18 @@
                     #as xml specific tags that cause errors
                     line = line.replace("<","[")
                     line = line.replace(">","]")
-                    main.log.report(line)
+                    main.log.report("\t" + line)
             return lines[2]
         except pexpect.EOF:
             main.log.error(self.name + ": EOF exception found")
             main.log.error(self.name + ":     " + self.handle.before)
             main.cleanup()
             main.exit()
+        except pexpect.TIMEOUT:
+            main.log.error(self.name + ": TIMEOUT exception found")
+            main.log.error(self.name + ":     " + self.handle.before)
+            main.cleanup()
+            main.exit()
         except:
             main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
             main.log.error( traceback.print_exc() )
@@ -784,7 +789,7 @@
         try:
             self.handle.sendline("")
             self.handle.expect("\$")
-            self.handle.sendline("onos-uninstall "+str(node_ip))
+            self.handle.sendline( "onos-uninstall "+str(node_ip) )
             self.handle.expect("\$")
 
             main.log.info("ONOS "+node_ip+" was uninstalled")
@@ -868,6 +873,8 @@
                         timeout=120)
                 if i == 1:
                     return main.FALSE
+            self.handle.sendline("")
+            self.handle.expect("\$")
             return main.TRUE
 
         except pexpect.EOF:
@@ -933,14 +940,15 @@
             self.handle.sendline("onos-wait-for-start " + node )
             self.handle.expect("onos-wait-for-start")
             #NOTE: this timeout is arbitrary"
-            i = self.handle.expect(["\$", pexpect.TIMEOUT], timeout = 300)
+            i = self.handle.expect(["\$", pexpect.TIMEOUT], timeout = 120)
             if i == 0:
                 main.log.info(self.name + ": " + node + " is up")
                 return main.TRUE
             elif i == 1:
                 #NOTE: since this function won't return until ONOS is ready,
                 #   we will kill it on timeout
-                self.handle.sendline("\003")    #Control-C
+                main.log.error("ONOS has not started yet")
+                self.handle.send("\x03")    #Control-C
                 self.handle.expect("\$")
                 return main.FALSE
         except pexpect.EOF:
@@ -1139,21 +1147,26 @@
                 str(dir_file))
 
 
-    def run_onos_topo_cfg(self):
+    def run_onos_topo_cfg(self, instance_name, json_file):
         '''
-         On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
+         On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg $OC1 filename
             which starts the rest and copies the json file to the onos instance
         '''
-        self.handle.sendline("")
-        self.handle.expect("\$")
-        self.handle.sendline("cd ~/ONOS/tools/test/bin")
-        self.handle.expect("/bin$")
-        self.handle.sendline("./onos-topo-cfg")
-        self.handle.expect("{}")
-        self.handle.sendline("cd ~")
-        self.handle.expect("\$")
-
-
+        try:
+            self.handle.sendline("")
+            self.handle.expect("\$")
+            self.handle.sendline("cd ~/ONOS/tools/test/bin")
+            self.handle.expect("/bin$")
+            cmd = "./onos-topo-cfg " +instance_name +" " +json_file
+            print "cmd = ", cmd
+            self.handle.sendline(cmd)
+            self.handle.expect("$")
+            self.handle.sendline("cd ~")
+            self.handle.expect("\$")
+            return main.TRUE
+        except:
+            return main.FALSE
+            
     def tshark_grep(self, grep, directory, interface='eth0'):
         '''
         Required:
@@ -1284,5 +1297,3 @@
             main.log.error( traceback.print_exc())
             main.log.info(self.name+" ::::::")
 
-
-
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py b/TestON/drivers/common/cli/quaggaclidriver.py
index 19717fb..0f84bc0 100644
--- a/TestON/drivers/common/cli/quaggaclidriver.py
+++ b/TestON/drivers/common/cli/quaggaclidriver.py
@@ -39,7 +39,6 @@
             return main.FALSE
 
     def loginQuagga(self, ip_address):
-
         self.name = self.options['name']
         self.handle = super(QuaggaCliDriver, self).connect(
             user_name=self.user_name, ip_address=ip_address,
@@ -56,7 +55,7 @@
             self.handle.expect("bgpd", timeout=5)
             self.handle.sendline("enable")
             self.handle.expect("bgpd#", timeout=5)
-            main.log.info("I am inside BGP peer Quagga!")
+            main.log.info("I in quagga on host " + str(ip_address))
 
             return self.handle
         else:
@@ -120,7 +119,7 @@
             else:
                 ingress.append("of:" + str(peer['attachmentDpid']).replace(":", "") + ":" + str(peer['attachmentPort']) )
 
-        selector = "[IPV4_DST{ip=" + prefix + "}, ETH_TYPE{ethType=800}]"
+        selector = "[ETH_TYPE{ethType=800}, IPV4_DST{ip=" + prefix + "}]"
         treatment = "[ETH_DST{mac=" + str(nextHopMac) + "}]"
 
         intent = egress + "/" + str(sorted(ingress)) + "/" + selector + "/" + treatment
@@ -158,7 +157,7 @@
     def extract_actual_routeIntents(self, get_intents_result):
         intents = []
         # TODO: delete the line below when change to Mininet demo script
-        get_intents_result=open("../tests/SdnIpTest/intents.json").read()
+        # get_intents_result=open("../tests/SdnIpTest/intents.json").read()
         intents_json_obj = json.loads(get_intents_result)
 
         for intent in intents_json_obj:
@@ -177,7 +176,7 @@
     def extract_actual_bgpIntents(self, get_intents_result):
         intents = []
         # TODO: delete the line below when change to Mininet demo script
-        get_intents_result=open("../tests/SdnIpTest/intents.json").read()
+        # get_intents_result=open("../tests/SdnIpTest/intents.json").read()
         intents_json_obj = json.loads(get_intents_result)
 
         for intent in intents_json_obj:
@@ -274,7 +273,7 @@
         except:
             main.log.warn("Probably not in config-router mode!")
             self.disconnect()
-        main.log.report("Adding Routes")
+        main.log.info("Adding Routes")
         j=0
         k=0
         while numRoutes > 255:
@@ -321,7 +320,7 @@
         except:
             main.log.warn("Probably not in config-router mode!")
             self.disconnect()
-        main.log.report("Deleting Routes")
+        main.log.info("Deleting Routes")
         j=0
         k=0
         while numRoutes > 255:
diff --git a/TestON/drivers/common/clidriver.py b/TestON/drivers/common/clidriver.py
index 797473d..00d00ed 100644
--- a/TestON/drivers/common/clidriver.py
+++ b/TestON/drivers/common/clidriver.py
@@ -76,7 +76,7 @@
 	    elif i==6:
 	        main.log.info("Password not required logged in")
 
-        self.handle.sendline("\n")
+        self.handle.sendline("")
         self.handle.expect('>|#|\$')
         return self.handle
 
@@ -142,7 +142,7 @@
             main.log.info("Found More screen to go , Sending a key to proceed")
             indexMore = self.handle.expect(["^:$", expectPrompt], timeout = timeoutVar)
             while indexMore == 0:
-                main.log.info("Found anoother More screen to go , Sending a key to proceed")
+                main.log.info("Found another More screen to go , Sending a key to proceed")
                 self.handle.sendcontrol("D")
                 indexMore = self.handle.expect(["^:$", expectPrompt], timeout = timeoutVar)
                 self.LASTRSP = self.LASTRSP + self.handle.before
diff --git a/TestON/tests/HATestClusterRestart/HATestClusterRestart.params b/TestON/tests/HATestClusterRestart/HATestClusterRestart.params
new file mode 100644
index 0000000..0a8bd57
--- /dev/null
+++ b/TestON/tests/HATestClusterRestart/HATestClusterRestart.params
@@ -0,0 +1,63 @@
+<PARAMS>
+    <testcases>1,2,8,3,4,5,[6],7,8,4,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+    <ENV>
+    <cellName>HA</cellName>
+    </ENV>
+    <Git>False</Git>
+
+    <CTRL>
+        <ip1>10.128.30.11</ip1>
+        <port1>6633</port1>
+
+        <ip2>10.128.30.12</ip2>
+        <port2>6633</port2>
+
+        <ip3>10.128.30.13</ip3>
+        <port3>6633</port3>
+
+        <ip4>10.128.30.14</ip4>
+        <port4>6633</port4>
+
+        <ip5>10.128.30.15</ip5>
+        <port5>6633</port5>
+
+        <ip6>10.128.30.16</ip6>
+        <port6>6633</port6>
+
+        <ip7>10.128.30.17</ip7>
+        <port7>6633</port7>
+    </CTRL>
+    <TESTONUSER>admin</TESTONUSER>
+    <TESTONIP>10.128.30.10</TESTONIP>
+    <PING>
+        <source1>h8</source1>
+        <source2>h9</source2>
+        <source3>h10</source3>
+        <source4>h11</source4>
+        <source5>h12</source5>
+        <source6>h13</source6>
+        <source7>h14</source7>
+        <source8>h15</source8>
+        <source9>h16</source9>
+        <source10>h17</source10>
+        <target1>10.0.0.18</target1>
+        <target2>10.0.0.19</target2>
+        <target3>10.0.0.20</target3>
+        <target4>10.0.0.21</target4>
+        <target5>10.0.0.22</target5>
+        <target6>10.0.0.23</target6>
+        <target7>10.0.0.24</target7>
+        <target8>10.0.0.25</target8>
+        <target9>10.0.0.26</target9>
+        <target10>10.0.0.27</target10>
+    </PING>
+    <timers>
+        <LinkDiscovery>2</LinkDiscovery>
+        <SwitchDiscovery>2</SwitchDiscovery>
+    </timers>
+    <MNtcpdump>
+        <intf>eth0</intf>
+        <port> </port>
+        <folder>~/packet_captures/</folder>
+    </MNtcpdump>
+</PARAMS>
diff --git a/TestON/tests/HATestClusterRestart/HATestClusterRestart.py b/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
new file mode 100644
index 0000000..47dc744
--- /dev/null
+++ b/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
@@ -0,0 +1,1202 @@
+'''
+Description: This test is to determine if ONOS can handle
+    all of it's nodes restarting
+
+List of test cases:
+CASE1: Compile ONOS and push it to the test machines
+CASE2: Assign mastership to controllers
+CASE3: Assign intents
+CASE4: Ping across added host intents
+CASE5: Reading state of ONOS
+CASE6: The Failure case.
+CASE7: Check state after control plane failure
+CASE8: Compare topo
+CASE9: Link s3-s28 down
+CASE10: Link s3-s28 up
+CASE11: Switch down
+CASE12: Switch up
+CASE13: Clean up
+'''
+class HATestClusterRestart:
+
+    def __init__(self) :
+        self.default = ''
+
+    def CASE1(self,main) :
+        '''
+        CASE1 is to compile ONOS and push it to the test machines
+
+        Startup sequence:
+        git pull
+        mvn clean install
+        onos-package
+        cell <name>
+        onos-verify-cell
+        NOTE: temporary - onos-remove-raft-logs
+        onos-install -f
+        onos-wait-for-start
+        '''
+        import time
+        main.log.report("ONOS HA test: Restart all ONOS nodes - initialization")
+        main.case("Setting up test environment")
+
+        # load some vairables from the params file
+        PULL_CODE = False
+        if main.params['Git'] == 'True':
+            PULL_CODE = True
+        cell_name = main.params['ENV']['cellName']
+
+        #set global variables
+        global ONOS1_ip
+        global ONOS1_port
+        global ONOS2_ip
+        global ONOS2_port
+        global ONOS3_ip
+        global ONOS3_port
+        global ONOS4_ip
+        global ONOS4_port
+        global ONOS5_ip
+        global ONOS5_port
+        global ONOS6_ip
+        global ONOS6_port
+        global ONOS7_ip
+        global ONOS7_port
+
+        ONOS1_ip = main.params['CTRL']['ip1']
+        ONOS1_port = main.params['CTRL']['port1']
+        ONOS2_ip = main.params['CTRL']['ip2']
+        ONOS2_port = main.params['CTRL']['port2']
+        ONOS3_ip = main.params['CTRL']['ip3']
+        ONOS3_port = main.params['CTRL']['port3']
+        ONOS4_ip = main.params['CTRL']['ip4']
+        ONOS4_port = main.params['CTRL']['port4']
+        ONOS5_ip = main.params['CTRL']['ip5']
+        ONOS5_port = main.params['CTRL']['port5']
+        ONOS6_ip = main.params['CTRL']['ip6']
+        ONOS6_port = main.params['CTRL']['port6']
+        ONOS7_ip = main.params['CTRL']['ip7']
+        ONOS7_port = main.params['CTRL']['port7']
+
+
+        main.step("Applying cell variable to environment")
+        cell_result = main.ONOSbench.set_cell(cell_name)
+        verify_result = main.ONOSbench.verify_cell()
+
+        #FIXME:this is short term fix 
+        main.log.report("Removing raft logs")
+        main.ONOSbench.onos_remove_raft_logs()
+        main.log.report("Uninstalling ONOS")
+        main.ONOSbench.onos_uninstall(ONOS1_ip)
+        main.ONOSbench.onos_uninstall(ONOS2_ip)
+        main.ONOSbench.onos_uninstall(ONOS3_ip)
+        main.ONOSbench.onos_uninstall(ONOS4_ip)
+        main.ONOSbench.onos_uninstall(ONOS5_ip)
+        main.ONOSbench.onos_uninstall(ONOS6_ip)
+        main.ONOSbench.onos_uninstall(ONOS7_ip)
+
+        clean_install_result = main.TRUE
+        git_pull_result = main.TRUE
+
+        main.step("Compiling the latest version of ONOS")
+        if PULL_CODE:
+            main.step("Git checkout and pull master")
+            main.ONOSbench.git_checkout("master")
+            git_pull_result = main.ONOSbench.git_pull()
+
+            main.step("Using mvn clean & install")
+            clean_install_result = main.TRUE
+            if git_pull_result == main.TRUE:
+                clean_install_result = main.ONOSbench.clean_install()
+            else:
+                main.log.warn("Did not pull new code so skipping mvn "+ \
+                        "clean install")
+        main.ONOSbench.get_version(report=True)
+
+        main.step("Creating ONOS package")
+        package_result = main.ONOSbench.onos_package()
+
+        main.step("Installing ONOS package")
+        onos1_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS1_ip)
+        onos2_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS2_ip)
+        onos3_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS3_ip)
+        onos4_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS4_ip)
+        onos5_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS5_ip)
+        onos6_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS6_ip)
+        onos7_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS7_ip)
+        onos_install_result = onos1_install_result and onos2_install_result\
+                and onos3_install_result and onos4_install_result\
+                and onos5_install_result and onos6_install_result\
+                and onos7_install_result
+        '''
+        #FIXME: work around until onos is less fragile
+        main.ONOSbench.handle.sendline("onos-cluster-install")
+        print main.ONOSbench.handle.expect("\$")
+        onos_install_result = main.TRUE
+        '''
+
+
+        main.step("Checking if ONOS is up yet")
+        #TODO: Refactor
+        # check bundle:list?
+        onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+        if not onos1_isup:
+            main.log.report("ONOS1 didn't start!")
+        onos2_isup = main.ONOSbench.isup(ONOS2_ip)
+        if not onos2_isup:
+            main.log.report("ONOS2 didn't start!")
+        onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+        if not onos3_isup:
+            main.log.report("ONOS3 didn't start!")
+        onos4_isup = main.ONOSbench.isup(ONOS4_ip)
+        if not onos4_isup:
+            main.log.report("ONOS4 didn't start!")
+        onos5_isup = main.ONOSbench.isup(ONOS5_ip)
+        if not onos5_isup:
+            main.log.report("ONOS5 didn't start!")
+        onos6_isup = main.ONOSbench.isup(ONOS6_ip)
+        if not onos6_isup:
+            main.log.report("ONOS6 didn't start!")
+        onos7_isup = main.ONOSbench.isup(ONOS7_ip)
+        if not onos7_isup:
+            main.log.report("ONOS7 didn't start!")
+        onos_isup_result = onos1_isup and onos2_isup and onos3_isup\
+                and onos4_isup and onos5_isup and onos6_isup and onos7_isup
+        # TODO: if it becomes an issue, we can retry this step  a few times
+
+
+        cli_result1 = main.ONOScli1.start_onos_cli(ONOS1_ip)
+        cli_result2 = main.ONOScli2.start_onos_cli(ONOS2_ip)
+        cli_result3 = main.ONOScli3.start_onos_cli(ONOS3_ip)
+        cli_result4 = main.ONOScli4.start_onos_cli(ONOS4_ip)
+        cli_result5 = main.ONOScli5.start_onos_cli(ONOS5_ip)
+        cli_result6 = main.ONOScli6.start_onos_cli(ONOS6_ip)
+        cli_result7 = main.ONOScli7.start_onos_cli(ONOS7_ip)
+        cli_results = cli_result1 and cli_result2 and cli_result3 and\
+                cli_result4 and cli_result5 and cli_result6 and cli_result7
+
+        main.step("Start Packet Capture MN")
+        main.Mininet2.start_tcpdump(
+                str(main.params['MNtcpdump']['folder'])+str(main.TEST)+"-MN.pcap",
+                intf = main.params['MNtcpdump']['intf'],
+                port = main.params['MNtcpdump']['port'])
+
+
+        case1_result = (clean_install_result and package_result and
+                cell_result and verify_result and onos_install_result and
+                onos_isup_result and cli_results)
+
+        utilities.assert_equals(expect=main.TRUE, actual=case1_result,
+                onpass="Test startup successful",
+                onfail="Test startup NOT successful")
+
+
+        #if case1_result==main.FALSE:
+        #    main.cleanup()
+        #    main.exit()
+
+    def CASE2(self,main) :
+        '''
+        Assign mastership to controllers
+        '''
+        import time
+        import json
+        import re
+
+
+        '''
+        ONOS1_ip = main.params['CTRL']['ip1']
+        ONOS1_port = main.params['CTRL']['port1']
+        ONOS2_ip = main.params['CTRL']['ip2']
+        ONOS2_port = main.params['CTRL']['port2']
+        ONOS3_ip = main.params['CTRL']['ip3']
+        ONOS3_port = main.params['CTRL']['port3']
+        ONOS4_ip = main.params['CTRL']['ip4']
+        ONOS4_port = main.params['CTRL']['port4']
+        ONOS5_ip = main.params['CTRL']['ip5']
+        ONOS5_port = main.params['CTRL']['port5']
+        ONOS6_ip = main.params['CTRL']['ip6']
+        ONOS6_port = main.params['CTRL']['port6']
+        ONOS7_ip = main.params['CTRL']['ip7']
+        ONOS7_port = main.params['CTRL']['port7']
+        '''
+
+
+        main.log.report("Assigning switches to controllers")
+        main.case("Assigning Controllers")
+        main.step("Assign switches to controllers")
+
+        for i in range (1,29):
+           main.Mininet1.assign_sw_controller(sw=str(i),count=7,
+                    ip1=ONOS1_ip,port1=ONOS1_port,
+                    ip2=ONOS2_ip,port2=ONOS2_port,
+                    ip3=ONOS3_ip,port3=ONOS3_port,
+                    ip4=ONOS4_ip,port4=ONOS4_port,
+                    ip5=ONOS5_ip,port5=ONOS5_port,
+                    ip6=ONOS6_ip,port6=ONOS6_port,
+                    ip7=ONOS7_ip,port7=ONOS7_port)
+
+        mastership_check = main.TRUE
+        for i in range (1,29):
+            response = main.Mininet1.get_sw_controller("s"+str(i))
+            try:
+                main.log.info(str(response))
+            except:
+                main.log.info(repr(response))
+            if re.search("tcp:"+ONOS1_ip,response)\
+                    and re.search("tcp:"+ONOS2_ip,response)\
+                    and re.search("tcp:"+ONOS3_ip,response)\
+                    and re.search("tcp:"+ONOS4_ip,response)\
+                    and re.search("tcp:"+ONOS5_ip,response)\
+                    and re.search("tcp:"+ONOS6_ip,response)\
+                    and re.search("tcp:"+ONOS7_ip,response):
+                mastership_check = mastership_check and main.TRUE
+            else:
+                mastership_check = main.FALSE
+        if mastership_check == main.TRUE:
+            main.log.report("Switch mastership assigned correctly")
+        utilities.assert_equals(expect = main.TRUE,actual=mastership_check,
+                onpass="Switch mastership assigned correctly",
+                onfail="Switches not assigned correctly to controllers")
+
+        #TODO: If assign roles is working reliably then manually 
+        #   assign mastership to the controller we want
+
+
+    def CASE3(self,main) :
+        """
+        Assign intents
+
+        """
+        import time
+        import json
+        import re
+        main.log.report("Adding host intents")
+        main.case("Adding host Intents")
+
+        main.step("Discovering  Hosts( Via pingall for now)")
+        #FIXME: Once we have a host discovery mechanism, use that instead
+
+        #REACTIVE FWD test
+        ping_result = main.FALSE
+        time1 = time.time()
+        ping_result = main.Mininet1.pingall()
+        time2 = time.time()
+        main.log.info("Time for pingall: %2f seconds" % (time2 - time1))
+
+        #uninstall onos-app-fwd
+        main.log.info("Uninstall reactive forwarding app")
+        main.ONOScli1.feature_uninstall("onos-app-fwd")
+        main.ONOScli2.feature_uninstall("onos-app-fwd")
+        main.ONOScli3.feature_uninstall("onos-app-fwd")
+        main.ONOScli4.feature_uninstall("onos-app-fwd")
+        main.ONOScli5.feature_uninstall("onos-app-fwd")
+        main.ONOScli6.feature_uninstall("onos-app-fwd")
+        main.ONOScli7.feature_uninstall("onos-app-fwd")
+
+        main.step("Add  host intents")
+        #TODO:  move the host numbers to params
+        import json
+        intents_json= json.loads(main.ONOScli1.hosts())
+        intent_add_result = main.FALSE
+        for i in range(8,18):
+            main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+            #NOTE: get host can return None
+            #TODO: handle this
+            host1_id = main.ONOScli1.get_host(host1)['id']
+            host2_id = main.ONOScli1.get_host(host2)['id']
+            tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
+            intent_add_result = intent_add_result and tmp_result
+        #TODO Check if intents all exist in datastore
+        #NOTE: Do we need to print this once the test is working?
+        #main.log.info(json.dumps(json.loads(main.ONOScli1.intents(json_format=True)),
+        #    sort_keys=True, indent=4, separators=(',', ': ') ) )
+
+    def CASE4(self,main) :
+        """
+        Ping across added host intents
+        """
+        description = " Ping across added host intents"
+        main.log.report(description)
+        main.case(description)
+        Ping_Result = main.TRUE
+        for i in range(8,18):
+            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+            Ping_Result = Ping_Result and ping
+            if ping==main.FALSE:
+                main.log.warn("Ping failed between h"+str(i)+" and h" + str(i+10))
+            elif ping==main.TRUE:
+                main.log.info("Ping test passed!")
+                Ping_Result = main.TRUE
+        if Ping_Result==main.FALSE:
+            main.log.report("Intents have not been installed correctly, pings failed.")
+        if Ping_Result==main.TRUE:
+            main.log.report("Intents have been installed correctly and verified by pings")
+        utilities.assert_equals(expect = main.TRUE,actual=Ping_Result,
+                onpass="Intents have been installed correctly and pings work",
+                onfail ="Intents have not been installed correctly, pings failed." )
+
+    def CASE5(self,main) :
+        '''
+        Reading state of ONOS
+        '''
+        import time
+        import json
+        from subprocess import Popen, PIPE
+        from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+
+        main.log.report("Setting up and gathering data for current state")
+        main.case("Setting up and gathering data for current state")
+        #The general idea for this test case is to pull the state of (intents,flows, topology,...) from each ONOS node
+        #We can then compare them with eachother and also with past states
+
+        main.step("Get the Mastership of each switch from each controller")
+        global mastership_state
+        ONOS1_mastership = main.ONOScli1.roles()
+        ONOS2_mastership = main.ONOScli2.roles()
+        ONOS3_mastership = main.ONOScli3.roles()
+        ONOS4_mastership = main.ONOScli4.roles()
+        ONOS5_mastership = main.ONOScli5.roles()
+        ONOS6_mastership = main.ONOScli6.roles()
+        ONOS7_mastership = main.ONOScli7.roles()
+        #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+        if "Error" in ONOS1_mastership or not ONOS1_mastership\
+                or "Error" in ONOS2_mastership or not ONOS2_mastership\
+                or "Error" in ONOS3_mastership or not ONOS3_mastership\
+                or "Error" in ONOS4_mastership or not ONOS4_mastership\
+                or "Error" in ONOS5_mastership or not ONOS5_mastership\
+                or "Error" in ONOS6_mastership or not ONOS6_mastership\
+                or "Error" in ONOS7_mastership or not ONOS7_mastership:
+                    main.log.report("Error in getting ONOS roles")
+                    main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+                    main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership))
+                    main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership))
+                    main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership))
+                    main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership))
+                    main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership))
+                    main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership))
+                    consistent_mastership = main.FALSE
+        elif ONOS1_mastership == ONOS2_mastership\
+                and ONOS1_mastership == ONOS3_mastership\
+                and ONOS1_mastership == ONOS4_mastership\
+                and ONOS1_mastership == ONOS5_mastership\
+                and ONOS1_mastership == ONOS6_mastership\
+                and ONOS1_mastership == ONOS7_mastership:
+                    mastership_state = ONOS1_mastership
+                    consistent_mastership = main.TRUE
+                    main.log.report("Switch roles are consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            consistent_mastership = main.FALSE
+        utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+                onpass="Switch roles are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of switch roles")
+
+
+        main.step("Get the intents from each controller")
+        global intent_state
+        ONOS1_intents = main.ONOScli1.intents( json_format=True )
+        ONOS2_intents = main.ONOScli2.intents( json_format=True )
+        ONOS3_intents = main.ONOScli3.intents( json_format=True )
+        ONOS4_intents = main.ONOScli4.intents( json_format=True )
+        ONOS5_intents = main.ONOScli5.intents( json_format=True )
+        ONOS6_intents = main.ONOScli6.intents( json_format=True )
+        ONOS7_intents = main.ONOScli7.intents( json_format=True )
+        intent_check = main.FALSE
+        if "Error" in ONOS1_intents or not ONOS1_intents\
+                or "Error" in ONOS2_intents or not ONOS2_intents\
+                or "Error" in ONOS3_intents or not ONOS3_intents\
+                or "Error" in ONOS4_intents or not ONOS4_intents\
+                or "Error" in ONOS5_intents or not ONOS5_intents\
+                or "Error" in ONOS6_intents or not ONOS6_intents\
+                or "Error" in ONOS7_intents or not ONOS7_intents:
+                    main.log.report("Error in getting ONOS intents")
+                    main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+                    main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents))
+                    main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents))
+                    main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents))
+                    main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents))
+                    main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents))
+                    main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents))
+        elif ONOS1_intents == ONOS2_intents\
+                and ONOS1_intents == ONOS3_intents\
+                and ONOS1_intents == ONOS4_intents\
+                and ONOS1_intents == ONOS5_intents\
+                and ONOS1_intents == ONOS6_intents\
+                and ONOS1_intents == ONOS7_intents:
+                    intent_state = ONOS1_intents
+                    intent_check = main.TRUE
+                    main.log.report("Intents are consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 intents: ", json.dumps(json.loads(ONOS1_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 intents: ", json.dumps(json.loads(ONOS2_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 intents: ", json.dumps(json.loads(ONOS3_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 intents: ", json.dumps(json.loads(ONOS4_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 intents: ", json.dumps(json.loads(ONOS5_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 intents: ", json.dumps(json.loads(ONOS6_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 intents: ", json.dumps(json.loads(ONOS7_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+        utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+                onpass="Intents are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of intents")
+
+
+        main.step("Get the flows from each controller")
+        global flow_state
+        ONOS1_flows = main.ONOScli1.flows( json_format=True )
+        ONOS2_flows = main.ONOScli2.flows( json_format=True )
+        ONOS3_flows = main.ONOScli3.flows( json_format=True )
+        ONOS4_flows = main.ONOScli4.flows( json_format=True )
+        ONOS5_flows = main.ONOScli5.flows( json_format=True )
+        ONOS6_flows = main.ONOScli6.flows( json_format=True )
+        ONOS7_flows = main.ONOScli7.flows( json_format=True )
+        flow_check = main.FALSE
+        if "Error" in ONOS1_flows or not ONOS1_flows\
+                or "Error" in ONOS2_flows or not ONOS2_flows\
+                or "Error" in ONOS3_flows or not ONOS3_flows\
+                or "Error" in ONOS4_flows or not ONOS4_flows\
+                or "Error" in ONOS5_flows or not ONOS5_flows\
+                or "Error" in ONOS6_flows or not ONOS6_flows\
+                or "Error" in ONOS7_flows or not ONOS7_flows:
+                    main.log.report("Error in getting ONOS intents")
+                    main.log.warn("ONOS1 flows repsponse: "+ ONOS1_flows)
+                    main.log.warn("ONOS2 flows repsponse: "+ ONOS2_flows)
+                    main.log.warn("ONOS3 flows repsponse: "+ ONOS3_flows)
+                    main.log.warn("ONOS4 flows repsponse: "+ ONOS4_flows)
+                    main.log.warn("ONOS5 flows repsponse: "+ ONOS5_flows)
+                    main.log.warn("ONOS6 flows repsponse: "+ ONOS6_flows)
+                    main.log.warn("ONOS7 flows repsponse: "+ ONOS7_flows)
+        elif len(json.loads(ONOS1_flows)) == len(json.loads(ONOS2_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS3_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS4_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS5_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS6_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS7_flows)):
+                #TODO: Do a better check, maybe compare flows on switches?
+                    flow_state = ONOS1_flows
+                    flow_check = main.TRUE
+                    main.log.report("Flow count is consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 flows: "+ json.dumps(json.loads(ONOS1_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 flows: "+ json.dumps(json.loads(ONOS2_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 flows: "+ json.dumps(json.loads(ONOS3_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 flows: "+ json.dumps(json.loads(ONOS4_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 flows: "+ json.dumps(json.loads(ONOS5_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 flows: "+ json.dumps(json.loads(ONOS6_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 flows: "+ json.dumps(json.loads(ONOS7_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+        utilities.assert_equals(expect = main.TRUE,actual=flow_check,
+                onpass="The flow count is consistent across all ONOS nodes",
+                onfail="ONOS nodes have different flow counts")
+
+
+        main.step("Get the OF Table entries")
+        global flows
+        flows=[]
+        for i in range(1,29):
+            flows.append(main.Mininet2.get_flowTable("s"+str(i),1.0))
+
+        #TODO: Compare switch flow tables with ONOS flow tables
+
+        main.step("Start continuous pings")
+        main.Mininet2.pingLong(src=main.params['PING']['source1'],
+                            target=main.params['PING']['target1'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source2'],
+                            target=main.params['PING']['target2'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source3'],
+                            target=main.params['PING']['target3'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source4'],
+                            target=main.params['PING']['target4'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source5'],
+                            target=main.params['PING']['target5'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source6'],
+                            target=main.params['PING']['target6'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source7'],
+                            target=main.params['PING']['target7'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source8'],
+                            target=main.params['PING']['target8'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source9'],
+                            target=main.params['PING']['target9'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source10'],
+                            target=main.params['PING']['target10'],pingTime=500)
+
+        main.step("Create TestONTopology object")
+        ctrls = []
+        count = 1
+        while True:
+            temp = ()
+            if ('ip' + str(count)) in main.params['CTRL']:
+                temp = temp + (getattr(main,('ONOS' + str(count))),)
+                temp = temp + ("ONOS"+str(count),)
+                temp = temp + (main.params['CTRL']['ip'+str(count)],)
+                temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+                ctrls.append(temp)
+                count = count + 1
+            else:
+                break
+        MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+        main.step("Collecting topology information from ONOS")
+        devices = []
+        devices.append( main.ONOScli1.devices() )
+        devices.append( main.ONOScli2.devices() )
+        devices.append( main.ONOScli3.devices() )
+        devices.append( main.ONOScli4.devices() )
+        devices.append( main.ONOScli5.devices() )
+        devices.append( main.ONOScli6.devices() )
+        devices.append( main.ONOScli7.devices() )
+        '''
+        hosts = []
+        hosts.append( main.ONOScli1.hosts() )
+        hosts.append( main.ONOScli2.hosts() )
+        hosts.append( main.ONOScli3.hosts() )
+        hosts.append( main.ONOScli4.hosts() )
+        hosts.append( main.ONOScli5.hosts() )
+        hosts.append( main.ONOScli6.hosts() )
+        hosts.append( main.ONOScli7.hosts() )
+        '''
+        ports = []
+        ports.append( main.ONOScli1.ports() )
+        ports.append( main.ONOScli2.ports() )
+        ports.append( main.ONOScli3.ports() )
+        ports.append( main.ONOScli4.ports() )
+        ports.append( main.ONOScli5.ports() )
+        ports.append( main.ONOScli6.ports() )
+        ports.append( main.ONOScli7.ports() )
+        links = []
+        links.append( main.ONOScli1.links() )
+        links.append( main.ONOScli2.links() )
+        links.append( main.ONOScli3.links() )
+        links.append( main.ONOScli4.links() )
+        links.append( main.ONOScli5.links() )
+        links.append( main.ONOScli6.links() )
+        links.append( main.ONOScli7.links() )
+
+
+        main.step("Comparing ONOS topology to MN")
+        devices_results = main.TRUE
+        ports_results = main.TRUE
+        links_results = main.TRUE
+        for controller in range(7): #TODO parameterize the number of controllers
+            if devices[controller] or not "Error" in devices[controller]:
+                current_devices_result =  main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+            else:
+                current_devices_result = main.FALSE
+            utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+                    onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+                    onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+            if ports[controller] or not "Error" in ports[controller]:
+                current_ports_result =  main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+            else:
+                current_ports_result = main.FALSE
+            utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+                    onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+                    onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+            if links[controller] or not "Error" in links[controller]:
+                current_links_result =  main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+            else:
+                current_links_result = main.FALSE
+            utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+                    onpass="ONOS"+str(int(controller+1))+" links view is correct",
+                    onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+
+            devices_results = devices_results and current_devices_result
+            ports_results = ports_results and current_ports_result
+            links_results = links_results and current_links_result
+
+        topo_result = devices_results and ports_results and links_results
+        utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+                onpass="Topology Check Test successful",
+                onfail="Topology Check Test NOT successful")
+
+        final_assert = main.TRUE
+        final_assert = final_assert and topo_result and flow_check \
+                and intent_check and consistent_mastership
+        utilities.assert_equals(expect=main.TRUE, actual=final_assert,
+                onpass="State check successful",
+                onfail="State check NOT successful")
+
+
+    def CASE6(self,main) :
+        '''
+        The Failure case.
+        '''
+        main.log.report("Restart entire ONOS cluster")
+        main.log.case("Restart entire ONOS cluster")
+        main.ONOSbench.onos_kill(ONOS1_ip)
+        main.ONOSbench.onos_kill(ONOS2_ip)
+        main.ONOSbench.onos_kill(ONOS3_ip)
+        main.ONOSbench.onos_kill(ONOS4_ip)
+        main.ONOSbench.onos_kill(ONOS5_ip)
+        main.ONOSbench.onos_kill(ONOS6_ip)
+        main.ONOSbench.onos_kill(ONOS7_ip)
+
+        main.step("Checking if ONOS is up yet")
+        count = 0
+        onos_isup_result = main.FALSE
+        while onos_isup_result == main.FALSE and count < 10:
+            onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+            onos2_isup = main.ONOSbench.isup(ONOS2_ip)
+            onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+            onos4_isup = main.ONOSbench.isup(ONOS4_ip)
+            onos5_isup = main.ONOSbench.isup(ONOS5_ip)
+            onos6_isup = main.ONOSbench.isup(ONOS6_ip)
+            onos7_isup = main.ONOSbench.isup(ONOS7_ip)
+            onos_isup_result = onos1_isup and onos2_isup and onos3_isup\
+                    and onos4_isup and onos5_isup and onos6_isup and onos7_isup
+            count = count + 1
+        # TODO: if it becomes an issue, we can retry this step  a few times
+
+
+        cli_result1 = main.ONOScli1.start_onos_cli(ONOS1_ip)
+        cli_result2 = main.ONOScli2.start_onos_cli(ONOS2_ip)
+        cli_result3 = main.ONOScli3.start_onos_cli(ONOS3_ip)
+        cli_result4 = main.ONOScli4.start_onos_cli(ONOS4_ip)
+        cli_result5 = main.ONOScli5.start_onos_cli(ONOS5_ip)
+        cli_result6 = main.ONOScli6.start_onos_cli(ONOS6_ip)
+        cli_result7 = main.ONOScli7.start_onos_cli(ONOS7_ip)
+        cli_results = cli_result1 and cli_result2 and cli_result3\
+                and cli_result4 and cli_result5 and cli_result6\
+                and cli_result7
+
+        case_results = main.TRUE and onos_isup_result and cli_results
+        utilities.assert_equals(expect=main.TRUE, actual=case_results,
+                onpass="ONOS restart successful",
+                onfail="ONOS restart NOT successful")
+
+
+    def CASE7(self,main) :
+        '''
+        Check state after ONOS failure
+        '''
+        import os
+        import json
+        main.case("Running ONOS Constant State Tests")
+
+        main.step("Check if switch roles are consistent across all nodes")
+        ONOS1_mastership = main.ONOScli1.roles()
+        ONOS2_mastership = main.ONOScli2.roles()
+        ONOS3_mastership = main.ONOScli3.roles()
+        ONOS4_mastership = main.ONOScli4.roles()
+        ONOS5_mastership = main.ONOScli5.roles()
+        ONOS6_mastership = main.ONOScli6.roles()
+        ONOS7_mastership = main.ONOScli7.roles()
+        #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+        if "Error" in ONOS1_mastership or not ONOS1_mastership\
+                or "Error" in ONOS2_mastership or not ONOS2_mastership\
+                or "Error" in ONOS3_mastership or not ONOS3_mastership\
+                or "Error" in ONOS4_mastership or not ONOS4_mastership\
+                or "Error" in ONOS5_mastership or not ONOS5_mastership\
+                or "Error" in ONOS6_mastership or not ONOS6_mastership\
+                or "Error" in ONOS7_mastership or not ONOS7_mastership:
+                    main.log.error("Error in getting ONOS mastership")
+                    main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+                    main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership))
+                    main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership))
+                    main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership))
+                    main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership))
+                    main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership))
+                    main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership))
+                    consistent_mastership = main.FALSE
+        elif ONOS1_mastership == ONOS2_mastership\
+                and ONOS1_mastership == ONOS3_mastership\
+                and ONOS1_mastership == ONOS4_mastership\
+                and ONOS1_mastership == ONOS5_mastership\
+                and ONOS1_mastership == ONOS6_mastership\
+                and ONOS1_mastership == ONOS7_mastership:
+                    #mastership_state = ONOS1_mastership
+                    consistent_mastership = main.TRUE
+                    main.log.report("Switch roles are consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            consistent_mastership = main.FALSE
+        utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+                onpass="Switch roles are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of switch roles")
+
+
+        description2 = "Compare switch roles from before failure"
+        main.step(description2)
+
+        current_json = json.loads(ONOS1_mastership)
+        old_json = json.loads(mastership_state)
+        mastership_check = main.TRUE
+        for i in range(1,29):
+            switchDPID = str(main.Mininet1.getSwitchDPID(switch="s"+str(i)))
+
+            current = [switch['master'] for switch in current_json if switchDPID in switch['id']]
+            old = [switch['master'] for switch in old_json if switchDPID in switch['id']]
+            if current == old:
+                mastership_check = mastership_check and main.TRUE
+            else:
+                main.log.warn("Mastership of switch %s changed" % switchDPID)
+                mastership_check = main.FALSE
+        if mastership_check == main.TRUE:
+            main.log.report("Mastership of Switches was not changed")
+        utilities.assert_equals(expect=main.TRUE,actual=mastership_check,
+                onpass="Mastership of Switches was not changed",
+                onfail="Mastership of some switches changed")
+        #NOTE: we expect mastership to change on controller failure
+        mastership_check = mastership_check #and consistent_mastership
+
+
+
+        main.step("Get the intents and compare across all nodes")
+        ONOS1_intents = main.ONOScli1.intents( json_format=True )
+        ONOS2_intents = main.ONOScli2.intents( json_format=True )
+        ONOS3_intents = main.ONOScli3.intents( json_format=True )
+        ONOS4_intents = main.ONOScli4.intents( json_format=True )
+        ONOS5_intents = main.ONOScli5.intents( json_format=True )
+        ONOS6_intents = main.ONOScli6.intents( json_format=True )
+        ONOS7_intents = main.ONOScli7.intents( json_format=True )
+        intent_check = main.FALSE
+        if "Error" in ONOS1_intents or not ONOS1_intents\
+                or "Error" in ONOS2_intents or not ONOS2_intents\
+                or "Error" in ONOS3_intents or not ONOS3_intents\
+                or "Error" in ONOS4_intents or not ONOS4_intents\
+                or "Error" in ONOS5_intents or not ONOS5_intents\
+                or "Error" in ONOS6_intents or not ONOS6_intents\
+                or "Error" in ONOS7_intents or not ONOS7_intents:
+                    main.log.report("Error in getting ONOS intents")
+                    main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+                    main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents))
+                    main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents))
+                    main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents))
+                    main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents))
+                    main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents))
+                    main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents))
+        elif ONOS1_intents == ONOS2_intents\
+                and ONOS1_intents == ONOS3_intents\
+                and ONOS1_intents == ONOS4_intents\
+                and ONOS1_intents == ONOS5_intents\
+                and ONOS1_intents == ONOS6_intents\
+                and ONOS1_intents == ONOS7_intents:
+                    intent_check = main.TRUE
+                    main.log.report("Intents are consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 intents: ", json.dumps(json.loads(ONOS1_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 intents: ", json.dumps(json.loads(ONOS2_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 intents: ", json.dumps(json.loads(ONOS3_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 intents: ", json.dumps(json.loads(ONOS4_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 intents: ", json.dumps(json.loads(ONOS5_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 intents: ", json.dumps(json.loads(ONOS6_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 intents: ", json.dumps(json.loads(ONOS7_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+        utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+                onpass="Intents are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of intents")
+
+        main.step("Compare current intents with intents before the failure")
+        if intent_state == ONOS1_intents:
+            same_intents = main.TRUE
+            main.log.report("Intents are consistent with before failure")
+        #TODO: possibly the states have changed? we may need to figure out what the aceptable states are
+        else:
+            same_intents = main.FALSE
+        utilities.assert_equals(expect = main.TRUE,actual=same_intents,
+                onpass="Intents are consistent with before failure",
+                onfail="The Intents changed during failure")
+        intent_check = intent_check and same_intents
+
+
+
+        main.step("Get the OF Table entries and compare to before component failure")
+        Flow_Tables = main.TRUE
+        flows2=[]
+        for i in range(28):
+            main.log.info("Checking flow table on s" + str(i+1))
+            tmp_flows = main.Mininet2.get_flowTable("s"+str(i+1),1.0)
+            flows2.append(tmp_flows)
+            Flow_Tables = Flow_Tables and main.Mininet2.flow_comp(flow1=flows[i],flow2=tmp_flows)
+            if Flow_Tables == main.FALSE:
+                main.log.info("Differences in flow table for switch: "+str(i+1))
+                break
+        if Flow_Tables == main.TRUE:
+            main.log.report("No changes were found in the flow tables")
+        utilities.assert_equals(expect=main.TRUE,actual=Flow_Tables,
+                onpass="No changes were found in the flow tables",
+                onfail="Changes were found in the flow tables")
+
+        main.step("Check the continuous pings to ensure that no packets were dropped during component failure")
+        #FIXME: This check is always failing. Investigate cause
+        #NOTE:  this may be something to do with file permsissions
+        #       or slight change in format
+        main.Mininet2.pingKill(main.params['TESTONUSER'], main.params['TESTONIP'])
+        Loss_In_Pings = main.FALSE 
+        #NOTE: checkForLoss returns main.FALSE with 0% packet loss
+        for i in range(8,18):
+            main.log.info("Checking for a loss in pings along flow from s" + str(i))
+            Loss_In_Pings = Loss_In_Pings or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i))
+        if Loss_In_Pings == main.TRUE:
+            main.log.info("Loss in ping detected")
+        elif Loss_In_Pings == main.ERROR:
+            main.log.info("There are multiple mininet process running")
+        elif Loss_In_Pings == main.FALSE:
+            main.log.info("No Loss in the pings")
+            main.log.report("No loss of dataplane connectivity")
+        utilities.assert_equals(expect=main.FALSE,actual=Loss_In_Pings,
+                onpass="No Loss of connectivity",
+                onfail="Loss of dataplane connectivity detected")
+
+
+        #TODO:add topology to this or leave as a seperate case?
+        result = mastership_check and intent_check and Flow_Tables and (not Loss_In_Pings)
+        result = int(result)
+        if result == main.TRUE:
+            main.log.report("Constant State Tests Passed")
+        utilities.assert_equals(expect=main.TRUE,actual=result,
+                onpass="Constant State Tests Passed",
+                onfail="Constant state tests failed")
+
+    def CASE8 (self,main):
+        '''
+        Compare topo
+        '''
+        import sys
+        sys.path.append("/home/admin/sts") # Trying to remove some dependancies, #FIXME add this path to params
+        from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+        import json
+        import time
+
+        description ="Compare ONOS Topology view to Mininet topology"
+        main.case(description)
+        main.log.report(description)
+        main.step("Create TestONTopology object")
+        ctrls = []
+        count = 1
+        while True:
+            temp = ()
+            if ('ip' + str(count)) in main.params['CTRL']:
+                temp = temp + (getattr(main,('ONOS' + str(count))),)
+                temp = temp + ("ONOS"+str(count),)
+                temp = temp + (main.params['CTRL']['ip'+str(count)],)
+                temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+                ctrls.append(temp)
+                count = count + 1
+            else:
+                break
+        MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+        main.step("Comparing ONOS topology to MN")
+        devices_results = main.TRUE
+        ports_results = main.TRUE
+        links_results = main.TRUE
+        topo_result = main.FALSE
+        start_time = time.time()
+        elapsed = 0
+        count = 0
+        while topo_result == main.FALSE and elapsed < 120:
+            count = count + 1
+            try:
+                main.step("Collecting topology information from ONOS")
+                devices = []
+                devices.append( main.ONOScli1.devices() )
+                devices.append( main.ONOScli2.devices() )
+                devices.append( main.ONOScli3.devices() )
+                devices.append( main.ONOScli4.devices() )
+                devices.append( main.ONOScli5.devices() )
+                devices.append( main.ONOScli6.devices() )
+                devices.append( main.ONOScli7.devices() )
+                '''
+                hosts = []
+                hosts.append( main.ONOScli1.hosts() )
+                hosts.append( main.ONOScli2.hosts() )
+                hosts.append( main.ONOScli3.hosts() )
+                hosts.append( main.ONOScli4.hosts() )
+                hosts.append( main.ONOScli5.hosts() )
+                hosts.append( main.ONOScli6.hosts() )
+                hosts.append( main.ONOScli7.hosts() )
+                '''
+                ports = []
+                ports.append( main.ONOScli1.ports() )
+                ports.append( main.ONOScli2.ports() )
+                ports.append( main.ONOScli3.ports() )
+                ports.append( main.ONOScli4.ports() )
+                ports.append( main.ONOScli5.ports() )
+                ports.append( main.ONOScli6.ports() )
+                ports.append( main.ONOScli7.ports() )
+                links = []
+                links.append( main.ONOScli1.links() )
+                links.append( main.ONOScli2.links() )
+                links.append( main.ONOScli3.links() )
+                links.append( main.ONOScli4.links() )
+                links.append( main.ONOScli5.links() )
+                links.append( main.ONOScli6.links() )
+                links.append( main.ONOScli7.links() )
+
+                for controller in range(7): #TODO parameterize the number of controllers
+                    if devices[controller] or not "Error" in devices[controller]:
+                        current_devices_result =  main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+                    else:
+                        current_devices_result = main.FALSE
+                    utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+                            onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+                            onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+                    if ports[controller] or not "Error" in ports[controller]:
+                        current_ports_result =  main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+                    else:
+                        current_ports_result = main.FALSE
+                    utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+                            onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+                            onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+                    if links[controller] or not "Error" in links[controller]:
+                        current_links_result =  main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+                    else:
+                        current_links_result = main.FALSE
+                    utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+                            onpass="ONOS"+str(int(controller+1))+" links view is correct",
+                            onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+            except:
+                main.log.error("something went wrong in topo comparison")
+                main.log.warn( repr( devices ) )
+                main.log.warn( repr( ports ) )
+                main.log.warn( repr( links ) )
+
+            devices_results = devices_results and current_devices_result
+            ports_results = ports_results and current_ports_result
+            links_results = links_results and current_links_result
+            topo_result = devices_results and ports_results and links_results
+            elapsed = time.time() - start_time
+        time_threshold = elapsed < 1
+        topo_result = topo_result and time_threshold
+        #TODO make sure this step is non-blocking. IE add a timeout
+        main.log.report("Very crass estimate for topology discovery/convergence: " +\
+                str(elapsed) + " seconds, " + str(count) +" tries" )
+        utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+                onpass="Topology Check Test successful",
+                onfail="Topology Check Test NOT successful")
+        if topo_result == main.TRUE:
+            main.log.report("ONOS topology view matches Mininet topology")
+
+
+    def CASE9 (self,main):
+        '''
+        Link s3-s28 down
+        '''
+        #NOTE: You should probably run a topology check after this
+
+        link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+        description = "Turn off a link to ensure that Link Discovery is working properly"
+        main.log.report(description)
+        main.case(description)
+
+
+        main.step("Kill Link between s3 and s28")
+        Link_Down = main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
+        main.log.info("Waiting " + str(link_sleep) + " seconds for link down to be discovered")
+        time.sleep(link_sleep)
+        utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
+                onpass="Link down succesful",
+                onfail="Failed to bring link down")
+        #TODO do some sort of check here
+
+    def CASE10 (self,main):
+        '''
+        Link s3-s28 up
+        '''
+        #NOTE: You should probably run a topology check after this
+
+        link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+        description = "Restore a link to ensure that Link Discovery is working properly"
+        main.log.report(description)
+        main.case(description)
+
+        main.step("Bring link between s3 and s28 back up")
+        Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
+        main.log.info("Waiting " + str(link_sleep) + " seconds for link up to be discovered")
+        time.sleep(link_sleep)
+        utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
+                onpass="Link up succesful",
+                onfail="Failed to bring link up")
+        #TODO do some sort of check here
+
+
+    def CASE11 (self, main) :
+        '''
+        Switch Down
+        '''
+        #NOTE: You should probably run a topology check after this
+        import time
+
+        switch_sleep = int(main.params['timers']['SwitchDiscovery'])
+
+        description = "Killing a switch to ensure it is discovered correctly"
+        main.log.report(description)
+        main.case(description)
+
+        #TODO: Make this switch parameterizable
+        main.step("Kill s28 ")
+        main.log.report("Deleting s28")
+        #FIXME: use new dynamic topo functions
+        main.Mininet1.del_switch("s28")
+        main.log.info("Waiting " + str(switch_sleep) + " seconds for switch down to be discovered")
+        time.sleep(switch_sleep)
+        #Peek at the deleted switch
+        main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+        #TODO do some sort of check here
+
+    def CASE12 (self, main) :
+        '''
+        Switch Up
+        '''
+        #NOTE: You should probably run a topology check after this
+        import time
+        #FIXME: use new dynamic topo functions
+        description = "Adding a switch to ensure it is discovered correctly"
+        main.log.report(description)
+        main.case(description)
+
+        main.step("Add back s28")
+        main.log.report("Adding back s28")
+        main.Mininet1.add_switch("s28", dpid = '0000000000002800')
+        #TODO: New dpid or same? Ask Thomas?
+        main.Mininet1.add_link('s28', 's3')
+        main.Mininet1.add_link('s28', 's6')
+        main.Mininet1.add_link('s28', 'h28')
+        main.Mininet1.assign_sw_controller(sw="28",count=7,
+                ip1=ONOS1_ip,port1=ONOS1_port,
+                ip2=ONOS2_ip,port2=ONOS2_port,
+                ip3=ONOS3_ip,port3=ONOS3_port,
+                ip4=ONOS4_ip,port4=ONOS4_port,
+                ip5=ONOS5_ip,port5=ONOS5_port,
+                ip6=ONOS6_ip,port6=ONOS6_port,
+                ip7=ONOS7_ip,port7=ONOS7_port)
+        main.log.info("Waiting " + str(switch_sleep) + " seconds for switch up to be discovered")
+        time.sleep(switch_sleep)
+        #Peek at the added switch
+        main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+        #TODO do some sort of check here
+
+    def CASE13 (self, main) :
+        '''
+        Clean up
+        '''
+        import os
+        import time
+        description = "Test Cleanup"
+        main.log.report(description)
+        main.case(description)
+        main.step("Killing tcpdumps")
+        main.Mininet2.stop_tcpdump()
+
+        main.step("Copying MN pcap and ONOS log files to test station")
+        testname = main.TEST
+        #NOTE: MN Pcap file is being saved to ~/packet_captures
+        #       scp this file as MN and TestON aren't necessarily the same vm
+        #FIXME: scp
+        #####mn files
+        #TODO: Load these from params
+        #NOTE: must end in /
+        log_folder = "/opt/onos/log/"
+        log_files = ["karaf.log", "karaf.log.1"]
+        #NOTE: must end in /
+        dst_dir = "~/packet_captures/"
+        for f in log_files:
+            main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS1-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS2_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS2-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS3_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS3-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS4_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS4-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS5_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS5-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS6_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS6-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS7_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS7-"+f )
+
+        #std*.log's
+        #NOTE: must end in /
+        log_folder = "/opt/onos/var/"
+        log_files = ["stderr.log", "stdout.log"]
+        #NOTE: must end in /
+        dst_dir = "~/packet_captures/"
+        for f in log_files:
+            main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS1-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS2_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS2-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS3_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS3-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS4_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS4-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS5_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS5-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS6_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS6-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS7_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS7-"+f )
+
+
+
+
+        #sleep so scp can finish
+        time.sleep(10)
+        main.step("Packing and rotating pcap archives")
+        os.system("~/TestON/dependencies/rotate.sh "+ str(testname))
+
+
+        #TODO: actually check something here
+        utilities.assert_equals(expect=main.TRUE, actual=main.TRUE,
+                onpass="Test cleanup successful",
+                onfail="Test cleanup NOT successful")
diff --git a/TestON/tests/HATestClusterRestart/HATestClusterRestart.topo b/TestON/tests/HATestClusterRestart/HATestClusterRestart.topo
new file mode 100644
index 0000000..4d4156c
--- /dev/null
+++ b/TestON/tests/HATestClusterRestart/HATestClusterRestart.topo
@@ -0,0 +1,173 @@
+<TOPOLOGY>
+    <COMPONENT>
+
+        <ONOSbench>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosDriver</type>
+            <connect_order>1</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOSbench>
+
+        <ONOScli1>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli1>
+
+        <ONOScli2>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>3</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli2>
+
+        <ONOScli3>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>4</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli3>
+
+
+        <ONOScli4>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>5</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli4>
+
+
+        <ONOScli5>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>6</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli5>
+
+
+        <ONOScli6>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>7</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli6>
+
+
+        <ONOScli7>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>8</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli7>
+
+        <ONOS1>
+            <host>10.128.30.11</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>9</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS1>
+
+        <ONOS2>
+            <host>10.128.30.12</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>10</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS2>
+
+        <ONOS3>
+            <host>10.128.30.13</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>11</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS3>
+
+        <ONOS4>
+            <host>10.128.30.14</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>12</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS4>
+
+        <ONOS5>
+            <host>10.128.30.15</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>13</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS5>
+
+        <ONOS6>
+            <host>10.128.30.16</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>14</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS6>
+
+        <ONOS7>
+            <host>10.128.30.17</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>15</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS7>
+
+        <Mininet1>
+            <host>10.128.30.9</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>MininetCliDriver</type>
+            <connect_order>16</connect_order>
+            <COMPONENTS>
+                #Specify the Option for mininet
+                <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+                <arg2> --topo mytopo </arg2>
+                <arg3> </arg3>
+                <controller> remote </controller>
+            </COMPONENTS>
+        </Mininet1>
+
+        <Mininet2>
+            <host>10.128.30.9</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>RemoteMininetDriver</type>
+            <connect_order>17</connect_order>
+            <COMPONENTS>
+                # Specify the Option for mininet
+                <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+                <arg2> --topo mytopo --arp</arg2>
+                <controller> remote </controller>
+             </COMPONENTS>
+        </Mininet2>
+
+    </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/HATestClusterRestart/__init__.py b/TestON/tests/HATestClusterRestart/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/HATestClusterRestart/__init__.py
diff --git a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params
new file mode 100644
index 0000000..0a8bd57
--- /dev/null
+++ b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params
@@ -0,0 +1,63 @@
+<PARAMS>
+    <testcases>1,2,8,3,4,5,[6],7,8,4,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+    <ENV>
+    <cellName>HA</cellName>
+    </ENV>
+    <Git>False</Git>
+
+    <CTRL>
+        <ip1>10.128.30.11</ip1>
+        <port1>6633</port1>
+
+        <ip2>10.128.30.12</ip2>
+        <port2>6633</port2>
+
+        <ip3>10.128.30.13</ip3>
+        <port3>6633</port3>
+
+        <ip4>10.128.30.14</ip4>
+        <port4>6633</port4>
+
+        <ip5>10.128.30.15</ip5>
+        <port5>6633</port5>
+
+        <ip6>10.128.30.16</ip6>
+        <port6>6633</port6>
+
+        <ip7>10.128.30.17</ip7>
+        <port7>6633</port7>
+    </CTRL>
+    <TESTONUSER>admin</TESTONUSER>
+    <TESTONIP>10.128.30.10</TESTONIP>
+    <PING>
+        <source1>h8</source1>
+        <source2>h9</source2>
+        <source3>h10</source3>
+        <source4>h11</source4>
+        <source5>h12</source5>
+        <source6>h13</source6>
+        <source7>h14</source7>
+        <source8>h15</source8>
+        <source9>h16</source9>
+        <source10>h17</source10>
+        <target1>10.0.0.18</target1>
+        <target2>10.0.0.19</target2>
+        <target3>10.0.0.20</target3>
+        <target4>10.0.0.21</target4>
+        <target5>10.0.0.22</target5>
+        <target6>10.0.0.23</target6>
+        <target7>10.0.0.24</target7>
+        <target8>10.0.0.25</target8>
+        <target9>10.0.0.26</target9>
+        <target10>10.0.0.27</target10>
+    </PING>
+    <timers>
+        <LinkDiscovery>2</LinkDiscovery>
+        <SwitchDiscovery>2</SwitchDiscovery>
+    </timers>
+    <MNtcpdump>
+        <intf>eth0</intf>
+        <port> </port>
+        <folder>~/packet_captures/</folder>
+    </MNtcpdump>
+</PARAMS>
diff --git a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
new file mode 100644
index 0000000..2af775d
--- /dev/null
+++ b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
@@ -0,0 +1,1202 @@
+'''
+Description: This test is to determine if ONOS can handle
+    a minority of it's nodes restarting
+
+List of test cases:
+CASE1: Compile ONOS and push it to the test machines
+CASE2: Assign mastership to controllers
+CASE3: Assign intents
+CASE4: Ping across added host intents
+CASE5: Reading state of ONOS
+CASE6: The Failure case.
+CASE7: Check state after control plane failure
+CASE8: Compare topo
+CASE9: Link s3-s28 down
+CASE10: Link s3-s28 up
+CASE11: Switch down
+CASE12: Switch up
+CASE13: Clean up
+'''
+class HATestMinorityRestart:
+
+    def __init__(self) :
+        self.default = ''
+
+    def CASE1(self,main) :
+        '''
+        CASE1 is to compile ONOS and push it to the test machines
+
+        Startup sequence:
+        git pull
+        mvn clean install
+        onos-package
+        cell <name>
+        onos-verify-cell
+        NOTE: temporary - onos-remove-raft-logs
+        onos-install -f
+        onos-wait-for-start
+        '''
+        import time
+        main.log.report("ONOS HA test: Restart minority of ONOS nodes - initialization")
+        main.case("Setting up test environment")
+
+        # load some vairables from the params file
+        PULL_CODE = False
+        if main.params['Git'] == 'True':
+            PULL_CODE = True
+        cell_name = main.params['ENV']['cellName']
+
+        #set global variables
+        global ONOS1_ip
+        global ONOS1_port
+        global ONOS2_ip
+        global ONOS2_port
+        global ONOS3_ip
+        global ONOS3_port
+        global ONOS4_ip
+        global ONOS4_port
+        global ONOS5_ip
+        global ONOS5_port
+        global ONOS6_ip
+        global ONOS6_port
+        global ONOS7_ip
+        global ONOS7_port
+
+        ONOS1_ip = main.params['CTRL']['ip1']
+        ONOS1_port = main.params['CTRL']['port1']
+        ONOS2_ip = main.params['CTRL']['ip2']
+        ONOS2_port = main.params['CTRL']['port2']
+        ONOS3_ip = main.params['CTRL']['ip3']
+        ONOS3_port = main.params['CTRL']['port3']
+        ONOS4_ip = main.params['CTRL']['ip4']
+        ONOS4_port = main.params['CTRL']['port4']
+        ONOS5_ip = main.params['CTRL']['ip5']
+        ONOS5_port = main.params['CTRL']['port5']
+        ONOS6_ip = main.params['CTRL']['ip6']
+        ONOS6_port = main.params['CTRL']['port6']
+        ONOS7_ip = main.params['CTRL']['ip7']
+        ONOS7_port = main.params['CTRL']['port7']
+
+
+        main.step("Applying cell variable to environment")
+        cell_result = main.ONOSbench.set_cell(cell_name)
+        verify_result = main.ONOSbench.verify_cell()
+
+        #FIXME:this is short term fix 
+        main.log.report("Removing raft logs")
+        main.ONOSbench.onos_remove_raft_logs()
+        main.log.report("Uninstalling ONOS")
+        main.ONOSbench.onos_uninstall(ONOS1_ip)
+        main.ONOSbench.onos_uninstall(ONOS2_ip)
+        main.ONOSbench.onos_uninstall(ONOS3_ip)
+        main.ONOSbench.onos_uninstall(ONOS4_ip)
+        main.ONOSbench.onos_uninstall(ONOS5_ip)
+        main.ONOSbench.onos_uninstall(ONOS6_ip)
+        main.ONOSbench.onos_uninstall(ONOS7_ip)
+
+        clean_install_result = main.TRUE
+        git_pull_result = main.TRUE
+
+        main.step("Compiling the latest version of ONOS")
+        if PULL_CODE:
+            main.step("Git checkout and pull master")
+            main.ONOSbench.git_checkout("master")
+            git_pull_result = main.ONOSbench.git_pull()
+
+            main.step("Using mvn clean & install")
+            clean_install_result = main.TRUE
+            if git_pull_result == main.TRUE:
+                clean_install_result = main.ONOSbench.clean_install()
+            else:
+                main.log.warn("Did not pull new code so skipping mvn "+ \
+                        "clean install")
+        main.ONOSbench.get_version(report=True)
+
+        main.step("Creating ONOS package")
+        package_result = main.ONOSbench.onos_package()
+
+        main.step("Installing ONOS package")
+        onos1_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS1_ip)
+        onos2_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS2_ip)
+        onos3_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS3_ip)
+        onos4_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS4_ip)
+        onos5_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS5_ip)
+        onos6_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS6_ip)
+        onos7_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS7_ip)
+        onos_install_result = onos1_install_result and onos2_install_result\
+                and onos3_install_result and onos4_install_result\
+                and onos5_install_result and onos6_install_result\
+                and onos7_install_result
+        '''
+        #FIXME: work around until onos is less fragile
+        main.ONOSbench.handle.sendline("onos-cluster-install")
+        print main.ONOSbench.handle.expect("\$")
+        onos_install_result = main.TRUE
+        '''
+
+
+        main.step("Checking if ONOS is up yet")
+        #TODO: Refactor
+        # check bundle:list?
+        onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+        if not onos1_isup:
+            main.log.report("ONOS1 didn't start!")
+        onos2_isup = main.ONOSbench.isup(ONOS2_ip)
+        if not onos2_isup:
+            main.log.report("ONOS2 didn't start!")
+        onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+        if not onos3_isup:
+            main.log.report("ONOS3 didn't start!")
+        onos4_isup = main.ONOSbench.isup(ONOS4_ip)
+        if not onos4_isup:
+            main.log.report("ONOS4 didn't start!")
+        onos5_isup = main.ONOSbench.isup(ONOS5_ip)
+        if not onos5_isup:
+            main.log.report("ONOS5 didn't start!")
+        onos6_isup = main.ONOSbench.isup(ONOS6_ip)
+        if not onos6_isup:
+            main.log.report("ONOS6 didn't start!")
+        onos7_isup = main.ONOSbench.isup(ONOS7_ip)
+        if not onos7_isup:
+            main.log.report("ONOS7 didn't start!")
+        onos_isup_result = onos1_isup and onos2_isup and onos3_isup\
+                and onos4_isup and onos5_isup and onos6_isup and onos7_isup
+        # TODO: if it becomes an issue, we can retry this step  a few times
+
+
+        cli_result1 = main.ONOScli1.start_onos_cli(ONOS1_ip)
+        cli_result2 = main.ONOScli2.start_onos_cli(ONOS2_ip)
+        cli_result3 = main.ONOScli3.start_onos_cli(ONOS3_ip)
+        cli_result4 = main.ONOScli4.start_onos_cli(ONOS4_ip)
+        cli_result5 = main.ONOScli5.start_onos_cli(ONOS5_ip)
+        cli_result6 = main.ONOScli6.start_onos_cli(ONOS6_ip)
+        cli_result7 = main.ONOScli7.start_onos_cli(ONOS7_ip)
+        cli_results = cli_result1 and cli_result2 and cli_result3 and\
+                cli_result4 and cli_result5 and cli_result6 and cli_result7
+
+        main.step("Start Packet Capture MN")
+        main.Mininet2.start_tcpdump(
+                str(main.params['MNtcpdump']['folder'])+str(main.TEST)+"-MN.pcap",
+                intf = main.params['MNtcpdump']['intf'],
+                port = main.params['MNtcpdump']['port'])
+
+
+        case1_result = (clean_install_result and package_result and
+                cell_result and verify_result and onos_install_result and
+                onos_isup_result and cli_results)
+
+        utilities.assert_equals(expect=main.TRUE, actual=case1_result,
+                onpass="Test startup successful",
+                onfail="Test startup NOT successful")
+
+
+        #if case1_result==main.FALSE:
+        #    main.cleanup()
+        #    main.exit()
+
+    def CASE2(self,main) :
+        '''
+        Assign mastership to controllers
+        '''
+        import time
+        import json
+        import re
+
+
+        '''
+        ONOS1_ip = main.params['CTRL']['ip1']
+        ONOS1_port = main.params['CTRL']['port1']
+        ONOS2_ip = main.params['CTRL']['ip2']
+        ONOS2_port = main.params['CTRL']['port2']
+        ONOS3_ip = main.params['CTRL']['ip3']
+        ONOS3_port = main.params['CTRL']['port3']
+        ONOS4_ip = main.params['CTRL']['ip4']
+        ONOS4_port = main.params['CTRL']['port4']
+        ONOS5_ip = main.params['CTRL']['ip5']
+        ONOS5_port = main.params['CTRL']['port5']
+        ONOS6_ip = main.params['CTRL']['ip6']
+        ONOS6_port = main.params['CTRL']['port6']
+        ONOS7_ip = main.params['CTRL']['ip7']
+        ONOS7_port = main.params['CTRL']['port7']
+        '''
+
+
+        main.log.report("Assigning switches to controllers")
+        main.case("Assigning Controllers")
+        main.step("Assign switches to controllers")
+
+        for i in range (1,29):
+           main.Mininet1.assign_sw_controller(sw=str(i),count=7,
+                    ip1=ONOS1_ip,port1=ONOS1_port,
+                    ip2=ONOS2_ip,port2=ONOS2_port,
+                    ip3=ONOS3_ip,port3=ONOS3_port,
+                    ip4=ONOS4_ip,port4=ONOS4_port,
+                    ip5=ONOS5_ip,port5=ONOS5_port,
+                    ip6=ONOS6_ip,port6=ONOS6_port,
+                    ip7=ONOS7_ip,port7=ONOS7_port)
+
+        mastership_check = main.TRUE
+        for i in range (1,29):
+            response = main.Mininet1.get_sw_controller("s"+str(i))
+            try:
+                main.log.info(str(response))
+            except:
+                main.log.info(repr(response))
+            if re.search("tcp:"+ONOS1_ip,response)\
+                    and re.search("tcp:"+ONOS2_ip,response)\
+                    and re.search("tcp:"+ONOS3_ip,response)\
+                    and re.search("tcp:"+ONOS4_ip,response)\
+                    and re.search("tcp:"+ONOS5_ip,response)\
+                    and re.search("tcp:"+ONOS6_ip,response)\
+                    and re.search("tcp:"+ONOS7_ip,response):
+                mastership_check = mastership_check and main.TRUE
+            else:
+                mastership_check = main.FALSE
+        if mastership_check == main.TRUE:
+            main.log.report("Switch mastership assigned correctly")
+        utilities.assert_equals(expect = main.TRUE,actual=mastership_check,
+                onpass="Switch mastership assigned correctly",
+                onfail="Switches not assigned correctly to controllers")
+
+        #TODO: If assign roles is working reliably then manually 
+        #   assign mastership to the controller we want
+
+
+    def CASE3(self,main) :
+        """
+        Assign intents
+
+        """
+        import time
+        import json
+        import re
+        main.log.report("Adding host intents")
+        main.case("Adding host Intents")
+
+        main.step("Discovering  Hosts( Via pingall for now)")
+        #FIXME: Once we have a host discovery mechanism, use that instead
+
+        #REACTIVE FWD test
+        ping_result = main.FALSE
+        time1 = time.time()
+        ping_result = main.Mininet1.pingall()
+        time2 = time.time()
+        main.log.info("Time for pingall: %2f seconds" % (time2 - time1))
+
+        #uninstall onos-app-fwd
+        main.log.info("Uninstall reactive forwarding app")
+        main.ONOScli1.feature_uninstall("onos-app-fwd")
+        main.ONOScli2.feature_uninstall("onos-app-fwd")
+        main.ONOScli3.feature_uninstall("onos-app-fwd")
+        main.ONOScli4.feature_uninstall("onos-app-fwd")
+        main.ONOScli5.feature_uninstall("onos-app-fwd")
+        main.ONOScli6.feature_uninstall("onos-app-fwd")
+        main.ONOScli7.feature_uninstall("onos-app-fwd")
+
+        main.step("Add  host intents")
+        #TODO:  move the host numbers to params
+        import json
+        intents_json= json.loads(main.ONOScli1.hosts())
+        intent_add_result = main.FALSE
+        for i in range(8,18):
+            main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+            #NOTE: get host can return None
+            #TODO: handle this
+            host1_id = main.ONOScli1.get_host(host1)['id']
+            host2_id = main.ONOScli1.get_host(host2)['id']
+            tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
+            intent_add_result = intent_add_result and tmp_result
+        #TODO Check if intents all exist in datastore
+        #NOTE: Do we need to print this once the test is working?
+        #main.log.info(json.dumps(json.loads(main.ONOScli1.intents(json_format=True)),
+        #    sort_keys=True, indent=4, separators=(',', ': ') ) )
+
+    def CASE4(self,main) :
+        """
+        Ping across added host intents
+        """
+        description = " Ping across added host intents"
+        main.log.report(description)
+        main.case(description)
+        Ping_Result = main.TRUE
+        for i in range(8,18):
+            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+            Ping_Result = Ping_Result and ping
+            if ping==main.FALSE:
+                main.log.warn("Ping failed between h"+str(i)+" and h" + str(i+10))
+            elif ping==main.TRUE:
+                main.log.info("Ping test passed!")
+                Ping_Result = main.TRUE
+        if Ping_Result==main.FALSE:
+            main.log.report("Intents have not been installed correctly, pings failed.")
+        if Ping_Result==main.TRUE:
+            main.log.report("Intents have been installed correctly and verified by pings")
+        utilities.assert_equals(expect = main.TRUE,actual=Ping_Result,
+                onpass="Intents have been installed correctly and pings work",
+                onfail ="Intents have not been installed correctly, pings failed." )
+
+    def CASE5(self,main) :
+        '''
+        Reading state of ONOS
+        '''
+        import time
+        import json
+        from subprocess import Popen, PIPE
+        from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+
+        main.log.report("Setting up and gathering data for current state")
+        main.case("Setting up and gathering data for current state")
+        #The general idea for this test case is to pull the state of (intents,flows, topology,...) from each ONOS node
+        #We can then compare them with eachother and also with past states
+
+        main.step("Get the Mastership of each switch from each controller")
+        global mastership_state
+        ONOS1_mastership = main.ONOScli1.roles()
+        ONOS2_mastership = main.ONOScli2.roles()
+        ONOS3_mastership = main.ONOScli3.roles()
+        ONOS4_mastership = main.ONOScli4.roles()
+        ONOS5_mastership = main.ONOScli5.roles()
+        ONOS6_mastership = main.ONOScli6.roles()
+        ONOS7_mastership = main.ONOScli7.roles()
+        #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+        if "Error" in ONOS1_mastership or not ONOS1_mastership\
+                or "Error" in ONOS2_mastership or not ONOS2_mastership\
+                or "Error" in ONOS3_mastership or not ONOS3_mastership\
+                or "Error" in ONOS4_mastership or not ONOS4_mastership\
+                or "Error" in ONOS5_mastership or not ONOS5_mastership\
+                or "Error" in ONOS6_mastership or not ONOS6_mastership\
+                or "Error" in ONOS7_mastership or not ONOS7_mastership:
+                    main.log.report("Error in getting ONOS roles")
+                    main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+                    main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership))
+                    main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership))
+                    main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership))
+                    main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership))
+                    main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership))
+                    main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership))
+                    consistent_mastership = main.FALSE
+        elif ONOS1_mastership == ONOS2_mastership\
+                and ONOS1_mastership == ONOS3_mastership\
+                and ONOS1_mastership == ONOS4_mastership\
+                and ONOS1_mastership == ONOS5_mastership\
+                and ONOS1_mastership == ONOS6_mastership\
+                and ONOS1_mastership == ONOS7_mastership:
+                    mastership_state = ONOS1_mastership
+                    consistent_mastership = main.TRUE
+                    main.log.report("Switch roles are consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            consistent_mastership = main.FALSE
+        utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+                onpass="Switch roles are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of switch roles")
+
+
+        main.step("Get the intents from each controller")
+        global intent_state
+        ONOS1_intents = main.ONOScli1.intents( json_format=True )
+        ONOS2_intents = main.ONOScli2.intents( json_format=True )
+        ONOS3_intents = main.ONOScli3.intents( json_format=True )
+        ONOS4_intents = main.ONOScli4.intents( json_format=True )
+        ONOS5_intents = main.ONOScli5.intents( json_format=True )
+        ONOS6_intents = main.ONOScli6.intents( json_format=True )
+        ONOS7_intents = main.ONOScli7.intents( json_format=True )
+        intent_check = main.FALSE
+        if "Error" in ONOS1_intents or not ONOS1_intents\
+                or "Error" in ONOS2_intents or not ONOS2_intents\
+                or "Error" in ONOS3_intents or not ONOS3_intents\
+                or "Error" in ONOS4_intents or not ONOS4_intents\
+                or "Error" in ONOS5_intents or not ONOS5_intents\
+                or "Error" in ONOS6_intents or not ONOS6_intents\
+                or "Error" in ONOS7_intents or not ONOS7_intents:
+                    main.log.report("Error in getting ONOS intents")
+                    main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+                    main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents))
+                    main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents))
+                    main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents))
+                    main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents))
+                    main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents))
+                    main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents))
+        elif ONOS1_intents == ONOS2_intents\
+                and ONOS1_intents == ONOS3_intents\
+                and ONOS1_intents == ONOS4_intents\
+                and ONOS1_intents == ONOS5_intents\
+                and ONOS1_intents == ONOS6_intents\
+                and ONOS1_intents == ONOS7_intents:
+                    intent_state = ONOS1_intents
+                    intent_check = main.TRUE
+                    main.log.report("Intents are consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 intents: ", json.dumps(json.loads(ONOS1_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 intents: ", json.dumps(json.loads(ONOS2_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 intents: ", json.dumps(json.loads(ONOS3_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 intents: ", json.dumps(json.loads(ONOS4_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 intents: ", json.dumps(json.loads(ONOS5_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 intents: ", json.dumps(json.loads(ONOS6_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 intents: ", json.dumps(json.loads(ONOS7_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+        utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+                onpass="Intents are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of intents")
+
+
+        main.step("Get the flows from each controller")
+        global flow_state
+        ONOS1_flows = main.ONOScli1.flows( json_format=True )
+        ONOS2_flows = main.ONOScli2.flows( json_format=True )
+        ONOS3_flows = main.ONOScli3.flows( json_format=True )
+        ONOS4_flows = main.ONOScli4.flows( json_format=True )
+        ONOS5_flows = main.ONOScli5.flows( json_format=True )
+        ONOS6_flows = main.ONOScli6.flows( json_format=True )
+        ONOS7_flows = main.ONOScli7.flows( json_format=True )
+        flow_check = main.FALSE
+        if "Error" in ONOS1_flows or not ONOS1_flows\
+                or "Error" in ONOS2_flows or not ONOS2_flows\
+                or "Error" in ONOS3_flows or not ONOS3_flows\
+                or "Error" in ONOS4_flows or not ONOS4_flows\
+                or "Error" in ONOS5_flows or not ONOS5_flows\
+                or "Error" in ONOS6_flows or not ONOS6_flows\
+                or "Error" in ONOS7_flows or not ONOS7_flows:
+                    main.log.report("Error in getting ONOS intents")
+                    main.log.warn("ONOS1 flows repsponse: "+ ONOS1_flows)
+                    main.log.warn("ONOS2 flows repsponse: "+ ONOS2_flows)
+                    main.log.warn("ONOS3 flows repsponse: "+ ONOS3_flows)
+                    main.log.warn("ONOS4 flows repsponse: "+ ONOS4_flows)
+                    main.log.warn("ONOS5 flows repsponse: "+ ONOS5_flows)
+                    main.log.warn("ONOS6 flows repsponse: "+ ONOS6_flows)
+                    main.log.warn("ONOS7 flows repsponse: "+ ONOS7_flows)
+        elif len(json.loads(ONOS1_flows)) == len(json.loads(ONOS2_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS3_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS4_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS5_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS6_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS7_flows)):
+                #TODO: Do a better check, maybe compare flows on switches?
+                    flow_state = ONOS1_flows
+                    flow_check = main.TRUE
+                    main.log.report("Flow count is consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 flows: "+ json.dumps(json.loads(ONOS1_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 flows: "+ json.dumps(json.loads(ONOS2_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 flows: "+ json.dumps(json.loads(ONOS3_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 flows: "+ json.dumps(json.loads(ONOS4_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 flows: "+ json.dumps(json.loads(ONOS5_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 flows: "+ json.dumps(json.loads(ONOS6_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 flows: "+ json.dumps(json.loads(ONOS7_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+        utilities.assert_equals(expect = main.TRUE,actual=flow_check,
+                onpass="The flow count is consistent across all ONOS nodes",
+                onfail="ONOS nodes have different flow counts")
+
+
+        main.step("Get the OF Table entries")
+        global flows
+        flows=[]
+        for i in range(1,29):
+            flows.append(main.Mininet2.get_flowTable("s"+str(i),1.0))
+
+        #TODO: Compare switch flow tables with ONOS flow tables
+
+        main.step("Start continuous pings")
+        main.Mininet2.pingLong(src=main.params['PING']['source1'],
+                            target=main.params['PING']['target1'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source2'],
+                            target=main.params['PING']['target2'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source3'],
+                            target=main.params['PING']['target3'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source4'],
+                            target=main.params['PING']['target4'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source5'],
+                            target=main.params['PING']['target5'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source6'],
+                            target=main.params['PING']['target6'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source7'],
+                            target=main.params['PING']['target7'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source8'],
+                            target=main.params['PING']['target8'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source9'],
+                            target=main.params['PING']['target9'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source10'],
+                            target=main.params['PING']['target10'],pingTime=500)
+
+        main.step("Create TestONTopology object")
+        ctrls = []
+        count = 1
+        while True:
+            temp = ()
+            if ('ip' + str(count)) in main.params['CTRL']:
+                temp = temp + (getattr(main,('ONOS' + str(count))),)
+                temp = temp + ("ONOS"+str(count),)
+                temp = temp + (main.params['CTRL']['ip'+str(count)],)
+                temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+                ctrls.append(temp)
+                count = count + 1
+            else:
+                break
+        MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+        main.step("Collecting topology information from ONOS")
+        devices = []
+        devices.append( main.ONOScli1.devices() )
+        devices.append( main.ONOScli2.devices() )
+        devices.append( main.ONOScli3.devices() )
+        devices.append( main.ONOScli4.devices() )
+        devices.append( main.ONOScli5.devices() )
+        devices.append( main.ONOScli6.devices() )
+        devices.append( main.ONOScli7.devices() )
+        '''
+        hosts = []
+        hosts.append( main.ONOScli1.hosts() )
+        hosts.append( main.ONOScli2.hosts() )
+        hosts.append( main.ONOScli3.hosts() )
+        hosts.append( main.ONOScli4.hosts() )
+        hosts.append( main.ONOScli5.hosts() )
+        hosts.append( main.ONOScli6.hosts() )
+        hosts.append( main.ONOScli7.hosts() )
+        '''
+        ports = []
+        ports.append( main.ONOScli1.ports() )
+        ports.append( main.ONOScli2.ports() )
+        ports.append( main.ONOScli3.ports() )
+        ports.append( main.ONOScli4.ports() )
+        ports.append( main.ONOScli5.ports() )
+        ports.append( main.ONOScli6.ports() )
+        ports.append( main.ONOScli7.ports() )
+        links = []
+        links.append( main.ONOScli1.links() )
+        links.append( main.ONOScli2.links() )
+        links.append( main.ONOScli3.links() )
+        links.append( main.ONOScli4.links() )
+        links.append( main.ONOScli5.links() )
+        links.append( main.ONOScli6.links() )
+        links.append( main.ONOScli7.links() )
+
+
+        main.step("Comparing ONOS topology to MN")
+        devices_results = main.TRUE
+        ports_results = main.TRUE
+        links_results = main.TRUE
+        for controller in range(7): #TODO parameterize the number of controllers
+            if devices[controller] or not "Error" in devices[controller]:
+                current_devices_result =  main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+            else:
+                current_devices_result = main.FALSE
+            utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+                    onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+                    onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+            if ports[controller] or not "Error" in ports[controller]:
+                current_ports_result =  main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+            else:
+                current_ports_result = main.FALSE
+            utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+                    onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+                    onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+            if links[controller] or not "Error" in links[controller]:
+                current_links_result =  main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+            else:
+                current_links_result = main.FALSE
+            utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+                    onpass="ONOS"+str(int(controller+1))+" links view is correct",
+                    onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+
+            devices_results = devices_results and current_devices_result
+            ports_results = ports_results and current_ports_result
+            links_results = links_results and current_links_result
+
+        topo_result = devices_results and ports_results and links_results
+        utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+                onpass="Topology Check Test successful",
+                onfail="Topology Check Test NOT successful")
+
+        final_assert = main.TRUE
+        final_assert = final_assert and topo_result and flow_check \
+                and intent_check and consistent_mastership
+        utilities.assert_equals(expect=main.TRUE, actual=final_assert,
+                onpass="State check successful",
+                onfail="State check NOT successful")
+
+
+    def CASE6(self,main) :
+        '''
+        The Failure case.
+        '''
+        main.log.report("Killing 3 ONOS nodes")
+        main.log.case("Restart minority of ONOS nodes")
+        #TODO: Randomize these nodes
+        main.ONOSbench.onos_kill(ONOS1_ip)
+        main.ONOSbench.onos_kill(ONOS2_ip)
+        main.ONOSbench.onos_kill(ONOS3_ip)
+
+        main.step("Checking if ONOS is up yet")
+        count = 0
+        onos_isup_result = main.FALSE
+        while onos_isup_result == main.FALSE and count < 10:
+            onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+            onos2_isup = main.ONOSbench.isup(ONOS2_ip)
+            onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+            onos_isup_result = onos1_isup and onos2_isup and onos3_isup
+            count = count + 1
+        # TODO: if it becomes an issue, we can retry this step  a few times
+
+
+        cli_result1 = main.ONOScli1.start_onos_cli(ONOS1_ip)
+        cli_result2 = main.ONOScli2.start_onos_cli(ONOS2_ip)
+        cli_result3 = main.ONOScli3.start_onos_cli(ONOS3_ip)
+        cli_results = cli_result1 and cli_result2 and cli_result3
+
+        case_results = main.TRUE and onos_isup_result and cli_results
+        utilities.assert_equals(expect=main.TRUE, actual=case_results,
+                onpass="ONOS restart successful",
+                onfail="ONOS restart NOT successful")
+
+
+    def CASE7(self,main) :
+        '''
+        Check state after ONOS failure
+        '''
+        import os
+        import json
+        main.case("Running ONOS Constant State Tests")
+
+        main.step("Check if switch roles are consistent across all nodes")
+        ONOS1_mastership = main.ONOScli1.roles()
+        ONOS2_mastership = main.ONOScli2.roles()
+        ONOS3_mastership = main.ONOScli3.roles()
+        ONOS4_mastership = main.ONOScli4.roles()
+        ONOS5_mastership = main.ONOScli5.roles()
+        ONOS6_mastership = main.ONOScli6.roles()
+        ONOS7_mastership = main.ONOScli7.roles()
+        print type(ONOS1_mastership)
+        print ONOS1_mastership
+        print type(ONOS2_mastership)
+        print ONOS2_mastership
+        print type(ONOS3_mastership)
+        print ONOS3_mastership
+        print type(ONOS4_mastership)
+        print ONOS4_mastership
+        print type(ONOS5_mastership)
+        print ONOS5_mastership
+        print type(ONOS6_mastership)
+        print ONOS6_mastership
+        print type(ONOS7_mastership)
+        print ONOS7_mastership
+        #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+        if "Error" in ONOS1_mastership or not ONOS1_mastership\
+                or "Error" in ONOS2_mastership or not ONOS2_mastership\
+                or "Error" in ONOS3_mastership or not ONOS3_mastership\
+                or "Error" in ONOS4_mastership or not ONOS4_mastership\
+                or "Error" in ONOS5_mastership or not ONOS5_mastership\
+                or "Error" in ONOS6_mastership or not ONOS6_mastership\
+                or "Error" in ONOS7_mastership or not ONOS7_mastership:
+                    main.log.error("Error in getting ONOS mastership")
+                    main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+                    main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership))
+                    main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership))
+                    main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership))
+                    main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership))
+                    main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership))
+                    main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership))
+                    consistent_mastership = main.FALSE
+        elif ONOS1_mastership == ONOS2_mastership\
+                and ONOS1_mastership == ONOS3_mastership\
+                and ONOS1_mastership == ONOS4_mastership\
+                and ONOS1_mastership == ONOS5_mastership\
+                and ONOS1_mastership == ONOS6_mastership\
+                and ONOS1_mastership == ONOS7_mastership:
+                    #mastership_state = ONOS1_mastership
+                    consistent_mastership = main.TRUE
+                    main.log.report("Switch roles are consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            consistent_mastership = main.FALSE
+        utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+                onpass="Switch roles are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of switch roles")
+
+
+        description2 = "Compare switch roles from before failure"
+        main.step(description2)
+
+        current_json = json.loads(ONOS1_mastership)
+        old_json = json.loads(mastership_state)
+        mastership_check = main.TRUE
+        for i in range(1,29):
+            switchDPID = str(main.Mininet1.getSwitchDPID(switch="s"+str(i)))
+
+            current = [switch['master'] for switch in current_json if switchDPID in switch['id']]
+            old = [switch['master'] for switch in old_json if switchDPID in switch['id']]
+            if current == old:
+                mastership_check = mastership_check and main.TRUE
+            else:
+                main.log.warn("Mastership of switch %s changed" % switchDPID)
+                mastership_check = main.FALSE
+        if mastership_check == main.TRUE:
+            main.log.report("Mastership of Switches was not changed")
+        utilities.assert_equals(expect=main.TRUE,actual=mastership_check,
+                onpass="Mastership of Switches was not changed",
+                onfail="Mastership of some switches changed")
+        #NOTE: we expect mastership to change on controller failure
+        mastership_check = mastership_check #and consistent_mastership
+
+
+
+        main.step("Get the intents and compare across all nodes")
+        ONOS1_intents = main.ONOScli1.intents( json_format=True )
+        ONOS2_intents = main.ONOScli2.intents( json_format=True )
+        ONOS3_intents = main.ONOScli3.intents( json_format=True )
+        ONOS4_intents = main.ONOScli4.intents( json_format=True )
+        ONOS5_intents = main.ONOScli5.intents( json_format=True )
+        ONOS6_intents = main.ONOScli6.intents( json_format=True )
+        ONOS7_intents = main.ONOScli7.intents( json_format=True )
+        intent_check = main.FALSE
+        if "Error" in ONOS1_intents or not ONOS1_intents\
+                or "Error" in ONOS2_intents or not ONOS2_intents\
+                or "Error" in ONOS3_intents or not ONOS3_intents\
+                or "Error" in ONOS4_intents or not ONOS4_intents\
+                or "Error" in ONOS5_intents or not ONOS5_intents\
+                or "Error" in ONOS6_intents or not ONOS6_intents\
+                or "Error" in ONOS7_intents or not ONOS7_intents:
+                    main.log.report("Error in getting ONOS intents")
+                    main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+                    main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents))
+                    main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents))
+                    main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents))
+                    main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents))
+                    main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents))
+                    main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents))
+        elif ONOS1_intents == ONOS2_intents\
+                and ONOS1_intents == ONOS3_intents\
+                and ONOS1_intents == ONOS4_intents\
+                and ONOS1_intents == ONOS5_intents\
+                and ONOS1_intents == ONOS6_intents\
+                and ONOS1_intents == ONOS7_intents:
+                    intent_check = main.TRUE
+                    main.log.report("Intents are consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 intents: ", json.dumps(json.loads(ONOS1_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 intents: ", json.dumps(json.loads(ONOS2_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 intents: ", json.dumps(json.loads(ONOS3_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 intents: ", json.dumps(json.loads(ONOS4_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 intents: ", json.dumps(json.loads(ONOS5_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 intents: ", json.dumps(json.loads(ONOS6_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 intents: ", json.dumps(json.loads(ONOS7_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+        utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+                onpass="Intents are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of intents")
+
+        main.step("Compare current intents with intents before the failure")
+        if intent_state == ONOS1_intents:
+            same_intents = main.TRUE
+            main.log.report("Intents are consistent with before failure")
+        #TODO: possibly the states have changed? we may need to figure out what the aceptable states are
+        else:
+            same_intents = main.FALSE
+        utilities.assert_equals(expect = main.TRUE,actual=same_intents,
+                onpass="Intents are consistent with before failure",
+                onfail="The Intents changed during failure")
+        intent_check = intent_check and same_intents
+
+
+
+        main.step("Get the OF Table entries and compare to before component failure")
+        Flow_Tables = main.TRUE
+        flows2=[]
+        for i in range(28):
+            main.log.info("Checking flow table on s" + str(i+1))
+            tmp_flows = main.Mininet2.get_flowTable("s"+str(i+1),1.0)
+            flows2.append(tmp_flows)
+            Flow_Tables = Flow_Tables and main.Mininet2.flow_comp(flow1=flows[i],flow2=tmp_flows)
+            if Flow_Tables == main.FALSE:
+                main.log.info("Differences in flow table for switch: "+str(i+1))
+                break
+        if Flow_Tables == main.TRUE:
+            main.log.report("No changes were found in the flow tables")
+        utilities.assert_equals(expect=main.TRUE,actual=Flow_Tables,
+                onpass="No changes were found in the flow tables",
+                onfail="Changes were found in the flow tables")
+
+        main.step("Check the continuous pings to ensure that no packets were dropped during component failure")
+        #FIXME: This check is always failing. Investigate cause
+        #NOTE:  this may be something to do with file permsissions
+        #       or slight change in format
+        main.Mininet2.pingKill(main.params['TESTONUSER'], main.params['TESTONIP'])
+        Loss_In_Pings = main.FALSE 
+        #NOTE: checkForLoss returns main.FALSE with 0% packet loss
+        for i in range(8,18):
+            main.log.info("Checking for a loss in pings along flow from s" + str(i))
+            Loss_In_Pings = Loss_In_Pings or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i))
+        if Loss_In_Pings == main.TRUE:
+            main.log.info("Loss in ping detected")
+        elif Loss_In_Pings == main.ERROR:
+            main.log.info("There are multiple mininet process running")
+        elif Loss_In_Pings == main.FALSE:
+            main.log.info("No Loss in the pings")
+            main.log.report("No loss of dataplane connectivity")
+        utilities.assert_equals(expect=main.FALSE,actual=Loss_In_Pings,
+                onpass="No Loss of connectivity",
+                onfail="Loss of dataplane connectivity detected")
+
+
+        #TODO:add topology to this or leave as a seperate case?
+        result = mastership_check and intent_check and Flow_Tables and (not Loss_In_Pings)
+        result = int(result)
+        if result == main.TRUE:
+            main.log.report("Constant State Tests Passed")
+        utilities.assert_equals(expect=main.TRUE,actual=result,
+                onpass="Constant State Tests Passed",
+                onfail="Constant state tests failed")
+
+    def CASE8 (self,main):
+        '''
+        Compare topo
+        '''
+        import sys
+        sys.path.append("/home/admin/sts") # Trying to remove some dependancies, #FIXME add this path to params
+        from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+        import json
+        import time
+
+        description ="Compare ONOS Topology view to Mininet topology"
+        main.case(description)
+        main.log.report(description)
+        main.step("Create TestONTopology object")
+        ctrls = []
+        count = 1
+        while True:
+            temp = ()
+            if ('ip' + str(count)) in main.params['CTRL']:
+                temp = temp + (getattr(main,('ONOS' + str(count))),)
+                temp = temp + ("ONOS"+str(count),)
+                temp = temp + (main.params['CTRL']['ip'+str(count)],)
+                temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+                ctrls.append(temp)
+                count = count + 1
+            else:
+                break
+        MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+        main.step("Comparing ONOS topology to MN")
+        devices_results = main.TRUE
+        ports_results = main.TRUE
+        links_results = main.TRUE
+        topo_result = main.FALSE
+        start_time = time.time()
+        elapsed = 0
+        count = 0
+        while topo_result == main.FALSE and elapsed < 120:
+            count = count + 1
+            try:
+                main.step("Collecting topology information from ONOS")
+                devices = []
+                devices.append( main.ONOScli1.devices() )
+                devices.append( main.ONOScli2.devices() )
+                devices.append( main.ONOScli3.devices() )
+                devices.append( main.ONOScli4.devices() )
+                devices.append( main.ONOScli5.devices() )
+                devices.append( main.ONOScli6.devices() )
+                devices.append( main.ONOScli7.devices() )
+                '''
+                hosts = []
+                hosts.append( main.ONOScli1.hosts() )
+                hosts.append( main.ONOScli2.hosts() )
+                hosts.append( main.ONOScli3.hosts() )
+                hosts.append( main.ONOScli4.hosts() )
+                hosts.append( main.ONOScli5.hosts() )
+                hosts.append( main.ONOScli6.hosts() )
+                hosts.append( main.ONOScli7.hosts() )
+                '''
+                ports = []
+                ports.append( main.ONOScli1.ports() )
+                ports.append( main.ONOScli2.ports() )
+                ports.append( main.ONOScli3.ports() )
+                ports.append( main.ONOScli4.ports() )
+                ports.append( main.ONOScli5.ports() )
+                ports.append( main.ONOScli6.ports() )
+                ports.append( main.ONOScli7.ports() )
+                links = []
+                links.append( main.ONOScli1.links() )
+                links.append( main.ONOScli2.links() )
+                links.append( main.ONOScli3.links() )
+                links.append( main.ONOScli4.links() )
+                links.append( main.ONOScli5.links() )
+                links.append( main.ONOScli6.links() )
+                links.append( main.ONOScli7.links() )
+
+                for controller in range(7): #TODO parameterize the number of controllers
+                    if devices[controller] or not "Error" in devices[controller]:
+                        current_devices_result =  main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+                    else:
+                        current_devices_result = main.FALSE
+                    utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+                            onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+                            onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+                    if ports[controller] or not "Error" in ports[controller]:
+                        current_ports_result =  main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+                    else:
+                        current_ports_result = main.FALSE
+                    utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+                            onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+                            onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+                    if links[controller] or not "Error" in links[controller]:
+                        current_links_result =  main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+                    else:
+                        current_links_result = main.FALSE
+                    utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+                            onpass="ONOS"+str(int(controller+1))+" links view is correct",
+                            onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+            except:
+                main.log.error("something went wrong in topo comparison")
+                main.log.warn( repr( devices ) )
+                main.log.warn( repr( ports ) )
+                main.log.warn( repr( links ) )
+
+            devices_results = devices_results and current_devices_result
+            ports_results = ports_results and current_ports_result
+            links_results = links_results and current_links_result
+            topo_result = devices_results and ports_results and links_results
+            elapsed = time.time() - start_time
+        time_threshold = elapsed < 1
+        topo_result = topo_result and time_threshold
+        #TODO make sure this step is non-blocking. IE add a timeout
+        main.log.report("Very crass estimate for topology discovery/convergence: " +\
+                str(elapsed) + " seconds, " + str(count) +" tries" )
+        utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+                onpass="Topology Check Test successful",
+                onfail="Topology Check Test NOT successful")
+        if topo_result == main.TRUE:
+            main.log.report("ONOS topology view matches Mininet topology")
+
+
+    def CASE9 (self,main):
+        '''
+        Link s3-s28 down
+        '''
+        #NOTE: You should probably run a topology check after this
+
+        link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+        description = "Turn off a link to ensure that Link Discovery is working properly"
+        main.log.report(description)
+        main.case(description)
+
+
+        main.step("Kill Link between s3 and s28")
+        Link_Down = main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
+        main.log.info("Waiting " + str(link_sleep) + " seconds for link down to be discovered")
+        time.sleep(link_sleep)
+        utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
+                onpass="Link down succesful",
+                onfail="Failed to bring link down")
+        #TODO do some sort of check here
+
+    def CASE10 (self,main):
+        '''
+        Link s3-s28 up
+        '''
+        #NOTE: You should probably run a topology check after this
+
+        link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+        description = "Restore a link to ensure that Link Discovery is working properly"
+        main.log.report(description)
+        main.case(description)
+
+        main.step("Bring link between s3 and s28 back up")
+        Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
+        main.log.info("Waiting " + str(link_sleep) + " seconds for link up to be discovered")
+        time.sleep(link_sleep)
+        utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
+                onpass="Link up succesful",
+                onfail="Failed to bring link up")
+        #TODO do some sort of check here
+
+
+    def CASE11 (self, main) :
+        '''
+        Switch Down
+        '''
+        #NOTE: You should probably run a topology check after this
+        import time
+
+        switch_sleep = int(main.params['timers']['SwitchDiscovery'])
+
+        description = "Killing a switch to ensure it is discovered correctly"
+        main.log.report(description)
+        main.case(description)
+
+        #TODO: Make this switch parameterizable
+        main.step("Kill s28 ")
+        main.log.report("Deleting s28")
+        #FIXME: use new dynamic topo functions
+        main.Mininet1.del_switch("s28")
+        main.log.info("Waiting " + str(switch_sleep) + " seconds for switch down to be discovered")
+        time.sleep(switch_sleep)
+        #Peek at the deleted switch
+        main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+        #TODO do some sort of check here
+
+    def CASE12 (self, main) :
+        '''
+        Switch Up
+        '''
+        #NOTE: You should probably run a topology check after this
+        import time
+        #FIXME: use new dynamic topo functions
+        description = "Adding a switch to ensure it is discovered correctly"
+        main.log.report(description)
+        main.case(description)
+
+        main.step("Add back s28")
+        main.log.report("Adding back s28")
+        main.Mininet1.add_switch("s28", dpid = '0000000000002800')
+        #TODO: New dpid or same? Ask Thomas?
+        main.Mininet1.add_link('s28', 's3')
+        main.Mininet1.add_link('s28', 's6')
+        main.Mininet1.add_link('s28', 'h28')
+        main.Mininet1.assign_sw_controller(sw="28",count=7,
+                ip1=ONOS1_ip,port1=ONOS1_port,
+                ip2=ONOS2_ip,port2=ONOS2_port,
+                ip3=ONOS3_ip,port3=ONOS3_port,
+                ip4=ONOS4_ip,port4=ONOS4_port,
+                ip5=ONOS5_ip,port5=ONOS5_port,
+                ip6=ONOS6_ip,port6=ONOS6_port,
+                ip7=ONOS7_ip,port7=ONOS7_port)
+        main.log.info("Waiting " + str(switch_sleep) + " seconds for switch up to be discovered")
+        time.sleep(switch_sleep)
+        #Peek at the added switch
+        main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+        #TODO do some sort of check here
+
+    def CASE13 (self, main) :
+        '''
+        Clean up
+        '''
+        import os
+        import time
+        description = "Test Cleanup"
+        main.log.report(description)
+        main.case(description)
+        main.step("Killing tcpdumps")
+        main.Mininet2.stop_tcpdump()
+
+        main.step("Copying MN pcap and ONOS log files to test station")
+        testname = main.TEST
+        #NOTE: MN Pcap file is being saved to ~/packet_captures
+        #       scp this file as MN and TestON aren't necessarily the same vm
+        #FIXME: scp
+        #####mn files
+        #TODO: Load these from params
+        #NOTE: must end in /
+        log_folder = "/opt/onos/log/"
+        log_files = ["karaf.log", "karaf.log.1"]
+        #NOTE: must end in /
+        dst_dir = "~/packet_captures/"
+        for f in log_files:
+            main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS1-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS2_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS2-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS3_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS3-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS4_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS4-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS5_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS5-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS6_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS6-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS7_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS7-"+f )
+
+        #std*.log's
+        #NOTE: must end in /
+        log_folder = "/opt/onos/var/"
+        log_files = ["stderr.log", "stdout.log"]
+        #NOTE: must end in /
+        dst_dir = "~/packet_captures/"
+        for f in log_files:
+            main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS1-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS2_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS2-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS3_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS3-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS4_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS4-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS5_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS5-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS6_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS6-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS7_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS7-"+f )
+
+
+
+
+        #sleep so scp can finish
+        time.sleep(10)
+        main.step("Packing and rotating pcap archives")
+        os.system("~/TestON/dependencies/rotate.sh "+ str(testname))
+
+
+        #TODO: actually check something here
+        utilities.assert_equals(expect=main.TRUE, actual=main.TRUE,
+                onpass="Test cleanup successful",
+                onfail="Test cleanup NOT successful")
diff --git a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.topo b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.topo
new file mode 100644
index 0000000..4d4156c
--- /dev/null
+++ b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.topo
@@ -0,0 +1,173 @@
+<TOPOLOGY>
+    <COMPONENT>
+
+        <ONOSbench>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosDriver</type>
+            <connect_order>1</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOSbench>
+
+        <ONOScli1>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli1>
+
+        <ONOScli2>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>3</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli2>
+
+        <ONOScli3>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>4</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli3>
+
+
+        <ONOScli4>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>5</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli4>
+
+
+        <ONOScli5>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>6</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli5>
+
+
+        <ONOScli6>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>7</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli6>
+
+
+        <ONOScli7>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>8</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli7>
+
+        <ONOS1>
+            <host>10.128.30.11</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>9</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS1>
+
+        <ONOS2>
+            <host>10.128.30.12</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>10</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS2>
+
+        <ONOS3>
+            <host>10.128.30.13</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>11</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS3>
+
+        <ONOS4>
+            <host>10.128.30.14</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>12</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS4>
+
+        <ONOS5>
+            <host>10.128.30.15</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>13</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS5>
+
+        <ONOS6>
+            <host>10.128.30.16</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>14</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS6>
+
+        <ONOS7>
+            <host>10.128.30.17</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>15</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS7>
+
+        <Mininet1>
+            <host>10.128.30.9</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>MininetCliDriver</type>
+            <connect_order>16</connect_order>
+            <COMPONENTS>
+                #Specify the Option for mininet
+                <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+                <arg2> --topo mytopo </arg2>
+                <arg3> </arg3>
+                <controller> remote </controller>
+            </COMPONENTS>
+        </Mininet1>
+
+        <Mininet2>
+            <host>10.128.30.9</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>RemoteMininetDriver</type>
+            <connect_order>17</connect_order>
+            <COMPONENTS>
+                # Specify the Option for mininet
+                <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+                <arg2> --topo mytopo --arp</arg2>
+                <controller> remote </controller>
+             </COMPONENTS>
+        </Mininet2>
+
+    </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/HATestMinorityRestart/__init__.py b/TestON/tests/HATestMinorityRestart/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/HATestMinorityRestart/__init__.py
diff --git a/TestON/tests/HATestSanity/HATestSanity.params b/TestON/tests/HATestSanity/HATestSanity.params
new file mode 100644
index 0000000..e1e75f9
--- /dev/null
+++ b/TestON/tests/HATestSanity/HATestSanity.params
@@ -0,0 +1,63 @@
+<PARAMS>
+    <testcases>1,2,8,3,4,5,[6],7,8,4,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+    <ENV>
+    <cellName>HA</cellName>
+    </ENV>
+    <Git>True</Git>
+
+    <CTRL>
+        <ip1>10.128.30.11</ip1>
+        <port1>6633</port1>
+
+        <ip2>10.128.30.12</ip2>
+        <port2>6633</port2>
+
+        <ip3>10.128.30.13</ip3>
+        <port3>6633</port3>
+
+        <ip4>10.128.30.14</ip4>
+        <port4>6633</port4>
+
+        <ip5>10.128.30.15</ip5>
+        <port5>6633</port5>
+
+        <ip6>10.128.30.16</ip6>
+        <port6>6633</port6>
+
+        <ip7>10.128.30.17</ip7>
+        <port7>6633</port7>
+    </CTRL>
+    <TESTONUSER>admin</TESTONUSER>
+    <TESTONIP>10.128.30.10</TESTONIP>
+    <PING>
+        <source1>h8</source1>
+        <source2>h9</source2>
+        <source3>h10</source3>
+        <source4>h11</source4>
+        <source5>h12</source5>
+        <source6>h13</source6>
+        <source7>h14</source7>
+        <source8>h15</source8>
+        <source9>h16</source9>
+        <source10>h17</source10>
+        <target1>10.0.0.18</target1>
+        <target2>10.0.0.19</target2>
+        <target3>10.0.0.20</target3>
+        <target4>10.0.0.21</target4>
+        <target5>10.0.0.22</target5>
+        <target6>10.0.0.23</target6>
+        <target7>10.0.0.24</target7>
+        <target8>10.0.0.25</target8>
+        <target9>10.0.0.26</target9>
+        <target10>10.0.0.27</target10>
+    </PING>
+    <timers>
+        <LinkDiscovery>2</LinkDiscovery>
+        <SwitchDiscovery>2</SwitchDiscovery>
+    </timers>
+    <MNtcpdump>
+        <intf>eth0</intf>
+        <port> </port>
+        <folder>~/packet_captures/</folder>
+    </MNtcpdump>
+</PARAMS>
diff --git a/TestON/tests/HATestSanity/HATestSanity.py b/TestON/tests/HATestSanity/HATestSanity.py
new file mode 100644
index 0000000..614d514
--- /dev/null
+++ b/TestON/tests/HATestSanity/HATestSanity.py
@@ -0,0 +1,1171 @@
+'''
+Description: This test is to determine if the HA test setup is
+    working correctly. There are no failures so this test should
+    have a 100% pass rate
+
+List of test cases:
+CASE1: Compile ONOS and push it to the test machines
+CASE2: Assign mastership to controllers
+CASE3: Assign intents
+CASE4: Ping across added host intents
+CASE5: Reading state of ONOS
+CASE6: The Failure case. Since this is the Sanity test, we do nothing.
+CASE7: Check state after control plane failure
+CASE8: Compare topo
+CASE9: Link s3-s28 down
+CASE10: Link s3-s28 up
+CASE11: Switch down
+CASE12: Switch up
+CASE13: Clean up
+'''
+class HATestSanity:
+
+    def __init__(self) :
+        self.default = ''
+
+    def CASE1(self,main) :
+        '''
+        CASE1 is to compile ONOS and push it to the test machines
+
+        Startup sequence:
+        git pull
+        mvn clean install
+        onos-package
+        cell <name>
+        onos-verify-cell
+        NOTE: temporary - onos-remove-raft-logs
+        onos-install -f
+        onos-wait-for-start
+        '''
+        import time
+        main.log.report("ONOS HA Sanity test - initialization")
+        main.case("Setting up test environment")
+        #TODO: save all the timers and output them for plotting
+
+        # load some vairables from the params file
+        PULL_CODE = False
+        if main.params['Git'] == 'True':
+            PULL_CODE = True
+        cell_name = main.params['ENV']['cellName']
+
+        #set global variables
+        global ONOS1_ip
+        global ONOS1_port
+        global ONOS2_ip
+        global ONOS2_port
+        global ONOS3_ip
+        global ONOS3_port
+        global ONOS4_ip
+        global ONOS4_port
+        global ONOS5_ip
+        global ONOS5_port
+        global ONOS6_ip
+        global ONOS6_port
+        global ONOS7_ip
+        global ONOS7_port
+
+        ONOS1_ip = main.params['CTRL']['ip1']
+        ONOS1_port = main.params['CTRL']['port1']
+        ONOS2_ip = main.params['CTRL']['ip2']
+        ONOS2_port = main.params['CTRL']['port2']
+        ONOS3_ip = main.params['CTRL']['ip3']
+        ONOS3_port = main.params['CTRL']['port3']
+        ONOS4_ip = main.params['CTRL']['ip4']
+        ONOS4_port = main.params['CTRL']['port4']
+        ONOS5_ip = main.params['CTRL']['ip5']
+        ONOS5_port = main.params['CTRL']['port5']
+        ONOS6_ip = main.params['CTRL']['ip6']
+        ONOS6_port = main.params['CTRL']['port6']
+        ONOS7_ip = main.params['CTRL']['ip7']
+        ONOS7_port = main.params['CTRL']['port7']
+
+
+        main.step("Applying cell variable to environment")
+        cell_result = main.ONOSbench.set_cell(cell_name)
+        verify_result = main.ONOSbench.verify_cell()
+
+        #FIXME:this is short term fix
+        main.log.report("Removing raft logs")
+        main.ONOSbench.onos_remove_raft_logs()
+        main.log.report("Uninstalling ONOS")
+        main.ONOSbench.onos_uninstall(ONOS1_ip)
+        main.ONOSbench.onos_uninstall(ONOS2_ip)
+        main.ONOSbench.onos_uninstall(ONOS3_ip)
+        main.ONOSbench.onos_uninstall(ONOS4_ip)
+        main.ONOSbench.onos_uninstall(ONOS5_ip)
+        main.ONOSbench.onos_uninstall(ONOS6_ip)
+        main.ONOSbench.onos_uninstall(ONOS7_ip)
+
+        clean_install_result = main.TRUE
+        git_pull_result = main.TRUE
+
+        main.step("Compiling the latest version of ONOS")
+        if PULL_CODE:
+            main.step("Git checkout and pull master")
+            main.ONOSbench.git_checkout("master")
+            git_pull_result = main.ONOSbench.git_pull()
+
+            main.step("Using mvn clean & install")
+            clean_install_result = main.TRUE
+            if git_pull_result == main.TRUE:
+                clean_install_result = main.ONOSbench.clean_install()
+            else:
+                main.log.warn("Did not pull new code so skipping mvn "+ \
+                        "clean install")
+        main.ONOSbench.get_version(report=True)
+
+        main.step("Creating ONOS package")
+        package_result = main.ONOSbench.onos_package()
+
+        main.step("Installing ONOS package")
+        onos1_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS1_ip)
+        onos2_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS2_ip)
+        onos3_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS3_ip)
+        onos4_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS4_ip)
+        onos5_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS5_ip)
+        onos6_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS6_ip)
+        onos7_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS7_ip)
+        onos_install_result = onos1_install_result and onos2_install_result\
+                and onos3_install_result and onos4_install_result\
+                and onos5_install_result and onos6_install_result\
+                and onos7_install_result
+        '''
+        #FIXME: work around until onos is less fragile
+        main.ONOSbench.handle.sendline("onos-cluster-install")
+        print main.ONOSbench.handle.expect("\$")
+        onos_install_result = main.TRUE
+        '''
+
+
+        main.step("Checking if ONOS is up yet")
+        #TODO: Refactor
+        # check bundle:list?
+        for i in range(2):
+            onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+            if not onos1_isup:
+                main.log.report("ONOS1 didn't start!")
+            onos2_isup = main.ONOSbench.isup(ONOS2_ip)
+            if not onos2_isup:
+                main.log.report("ONOS2 didn't start!")
+            onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+            if not onos3_isup:
+                main.log.report("ONOS3 didn't start!")
+            onos4_isup = main.ONOSbench.isup(ONOS4_ip)
+            if not onos4_isup:
+                main.log.report("ONOS4 didn't start!")
+            onos5_isup = main.ONOSbench.isup(ONOS5_ip)
+            if not onos5_isup:
+                main.log.report("ONOS5 didn't start!")
+            onos6_isup = main.ONOSbench.isup(ONOS6_ip)
+            if not onos6_isup:
+                main.log.report("ONOS6 didn't start!")
+            onos7_isup = main.ONOSbench.isup(ONOS7_ip)
+            if not onos7_isup:
+                main.log.report("ONOS7 didn't start!")
+            onos_isup_result = onos1_isup and onos2_isup and onos3_isup\
+                    and onos4_isup and onos5_isup and onos6_isup and onos7_isup
+            if onos_isup_result == main.TRUE:
+                break
+        # TODO: if it becomes an issue, we can retry this step  a few times
+
+
+        cli_result1 = main.ONOScli1.start_onos_cli(ONOS1_ip)
+        cli_result2 = main.ONOScli2.start_onos_cli(ONOS2_ip)
+        cli_result3 = main.ONOScli3.start_onos_cli(ONOS3_ip)
+        cli_result4 = main.ONOScli4.start_onos_cli(ONOS4_ip)
+        cli_result5 = main.ONOScli5.start_onos_cli(ONOS5_ip)
+        cli_result6 = main.ONOScli6.start_onos_cli(ONOS6_ip)
+        cli_result7 = main.ONOScli7.start_onos_cli(ONOS7_ip)
+        cli_results = cli_result1 and cli_result2 and cli_result3 and\
+                cli_result4 and cli_result5 and cli_result6 and cli_result7
+
+        main.step("Start Packet Capture MN")
+        main.Mininet2.start_tcpdump(
+                str(main.params['MNtcpdump']['folder'])+str(main.TEST)+"-MN.pcap",
+                intf = main.params['MNtcpdump']['intf'],
+                port = main.params['MNtcpdump']['port'])
+
+
+        case1_result = (clean_install_result and package_result and
+                cell_result and verify_result and onos_install_result and
+                onos_isup_result and cli_results)
+
+        utilities.assert_equals(expect=main.TRUE, actual=case1_result,
+                onpass="Test startup successful",
+                onfail="Test startup NOT successful")
+
+
+        if case1_result==main.FALSE:
+            main.cleanup()
+            main.exit()
+
+    def CASE2(self,main) :
+        '''
+        Assign mastership to controllers
+        '''
+        import time
+        import json
+        import re
+
+
+        '''
+        ONOS1_ip = main.params['CTRL']['ip1']
+        ONOS1_port = main.params['CTRL']['port1']
+        ONOS2_ip = main.params['CTRL']['ip2']
+        ONOS2_port = main.params['CTRL']['port2']
+        ONOS3_ip = main.params['CTRL']['ip3']
+        ONOS3_port = main.params['CTRL']['port3']
+        ONOS4_ip = main.params['CTRL']['ip4']
+        ONOS4_port = main.params['CTRL']['port4']
+        ONOS5_ip = main.params['CTRL']['ip5']
+        ONOS5_port = main.params['CTRL']['port5']
+        ONOS6_ip = main.params['CTRL']['ip6']
+        ONOS6_port = main.params['CTRL']['port6']
+        ONOS7_ip = main.params['CTRL']['ip7']
+        ONOS7_port = main.params['CTRL']['port7']
+        '''
+
+
+        main.log.report("Assigning switches to controllers")
+        main.case("Assigning Controllers")
+        main.step("Assign switches to controllers")
+
+        for i in range (1,29):
+           main.Mininet1.assign_sw_controller(sw=str(i),count=7,
+                    ip1=ONOS1_ip,port1=ONOS1_port,
+                    ip2=ONOS2_ip,port2=ONOS2_port,
+                    ip3=ONOS3_ip,port3=ONOS3_port,
+                    ip4=ONOS4_ip,port4=ONOS4_port,
+                    ip5=ONOS5_ip,port5=ONOS5_port,
+                    ip6=ONOS6_ip,port6=ONOS6_port,
+                    ip7=ONOS7_ip,port7=ONOS7_port)
+
+        mastership_check = main.TRUE
+        for i in range (1,29):
+            response = main.Mininet1.get_sw_controller("s"+str(i))
+            try:
+                main.log.info(str(response))
+            except:
+                main.log.info(repr(response))
+            if re.search("tcp:"+ONOS1_ip,response)\
+                    and re.search("tcp:"+ONOS2_ip,response)\
+                    and re.search("tcp:"+ONOS3_ip,response)\
+                    and re.search("tcp:"+ONOS4_ip,response)\
+                    and re.search("tcp:"+ONOS5_ip,response)\
+                    and re.search("tcp:"+ONOS6_ip,response)\
+                    and re.search("tcp:"+ONOS7_ip,response):
+                mastership_check = mastership_check and main.TRUE
+            else:
+                mastership_check = main.FALSE
+        if mastership_check == main.TRUE:
+            main.log.report("Switch mastership assigned correctly")
+        utilities.assert_equals(expect = main.TRUE,actual=mastership_check,
+                onpass="Switch mastership assigned correctly",
+                onfail="Switches not assigned correctly to controllers")
+
+        #TODO: If assign roles is working reliably then manually 
+        #   assign mastership to the controller we want
+
+
+    def CASE3(self,main) :
+        """
+        Assign intents
+
+        """
+        import time
+        import json
+        import re
+        main.log.report("Adding host intents")
+        main.case("Adding host Intents")
+
+        main.step("Discovering  Hosts( Via pingall for now)")
+        #FIXME: Once we have a host discovery mechanism, use that instead
+
+        #REACTIVE FWD test
+        ping_result = main.FALSE
+        time1 = time.time()
+        ping_result = main.Mininet1.pingall()
+        time2 = time.time()
+        main.log.info("Time for pingall: %2f seconds" % (time2 - time1))
+
+        #uninstall onos-app-fwd
+        main.log.info("Uninstall reactive forwarding app")
+        main.ONOScli1.feature_uninstall("onos-app-fwd")
+        main.ONOScli2.feature_uninstall("onos-app-fwd")
+        main.ONOScli3.feature_uninstall("onos-app-fwd")
+        main.ONOScli4.feature_uninstall("onos-app-fwd")
+        main.ONOScli5.feature_uninstall("onos-app-fwd")
+        main.ONOScli6.feature_uninstall("onos-app-fwd")
+        main.ONOScli7.feature_uninstall("onos-app-fwd")
+
+        main.step("Add  host intents")
+        #TODO:  move the host numbers to params
+        import json
+        intents_json= json.loads(main.ONOScli1.hosts())
+        intent_add_result = main.FALSE
+        for i in range(8,18):
+            main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+            #NOTE: get host can return None
+            #TODO: handle this
+            host1_id = main.ONOScli1.get_host(host1)['id']
+            host2_id = main.ONOScli1.get_host(host2)['id']
+            tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
+            intent_add_result = intent_add_result and tmp_result
+        #TODO Check if intents all exist in datastore
+        #NOTE: Do we need to print this once the test is working?
+        #main.log.info(json.dumps(json.loads(main.ONOScli1.intents(json_format=True)),
+        #    sort_keys=True, indent=4, separators=(',', ': ') ) )
+
+    def CASE4(self,main) :
+        """
+        Ping across added host intents
+        """
+        description = " Ping across added host intents"
+        main.log.report(description)
+        main.case(description)
+        Ping_Result = main.TRUE
+        for i in range(8,18):
+            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+            Ping_Result = Ping_Result and ping
+            if ping==main.FALSE:
+                main.log.warn("Ping failed between h"+str(i)+" and h" + str(i+10))
+            elif ping==main.TRUE:
+                main.log.info("Ping test passed!")
+                Ping_Result = main.TRUE
+        if Ping_Result==main.FALSE:
+            main.log.report("Intents have not been installed correctly, pings failed.")
+        if Ping_Result==main.TRUE:
+            main.log.report("Intents have been installed correctly and verified by pings")
+        utilities.assert_equals(expect = main.TRUE,actual=Ping_Result,
+                onpass="Intents have been installed correctly and pings work",
+                onfail ="Intents have not been installed correctly, pings failed." )
+
+    def CASE5(self,main) :
+        '''
+        Reading state of ONOS
+        '''
+        import time
+        import json
+        from subprocess import Popen, PIPE
+        from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+
+        main.log.report("Setting up and gathering data for current state")
+        main.case("Setting up and gathering data for current state")
+        #The general idea for this test case is to pull the state of (intents,flows, topology,...) from each ONOS node
+        #We can then compare them with eachother and also with past states
+
+        main.step("Get the Mastership of each switch from each controller")
+        global mastership_state
+        ONOS1_mastership = main.ONOScli1.roles()
+        ONOS2_mastership = main.ONOScli2.roles()
+        ONOS3_mastership = main.ONOScli3.roles()
+        ONOS4_mastership = main.ONOScli4.roles()
+        ONOS5_mastership = main.ONOScli5.roles()
+        ONOS6_mastership = main.ONOScli6.roles()
+        ONOS7_mastership = main.ONOScli7.roles()
+        #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+        if "Error" in ONOS1_mastership or not ONOS1_mastership\
+                or "Error" in ONOS2_mastership or not ONOS2_mastership\
+                or "Error" in ONOS3_mastership or not ONOS3_mastership\
+                or "Error" in ONOS4_mastership or not ONOS4_mastership\
+                or "Error" in ONOS5_mastership or not ONOS5_mastership\
+                or "Error" in ONOS6_mastership or not ONOS6_mastership\
+                or "Error" in ONOS7_mastership or not ONOS7_mastership:
+                    main.log.report("Error in getting ONOS roles")
+                    main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+                    main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership))
+                    main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership))
+                    main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership))
+                    main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership))
+                    main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership))
+                    main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership))
+                    consistent_mastership = main.FALSE
+        elif ONOS1_mastership == ONOS2_mastership\
+                and ONOS1_mastership == ONOS3_mastership\
+                and ONOS1_mastership == ONOS4_mastership\
+                and ONOS1_mastership == ONOS5_mastership\
+                and ONOS1_mastership == ONOS6_mastership\
+                and ONOS1_mastership == ONOS7_mastership:
+                    mastership_state = ONOS1_mastership
+                    consistent_mastership = main.TRUE
+                    main.log.report("Switch roles are consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            consistent_mastership = main.FALSE
+        utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+                onpass="Switch roles are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of switch roles")
+
+
+        main.step("Get the intents from each controller")
+        global intent_state
+        ONOS1_intents = main.ONOScli1.intents( json_format=True )
+        ONOS2_intents = main.ONOScli2.intents( json_format=True )
+        ONOS3_intents = main.ONOScli3.intents( json_format=True )
+        ONOS4_intents = main.ONOScli4.intents( json_format=True )
+        ONOS5_intents = main.ONOScli5.intents( json_format=True )
+        ONOS6_intents = main.ONOScli6.intents( json_format=True )
+        ONOS7_intents = main.ONOScli7.intents( json_format=True )
+        intent_check = main.FALSE
+        if "Error" in ONOS1_intents or not ONOS1_intents\
+                or "Error" in ONOS2_intents or not ONOS2_intents\
+                or "Error" in ONOS3_intents or not ONOS3_intents\
+                or "Error" in ONOS4_intents or not ONOS4_intents\
+                or "Error" in ONOS5_intents or not ONOS5_intents\
+                or "Error" in ONOS6_intents or not ONOS6_intents\
+                or "Error" in ONOS7_intents or not ONOS7_intents:
+                    main.log.report("Error in getting ONOS intents")
+                    main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+                    main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents))
+                    main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents))
+                    main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents))
+                    main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents))
+                    main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents))
+                    main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents))
+        elif ONOS1_intents == ONOS2_intents\
+                and ONOS1_intents == ONOS3_intents\
+                and ONOS1_intents == ONOS4_intents\
+                and ONOS1_intents == ONOS5_intents\
+                and ONOS1_intents == ONOS6_intents\
+                and ONOS1_intents == ONOS7_intents:
+                    intent_state = ONOS1_intents
+                    intent_check = main.TRUE
+                    main.log.report("Intents are consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 intents: ", json.dumps(json.loads(ONOS1_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 intents: ", json.dumps(json.loads(ONOS2_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 intents: ", json.dumps(json.loads(ONOS3_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 intents: ", json.dumps(json.loads(ONOS4_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 intents: ", json.dumps(json.loads(ONOS5_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 intents: ", json.dumps(json.loads(ONOS6_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 intents: ", json.dumps(json.loads(ONOS7_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+        utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+                onpass="Intents are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of intents")
+
+
+        main.step("Get the flows from each controller")
+        global flow_state
+        ONOS1_flows = main.ONOScli1.flows( json_format=True )
+        ONOS2_flows = main.ONOScli2.flows( json_format=True )
+        ONOS3_flows = main.ONOScli3.flows( json_format=True )
+        ONOS4_flows = main.ONOScli4.flows( json_format=True )
+        ONOS5_flows = main.ONOScli5.flows( json_format=True )
+        ONOS6_flows = main.ONOScli6.flows( json_format=True )
+        ONOS7_flows = main.ONOScli7.flows( json_format=True )
+        flow_check = main.FALSE
+        if "Error" in ONOS1_flows or not ONOS1_flows\
+                or "Error" in ONOS2_flows or not ONOS2_flows\
+                or "Error" in ONOS3_flows or not ONOS3_flows\
+                or "Error" in ONOS4_flows or not ONOS4_flows\
+                or "Error" in ONOS5_flows or not ONOS5_flows\
+                or "Error" in ONOS6_flows or not ONOS6_flows\
+                or "Error" in ONOS7_flows or not ONOS7_flows:
+                    main.log.report("Error in getting ONOS intents")
+                    main.log.warn("ONOS1 flows repsponse: "+ ONOS1_flows)
+                    main.log.warn("ONOS2 flows repsponse: "+ ONOS2_flows)
+                    main.log.warn("ONOS3 flows repsponse: "+ ONOS3_flows)
+                    main.log.warn("ONOS4 flows repsponse: "+ ONOS4_flows)
+                    main.log.warn("ONOS5 flows repsponse: "+ ONOS5_flows)
+                    main.log.warn("ONOS6 flows repsponse: "+ ONOS6_flows)
+                    main.log.warn("ONOS7 flows repsponse: "+ ONOS7_flows)
+        elif len(json.loads(ONOS1_flows)) == len(json.loads(ONOS2_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS3_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS4_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS5_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS6_flows))\
+                and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS7_flows)):
+                #TODO: Do a better check, maybe compare flows on switches?
+                    flow_state = ONOS1_flows
+                    flow_check = main.TRUE
+                    main.log.report("Flow count is consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 flows: "+ json.dumps(json.loads(ONOS1_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 flows: "+ json.dumps(json.loads(ONOS2_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 flows: "+ json.dumps(json.loads(ONOS3_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 flows: "+ json.dumps(json.loads(ONOS4_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 flows: "+ json.dumps(json.loads(ONOS5_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 flows: "+ json.dumps(json.loads(ONOS6_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 flows: "+ json.dumps(json.loads(ONOS7_flows),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+        utilities.assert_equals(expect = main.TRUE,actual=flow_check,
+                onpass="The flow count is consistent across all ONOS nodes",
+                onfail="ONOS nodes have different flow counts")
+
+
+        main.step("Get the OF Table entries")
+        global flows
+        flows=[]
+        for i in range(1,29):
+            flows.append(main.Mininet2.get_flowTable("s"+str(i),1.0))
+
+        #TODO: Compare switch flow tables with ONOS flow tables
+
+        main.step("Start continuous pings")
+        main.Mininet2.pingLong(src=main.params['PING']['source1'],
+                            target=main.params['PING']['target1'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source2'],
+                            target=main.params['PING']['target2'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source3'],
+                            target=main.params['PING']['target3'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source4'],
+                            target=main.params['PING']['target4'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source5'],
+                            target=main.params['PING']['target5'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source6'],
+                            target=main.params['PING']['target6'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source7'],
+                            target=main.params['PING']['target7'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source8'],
+                            target=main.params['PING']['target8'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source9'],
+                            target=main.params['PING']['target9'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source10'],
+                            target=main.params['PING']['target10'],pingTime=500)
+
+        main.step("Create TestONTopology object")
+        ctrls = []
+        count = 1
+        while True:
+            temp = ()
+            if ('ip' + str(count)) in main.params['CTRL']:
+                temp = temp + (getattr(main,('ONOS' + str(count))),)
+                temp = temp + ("ONOS"+str(count),)
+                temp = temp + (main.params['CTRL']['ip'+str(count)],)
+                temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+                ctrls.append(temp)
+                count = count + 1
+            else:
+                break
+        MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+        main.step("Collecting topology information from ONOS")
+        devices = []
+        devices.append( main.ONOScli1.devices() )
+        devices.append( main.ONOScli2.devices() )
+        devices.append( main.ONOScli3.devices() )
+        devices.append( main.ONOScli4.devices() )
+        devices.append( main.ONOScli5.devices() )
+        devices.append( main.ONOScli6.devices() )
+        devices.append( main.ONOScli7.devices() )
+        '''
+        hosts = []
+        hosts.append( main.ONOScli1.hosts() )
+        hosts.append( main.ONOScli2.hosts() )
+        hosts.append( main.ONOScli3.hosts() )
+        hosts.append( main.ONOScli4.hosts() )
+        hosts.append( main.ONOScli5.hosts() )
+        hosts.append( main.ONOScli6.hosts() )
+        hosts.append( main.ONOScli7.hosts() )
+        '''
+        ports = []
+        ports.append( main.ONOScli1.ports() )
+        ports.append( main.ONOScli2.ports() )
+        ports.append( main.ONOScli3.ports() )
+        ports.append( main.ONOScli4.ports() )
+        ports.append( main.ONOScli5.ports() )
+        ports.append( main.ONOScli6.ports() )
+        ports.append( main.ONOScli7.ports() )
+        links = []
+        links.append( main.ONOScli1.links() )
+        links.append( main.ONOScli2.links() )
+        links.append( main.ONOScli3.links() )
+        links.append( main.ONOScli4.links() )
+        links.append( main.ONOScli5.links() )
+        links.append( main.ONOScli6.links() )
+        links.append( main.ONOScli7.links() )
+
+
+        main.step("Comparing ONOS topology to MN")
+        devices_results = main.TRUE
+        ports_results = main.TRUE
+        links_results = main.TRUE
+        for controller in range(7): #TODO parameterize the number of controllers
+            if devices[controller] or not "Error" in devices[controller]:
+                current_devices_result =  main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+            else:
+                current_devices_result = main.FALSE
+            utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+                    onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+                    onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+            if ports[controller] or not "Error" in ports[controller]:
+                current_ports_result =  main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+            else:
+                current_ports_result = main.FALSE
+            utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+                    onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+                    onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+            if links[controller] or not "Error" in links[controller]:
+                current_links_result =  main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+            else:
+                current_links_result = main.FALSE
+            utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+                    onpass="ONOS"+str(int(controller+1))+" links view is correct",
+                    onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+
+            devices_results = devices_results and current_devices_result
+            ports_results = ports_results and current_ports_result
+            links_results = links_results and current_links_result
+
+        topo_result = devices_results and ports_results and links_results
+        utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+                onpass="Topology Check Test successful",
+                onfail="Topology Check Test NOT successful")
+
+        final_assert = main.TRUE
+        final_assert = final_assert and topo_result and flow_check \
+                and intent_check and consistent_mastership
+        utilities.assert_equals(expect=main.TRUE, actual=final_assert,
+                onpass="State check successful",
+                onfail="State check NOT successful")
+
+
+    def CASE6(self,main) :
+        '''
+        The Failure case. Since this is the Sanity test, we do nothing.
+        '''
+        import time
+        main.log.report("Wait 60 seconds instead of inducing a failure")
+        time.sleep(60)
+        utilities.assert_equals(expect=main.TRUE, actual=main.TRUE,
+                onpass="Sleeping 60 seconds",
+                onfail="Something is terribly wrong with my math")
+
+    def CASE7(self,main) :
+        '''
+        Check state after ONOS failure
+        '''
+        import os
+        import json
+        main.case("Running ONOS Constant State Tests")
+
+        main.step("Check if switch roles are consistent across all nodes")
+        ONOS1_mastership = main.ONOScli1.roles()
+        ONOS2_mastership = main.ONOScli2.roles()
+        ONOS3_mastership = main.ONOScli3.roles()
+        ONOS4_mastership = main.ONOScli4.roles()
+        ONOS5_mastership = main.ONOScli5.roles()
+        ONOS6_mastership = main.ONOScli6.roles()
+        ONOS7_mastership = main.ONOScli7.roles()
+        #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+        if "Error" in ONOS1_mastership or not ONOS1_mastership\
+                or "Error" in ONOS2_mastership or not ONOS2_mastership\
+                or "Error" in ONOS3_mastership or not ONOS3_mastership\
+                or "Error" in ONOS4_mastership or not ONOS4_mastership\
+                or "Error" in ONOS5_mastership or not ONOS5_mastership\
+                or "Error" in ONOS6_mastership or not ONOS6_mastership\
+                or "Error" in ONOS7_mastership or not ONOS7_mastership:
+                    main.log.error("Error in getting ONOS mastership")
+                    main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+                    main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership))
+                    main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership))
+                    main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership))
+                    main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership))
+                    main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership))
+                    main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership))
+                    consistent_mastership = main.FALSE
+        elif ONOS1_mastership == ONOS2_mastership\
+                and ONOS1_mastership == ONOS3_mastership\
+                and ONOS1_mastership == ONOS4_mastership\
+                and ONOS1_mastership == ONOS5_mastership\
+                and ONOS1_mastership == ONOS6_mastership\
+                and ONOS1_mastership == ONOS7_mastership:
+                    #mastership_state = ONOS1_mastership
+                    consistent_mastership = main.TRUE
+                    main.log.report("Switch roles are consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            consistent_mastership = main.FALSE
+        utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+                onpass="Switch roles are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of switch roles")
+
+
+        description2 = "Compare switch roles from before failure"
+        main.step(description2)
+
+        current_json = json.loads(ONOS1_mastership)
+        old_json = json.loads(mastership_state)
+        mastership_check = main.TRUE
+        for i in range(1,29):
+            switchDPID = str(main.Mininet1.getSwitchDPID(switch="s"+str(i)))
+
+            current = [switch['master'] for switch in current_json if switchDPID in switch['id']]
+            old = [switch['master'] for switch in old_json if switchDPID in switch['id']]
+            if current == old:
+                mastership_check = mastership_check and main.TRUE
+            else:
+                main.log.warn("Mastership of switch %s changed" % switchDPID)
+                mastership_check = main.FALSE
+        if mastership_check == main.TRUE:
+            main.log.report("Mastership of Switches was not changed")
+        utilities.assert_equals(expect=main.TRUE,actual=mastership_check,
+                onpass="Mastership of Switches was not changed",
+                onfail="Mastership of some switches changed")
+        mastership_check = mastership_check and consistent_mastership
+
+
+
+        main.step("Get the intents and compare across all nodes")
+        ONOS1_intents = main.ONOScli1.intents( json_format=True )
+        ONOS2_intents = main.ONOScli2.intents( json_format=True )
+        ONOS3_intents = main.ONOScli3.intents( json_format=True )
+        ONOS4_intents = main.ONOScli4.intents( json_format=True )
+        ONOS5_intents = main.ONOScli5.intents( json_format=True )
+        ONOS6_intents = main.ONOScli6.intents( json_format=True )
+        ONOS7_intents = main.ONOScli7.intents( json_format=True )
+        intent_check = main.FALSE
+        if "Error" in ONOS1_intents or not ONOS1_intents\
+                or "Error" in ONOS2_intents or not ONOS2_intents\
+                or "Error" in ONOS3_intents or not ONOS3_intents\
+                or "Error" in ONOS4_intents or not ONOS4_intents\
+                or "Error" in ONOS5_intents or not ONOS5_intents\
+                or "Error" in ONOS6_intents or not ONOS6_intents\
+                or "Error" in ONOS7_intents or not ONOS7_intents:
+                    main.log.report("Error in getting ONOS intents")
+                    main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+                    main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents))
+                    main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents))
+                    main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents))
+                    main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents))
+                    main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents))
+                    main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents))
+        elif ONOS1_intents == ONOS2_intents\
+                and ONOS1_intents == ONOS3_intents\
+                and ONOS1_intents == ONOS4_intents\
+                and ONOS1_intents == ONOS5_intents\
+                and ONOS1_intents == ONOS6_intents\
+                and ONOS1_intents == ONOS7_intents:
+                    intent_check = main.TRUE
+                    main.log.report("Intents are consistent across all ONOS nodes")
+        else:
+            main.log.warn("ONOS1 intents: ", json.dumps(json.loads(ONOS1_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS2 intents: ", json.dumps(json.loads(ONOS2_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS3 intents: ", json.dumps(json.loads(ONOS3_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS4 intents: ", json.dumps(json.loads(ONOS4_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS5 intents: ", json.dumps(json.loads(ONOS5_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS6 intents: ", json.dumps(json.loads(ONOS6_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+            main.log.warn("ONOS7 intents: ", json.dumps(json.loads(ONOS7_intents),
+                sort_keys=True, indent=4, separators=(',', ': ')))
+        utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+                onpass="Intents are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of intents")
+
+        main.step("Compare current intents with intents before the failure")
+        if intent_state == ONOS1_intents:
+            same_intents = main.TRUE
+            main.log.report("Intents are consistent with before failure")
+        #TODO: possibly the states have changed? we may need to figure out what the aceptable states are
+        else:
+            same_intents = main.FALSE
+        utilities.assert_equals(expect = main.TRUE,actual=same_intents,
+                onpass="Intents are consistent with before failure",
+                onfail="The Intents changed during failure")
+        intent_check = intent_check and same_intents
+
+
+
+        main.step("Get the OF Table entries and compare to before component failure")
+        Flow_Tables = main.TRUE
+        flows2=[]
+        for i in range(28):
+            main.log.info("Checking flow table on s" + str(i+1))
+            tmp_flows = main.Mininet2.get_flowTable("s"+str(i+1),1.0)
+            flows2.append(tmp_flows)
+            Flow_Tables = Flow_Tables and main.Mininet2.flow_comp(flow1=flows[i],flow2=tmp_flows)
+            if Flow_Tables == main.FALSE:
+                main.log.info("Differences in flow table for switch: "+str(i+1))
+                break
+        if Flow_Tables == main.TRUE:
+            main.log.report("No changes were found in the flow tables")
+        utilities.assert_equals(expect=main.TRUE,actual=Flow_Tables,
+                onpass="No changes were found in the flow tables",
+                onfail="Changes were found in the flow tables")
+
+        main.step("Check the continuous pings to ensure that no packets were dropped during component failure")
+        #FIXME: This check is always failing. Investigate cause
+        #NOTE:  this may be something to do with file permsissions
+        #       or slight change in format
+        main.Mininet2.pingKill(main.params['TESTONUSER'], main.params['TESTONIP'])
+        Loss_In_Pings = main.FALSE 
+        #NOTE: checkForLoss returns main.FALSE with 0% packet loss
+        for i in range(8,18):
+            main.log.info("Checking for a loss in pings along flow from s" + str(i))
+            Loss_In_Pings = Loss_In_Pings or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i))
+        if Loss_In_Pings == main.TRUE:
+            main.log.info("Loss in ping detected")
+        elif Loss_In_Pings == main.ERROR:
+            main.log.info("There are multiple mininet process running")
+        elif Loss_In_Pings == main.FALSE:
+            main.log.info("No Loss in the pings")
+            main.log.report("No loss of dataplane connectivity")
+        utilities.assert_equals(expect=main.FALSE,actual=Loss_In_Pings,
+                onpass="No Loss of connectivity",
+                onfail="Loss of dataplane connectivity detected")
+
+
+        #TODO:add topology to this or leave as a seperate case?
+        result = mastership_check and intent_check and Flow_Tables and (not Loss_In_Pings)
+        result = int(result)
+        if result == main.TRUE:
+            main.log.report("Constant State Tests Passed")
+        utilities.assert_equals(expect=main.TRUE,actual=result,
+                onpass="Constant State Tests Passed",
+                onfail="Constant state tests failed")
+
+    def CASE8 (self,main):
+        '''
+        Compare topo
+        '''
+        import sys
+        sys.path.append("/home/admin/sts") # Trying to remove some dependancies, #FIXME add this path to params
+        from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+        import json
+        import time
+
+        description ="Compare ONOS Topology view to Mininet topology"
+        main.case(description)
+        main.log.report(description)
+        main.step("Create TestONTopology object")
+        ctrls = []
+        count = 1
+        while True:
+            temp = ()
+            if ('ip' + str(count)) in main.params['CTRL']:
+                temp = temp + (getattr(main,('ONOS' + str(count))),)
+                temp = temp + ("ONOS"+str(count),)
+                temp = temp + (main.params['CTRL']['ip'+str(count)],)
+                temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+                ctrls.append(temp)
+                count = count + 1
+            else:
+                break
+        MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+        main.step("Comparing ONOS topology to MN")
+        devices_results = main.TRUE
+        ports_results = main.TRUE
+        links_results = main.TRUE
+        topo_result = main.FALSE
+        start_time = time.time()
+        elapsed = 0
+        count = 0
+        while topo_result == main.FALSE and elapsed < 120:
+            print "cond 1:" + str(topo_result == main.FALSE)
+            print "cond 2:" + str(elapsed < 120)
+            count = count + 1
+            try:
+                main.step("Collecting topology information from ONOS")
+                devices = []
+                devices.append( main.ONOScli1.devices() )
+                devices.append( main.ONOScli2.devices() )
+                devices.append( main.ONOScli3.devices() )
+                devices.append( main.ONOScli4.devices() )
+                devices.append( main.ONOScli5.devices() )
+                devices.append( main.ONOScli6.devices() )
+                devices.append( main.ONOScli7.devices() )
+                '''
+                hosts = []
+                hosts.append( main.ONOScli1.hosts() )
+                hosts.append( main.ONOScli2.hosts() )
+                hosts.append( main.ONOScli3.hosts() )
+                hosts.append( main.ONOScli4.hosts() )
+                hosts.append( main.ONOScli5.hosts() )
+                hosts.append( main.ONOScli6.hosts() )
+                hosts.append( main.ONOScli7.hosts() )
+                '''
+                ports = []
+                ports.append( main.ONOScli1.ports() )
+                ports.append( main.ONOScli2.ports() )
+                ports.append( main.ONOScli3.ports() )
+                ports.append( main.ONOScli4.ports() )
+                ports.append( main.ONOScli5.ports() )
+                ports.append( main.ONOScli6.ports() )
+                ports.append( main.ONOScli7.ports() )
+                links = []
+                links.append( main.ONOScli1.links() )
+                links.append( main.ONOScli2.links() )
+                links.append( main.ONOScli3.links() )
+                links.append( main.ONOScli4.links() )
+                links.append( main.ONOScli5.links() )
+                links.append( main.ONOScli6.links() )
+                links.append( main.ONOScli7.links() )
+
+                for controller in range(7): #TODO parameterize the number of controllers
+                    if devices[controller] or not "Error" in devices[controller]:
+                        current_devices_result =  main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+                    else:
+                        current_devices_result = main.FALSE
+                    utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+                            onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+                            onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+                    if ports[controller] or not "Error" in ports[controller]:
+                        current_ports_result =  main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+                    else:
+                        current_ports_result = main.FALSE
+                    utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+                            onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+                            onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+                    if links[controller] or not "Error" in links[controller]:
+                        current_links_result =  main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+                    else:
+                        current_links_result = main.FALSE
+                    utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+                            onpass="ONOS"+str(int(controller+1))+" links view is correct",
+                            onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+            except:
+                main.log.error("something went wrong in topo comparison")
+                main.log.warn( repr( devices ) )
+                main.log.warn( repr( ports ) )
+                main.log.warn( repr( links ) )
+
+            devices_results = devices_results and current_devices_result
+            ports_results = ports_results and current_ports_result
+            links_results = links_results and current_links_result
+            topo_result = devices_results and ports_results and links_results
+            elapsed = time.time() - start_time
+        time_threshold = elapsed < 1
+        topo_result = topo_result and time_threshold
+        #TODO make sure this step is non-blocking. IE add a timeout
+        main.log.report("Very crass estimate for topology discovery/convergence: " +\
+                str(elapsed) + " seconds, " + str(count) +" tries" )
+        utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+                onpass="Topology Check Test successful",
+                onfail="Topology Check Test NOT successful")
+        if topo_result == main.TRUE:
+            main.log.report("ONOS topology view matches Mininet topology")
+
+
+    def CASE9 (self,main):
+        '''
+        Link s3-s28 down
+        '''
+        #NOTE: You should probably run a topology check after this
+
+        link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+        description = "Turn off a link to ensure that Link Discovery is working properly"
+        main.log.report(description)
+        main.case(description)
+
+
+        main.step("Kill Link between s3 and s28")
+        Link_Down = main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
+        main.log.info("Waiting " + str(link_sleep) + " seconds for link down to be discovered")
+        time.sleep(link_sleep)
+        utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
+                onpass="Link down succesful",
+                onfail="Failed to bring link down")
+        #TODO do some sort of check here
+
+    def CASE10 (self,main):
+        '''
+        Link s3-s28 up
+        '''
+        #NOTE: You should probably run a topology check after this
+
+        link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+        description = "Restore a link to ensure that Link Discovery is working properly"
+        main.log.report(description)
+        main.case(description)
+
+        main.step("Bring link between s3 and s28 back up")
+        Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
+        main.log.info("Waiting " + str(link_sleep) + " seconds for link up to be discovered")
+        time.sleep(link_sleep)
+        utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
+                onpass="Link up succesful",
+                onfail="Failed to bring link up")
+        #TODO do some sort of check here
+
+
+    def CASE11 (self, main) :
+        '''
+        Switch Down
+        '''
+        #NOTE: You should probably run a topology check after this
+        import time
+
+        switch_sleep = int(main.params['timers']['SwitchDiscovery'])
+
+        description = "Killing a switch to ensure it is discovered correctly"
+        main.log.report(description)
+        main.case(description)
+
+        #TODO: Make this switch parameterizable
+        main.step("Kill s28 ")
+        main.log.report("Deleting s28")
+        #FIXME: use new dynamic topo functions
+        main.Mininet1.del_switch("s28")
+        main.log.info("Waiting " + str(switch_sleep) + " seconds for switch down to be discovered")
+        time.sleep(switch_sleep)
+        #Peek at the deleted switch
+        main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+        #TODO do some sort of check here
+
+    def CASE12 (self, main) :
+        '''
+        Switch Up
+        '''
+        #NOTE: You should probably run a topology check after this
+        import time
+        #FIXME: use new dynamic topo functions
+        description = "Adding a switch to ensure it is discovered correctly"
+        main.log.report(description)
+        main.case(description)
+
+        main.step("Add back s28")
+        main.log.report("Adding back s28")
+        main.Mininet1.add_switch("s28", dpid = '0000000000002800')
+        #TODO: New dpid or same? Ask Thomas?
+        main.Mininet1.add_link('s28', 's3')
+        main.Mininet1.add_link('s28', 's6')
+        main.Mininet1.add_link('s28', 'h28')
+        main.Mininet1.assign_sw_controller(sw="28",count=7,
+                ip1=ONOS1_ip,port1=ONOS1_port,
+                ip2=ONOS2_ip,port2=ONOS2_port,
+                ip3=ONOS3_ip,port3=ONOS3_port,
+                ip4=ONOS4_ip,port4=ONOS4_port,
+                ip5=ONOS5_ip,port5=ONOS5_port,
+                ip6=ONOS6_ip,port6=ONOS6_port,
+                ip7=ONOS7_ip,port7=ONOS7_port)
+        main.log.info("Waiting " + str(switch_sleep) + " seconds for switch up to be discovered")
+        time.sleep(switch_sleep)
+        #Peek at the added switch
+        main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+        #TODO do some sort of check here
+
+    def CASE13 (self, main) :
+        '''
+        Clean up
+        '''
+        import os
+        import time
+        description = "Test Cleanup"
+        main.log.report(description)
+        main.case(description)
+        main.step("Killing tcpdumps")
+        main.Mininet2.stop_tcpdump()
+
+        main.step("Copying MN pcap and ONOS log files to test station")
+        testname = main.TEST
+        #NOTE: MN Pcap file is being saved to ~/packet_captures
+        #       scp this file as MN and TestON aren't necessarily the same vm
+        #FIXME: scp
+        #####mn files
+        #TODO: Load these from params
+        #NOTE: must end in /
+        log_folder = "/opt/onos/log/"
+        log_files = ["karaf.log", "karaf.log.1"]
+        #NOTE: must end in /
+        dst_dir = "~/packet_captures/"
+        for f in log_files:
+            main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS1-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS2_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS2-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS3_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS3-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS4_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS4-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS5_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS5-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS6_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS6-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS7_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS7-"+f )
+
+        #std*.log's
+        #NOTE: must end in /
+        log_folder = "/opt/onos/var/"
+        log_files = ["stderr.log", "stdout.log"]
+        #NOTE: must end in /
+        dst_dir = "~/packet_captures/"
+        for f in log_files:
+            main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS1-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS2_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS2-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS3_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS3-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS4_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS4-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS5_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS5-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS6_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS6-"+f )
+            main.ONOSbench.secureCopy( "sdn", ONOS7_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS7-"+f )
+
+
+
+
+        #sleep so scp can finish
+        time.sleep(10)
+        main.step("Packing and rotating pcap archives")
+        os.system("~/TestON/dependencies/rotate.sh "+ str(testname))
+
+
+        #TODO: actually check something here
+        utilities.assert_equals(expect=main.TRUE, actual=main.TRUE,
+                onpass="Test cleanup successful",
+                onfail="Test cleanup NOT successful")
diff --git a/TestON/tests/HATestSanity/HATestSanity.topo b/TestON/tests/HATestSanity/HATestSanity.topo
new file mode 100644
index 0000000..4d4156c
--- /dev/null
+++ b/TestON/tests/HATestSanity/HATestSanity.topo
@@ -0,0 +1,173 @@
+<TOPOLOGY>
+    <COMPONENT>
+
+        <ONOSbench>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosDriver</type>
+            <connect_order>1</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOSbench>
+
+        <ONOScli1>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli1>
+
+        <ONOScli2>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>3</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli2>
+
+        <ONOScli3>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>4</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli3>
+
+
+        <ONOScli4>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>5</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli4>
+
+
+        <ONOScli5>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>6</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli5>
+
+
+        <ONOScli6>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>7</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli6>
+
+
+        <ONOScli7>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>8</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli7>
+
+        <ONOS1>
+            <host>10.128.30.11</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>9</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS1>
+
+        <ONOS2>
+            <host>10.128.30.12</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>10</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS2>
+
+        <ONOS3>
+            <host>10.128.30.13</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>11</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS3>
+
+        <ONOS4>
+            <host>10.128.30.14</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>12</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS4>
+
+        <ONOS5>
+            <host>10.128.30.15</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>13</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS5>
+
+        <ONOS6>
+            <host>10.128.30.16</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>14</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS6>
+
+        <ONOS7>
+            <host>10.128.30.17</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>15</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS7>
+
+        <Mininet1>
+            <host>10.128.30.9</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>MininetCliDriver</type>
+            <connect_order>16</connect_order>
+            <COMPONENTS>
+                #Specify the Option for mininet
+                <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+                <arg2> --topo mytopo </arg2>
+                <arg3> </arg3>
+                <controller> remote </controller>
+            </COMPONENTS>
+        </Mininet1>
+
+        <Mininet2>
+            <host>10.128.30.9</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>RemoteMininetDriver</type>
+            <connect_order>17</connect_order>
+            <COMPONENTS>
+                # Specify the Option for mininet
+                <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+                <arg2> --topo mytopo --arp</arg2>
+                <controller> remote </controller>
+             </COMPONENTS>
+        </Mininet2>
+
+    </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/HATestSanity/__init__.py b/TestON/tests/HATestSanity/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/HATestSanity/__init__.py
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.py b/TestON/tests/IntentPerfNext/IntentPerfNext.py
index 493f1f2..73aa304 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.py
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.py
@@ -495,6 +495,7 @@
             time.sleep(120 / int(cluster_count))
             for node in range(1, cluster_count+1):
                 with open(save_dir) as f_onos:
+                    line_count = 0
                     for line in f_onos:
                         line = line[1:]
                         line = line.split(": ")
diff --git a/TestON/tests/MultiProd/MultiProd.params b/TestON/tests/MultiProd/MultiProd.params
index 2f99555..3007fb2 100755
--- a/TestON/tests/MultiProd/MultiProd.params
+++ b/TestON/tests/MultiProd/MultiProd.params
@@ -1,6 +1,6 @@
 <PARAMS>
     
-    <testcases>1,4,5,6,7,8,9</testcases>
+    <testcases>1,4,10,5,6,7,8,6,8,9</testcases>
 
     #Environment variables
     <ENV>
diff --git a/TestON/tests/MultiProd/MultiProd.py b/TestON/tests/MultiProd/MultiProd.py
index 33d86b4..7545f3e 100755
--- a/TestON/tests/MultiProd/MultiProd.py
+++ b/TestON/tests/MultiProd/MultiProd.py
@@ -17,11 +17,12 @@
     def CASE1(self, main):
         '''
         Startup sequence:
+        cell <name>
+        onos-verify-cell
+        onos-remove-raft-logs        
         git pull
         mvn clean install
         onos-package
-        cell <name>
-        onos-verify-cell
         onos-install -f
         onos-wait-for-start
         '''
@@ -32,11 +33,23 @@
         ONOS3_ip = main.params['CTRL']['ip3']
         ONOS1_port = main.params['CTRL']['port1']
         ONOS2_port = main.params['CTRL']['port2']
-        ONOS3_port = main.params['CTRL']['port3']
-        
+        ONOS3_port = main.params['CTRL']['port3']   
+       
         main.case("Setting up test environment")
         main.log.report("This testcase is testing setting up test environment") 
         main.log.report("__________________________________")
+ 
+        main.step("Applying cell variable to environment")
+        cell_result1 = main.ONOSbench.set_cell(cell_name)
+        #cell_result2 = main.ONOScli1.set_cell(cell_name)
+        #cell_result3 = main.ONOScli2.set_cell(cell_name)
+        #cell_result4 = main.ONOScli3.set_cell(cell_name)
+        verify_result = main.ONOSbench.verify_cell() 
+        cell_result = cell_result1
+
+        main.step("Removing raft logs before a clen installation of ONOS")
+        remove_log_Result = main.ONOSbench.onos_remove_raft_logs()        
+
         main.step("Git checkout and pull master and get version")
         main.ONOSbench.git_checkout("master")
         git_pull_result = main.ONOSbench.git_pull()
@@ -48,14 +61,6 @@
             clean_install_result = main.ONOSbench.clean_install()
             #clean_install_result = main.TRUE 
 
-        main.step("Applying cell variable to environment")
-        cell_result1 = main.ONOSbench.set_cell(cell_name)
-        #cell_result2 = main.ONOScli1.set_cell(cell_name)
-        #cell_result3 = main.ONOScli2.set_cell(cell_name)
-        #cell_result4 = main.ONOScli3.set_cell(cell_name)
-        verify_result = main.ONOSbench.verify_cell() 
-        cell_result = cell_result1
-
         main.step("Creating ONOS package")
         package_result = main.ONOSbench.onos_package()
 
@@ -223,9 +228,9 @@
         devices1 = main.ONOScli1.devices()
         devices2 = main.ONOScli2.devices()
         devices3 = main.ONOScli3.devices()
-        print "devices1 = ", devices1
-        print "devices2 = ", devices2
-        print "devices3 = ", devices3
+        #print "devices1 = ", devices1
+        #print "devices2 = ", devices2
+        #print "devices3 = ", devices3
         hosts1 = main.ONOScli1.hosts()
         hosts2 = main.ONOScli2.hosts()
         hosts3 = main.ONOScli3.hosts()
@@ -355,14 +360,36 @@
                 onpass="Topology Check Test successful",
                 onfail="Topology Check Test NOT successful")
 
+
+
+
+    def CASE10(self):
+        main.log.report("This testcase uninstalls the reactive forwarding app")
+        main.log.report("__________________________________")
+        main.case("Uninstalling reactive forwarding app")
+        #Unistall onos-app-fwd app to disable reactive forwarding
+        appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-fwd")
+        appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-fwd")
+        appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-fwd")
+        main.log.info("onos-app-fwd uninstalled")
+
+        #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+        #So sleep for 15s
+        time.sleep(15)
+        
+        hosts = main.ONOScli1.hosts()
+        main.log.info(hosts)
+        
+        case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3
+        utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
+
+
     def CASE6(self):
         main.log.report("This testcase is testing the addition of host intents and then doing pingall")
         main.log.report("__________________________________")        
-        main.case("Uninstalling reactive forwarding app and addhost intents")
+        main.case("Obtaining hostsfor adding host intents")
         main.step("Get hosts")
-        main.ONOScli1.handle.sendline("hosts")
-        main.ONOScli1.handle.expect("onos>")
-        hosts = main.ONOScli1.handle.before
+        hosts = main.ONOScli1.hosts()
         main.log.info(hosts)
 
         main.step("Get all devices id")
@@ -371,7 +398,8 @@
 
         #ONOS displays the hosts in hex format unlike mininet which does in decimal format
         #So take care while adding intents
-
+        
+        '''
         main.step("Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
         hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
         hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
@@ -383,16 +411,17 @@
         hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
         hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
         hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1") 
+        '''
 
-
-        #Unistall onos-app-fwd app to disable reactive forwarding
-        main.step("Unistall onos-app-fwd app to disable reactive forwarding")
-        appUninstall_result = main.ONOScli1.feature_uninstall("onos-app-fwd")
-        main.log.info("onos-app-fwd uninstalled")
-
-        #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
-        #So sleep for 15s
-        time.sleep(15)
+        for i in range(8,18):
+            main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+            #NOTE: get host can return None
+            #TODO: handle this
+            host1_id = main.ONOScli1.get_host(host1)['id']
+            host2_id = main.ONOScli1.get_host(host2)['id']
+            tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
 
         flowHandle = main.ONOScli1.flows()
         #print "flowHandle = ", flowHandle
@@ -634,7 +663,7 @@
 
     def CASE8(self):
         '''
-        Host intents removal
+        Intent removal
         ''' 
         main.log.report("This testcase removes host intents before adding the point intents")
         main.log.report("__________________________________")        
@@ -643,31 +672,37 @@
         main.step("Obtain the intent id's")
         intent_result = main.ONOScli1.intents()
         #print "intent_result = ",intent_result
+        
         intent_linewise = intent_result.split("\n")
-        intent_linewise = intent_linewise[1:-1] #ignore the first and last item of the list obtained from split 
-        #for line in intent_linewise:
-            #print "line = ", line
-        intentids = []
+        intentList = []
         for line in intent_linewise:
+            if line.startswith("id="):
+                intentList.append(line)
+
+        intentids = []
+        for line in intentList:
             intentids.append(line.split(",")[0].split("=")[1])
         for id in intentids:
             print "id = ", id
-        
+
         main.step("Iterate through the intentids list and remove each intent")
         for id in intentids:
             main.ONOScli1.remove_intent(intent_id = id)
-        
+
         intent_result = main.ONOScli1.intents()
         intent_linewise = intent_result.split("\n")
-        intent_linewise = intent_linewise[1:-1] #ignore the first and last item of the list obtained from split 
-        
+        list_afterRemoval = []
+        for line in intent_linewise:
+            if line.startswith("id="):
+                list_afterRemoval.append(line)
+
         intentState = {}
-        for id, line in zip(intentids, intent_linewise):
+        for id, line in zip(intentids, list_afterRemoval):
             #print "line after removing intent = ", line
             x = line.split(",")
             state = x[1].split("=")[1]
             intentState[id] = state
-            
+
         case8_result = main.TRUE
         for key,value in intentState.iteritems():
             print "key,value = ", key, value
@@ -676,14 +711,39 @@
             else:    
                 case8_result = case8_result and main.FALSE
 
-        if case8_result == main.TRUE:
+        i = 8
+        Ping_Result = main.TRUE
+        while i <18 :
+            main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
+            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+            if ping==main.TRUE:
+                i = 19
+                Ping_Result = main.TRUE
+            elif ping==main.FALSE:
+                i+=1
+                Ping_Result = main.FALSE
+            else:
+                main.log.info("Unknown error")
+                Ping_Result = main.ERROR
+        
+        #Note: If the ping result failed, that means the intents have been withdrawn correctly.
+        if Ping_Result==main.TRUE:
+            main.log.report("Host intents have not been withdrawn correctly")
+            #main.cleanup()
+            #main.exit()
+        if Ping_Result==main.FALSE:
+            main.log.report("Host intents have been withdrawn correctly")
+
+        case8_result = case8_result and Ping_Result
+
+        if case8_result == main.FALSE:
             main.log.report("Intent removal successful")
         else:
             main.log.report("Intent removal failed")
                         
-        utilities.assert_equals(expect=main.TRUE, actual=case8_result,
-                onpass="Intent removal test successful",
-                onfail="Intent removal test failed")
+        utilities.assert_equals(expect=main.FALSE, actual=case8_result,
+                onpass="Intent removal test failed",
+                onfail="Intent removal test successful")
              
 
     def CASE9(self):
@@ -696,117 +756,117 @@
         main.log.info("Adding point intents")
         main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)") 
         main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008", 1, "of:0000000000006018", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018", 1, "of:0000000000003008", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
         main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009", 1, "of:0000000000006019", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019", 1, "of:0000000000003009", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
         
         main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010", 1, "of:0000000000006020", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020", 1, "of:0000000000003010", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
 
         main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011", 1, "of:0000000000006021", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021", 1, "of:0000000000003011", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012", 1, "of:0000000000006022", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022", 1, "of:0000000000003012", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013", 1, "of:0000000000006023", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023", 1, "of:0000000000003013", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
 
         main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014", 1, "of:0000000000006024", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024", 1, "of:0000000000003014", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015", 1, "of:0000000000006025", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025", 1, "of:0000000000003015", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016", 1, "of:0000000000006026", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026", 1, "of:0000000000003016", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
@@ -814,13 +874,13 @@
 
 
         main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017", 1, "of:0000000000006027", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027", 1, "of:0000000000003017", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
@@ -867,3 +927,163 @@
                 onpass="Ping all test after Point intents addition successful",
                 onfail="Ping all test after Point intents addition failed")
 
+    def CASE31(self):
+        ''' 
+            This test case adds point intent related to SDN-IP matching on ICMP (ethertype=IPV4, ipProto=1)
+        '''
+        import json
+
+        main.log.report("This test case adds point intent related to SDN-IP matching on ICMP")
+        main.case("Adding bidirectional point intent related to SDN-IP matching on ICMP")
+        main.step("Adding bidirectional point intent")
+        #add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=1  of:0000000000003008/1 of:0000000000006018/1
+        
+        hosts_json = json.loads(main.ONOScli1.hosts())
+        for  i in range(8,11):
+            main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
+            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+            host1_id = main.ONOScli1.get_host(host1)['id']
+            host2_id = main.ONOScli1.get_host(host2)['id']
+            for host in hosts_json:
+                if host['id'] == host1_id:
+                    ip1 = host['ips'][0]
+                    ip1 = str(ip1+"/32")
+                    print "ip1 = ", ip1
+                    device1 = host['location']['device']
+                    device1 = str(device1+"/1")
+                    print "device1 = ", device1
+                elif host['id'] == host2_id:
+                    ip2 = str(host['ips'][0])+"/32"
+                    print "ip2 = ", ip2
+                    device2 = host['location']["device"]
+                    device2 = str(device2+"/1")
+                    print "device2 = ", device2
+                
+            p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
+                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
+            
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info(get_intent_result)
+ 
+            p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1, 
+                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto']) 
+            
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info(get_intent_result)
+            if (p_intent_result1 and p_intent_result2) == main.TRUE:
+                #get_intent_result = main.ONOScli1.intents()
+                #main.log.info(get_intent_result)
+                main.log.info("Point intent related to SDN-IP matching on ICMP install successful")
+       
+        time.sleep(15) 
+        get_intent_result = main.ONOScli1.intents()
+        main.log.info("intents = "+ get_intent_result)
+        get_flows_result = main.ONOScli1.flows()
+        main.log.info("flows = " + get_flows_result)
+        
+        count = 1
+        i = 8
+        Ping_Result = main.TRUE
+        while i <11 :
+            main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
+            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+            if ping == main.FALSE and count <3:
+                count+=1
+                #i = 8
+                Ping_Result = main.FALSE
+                main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
+                time.sleep(2)
+            elif ping==main.FALSE:
+                main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
+                i=19
+                Ping_Result = main.FALSE
+            elif ping==main.TRUE:
+                main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
+                i+=1
+                Ping_Result = main.TRUE
+            else:
+                main.log.info("Unknown error")
+                Ping_Result = main.ERROR
+        if Ping_Result==main.FALSE:
+            main.log.report("Ping test after Point intents related to SDN-IP matching on ICMP failed.")
+            #main.cleanup()
+            #main.exit()
+        if Ping_Result==main.TRUE:
+            main.log.report("Ping all test after Point intents related to SDN-IP matching on ICMP successful")
+                   
+        case31_result = Ping_Result and p_intent_result1 and p_intent_result2
+        utilities.assert_equals(expect=main.TRUE, actual=case31_result,
+                onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
+                onfail="Point intent related to SDN-IP matching on ICMP and ping test failed")
+   
+    def CASE32(self):
+        ''' 
+            This test case adds point intent related to SDN-IP matching on TCP (ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001)
+            Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001
+        '''
+        import json
+
+        main.log.report("This test case adds point intent related to SDN-IP matching on TCP")
+        main.case("Adding bidirectional point intent related to SDN-IP matching on TCP")
+        main.step("Adding bidirectional point intent")
+        """
+        add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001  of:0000000000003008/1 of:0000000000006018/1
+
+        add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001  of:0000000000006018/1 of:0000000000003008/1
+    
+        add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001  of:0000000000003008/1 of:0000000000006018/1
+
+        add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001  of:0000000000006018/1 of:0000000000003008/1
+
+        """           
+    
+        hosts_json = json.loads(main.ONOScli1.hosts())
+        for  i in range(8,9):
+            main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
+            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+            host1_id = main.ONOScli1.get_host(host1)['id']
+            host2_id = main.ONOScli1.get_host(host2)['id']
+            for host in hosts_json:
+                if host['id'] == host1_id:
+                    ip1 = host['ips'][0]
+                    ip1 = str(ip1+"/32")
+                    print "ip1 = ", ip1
+                    device1 = host['location']['device']
+                    device1 = str(device1+"/1")
+                    print "device1 = ", device1
+                elif host['id'] == host2_id:
+                    ip2 = str(host['ips'][0])+"/32"
+                    print "ip2 = ", ip2
+                    device2 = host['location']["device"]
+                    device2 = str(device2+"/1")
+                    print "device2 = ", device2
+                
+            p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
+                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort']) 
+            p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1, 
+                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
+
+            p_intent_result3 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
+                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
+            p_intent_result4 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
+                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort']) 
+
+            p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4
+            if p_intent_result ==main.TRUE:
+                get_intent_result = main.ONOScli1.intents()
+                main.log.info(get_intent_result)
+                main.log.info("Point intent related to SDN-IP matching on TCP install successful")
+        
+        iperf_result = main.Mininet1.iperf('h8', 'h18') 
+        if iperf_result == main.TRUE:
+            main.log.report("iperf test successful")
+        else:
+            main.log.report("iperf test failed")
+
+
+        case32_result = p_intent_result and iperf_result
+        utilities.assert_equals(expect=main.TRUE, actual=case32_result,
+                onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
+                onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed") 
diff --git a/TestON/tests/MultiProd13/MultiProd13.params b/TestON/tests/MultiProd13/MultiProd13.params
index b60f5cf..f41abe2 100755
--- a/TestON/tests/MultiProd13/MultiProd13.params
+++ b/TestON/tests/MultiProd13/MultiProd13.params
@@ -1,6 +1,6 @@
 <PARAMS>
     
-    <testcases>1,4,10,31</testcases>    
+    <testcases>1,4,10,31,32</testcases>    
 
     #Environment variables
     <ENV>
@@ -16,6 +16,14 @@
         <port3>6633</port3>
     </CTRL>
 
+    <SDNIP>
+        <ethType>IPV4</ethType>
+        <tcpProto>6</tcpProto>
+        <icmpProto>1</icmpProto>
+        <srcPort>5001</srcPort>
+        <dstPort>5001</dstPort>
+    </SDNIP>
+
     <PING>
         <source1>h8</source1>
         <source2>h9</source2>
diff --git a/TestON/tests/MultiProd13/MultiProd13.py b/TestON/tests/MultiProd13/MultiProd13.py
index d825c62..40f41b6 100755
--- a/TestON/tests/MultiProd13/MultiProd13.py
+++ b/TestON/tests/MultiProd13/MultiProd13.py
@@ -17,11 +17,12 @@
     def CASE1(self, main):
         '''
         Startup sequence:
+        cell <name>
+        onos-verify-cell
+        onos-remove-raft-logs        
         git pull
         mvn clean install
         onos-package
-        cell <name>
-        onos-verify-cell
         onos-install -f
         onos-wait-for-start
         '''
@@ -32,11 +33,23 @@
         ONOS3_ip = main.params['CTRL']['ip3']
         ONOS1_port = main.params['CTRL']['port1']
         ONOS2_port = main.params['CTRL']['port2']
-        ONOS3_port = main.params['CTRL']['port3']
-        
+        ONOS3_port = main.params['CTRL']['port3']   
+       
         main.case("Setting up test environment")
         main.log.report("This testcase is testing setting up test environment") 
         main.log.report("__________________________________")
+ 
+        main.step("Applying cell variable to environment")
+        cell_result1 = main.ONOSbench.set_cell(cell_name)
+        #cell_result2 = main.ONOScli1.set_cell(cell_name)
+        #cell_result3 = main.ONOScli2.set_cell(cell_name)
+        #cell_result4 = main.ONOScli3.set_cell(cell_name)
+        verify_result = main.ONOSbench.verify_cell() 
+        cell_result = cell_result1
+
+        main.step("Removing raft logs before a clen installation of ONOS")
+        remove_log_Result = main.ONOSbench.onos_remove_raft_logs()        
+
         main.step("Git checkout and pull master and get version")
         main.ONOSbench.git_checkout("master")
         git_pull_result = main.ONOSbench.git_pull()
@@ -48,14 +61,6 @@
             clean_install_result = main.ONOSbench.clean_install()
             #clean_install_result = main.TRUE 
 
-        main.step("Applying cell variable to environment")
-        cell_result1 = main.ONOSbench.set_cell(cell_name)
-        #cell_result2 = main.ONOScli1.set_cell(cell_name)
-        #cell_result3 = main.ONOScli2.set_cell(cell_name)
-        #cell_result4 = main.ONOScli3.set_cell(cell_name)
-        verify_result = main.ONOSbench.verify_cell() 
-        cell_result = cell_result1
-
         main.step("Creating ONOS package")
         package_result = main.ONOSbench.onos_package()
 
@@ -371,7 +376,10 @@
         #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
         #So sleep for 15s
         time.sleep(15)
-
+        
+        hosts = main.ONOScli1.hosts()
+        main.log.info(hosts)
+        
         case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3
         utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
 
@@ -709,6 +717,7 @@
             main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
             ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
             if ping==main.TRUE:
+                i = 19
                 Ping_Result = main.TRUE
             elif ping==main.FALSE:
                 i+=1
@@ -733,8 +742,8 @@
             main.log.report("Intent removal failed")
                         
         utilities.assert_equals(expect=main.FALSE, actual=case8_result,
-                onpass="Intent removal test successful",
-                onfail="Intent removal test failed")
+                onpass="Intent removal test failed",
+                onfail="Intent removal test successful")
              
 
     def CASE9(self):
@@ -747,117 +756,117 @@
         main.log.info("Adding point intents")
         main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)") 
         main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008", 1, "of:0000000000006018", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018", 1, "of:0000000000003008", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
         main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009", 1, "of:0000000000006019", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019", 1, "of:0000000000003009", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
         
         main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010", 1, "of:0000000000006020", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020", 1, "of:0000000000003010", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
 
         main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011", 1, "of:0000000000006021", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021", 1, "of:0000000000003011", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012", 1, "of:0000000000006022", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022", 1, "of:0000000000003012", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013", 1, "of:0000000000006023", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023", 1, "of:0000000000003013", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
 
         main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014", 1, "of:0000000000006024", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024", 1, "of:0000000000003014", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015", 1, "of:0000000000006025", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025", 1, "of:0000000000003015", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016", 1, "of:0000000000006026", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026", 1, "of:0000000000003016", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
@@ -865,13 +874,13 @@
 
 
         main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017", 1, "of:0000000000006027", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
             #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027", 1, "of:0000000000003017", 1)
+        ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOScli1.intents()
             main.log.info("Point to point intent install successful")
@@ -925,6 +934,7 @@
         import json
 
         main.log.report("This test case adds point intent related to SDN-IP matching on ICMP")
+        main.case("Adding bidirectional point intent related to SDN-IP matching on ICMP")
         main.step("Adding bidirectional point intent")
         #add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=1  of:0000000000003008/1 of:0000000000006018/1
         
@@ -937,15 +947,143 @@
             host2_id = main.ONOScli1.get_host(host2)['id']
             for host in hosts_json:
                 if host['id'] == host1_id:
-                    ip1 = host['ips']+"/"+"32"
-                    device1 = str(host['location']['device'])
-                    port1 = 1
+                    ip1 = host['ips'][0]
+                    ip1 = str(ip1+"/32")
                     print "ip1 = ", ip1
+                    device1 = host['location']['device']
+                    device1 = str(device1+"/1")
                     print "device1 = ", device1
                 elif host['id'] == host2_id:
-                    ip2 = str(host['ips'])+"/"+"32"
-                    device2 = str(host['location']["device"])
-                    port2 = 1
+                    ip2 = str(host['ips'][0])+"/32"
                     print "ip2 = ", ip2
+                    device2 = host['location']["device"]
+                    device2 = str(device2+"/1")
                     print "device2 = ", device2
-           
+                
+            p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
+                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
+            
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info(get_intent_result)
+ 
+            p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1, 
+                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto']) 
+            
+            get_intent_result = main.ONOScli1.intents()
+            main.log.info(get_intent_result)
+            if (p_intent_result1 and p_intent_result2) == main.TRUE:
+                #get_intent_result = main.ONOScli1.intents()
+                #main.log.info(get_intent_result)
+                main.log.info("Point intent related to SDN-IP matching on ICMP install successful")
+       
+        time.sleep(15) 
+        get_intent_result = main.ONOScli1.intents()
+        main.log.info("intents = "+ get_intent_result)
+        get_flows_result = main.ONOScli1.flows()
+        main.log.info("flows = " + get_flows_result)
+        
+        count = 1
+        i = 8
+        Ping_Result = main.TRUE
+        while i <11 :
+            main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
+            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+            if ping == main.FALSE and count <3:
+                count+=1
+                #i = 8
+                Ping_Result = main.FALSE
+                main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
+                time.sleep(2)
+            elif ping==main.FALSE:
+                main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
+                i=19
+                Ping_Result = main.FALSE
+            elif ping==main.TRUE:
+                main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
+                i+=1
+                Ping_Result = main.TRUE
+            else:
+                main.log.info("Unknown error")
+                Ping_Result = main.ERROR
+        if Ping_Result==main.FALSE:
+            main.log.report("Ping test after Point intents related to SDN-IP matching on ICMP failed.")
+            #main.cleanup()
+            #main.exit()
+        if Ping_Result==main.TRUE:
+            main.log.report("Ping all test after Point intents related to SDN-IP matching on ICMP successful")
+                   
+        case31_result = Ping_Result and p_intent_result1 and p_intent_result2
+        utilities.assert_equals(expect=main.TRUE, actual=case31_result,
+                onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
+                onfail="Point intent related to SDN-IP matching on ICMP and ping test failed")
+   
+    def CASE32(self):
+        ''' 
+            This test case adds point intent related to SDN-IP matching on TCP (ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001)
+            Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001
+        '''
+        import json
+
+        main.log.report("This test case adds point intent related to SDN-IP matching on TCP")
+        main.case("Adding bidirectional point intent related to SDN-IP matching on TCP")
+        main.step("Adding bidirectional point intent")
+        """
+        add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001  of:0000000000003008/1 of:0000000000006018/1
+
+        add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001  of:0000000000006018/1 of:0000000000003008/1
+    
+        add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001  of:0000000000003008/1 of:0000000000006018/1
+
+        add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001  of:0000000000006018/1 of:0000000000003008/1
+
+        """           
+    
+        hosts_json = json.loads(main.ONOScli1.hosts())
+        for  i in range(8,9):
+            main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
+            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+            host1_id = main.ONOScli1.get_host(host1)['id']
+            host2_id = main.ONOScli1.get_host(host2)['id']
+            for host in hosts_json:
+                if host['id'] == host1_id:
+                    ip1 = host['ips'][0]
+                    ip1 = str(ip1+"/32")
+                    print "ip1 = ", ip1
+                    device1 = host['location']['device']
+                    device1 = str(device1+"/1")
+                    print "device1 = ", device1
+                elif host['id'] == host2_id:
+                    ip2 = str(host['ips'][0])+"/32"
+                    print "ip2 = ", ip2
+                    device2 = host['location']["device"]
+                    device2 = str(device2+"/1")
+                    print "device2 = ", device2
+                
+            p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
+                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort']) 
+            p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1, 
+                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
+
+            p_intent_result3 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
+                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
+            p_intent_result4 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
+                                  ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort']) 
+
+            p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4
+            if p_intent_result ==main.TRUE:
+                get_intent_result = main.ONOScli1.intents()
+                main.log.info(get_intent_result)
+                main.log.info("Point intent related to SDN-IP matching on TCP install successful")
+        
+        iperf_result = main.Mininet1.iperf('h8', 'h18') 
+        if iperf_result == main.TRUE:
+            main.log.report("iperf test successful")
+        else:
+            main.log.report("iperf test failed")
+
+
+        case32_result = p_intent_result and iperf_result
+        utilities.assert_equals(expect=main.TRUE, actual=case32_result,
+                onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
+                onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed") 
diff --git a/TestON/tests/ProdFunc/ProdFunc.params b/TestON/tests/ProdFunc/ProdFunc.params
index 9b44a53..6879c37 100755
--- a/TestON/tests/ProdFunc/ProdFunc.params
+++ b/TestON/tests/ProdFunc/ProdFunc.params
@@ -1,6 +1,6 @@
 <PARAMS>
     
-    <testcases>1,4,5,6,7,8,9</testcases>
+    <testcases>1,4,10,5,6,7,8,6,8,9</testcases>
 
     #Environment variables
     <ENV>
diff --git a/TestON/tests/ProdFunc/ProdFunc.py b/TestON/tests/ProdFunc/ProdFunc.py
index 67a2981..7464739 100755
--- a/TestON/tests/ProdFunc/ProdFunc.py
+++ b/TestON/tests/ProdFunc/ProdFunc.py
@@ -6,7 +6,6 @@
 import sys
 import os
 import re
-import time
 import json
 
 time.sleep(1)
@@ -17,11 +16,12 @@
     def CASE1(self, main):
         '''
         Startup sequence:
+        cell <name>
+        onos-verify-cell
+        onos-remove-raft-log
         git pull
         mvn clean install
         onos-package
-        cell <name>
-        onos-verify-cell
         onos-install -f
         onos-wait-for-start
         '''
@@ -33,6 +33,17 @@
         main.case("Setting up test environment")
         main.log.report("This testcase is testing setting up test environment")
         main.log.report("__________________________________") 
+
+        main.step("Applying cell variable to environment")
+        cell_result1 = main.ONOSbench.set_cell(cell_name)
+        verify_result = main.ONOSbench.verify_cell()
+        cell_result2 = main.ONOS2.set_cell(cell_name)
+        verify_result = main.ONOS2.verify_cell()
+        cell_result = cell_result1 and cell_result2
+        
+        main.step("Removing raft logs before a clen installation of ONOS")
+        main.ONOSbench.onos_remove_raft_logs()
+
         main.step("Git checkout and pull master and get version")
         main.ONOSbench.git_checkout("master")
         git_pull_result = main.ONOSbench.git_pull()
@@ -43,21 +54,10 @@
             main.step("Using mvn clean & install")
             clean_install_result = main.ONOSbench.clean_install()
             #clean_install_result = main.TRUE
-        
-        main.step("Applying cell variable to environment")
-        cell_result1 = main.ONOSbench.set_cell(cell_name)
-        verify_result = main.ONOSbench.verify_cell()
-        cell_result2 = main.ONOS2.set_cell(cell_name)
-        #verify_result = main.ONOS2.verify_cell()
-        main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
-        
-        cell_result = cell_result1 and cell_result2
-
+         
         main.step("Creating ONOS package")
         package_result = main.ONOSbench.onos_package()
 
-        #main.step("Creating a cell")
-        #cell_create_result = main.ONOSbench.create_cell_file(**************)
 
         main.step("Installing ONOS package")
         onos_install_result = main.ONOSbench.onos_install()
@@ -74,6 +74,8 @@
        
         main.step("Starting ONOS service")
         start_result = main.ONOSbench.onos_start(ONOS1_ip)
+        
+        main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])        
 
         case1_result = (package_result and\
                 cell_result and verify_result and onos_install_result and\
@@ -125,6 +127,218 @@
         main.log.info("onos command returned: "+cmd_result2)
 
 
+    def CASE20(self):
+        '''
+            Exit from mininet cli
+            reinstall ONOS
+        '''
+        main.log.report("This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology")
+        main.log.report("_____________________________________________")
+        main.step("Disconnecting mininet and restarting ONOS")
+        main.step("Disconnecting mininet and restarting ONOS")
+        mininet_disconnect = main.Mininet1.disconnect()
+
+        main.step("Applying cell variable to environment")
+        cell_result1 = main.ONOSbench.set_cell(cell_name)
+        verify_result = main.ONOSbench.verify_cell()
+        cell_result2 = main.ONOS2.set_cell(cell_name)
+        verify_result = main.ONOS2.verify_cell()
+        cell_result = cell_result1 and cell_result2
+
+        onos_install_result = main.ONOSbench.onos_install()
+        if onos_install_result == main.TRUE:
+            main.log.report("Installing ONOS package successful")
+        else:
+            main.log.report("Installing ONOS package failed")
+
+        onos1_isup = main.ONOSbench.isup()
+        if onos1_isup == main.TRUE:
+            main.log.report("ONOS instance is up and ready")
+        else:
+            main.log.report("ONOS instance may not be up")
+
+        main.step("Starting ONOS service")
+        start_result = main.ONOSbench.onos_start(ONOS1_ip)
+       
+        print "mininet_disconnect =", mininet_disconnect
+        print "onos_install_result =", onos_install_result
+        print "onos1_isup =", onos1_isup
+        print "start_result =", start_result
+ 
+        case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
+        utilities.assert_equals(expect=main.TRUE, actual=case20_result,
+                onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
+                onfail="Exiting functionality mininet topology and reinstalling ONOS failed") 
+
+    def CASE21(self, main):
+        import time
+        '''
+            On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
+            which starts the rest and copies the links json file to the onos instance
+            Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt 
+            from the json config file
+        ''' 
+        main.log.report("This testcase starts the packet layer topology and REST")
+        main.log.report("_____________________________________________")
+        main.case("Starting LINC-OE and other components")
+        main.step("Starting LINC-OE and other components")
+        start_console_result = main.LincOE1.start_console()
+        optical_mn_script = main.LincOE2.run_optical_mn_script()
+        onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(instance_name = main.params['CTRL']['ip1'], json_file = main.params['OPTICAL']['jsonfile'])
+            
+        print "start_console_result =",start_console_result 
+        print "optical_mn_script = ",optical_mn_script 
+        print "onos_topo_cfg_result =",onos_topo_cfg_result 
+
+        case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result
+        utilities.assert_equals(expect=main.TRUE, actual=case21_result,
+                onpass="Packet optical topology spawned successsfully",
+                onfail="Packet optical topology spawning failed") 
+
+
+    def CASE22(self, main):
+        '''
+            Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host.
+             Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2
+            and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed
+        '''
+
+        main.log.report("This testcase compares the optical+packet topology against what is expected")
+        main.case("Topology comparision")
+        main.step("Topology comparision")
+        main.ONOS3.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+        devices_result = main.ONOS3.devices(json_format = False)
+
+        print "devices_result = ", devices_result
+        devices_linewise = devices_result.split("\n")
+        devices_linewise = devices_linewise[1:-1]
+        roadmCount = 0
+        packetLayerSWCount = 0
+        for line in devices_linewise:
+            components = line.split(",")
+            availability = components[1].split("=")[1]
+            type = components[3].split("=")[1]
+            if availability == 'true' and type == 'ROADM':
+                roadmCount += 1
+            elif availability == 'true' and type =='SWITCH':
+                packetLayerSWCount += 1
+        if roadmCount == 4:
+            print "Number of Optical Switches = %d and is correctly detected" %roadmCount
+            main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is correctly detected")
+            opticalSW_result = main.TRUE
+        else:
+            print "Number of Optical Switches = %d and is wrong" %roadCount
+            main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is wrong")
+            opticalSW_result = main.FALSE
+
+        if packetLayerSWCount == 2:
+            print "Number of Packet layer or mininet Switches = %d and is correctly detected" %packetLayerSWCount
+            main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is correctly detected")
+            packetSW_result = main.TRUE
+        else:
+            print "Number of Packet layer or mininet Switches = %d and is wrong" %packetLayerSWCount
+            main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is wrong")
+            packetSW_result = main.FALSE
+        print "_________________________________"
+        
+        links_result = main.ONOS3.links(json_format = False)
+        print "links_result = ", links_result
+        print "_________________________________"
+        
+
+
+        #Discover hosts using pingall
+        pingall_result = main.LincOE2.pingall()    
+    
+        hosts_result = main.ONOS3.hosts(json_format = False)
+        main.log.info("hosts_result = "+hosts_result)   
+        main.log.info("_________________________________")
+        hosts_linewise = hosts_result.split("\n")
+        hosts_linewise = hosts_linewise[1:-1]
+        hostCount = 0
+        for line in hosts_linewise:
+            hostid = line.split(",")[0].split("=")[1]
+            hostCount +=1
+        if hostCount ==2:
+            print "Number of hosts = %d and is correctly detected" %hostCount
+            main.log.info("Number of hosts = " + str(hostCount) +" and is correctly detected")
+            hostDiscovery = main.TRUE
+        else:
+            print "Number of hosts = %d and is wrong" %hostCount
+            main.log.info("Number of hosts = " + str(hostCount) +" and is wrong")
+            hostDiscovery = main.FALSE
+        
+        case22_result = opticalSW_result and packetSW_result and hostDiscovery
+        utilities.assert_equals(expect=main.TRUE, actual=case22_result,
+                onpass="Packet optical topology discovery successful",
+                onfail="Packet optical topology discovery failed")
+
+    def CASE23(self, main):
+        import time
+        '''
+            Add bidirectional point intents between 2 packet layer(mininet) devices and 
+            ping mininet hosts
+        '''
+        main.log.report("This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts")
+        main.case("Topology comparision")
+        main.step("Adding point intents")
+        ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0001/1", "of:0000ffffffff0002/1")
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS3.intents()
+            main.log.info("Point to point intent install successful")
+            main.log.info(get_intent_result)
+
+        ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0002/1", "of:0000ffffffff0001/1")
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS3.intents()
+            main.log.info("Point to point intent install successful")
+            main.log.info(get_intent_result)
+
+        time.sleep(10)
+        flowHandle = main.ONOS3.flows()
+        #print "flowHandle = ", flowHandle
+        main.log.info("flows :" + flowHandle)
+
+        # Sleep for 30 seconds to provide time for the intent state to change
+        time.sleep(30)
+        intentHandle = main.ONOS3.intents()        
+        main.log.info("intents :" + intentHandle)        
+ 
+        Ping_Result = main.TRUE
+        count = 1
+        main.log.info("\n\nh1 is Pinging h2")
+        ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+        #ping = main.LincOE2.pinghost()
+        if ping == main.FALSE and count<5:
+            count+=1
+            Ping_Result = main.FALSE
+            main.log.info("Ping between h1 and h2  failed. Making attempt number "+str(count) + " in 2 seconds")
+            time.sleep(2)
+            ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+            #ping = main.LincOE2.pinghost()
+        elif ping==main.FALSE:
+            main.log.info("All ping attempts between h1 and h2 have failed")
+            Ping_Result = main.FALSE
+        elif ping==main.TRUE:
+            main.log.info("Ping test between h1 and h2 passed!")
+            Ping_Result = main.TRUE
+        else:
+            main.log.info("Unknown error")
+            Ping_Result = main.ERROR
+        
+        if Ping_Result==main.FALSE:
+            main.log.report("Point intents for packet optical have not ben installed correctly. Cleaning up")
+        if Ping_Result==main.TRUE:
+            main.log.report("Point Intents for packet optical have been installed correctly")
+
+        case23_result = Ping_Result
+        utilities.assert_equals(expect=main.TRUE, actual=case23_result,
+                onpass="Point intents addition for packet optical and Pingall Test successful",
+                onfail="Point intents addition for packet optical and Pingall Test NOT successful")
+
+
+
+
 
     def CASE4(self, main):
         import re
@@ -235,17 +449,33 @@
         else:
             main.log.report("Pingall Test in reactive mode to discover the hosts failed")
 
-        utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall T        est successful",onfail="Controller assignment and Pingall Test NOT successful")   
+        utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")   
+
+    def CASE10(self):
+        main.log.report("This testcase uninstalls the reactive forwarding app")
+        main.log.report("__________________________________")
+        main.case("Uninstalling reactive forwarding app")
+        #Unistall onos-app-fwd app to disable reactive forwarding
+        appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
+        main.log.info("onos-app-fwd uninstalled")
+
+        #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+        #So sleep for 15s
+        time.sleep(15)
+
+        flows = main.ONOS2.flows()
+        main.log.info(flows)
+
+        case10_result = appUninstall_result
+        utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed") 
 
     
     def CASE6(self):
-        main.log.report("This testcase is testing the addition of host intents and then doing pingall")
+        main.log.report("This testcase is testing the addition of host intents and then does pingall")
         main.log.report("__________________________________")
-        main.case("Uninstalling reactive forwarding app and addhost intents")
+        main.case("Obtaining host id's")
         main.step("Get hosts")
-        main.ONOS2.handle.sendline("hosts")
-        main.ONOS2.handle.expect("onos>")
-        hosts = main.ONOS2.handle.before
+        hosts = main.ONOS2.hosts()
         main.log.info(hosts)
 
         main.step("Get all devices id")
@@ -254,7 +484,7 @@
         
         #ONOS displays the hosts in hex format unlike mininet which does in decimal format
         #So take care while adding intents
-        
+        '''
         main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
         hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
         hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
@@ -266,22 +496,24 @@
         hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
         hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1") 
         hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
-
- 
-        
         print "_____________________________________________________________________________________"
+        '''
         
-        #Unistall onos-app-fwd app to disable reactive forwarding
-        appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
-        main.log.info("onos-app-fwd uninstalled")
+        for i in range(8,18):
+            main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+            #NOTE: get host can return None
+            #TODO: handle this
+            host1_id = main.ONOS2.get_host(host1)['id']
+            host2_id = main.ONOS2.get_host(host2)['id']
+            tmp_result = main.ONOS2.add_host_intent(host1_id, host2_id )        
 
-        #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
-        #So sleep for 15s
-        time.sleep(15)
-        
+        time.sleep(10)
+        h_intents = main.ONOS2.intents()
+        main.log.info("intents:" +h_intents)
         flowHandle = main.ONOS2.flows()
-        #print "flowHandle = ", flowHandle
-        main.log.info("flow:" +flowHandle)
+        #main.log.info("flow:" +flowHandle)
 
         count = 1
         i = 8
@@ -315,7 +547,7 @@
             main.log.report("Ping all test after Host intent addition successful")
             
         case6_result = Ping_Result
-        utilities.assert_equals(expect=main.TRUE, actual=case4_result,
+        utilities.assert_equals(expect=main.TRUE, actual=case6_result,
                 onpass="Pingall Test after Host intents addition successful",
                 onfail="Pingall Test after Host intents addition failed")
 
@@ -413,6 +645,7 @@
         main.log.report("__________________________________")
         main.log.report("Killing a link to ensure that link discovery is consistent")
         main.case("Killing a link to Ensure that Link Discovery is Working Properly")
+        '''
         main.step("Start continuous pings")
        
         main.Mininet2.pingLong(src=main.params['PING']['source1'],
@@ -435,7 +668,7 @@
                             target=main.params['PING']['target9'],pingTime=500)
         main.Mininet2.pingLong(src=main.params['PING']['source10'],
                             target=main.params['PING']['target10'],pingTime=500)
-
+        '''
 
         main.step("Determine the current number of switches and links")
         topology_output = main.ONOS2.topology()
@@ -470,30 +703,9 @@
                 onpass="Link up discovered properly",
                 onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
             
-        #Check ping result here..add code for it
-        main.step("Start continuous pings")
-       
-        main.Mininet2.pingLong(src=main.params['PING']['source1'],
-                            target=main.params['PING']['target1'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source2'],
-                            target=main.params['PING']['target2'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source3'],
-                            target=main.params['PING']['target3'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source4'],
-                            target=main.params['PING']['target4'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source5'],
-                            target=main.params['PING']['target5'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source6'],
-                            target=main.params['PING']['target6'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source7'],
-                            target=main.params['PING']['target7'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source8'],
-                            target=main.params['PING']['target8'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source9'],
-                            target=main.params['PING']['target9'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source10'],
-                            target=main.params['PING']['target10'],pingTime=500)
-
+        #NOTE Check ping result here..add code for it
+        
+        
         main.step("Compare ONOS Topology to MN Topology")
         Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
         MNTopo = Topo
@@ -532,19 +744,22 @@
         '''
         Host intents removal
         ''' 
-        main.log.report("This testcase removes host intents before adding the point intents")
+        main.log.report("This testcase removes host intents before adding the same intents or point intents")
         main.log.report("__________________________________")        
         main.log.info("Host intents removal")
         main.case("Removing host intents")
         main.step("Obtain the intent id's")
         intent_result = main.ONOS2.intents()
         #print "intent_result = ",intent_result
+        
         intent_linewise = intent_result.split("\n")
-        intent_linewise = intent_linewise[1:-1] #ignore the first and last item of the list obtained from split 
-        #for line in intent_linewise:
-            #print "line = ", line
-        intentids = []
+        intentList = []
         for line in intent_linewise:
+            if line.startswith("id="):
+                intentList.append(line)
+        
+        intentids = []
+        for line in intentList:
             intentids.append(line.split(",")[0].split("=")[1])
         for id in intentids:
             print "id = ", id
@@ -555,10 +770,13 @@
         
         intent_result = main.ONOS2.intents()
         intent_linewise = intent_result.split("\n")
-        intent_linewise = intent_linewise[1:-1] #ignore the first and last item of the list obtained from split 
-        
+        list_afterRemoval = []
+        for line in intent_linewise:
+            if line.startswith("id="):
+                list_afterRemoval.append(line)
+
         intentState = {}
-        for id, line in zip(intentids, intent_linewise):
+        for id, line in zip(intentids, list_afterRemoval):
             #print "line after removing intent = ", line
             x = line.split(",")
             state = x[1].split("=")[1]
@@ -576,13 +794,41 @@
             main.log.report("Intent removal successful")
         else:
             main.log.report("Intent removal failed")
-                        
-        utilities.assert_equals(expect=main.TRUE, actual=case8_result,
-                onpass="Intent removal test successful",
-                onfail="Intent removal test failed")
+       
+        Ping_Result = main.TRUE
+        if case8_result == main.TRUE:
+            i = 8
+            while i <18 :
+                main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
+                ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+                if ping==main.TRUE:
+                    i = 19
+                    Ping_Result = Ping_Result and main.TRUE
+                elif ping==main.FALSE:
+                    i+=1
+                    Ping_Result = Ping_Result and main.FALSE
+                else:
+                    main.log.info("Unknown error")
+                    Ping_Result = main.ERROR
 
+            #Note: If the ping result failed, that means the intents have been withdrawn correctly.
+        if Ping_Result==main.TRUE:
+            main.log.report("Host intents have not been withdrawn correctly")
+            #main.cleanup()
+            #main.exit()
+        if Ping_Result==main.FALSE:
+            main.log.report("Host intents have been withdrawn correctly")
 
-   
+        case8_result = case8_result and Ping_Result
+
+        if case8_result == main.FALSE:
+            main.log.report("Intent removal successful")
+        else:
+            main.log.report("Intent removal failed")
+
+        utilities.assert_equals(expect=main.FALSE, actual=case8_result,
+                onpass="Intent removal test failed",
+                onfail="Intent removal test passed")
 
 
     def CASE9(self):
@@ -591,135 +837,135 @@
         main.log.info("Adding point intents")
         main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)") 
         main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008", 1, "of:0000000000006018", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018", 1, "of:0000000000003008", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
         main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009", 1, "of:0000000000006019", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019", 1, "of:0000000000003009", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
         
         main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010", 1, "of:0000000000006020", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020", 1, "of:0000000000003010", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
 
         main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011", 1, "of:0000000000006021", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021", 1, "of:0000000000003011", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012", 1, "of:0000000000006022", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022", 1, "of:0000000000003012", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013", 1, "of:0000000000006023", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023", 1, "of:0000000000003013", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
 
         main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014", 1, "of:0000000000006024", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024", 1, "of:0000000000003014", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015", 1, "of:0000000000006025", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025", 1, "of:0000000000003015", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016", 1, "of:0000000000006026", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026", 1, "of:0000000000003016", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
 
 
         main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017", 1, "of:0000000000006027", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027", 1, "of:0000000000003017", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
 
         print("_______________________________________________________________________________________")
 
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.params b/TestON/tests/ProdFunc13/ProdFunc13.params
index 9b44a53..a77dd02 100755
--- a/TestON/tests/ProdFunc13/ProdFunc13.params
+++ b/TestON/tests/ProdFunc13/ProdFunc13.params
@@ -1,6 +1,6 @@
 <PARAMS>
     
-    <testcases>1,4,5,6,7,8,9</testcases>
+    <testcases>1,4,10,5,6,7,8,6,8,9,20,21,22,10,23,24</testcases>
 
     #Environment variables
     <ENV>
@@ -40,4 +40,10 @@
         <SwitchDiscovery>31</SwitchDiscovery>
     </timers>
 
+    <OPTICAL>
+        <jsonfile> /home/admin/ONOS/tools/test/topos/oe-nonlinear-4.json </jsonfile>
+    </OPTICAL>    
+
+
+
 </PARAMS>
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.py b/TestON/tests/ProdFunc13/ProdFunc13.py
index 63a15cc..205bfb8 100755
--- a/TestON/tests/ProdFunc13/ProdFunc13.py
+++ b/TestON/tests/ProdFunc13/ProdFunc13.py
@@ -6,7 +6,6 @@
 import sys
 import os
 import re
-import time
 import json
 
 time.sleep(1)
@@ -17,11 +16,12 @@
     def CASE1(self, main):
         '''
         Startup sequence:
+        cell <name>
+        onos-verify-cell
+        onos-remove-raft-log
         git pull
         mvn clean install
         onos-package
-        cell <name>
-        onos-verify-cell
         onos-install -f
         onos-wait-for-start
         '''
@@ -33,6 +33,17 @@
         main.case("Setting up test environment")
         main.log.report("This testcase is testing setting up test environment")
         main.log.report("__________________________________") 
+
+        main.step("Applying cell variable to environment")
+        cell_result1 = main.ONOSbench.set_cell(cell_name)
+        verify_result = main.ONOSbench.verify_cell()
+        cell_result2 = main.ONOS2.set_cell(cell_name)
+        verify_result = main.ONOS2.verify_cell()
+        cell_result = cell_result1 and cell_result2
+        
+        main.step("Removing raft logs before a clen installation of ONOS")
+        main.ONOSbench.onos_remove_raft_logs()
+
         main.step("Git checkout and pull master and get version")
         main.ONOSbench.git_checkout("master")
         git_pull_result = main.ONOSbench.git_pull()
@@ -43,21 +54,10 @@
             main.step("Using mvn clean & install")
             clean_install_result = main.ONOSbench.clean_install()
             #clean_install_result = main.TRUE
-        
-        main.step("Applying cell variable to environment")
-        cell_result1 = main.ONOSbench.set_cell(cell_name)
-        verify_result = main.ONOSbench.verify_cell()
-        cell_result2 = main.ONOS2.set_cell(cell_name)
-        #verify_result = main.ONOS2.verify_cell()
-        main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
-        
-        cell_result = cell_result1 and cell_result2
-
+         
         main.step("Creating ONOS package")
         package_result = main.ONOSbench.onos_package()
 
-        #main.step("Creating a cell")
-        #cell_create_result = main.ONOSbench.create_cell_file(**************)
 
         main.step("Installing ONOS package")
         onos_install_result = main.ONOSbench.onos_install()
@@ -74,6 +74,8 @@
        
         main.step("Starting ONOS service")
         start_result = main.ONOSbench.onos_start(ONOS1_ip)
+        
+        main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])        
 
         case1_result = (package_result and\
                 cell_result and verify_result and onos_install_result and\
@@ -125,6 +127,273 @@
         main.log.info("onos command returned: "+cmd_result2)
 
 
+    def CASE20(self):
+        '''
+            Exit from mininet cli
+            reinstall ONOS
+        '''
+        main.log.report("This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology")
+        main.log.report("_____________________________________________")
+        main.step("Disconnecting mininet and restarting ONOS")
+        main.step("Disconnecting mininet and restarting ONOS")
+        mininet_disconnect = main.Mininet1.disconnect()
+
+        main.step("Applying cell variable to environment")
+        cell_result1 = main.ONOSbench.set_cell(cell_name)
+        verify_result = main.ONOSbench.verify_cell()
+        cell_result2 = main.ONOS2.set_cell(cell_name)
+        verify_result = main.ONOS2.verify_cell()
+        cell_result = cell_result1 and cell_result2
+
+        onos_install_result = main.ONOSbench.onos_install()
+        if onos_install_result == main.TRUE:
+            main.log.report("Installing ONOS package successful")
+        else:
+            main.log.report("Installing ONOS package failed")
+
+        onos1_isup = main.ONOSbench.isup()
+        if onos1_isup == main.TRUE:
+            main.log.report("ONOS instance is up and ready")
+        else:
+            main.log.report("ONOS instance may not be up")
+
+        main.step("Starting ONOS service")
+        start_result = main.ONOSbench.onos_start(ONOS1_ip)
+       
+        print "mininet_disconnect =", mininet_disconnect
+        print "onos_install_result =", onos_install_result
+        print "onos1_isup =", onos1_isup
+        print "start_result =", start_result
+ 
+        case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
+        utilities.assert_equals(expect=main.TRUE, actual=case20_result,
+                onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
+                onfail="Exiting functionality mininet topology and reinstalling ONOS failed") 
+
+    def CASE21(self, main):
+        import time
+        '''
+            On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
+            which starts the rest and copies the links json file to the onos instance
+            Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt 
+            from the json config file
+        ''' 
+        main.log.report("This testcase starts the packet layer topology and REST")
+        main.log.report("_____________________________________________")
+        main.case("Starting LINC-OE and other components")
+        main.step("Starting LINC-OE and other components")
+        start_console_result = main.LincOE1.start_console()
+        optical_mn_script = main.LincOE2.run_optical_mn_script()
+        onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(instance_name = main.params['CTRL']['ip1'], json_file = main.params['OPTICAL']['jsonfile'])
+            
+        print "start_console_result =",start_console_result 
+        print "optical_mn_script = ",optical_mn_script 
+        print "onos_topo_cfg_result =",onos_topo_cfg_result 
+
+        case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result
+        utilities.assert_equals(expect=main.TRUE, actual=case21_result,
+                onpass="Packet optical topology spawned successsfully",
+                onfail="Packet optical topology spawning failed") 
+
+
+    def CASE22(self, main):
+        '''
+            Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host.
+             Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2
+            and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed
+        '''
+
+        main.log.report("This testcase compares the optical+packet topology against what is expected")
+        main.case("Topology comparision")
+        main.step("Topology comparision")
+        main.ONOS3.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+        devices_result = main.ONOS3.devices(json_format = False)
+
+        print "devices_result = ", devices_result
+        devices_linewise = devices_result.split("\n")
+        devices_linewise = devices_linewise[1:-1]
+        roadmCount = 0
+        packetLayerSWCount = 0
+        for line in devices_linewise:
+            components = line.split(",")
+            availability = components[1].split("=")[1]
+            type = components[3].split("=")[1]
+            if availability == 'true' and type == 'ROADM':
+                roadmCount += 1
+            elif availability == 'true' and type =='SWITCH':
+                packetLayerSWCount += 1
+        if roadmCount == 4:
+            print "Number of Optical Switches = %d and is correctly detected" %roadmCount
+            main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is correctly detected")
+            opticalSW_result = main.TRUE
+        else:
+            print "Number of Optical Switches = %d and is wrong" %roadCount
+            main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is wrong")
+            opticalSW_result = main.FALSE
+
+        if packetLayerSWCount == 2:
+            print "Number of Packet layer or mininet Switches = %d and is correctly detected" %packetLayerSWCount
+            main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is correctly detected")
+            packetSW_result = main.TRUE
+        else:
+            print "Number of Packet layer or mininet Switches = %d and is wrong" %packetLayerSWCount
+            main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is wrong")
+            packetSW_result = main.FALSE
+        print "_________________________________"
+        
+        links_result = main.ONOS3.links(json_format = False)
+        print "links_result = ", links_result
+        print "_________________________________"
+        
+
+
+        #Discover hosts using pingall
+        pingall_result = main.LincOE2.pingall()    
+    
+        hosts_result = main.ONOS3.hosts(json_format = False)
+        main.log.info("hosts_result = "+hosts_result)   
+        main.log.info("_________________________________")
+        hosts_linewise = hosts_result.split("\n")
+        hosts_linewise = hosts_linewise[1:-1]
+        hostCount = 0
+        for line in hosts_linewise:
+            hostid = line.split(",")[0].split("=")[1]
+            hostCount +=1
+        if hostCount ==2:
+            print "Number of hosts = %d and is correctly detected" %hostCount
+            main.log.info("Number of hosts = " + str(hostCount) +" and is correctly detected")
+            hostDiscovery = main.TRUE
+        else:
+            print "Number of hosts = %d and is wrong" %hostCount
+            main.log.info("Number of hosts = " + str(hostCount) +" and is wrong")
+            hostDiscovery = main.FALSE
+        
+        case22_result = opticalSW_result and packetSW_result and hostDiscovery
+        utilities.assert_equals(expect=main.TRUE, actual=case22_result,
+                onpass="Packet optical topology discovery successful",
+                onfail="Packet optical topology discovery failed")
+
+    def CASE23(self, main):
+        import time
+        '''
+            Add bidirectional point intents between 2 packet layer(mininet) devices and 
+            ping mininet hosts
+        '''
+        main.log.report("This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts")
+        main.case("Topology comparision")
+        main.step("Adding point intents")
+        ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0001/1", "of:0000ffffffff0002/1")
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS3.intents()
+            main.log.info("Point to point intent install successful")
+            main.log.info(get_intent_result)
+
+        ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0002/1", "of:0000ffffffff0001/1")
+        if ptp_intent_result == main.TRUE:
+            get_intent_result = main.ONOS3.intents()
+            main.log.info("Point to point intent install successful")
+            main.log.info(get_intent_result)
+
+        time.sleep(10)
+        flowHandle = main.ONOS3.flows()
+        main.log.info("flows :" + flowHandle)
+
+        # Sleep for 30 seconds to provide time for the intent state to change
+        time.sleep(30)
+        intentHandle = main.ONOS3.intents()        
+        main.log.info("intents :" + intentHandle)        
+ 
+        Ping_Result = main.TRUE
+        count = 1
+        main.log.info("\n\nh1 is Pinging h2")
+        ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+        #ping = main.LincOE2.pinghost()
+        if ping == main.FALSE and count<5:
+            count+=1
+            Ping_Result = main.FALSE
+            main.log.info("Ping between h1 and h2  failed. Making attempt number "+str(count) + " in 2 seconds")
+            time.sleep(2)
+            ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+            #ping = main.LincOE2.pinghost()
+        elif ping==main.FALSE:
+            main.log.info("All ping attempts between h1 and h2 have failed")
+            Ping_Result = main.FALSE
+        elif ping==main.TRUE:
+            main.log.info("Ping test between h1 and h2 passed!")
+            Ping_Result = main.TRUE
+        else:
+            main.log.info("Unknown error")
+            Ping_Result = main.ERROR
+        
+        if Ping_Result==main.FALSE:
+            main.log.report("Point intents for packet optical have not ben installed correctly. Cleaning up")
+        if Ping_Result==main.TRUE:
+            main.log.report("Point Intents for packet optical have been installed correctly")
+
+        case23_result = Ping_Result
+        utilities.assert_equals(expect=main.TRUE, actual=case23_result,
+                onpass="Point intents addition for packet optical and Pingall Test successful",
+                onfail="Point intents addition for packet optical and Pingall Test NOT successful")
+
+
+
+    def CASE24(self, main):
+        import time
+        '''
+            Test Rerouting of Packet Optical by bringing a port down (port 22) of a switch(switchID=1), so that link (between switch1 port22 - switch4-port30) is inactive
+            and do a ping test. If rerouting is successful, ping should pass. also check the flows
+        '''
+        main.log.report("This testcase tests rerouting and pings mininet hosts")
+        main.step("Test rerouting and pings mininet hosts")
+        main.case("Bring a port down and verify the link state")
+        main.LincOE1.port_down(sw_id=1, pt_id=22) 
+        links_result = main.ONOS3.links()
+        links_state_result = main.FALSE
+        for item in links_result:
+            if item('src') == "of:0000ffffffffff01/22" and item('dst') == "of:0000ffffffffff04/30":
+                links_state = item('state')
+                if links_state == "INACTIVE":
+                    main.log.info("Links state is inactive as expected due to one of the ports being down")
+                    main.log.report("Links state is inactive as expected due to one of the ports being down")
+                    links_state_result = main.TRUE
+                    break
+                else:
+                    main.log.info("Links state is not inactive as expected")
+                    main.log.report("Links state is not inactive as expected")
+                    links_state_result = main.FALSE
+
+        main.case("Verify Rerouting by a ping test")
+        Ping_Result = main.TRUE
+        count = 1
+        main.log.info("\n\nh1 is Pinging h2")
+        ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+        #ping = main.LincOE2.pinghost()
+        if ping == main.FALSE and count<5:
+            count+=1
+            Ping_Result = main.FALSE
+            main.log.info("Ping between h1 and h2  failed. Making attempt number "+str(count) + " in 2 seconds")
+            time.sleep(2)
+            ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+            #ping = main.LincOE2.pinghost()
+        elif ping==main.FALSE:
+            main.log.info("All ping attempts between h1 and h2 have failed")
+            Ping_Result = main.FALSE
+        elif ping==main.TRUE:
+            main.log.info("Ping test between h1 and h2 passed!")
+            Ping_Result = main.TRUE
+        else:
+            main.log.info("Unknown error")
+            Ping_Result = main.ERROR
+
+        if Ping_Result==main.FALSE:
+            main.log.report("Ping test successful ")
+        if Ping_Result==main.TRUE:
+            main.log.report("Ping test failed")
+
+        case24_result = Ping_Result and links_state_result
+        utilities.assert_equals(expect=main.TRUE, actual=case24_result,
+                onpass="Packet optical rerouting successful",
+                onfail="Packet optical rerouting failed")
 
     def CASE4(self, main):
         import re
@@ -235,17 +504,33 @@
         else:
             main.log.report("Pingall Test in reactive mode to discover the hosts failed")
 
-        utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall T        est successful",onfail="Controller assignment and Pingall Test NOT successful")   
+        utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")   
+
+    def CASE10(self):
+        main.log.report("This testcase uninstalls the reactive forwarding app")
+        main.log.report("__________________________________")
+        main.case("Uninstalling reactive forwarding app")
+        #Unistall onos-app-fwd app to disable reactive forwarding
+        appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
+        main.log.info("onos-app-fwd uninstalled")
+
+        #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+        #So sleep for 15s
+        time.sleep(15)
+
+        flows = main.ONOS2.flows()
+        main.log.info(flows)
+
+        case10_result = appUninstall_result
+        utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed") 
 
     
     def CASE6(self):
-        main.log.report("This testcase is testing the addition of host intents and then doing pingall")
+        main.log.report("This testcase is testing the addition of host intents and then does pingall")
         main.log.report("__________________________________")
-        main.case("Uninstalling reactive forwarding app and addhost intents")
+        main.case("Obtaining host id's")
         main.step("Get hosts")
-        main.ONOS2.handle.sendline("hosts")
-        main.ONOS2.handle.expect("onos>")
-        hosts = main.ONOS2.handle.before
+        hosts = main.ONOS2.hosts()
         main.log.info(hosts)
 
         main.step("Get all devices id")
@@ -254,7 +539,7 @@
         
         #ONOS displays the hosts in hex format unlike mininet which does in decimal format
         #So take care while adding intents
-        
+        '''
         main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
         hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
         hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
@@ -266,22 +551,24 @@
         hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
         hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1") 
         hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
-
- 
-        
         print "_____________________________________________________________________________________"
+        '''
         
-        #Unistall onos-app-fwd app to disable reactive forwarding
-        appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
-        main.log.info("onos-app-fwd uninstalled")
+        for i in range(8,18):
+            main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+            #NOTE: get host can return None
+            #TODO: handle this
+            host1_id = main.ONOS2.get_host(host1)['id']
+            host2_id = main.ONOS2.get_host(host2)['id']
+            tmp_result = main.ONOS2.add_host_intent(host1_id, host2_id )        
 
-        #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
-        #So sleep for 15s
-        time.sleep(15)
-        
+        time.sleep(10)
+        h_intents = main.ONOS2.intents()
+        main.log.info("intents:" +h_intents)
         flowHandle = main.ONOS2.flows()
-        #print "flowHandle = ", flowHandle
-        main.log.info("flow:" +flowHandle)
+        #main.log.info("flow:" +flowHandle)
 
         count = 1
         i = 8
@@ -315,7 +602,7 @@
             main.log.report("Ping all test after Host intent addition successful")
             
         case6_result = Ping_Result
-        utilities.assert_equals(expect=main.TRUE, actual=case4_result,
+        utilities.assert_equals(expect=main.TRUE, actual=case6_result,
                 onpass="Pingall Test after Host intents addition successful",
                 onfail="Pingall Test after Host intents addition failed")
 
@@ -413,6 +700,7 @@
         main.log.report("__________________________________")
         main.log.report("Killing a link to ensure that link discovery is consistent")
         main.case("Killing a link to Ensure that Link Discovery is Working Properly")
+        '''
         main.step("Start continuous pings")
        
         main.Mininet2.pingLong(src=main.params['PING']['source1'],
@@ -435,7 +723,7 @@
                             target=main.params['PING']['target9'],pingTime=500)
         main.Mininet2.pingLong(src=main.params['PING']['source10'],
                             target=main.params['PING']['target10'],pingTime=500)
-
+        '''
 
         main.step("Determine the current number of switches and links")
         topology_output = main.ONOS2.topology()
@@ -470,30 +758,9 @@
                 onpass="Link up discovered properly",
                 onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
             
-        #Check ping result here..add code for it
-        main.step("Start continuous pings")
-       
-        main.Mininet2.pingLong(src=main.params['PING']['source1'],
-                            target=main.params['PING']['target1'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source2'],
-                            target=main.params['PING']['target2'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source3'],
-                            target=main.params['PING']['target3'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source4'],
-                            target=main.params['PING']['target4'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source5'],
-                            target=main.params['PING']['target5'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source6'],
-                            target=main.params['PING']['target6'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source7'],
-                            target=main.params['PING']['target7'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source8'],
-                            target=main.params['PING']['target8'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source9'],
-                            target=main.params['PING']['target9'],pingTime=500)
-        main.Mininet2.pingLong(src=main.params['PING']['source10'],
-                            target=main.params['PING']['target10'],pingTime=500)
-
+        #NOTE Check ping result here..add code for it
+        
+        
         main.step("Compare ONOS Topology to MN Topology")
         Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
         MNTopo = Topo
@@ -532,19 +799,22 @@
         '''
         Host intents removal
         ''' 
-        main.log.report("This testcase removes host intents before adding the point intents")
+        main.log.report("This testcase removes host intents before adding the same intents or point intents")
         main.log.report("__________________________________")        
         main.log.info("Host intents removal")
         main.case("Removing host intents")
         main.step("Obtain the intent id's")
         intent_result = main.ONOS2.intents()
         #print "intent_result = ",intent_result
+        
         intent_linewise = intent_result.split("\n")
-        intent_linewise = intent_linewise[1:-1] #ignore the first and last item of the list obtained from split 
-        #for line in intent_linewise:
-            #print "line = ", line
-        intentids = []
+        intentList = []
         for line in intent_linewise:
+            if line.startswith("id="):
+                intentList.append(line)
+        
+        intentids = []
+        for line in intentList:
             intentids.append(line.split(",")[0].split("=")[1])
         for id in intentids:
             print "id = ", id
@@ -555,10 +825,13 @@
         
         intent_result = main.ONOS2.intents()
         intent_linewise = intent_result.split("\n")
-        intent_linewise = intent_linewise[1:-1] #ignore the first and last item of the list obtained from split 
-        
+        list_afterRemoval = []
+        for line in intent_linewise:
+            if line.startswith("id="):
+                list_afterRemoval.append(line)
+
         intentState = {}
-        for id, line in zip(intentids, intent_linewise):
+        for id, line in zip(intentids, list_afterRemoval):
             #print "line after removing intent = ", line
             x = line.split(",")
             state = x[1].split("=")[1]
@@ -576,13 +849,41 @@
             main.log.report("Intent removal successful")
         else:
             main.log.report("Intent removal failed")
-                        
-        utilities.assert_equals(expect=main.TRUE, actual=case8_result,
-                onpass="Intent removal test successful",
-                onfail="Intent removal test failed")
+       
+        Ping_Result = main.TRUE
+        if case8_result == main.TRUE:
+            i = 8
+            while i <18 :
+                main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
+                ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+                if ping==main.TRUE:
+                    i = 19
+                    Ping_Result = Ping_Result and main.TRUE
+                elif ping==main.FALSE:
+                    i+=1
+                    Ping_Result = Ping_Result and main.FALSE
+                else:
+                    main.log.info("Unknown error")
+                    Ping_Result = main.ERROR
 
+            #Note: If the ping result failed, that means the intents have been withdrawn correctly.
+        if Ping_Result==main.TRUE:
+            main.log.report("Host intents have not been withdrawn correctly")
+            #main.cleanup()
+            #main.exit()
+        if Ping_Result==main.FALSE:
+            main.log.report("Host intents have been withdrawn correctly")
 
-   
+        case8_result = case8_result and Ping_Result
+
+        if case8_result == main.FALSE:
+            main.log.report("Intent removal successful")
+        else:
+            main.log.report("Intent removal failed")
+
+        utilities.assert_equals(expect=main.FALSE, actual=case8_result,
+                onpass="Intent removal test failed",
+                onfail="Intent removal test passed")
 
 
     def CASE9(self):
@@ -591,135 +892,135 @@
         main.log.info("Adding point intents")
         main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)") 
         main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008", 1, "of:0000000000006018", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018", 1, "of:0000000000003008", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
         main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009", 1, "of:0000000000006019", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019", 1, "of:0000000000003009", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
         
         main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010", 1, "of:0000000000006020", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020", 1, "of:0000000000003010", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
 
         main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011", 1, "of:0000000000006021", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021", 1, "of:0000000000003011", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012", 1, "of:0000000000006022", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022", 1, "of:0000000000003012", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013", 1, "of:0000000000006023", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023", 1, "of:0000000000003013", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
 
         main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014", 1, "of:0000000000006024", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024", 1, "of:0000000000003014", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015", 1, "of:0000000000006025", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025", 1, "of:0000000000003015", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
             
         main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016", 1, "of:0000000000006026", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026", 1, "of:0000000000003016", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
 
 
         main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017", 1, "of:0000000000006027", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
        
-        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027", 1, "of:0000000000003017", 1)
+        ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
         if ptp_intent_result == main.TRUE:
             get_intent_result = main.ONOS2.intents()
             main.log.info("Point to point intent install successful")
-            main.log.info(get_intent_result)
+            #main.log.info(get_intent_result)
 
         print("_______________________________________________________________________________________")
 
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.topo b/TestON/tests/ProdFunc13/ProdFunc13.topo
index cf6ffac..c592e18 100755
--- a/TestON/tests/ProdFunc13/ProdFunc13.topo
+++ b/TestON/tests/ProdFunc13/ProdFunc13.topo
@@ -28,12 +28,22 @@
             <COMPONENTS> </COMPONENTS>
         </ONOS2>
 
+         <ONOS3>
+            <host>10.128.10.11</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>4</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS3>
+       
+
         <Mininet1>
             <host>10.128.10.11</host>
             <user>admin</user>
             <password>onos_test</password>
             <type>MininetCliDriver</type>
-            <connect_order>4</connect_order>
+            <connect_order>5</connect_order>
             <COMPONENTS>
                 #Specify the Option for mininet
                 <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
@@ -48,7 +58,7 @@
             <user>admin</user>
             <password>onos_test</password>
             <type>RemoteMininetDriver</type>
-            <connect_order>5</connect_order>
+            <connect_order>6</connect_order>
             <COMPONENTS>
                 #Specify the Option for mininet
                 <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
@@ -57,5 +67,37 @@
                 <controller> remote </controller>
             </COMPONENTS>
         </Mininet2>
+
+        <LincOE1>
+            <host>10.128.20.30</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>LincOEDriver</type>
+            <connect_order>7</connect_order>
+            <COMPONENTS>
+                <arg1> </arg1>
+            </COMPONENTS>
+        </LincOE1>
+
+        <LincOE2>
+            <host>10.128.20.30</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>RemoteMininetDriver</type>
+            <connect_order>8</connect_order>
+            <COMPONENTS>
+                <arg1> sudo python /home/admin/optical.py </arg1>
+                <arg2> </arg2>
+            </COMPONENTS>
+        </LincOE2>
+
+        <LincOE3>
+            <host>10.128.20.30</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>LincOEDriver</type>
+            <connect_order>9</connect_order>
+        </LincOE3>
+ 
     </COMPONENT>
 </TOPOLOGY>
diff --git a/TestON/tests/SdnIpTest/SdnIpTest.py b/TestON/tests/SdnIpTest/SdnIpTest.py
index dd73766..543bea2 100755
--- a/TestON/tests/SdnIpTest/SdnIpTest.py
+++ b/TestON/tests/SdnIpTest/SdnIpTest.py
@@ -1,3 +1,4 @@
+from cupshelpers.config import prefix
 
 #Testing the basic functionality of SDN-IP
 
@@ -24,38 +25,51 @@
         SDNIP_JSON_FILE_PATH = "../tests/SdnIpTest/sdnip.json"
         # all expected routes for all BGP peers
         allRoutes_expected = []
-        main.step("Start to generate routes for BGP peer on host1")
-        prefixes = main.Quaggacli.generate_prefixes(1, 3)
-        main.log.info(prefixes)
+        main.step("Start to generate routes for all BGP peers")
+        #bgpPeerHosts = []
+        #for i in range(3, 5):
+        #    bgpPeerHosts.append("host" + str(i))
+        #main.log.info("BGP Peer Hosts are:" + bgpPeerHosts)
 
-        # TODO: delete the static prefix below after integration with Demo Mininet script
-        prefixes = []
-        prefixes.append("172.16.30.0/24")
-        prefixes.append("1.0.0.0/24")
-        prefixes.append("2.0.0.0/24")
-        prefixes.append("3.0.0.0/24")
+        #for i in range(3, 5):
+         #   QuaggaCliHost = "QuaggaCliHost" + str(i)
+          #  prefixes = main.QuaggaCliHost.generate_prefixes(3, 10)
 
+           # main.log.info(prefixes)
+            #allRoutes_expected.append(prefixes)
+        main.log.info("Generate prefixes for host3")
+        prefixes_host3 = main.QuaggaCliHost3.generate_prefixes(3, 10)
+        main.log.info(prefixes_host3)
+        # generate route with next hop
+        for prefix in prefixes_host3:
+            allRoutes_expected.append(prefix + "/" + "192.168.20.1")
+        routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents(prefixes_host3, "192.168.20.1", "00:00:00:00:02:02", SDNIP_JSON_FILE_PATH)
 
-        for prefix in prefixes:
-            # generate route with next hop
-            allRoutes_expected.append(prefix + "/" + "1.1.1.1")
+        main.log.info("Generate prefixes for host4")
+        prefixes_host4 = main.QuaggaCliHost4.generate_prefixes(4, 10)
+        main.log.info(prefixes_host4)
+        # generate route with next hop
+        for prefix in prefixes_host4:
+            allRoutes_expected.append(prefix + "/" + "192.168.30.1")
+        routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents(prefixes_host4, "192.168.30.1", "00:00:00:00:03:01", SDNIP_JSON_FILE_PATH)
 
-        routeIntents_expected = main.Quaggacli.generate_expected_onePeerRouteIntents(prefixes, "192.168.30.1", "00:00:00:00:03:01", SDNIP_JSON_FILE_PATH)
+        routeIntents_expected = routeIntents_expected_host3 + routeIntents_expected_host4
 
-        # start to insert routes into the bgp peer
-        main.step("Start Quagga-cli on host1")
-        main.Quaggacli.loginQuagga("1.1.1.1")
+        main.step("Login all BGP peers and add routes into peers")
+        main.log.info("Login Quagga CLI on host3")
+        main.QuaggaCliHost3.loginQuagga("1.168.30.2")
+        main.log.info("Enter configuration model of Quagga CLI on host3")
+        main.QuaggaCliHost3.enter_config(64514)
+        main.log.info("Add routes to Quagga on host3")
+        main.QuaggaCliHost3.add_routes(prefixes_host3, 1)
 
-        main.step("Start to configure Quagga on host1")
-        main.Quaggacli.enter_config(64513)
-    
-        main.step("Start to generate and add routes for BGP peer on host1")
-        routes = main.Quaggacli.generate_prefixes(8, 3)
-        main.Quaggacli.add_routes(routes, 1)
-             
-        # add generates routes to allRoutes
-        for route in routes:
-            allRoutes_expected.append(route + "/" + "1.1.1.1")
+        main.log.info("Login Quagga CLI on host4")
+        main.QuaggaCliHost4.loginQuagga("1.168.30.3")
+        main.log.info("Enter configuration model of Quagga CLI on host4")
+        main.QuaggaCliHost4.enter_config(64516)
+        main.log.info("Add routes to Quagga on host4")
+        main.QuaggaCliHost4.add_routes(prefixes_host4, 1)
+
 
         cell_name = main.params['ENV']['cellName']
         ONOS1_ip = main.params['CTRL']['ip1']
@@ -77,42 +91,46 @@
         main.log.info(list_result)
 
         #get all routes inside SDN-IP
-        get_routes_result = main.ONOScli.routes(json_format=True)  
+        get_routes_result = main.ONOScli.routes(json_format=True)
                      
         # parse routes from ONOS CLI
-        allRoutes_actual = main.Quaggacli.extract_actual_routes(get_routes_result)
+        allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
       
+        allRoutes_str_expected = str(sorted(allRoutes_expected))
+        allRoutes_str_actual = str(allRoutes_actual).replace('u',"")
         main.step("Check routes installed")
         main.log.info("Routes expected:")
-        main.log.info(sorted(allRoutes_expected))
+        main.log.info(allRoutes_str_expected)
         main.log.info("Routes get from ONOS CLI:")
-        main.log.info(allRoutes_actual)
-        utilities.assert_equals(expect=sorted(allRoutes_expected), actual=allRoutes_actual,
+        main.log.info(allRoutes_str_actual)
+        utilities.assert_equals(expect=allRoutes_str_expected, actual=allRoutes_str_actual,
                                 onpass="***Routes in SDN-IP are correct!***",
                                 onfail="***Routes in SDN-IP are wrong!***")
 
-        time.sleep(2)
+        time.sleep(20)
         get_intents_result = main.ONOScli.intents(json_format=True)
 
 
         main.step("Check MultiPointToSinglePointIntent intents installed")
         # route_intents_expected are generated when generating routes
         # get rpoute intents from ONOS CLI
-        routeIntents_actual  = main.Quaggacli.extract_actual_routeIntents(get_intents_result)
+        routeIntents_actual  = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
+        routeIntents_str_expected = str(sorted(routeIntents_expected))
+        routeIntents_str_actual = str(routeIntents_actual).replace('u',"")
         main.log.info("MultiPointToSinglePoint intents expected:")
-        main.log.info(routeIntents_expected)
+        main.log.info(routeIntents_str_expected)
         main.log.info("MultiPointToSinglePoint intents get from ONOS CLI:")
-        main.log.info(routeIntents_actual)
-        utilities.assert_equals(expect=True, actual=eq(routeIntents_expected, routeIntents_actual),
+        main.log.info(routeIntents_str_actual)
+        utilities.assert_equals(expect=True, actual=eq(routeIntents_str_expected, routeIntents_str_actual),
                                 onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***",
                                 onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***")
 
 
         main.step("Check BGP PointToPointIntent intents installed")
         # bgp intents expected
-        bgpIntents_expected = main.Quaggacli.generate_expected_bgpIntents(SDNIP_JSON_FILE_PATH)
+        bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents(SDNIP_JSON_FILE_PATH)
         # get BGP intents from ONOS CLI
-        bgpIntents_actual = main.Quaggacli.extract_actual_bgpIntents(get_intents_result)
+        bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents(get_intents_result)
 
         bgpIntents_str_expected = str(bgpIntents_expected).replace('u',"")
         bgpIntents_str_actual = str(bgpIntents_actual)
diff --git a/TestON/tests/SdnIpTest/SdnIpTest.topo b/TestON/tests/SdnIpTest/SdnIpTest.topo
index 1d23878..a2d9616 100755
--- a/TestON/tests/SdnIpTest/SdnIpTest.topo
+++ b/TestON/tests/SdnIpTest/SdnIpTest.topo
@@ -28,14 +28,30 @@
             <COMPONENTS> </COMPONENTS>
         </ONOS1>
 
-      	<Quaggacli>
+        <QuaggaCliHost3>
             <host>127.0.0.1</host>
             <user>username</user>
             <password>password</password>
             <type>QuaggaCliDriver</type>
             <connect_order>5</connect_order>
             <COMPONENTS> </COMPONENTS>
-        </Quaggacli>
+        </QuaggaCliHost3>
+        <QuaggaCliHost4>
+            <host>127.0.0.1</host>
+            <user>username</user>
+            <password>password</password>
+            <type>QuaggaCliDriver</type>
+            <connect_order>5</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </QuaggaCliHost4>
+        <QuaggaCliHost5>
+            <host>127.0.0.1</host>
+            <user>username</user>
+            <password>password</password>
+            <type>QuaggaCliDriver</type>
+            <connect_order>5</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </QuaggaCliHost5>
 
     </COMPONENT>
 </TOPOLOGY>
diff --git a/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.params b/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.params
new file mode 100644
index 0000000..e1e75f9
--- /dev/null
+++ b/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.params
@@ -0,0 +1,63 @@
+<PARAMS>
+    <testcases>1,2,8,3,4,5,[6],7,8,4,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+    <ENV>
+    <cellName>HA</cellName>
+    </ENV>
+    <Git>True</Git>
+
+    <CTRL>
+        <ip1>10.128.30.11</ip1>
+        <port1>6633</port1>
+
+        <ip2>10.128.30.12</ip2>
+        <port2>6633</port2>
+
+        <ip3>10.128.30.13</ip3>
+        <port3>6633</port3>
+
+        <ip4>10.128.30.14</ip4>
+        <port4>6633</port4>
+
+        <ip5>10.128.30.15</ip5>
+        <port5>6633</port5>
+
+        <ip6>10.128.30.16</ip6>
+        <port6>6633</port6>
+
+        <ip7>10.128.30.17</ip7>
+        <port7>6633</port7>
+    </CTRL>
+    <TESTONUSER>admin</TESTONUSER>
+    <TESTONIP>10.128.30.10</TESTONIP>
+    <PING>
+        <source1>h8</source1>
+        <source2>h9</source2>
+        <source3>h10</source3>
+        <source4>h11</source4>
+        <source5>h12</source5>
+        <source6>h13</source6>
+        <source7>h14</source7>
+        <source8>h15</source8>
+        <source9>h16</source9>
+        <source10>h17</source10>
+        <target1>10.0.0.18</target1>
+        <target2>10.0.0.19</target2>
+        <target3>10.0.0.20</target3>
+        <target4>10.0.0.21</target4>
+        <target5>10.0.0.22</target5>
+        <target6>10.0.0.23</target6>
+        <target7>10.0.0.24</target7>
+        <target8>10.0.0.25</target8>
+        <target9>10.0.0.26</target9>
+        <target10>10.0.0.27</target10>
+    </PING>
+    <timers>
+        <LinkDiscovery>2</LinkDiscovery>
+        <SwitchDiscovery>2</SwitchDiscovery>
+    </timers>
+    <MNtcpdump>
+        <intf>eth0</intf>
+        <port> </port>
+        <folder>~/packet_captures/</folder>
+    </MNtcpdump>
+</PARAMS>
diff --git a/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.py b/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.py
new file mode 100644
index 0000000..e6f2fde
--- /dev/null
+++ b/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.py
@@ -0,0 +1,814 @@
+'''
+Description: This test is to determine if a single
+    instance ONOS 'cluster' can handle a restart
+
+List of test cases:
+CASE1: Compile ONOS and push it to the test machines
+CASE2: Assign mastership to controllers
+CASE3: Assign intents
+CASE4: Ping across added host intents
+CASE5: Reading state of ONOS
+CASE6: The Failure case. Since this is the Sanity test, we do nothing.
+CASE7: Check state after control plane failure
+CASE8: Compare topo
+CASE9: Link s3-s28 down
+CASE10: Link s3-s28 up
+CASE11: Switch down
+CASE12: Switch up
+CASE13: Clean up
+'''
+class SingleInstanceHATestRestart:
+
+    def __init__(self) :
+        self.default = ''
+
+    def CASE1(self,main) :
+        '''
+        CASE1 is to compile ONOS and push it to the test machines
+
+        Startup sequence:
+        git pull
+        mvn clean install
+        onos-package
+        cell <name>
+        onos-verify-cell
+        NOTE: temporary - onos-remove-raft-logs
+        onos-install -f
+        onos-wait-for-start
+        '''
+        import time
+        main.log.report("ONOS Single node cluster restart HA test - initialization")
+        main.case("Setting up test environment")
+
+        # load some vairables from the params file
+        PULL_CODE = False
+        if main.params['Git'] == 'True':
+            PULL_CODE = True
+        cell_name = main.params['ENV']['cellName']
+
+        #set global variables
+        global ONOS1_ip
+        global ONOS1_port
+        global ONOS2_ip
+        global ONOS2_port
+        global ONOS3_ip
+        global ONOS3_port
+        global ONOS4_ip
+        global ONOS4_port
+        global ONOS5_ip
+        global ONOS5_port
+        global ONOS6_ip
+        global ONOS6_port
+        global ONOS7_ip
+        global ONOS7_port
+
+        ONOS1_ip = main.params['CTRL']['ip1']
+        ONOS1_port = main.params['CTRL']['port1']
+        ONOS2_ip = main.params['CTRL']['ip2']
+        ONOS2_port = main.params['CTRL']['port2']
+        ONOS3_ip = main.params['CTRL']['ip3']
+        ONOS3_port = main.params['CTRL']['port3']
+        ONOS4_ip = main.params['CTRL']['ip4']
+        ONOS4_port = main.params['CTRL']['port4']
+        ONOS5_ip = main.params['CTRL']['ip5']
+        ONOS5_port = main.params['CTRL']['port5']
+        ONOS6_ip = main.params['CTRL']['ip6']
+        ONOS6_port = main.params['CTRL']['port6']
+        ONOS7_ip = main.params['CTRL']['ip7']
+        ONOS7_port = main.params['CTRL']['port7']
+
+
+        main.step("Applying cell variable to environment")
+        cell_result = main.ONOSbench.set_cell(cell_name)
+        verify_result = main.ONOSbench.verify_cell()
+
+        #FIXME:this is short term fix
+        main.log.report("Removing raft logs")
+        main.ONOSbench.onos_remove_raft_logs()
+        main.log.report("Uninstalling ONOS")
+        main.ONOSbench.onos_uninstall(ONOS1_ip)
+        main.ONOSbench.onos_uninstall(ONOS2_ip)
+        main.ONOSbench.onos_uninstall(ONOS3_ip)
+        main.ONOSbench.onos_uninstall(ONOS4_ip)
+        main.ONOSbench.onos_uninstall(ONOS5_ip)
+        main.ONOSbench.onos_uninstall(ONOS6_ip)
+        main.ONOSbench.onos_uninstall(ONOS7_ip)
+
+        clean_install_result = main.TRUE
+        git_pull_result = main.TRUE
+
+        main.step("Compiling the latest version of ONOS")
+        if PULL_CODE:
+            main.step("Git checkout and pull master")
+            main.ONOSbench.git_checkout("master")
+            git_pull_result = main.ONOSbench.git_pull()
+
+            main.step("Using mvn clean & install")
+            clean_install_result = main.TRUE
+            if git_pull_result == main.TRUE:
+                clean_install_result = main.ONOSbench.clean_install()
+            else:
+                main.log.warn("Did not pull new code so skipping mvn "+ \
+                        "clean install")
+        main.ONOSbench.get_version(report=True)
+
+        main.step("Creating ONOS package")
+        package_result = main.ONOSbench.onos_package()
+
+        main.step("Installing ONOS package")
+        onos1_install_result = main.ONOSbench.onos_install(options="-f",
+                node=ONOS1_ip)
+
+
+        main.step("Checking if ONOS is up yet")
+        #TODO: Refactor
+        # check bundle:list?
+        #this should be enough for ONOS to start
+        time.sleep(60)
+        onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+        if not onos1_isup:
+            main.log.report("ONOS1 didn't start!")
+        # TODO: if it becomes an issue, we can retry this step  a few times
+
+
+        cli_result1 = main.ONOScli1.start_onos_cli(ONOS1_ip)
+
+        main.step("Start Packet Capture MN")
+        main.Mininet2.start_tcpdump(
+                str(main.params['MNtcpdump']['folder'])+str(main.TEST)+"-MN.pcap",
+                intf = main.params['MNtcpdump']['intf'],
+                port = main.params['MNtcpdump']['port'])
+
+
+        case1_result = (clean_install_result and package_result and
+                cell_result and verify_result and onos1_install_result and
+                onos1_isup and cli1_results)
+
+        utilities.assert_equals(expect=main.TRUE, actual=case1_result,
+                onpass="Test startup successful",
+                onfail="Test startup NOT successful")
+
+
+        if case1_result==main.FALSE:
+            main.cleanup()
+            main.exit()
+
+    def CASE2(self,main) :
+        '''
+        Assign mastership to controllers
+        '''
+        import time
+        import json
+        import re
+
+        main.log.report("Assigning switches to controllers")
+        main.case("Assigning Controllers")
+        main.step("Assign switches to controllers")
+
+        for i in range (1,29):
+           main.Mininet1.assign_sw_controller(sw=str(i),
+                    ip1=ONOS1_ip,port1=ONOS1_port)
+
+        mastership_check = main.TRUE
+        for i in range (1,29):
+            response = main.Mininet1.get_sw_controller("s"+str(i))
+            try:
+                main.log.info(str(response))
+            except:
+                main.log.info(repr(response))
+            if re.search("tcp:"+ONOS1_ip,response):
+                mastership_check = mastership_check and main.TRUE
+            else:
+                mastership_check = main.FALSE
+        if mastership_check == main.TRUE:
+            main.log.report("Switch mastership assigned correctly")
+        utilities.assert_equals(expect = main.TRUE,actual=mastership_check,
+                onpass="Switch mastership assigned correctly",
+                onfail="Switches not assigned correctly to controllers")
+
+        #TODO: If assign roles is working reliably then manually 
+        #   assign mastership to the controller we want
+
+
+    def CASE3(self,main) :
+        """
+        Assign intents
+
+        """
+        import time
+        import json
+        import re
+        main.log.report("Adding host intents")
+        main.case("Adding host Intents")
+
+        main.step("Discovering  Hosts( Via pingall for now)")
+        #FIXME: Once we have a host discovery mechanism, use that instead
+
+        #REACTIVE FWD test
+        ping_result = main.FALSE
+        time1 = time.time()
+        ping_result = main.Mininet1.pingall()
+        time2 = time.time()
+        main.log.info("Time for pingall: %2f seconds" % (time2 - time1))
+
+        #uninstall onos-app-fwd
+        main.log.info("Uninstall reactive forwarding app")
+        main.ONOScli1.feature_uninstall("onos-app-fwd")
+
+        main.step("Add  host intents")
+        #TODO:  move the host numbers to params
+        import json
+        intents_json= json.loads(main.ONOScli1.hosts())
+        intent_add_result = main.FALSE
+        for i in range(8,18):
+            main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+            host1 =  "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+            host2 =  "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+            #NOTE: get host can return None
+            #TODO: handle this
+            host1_id = main.ONOScli1.get_host(host1)['id']
+            host2_id = main.ONOScli1.get_host(host2)['id']
+            tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
+            intent_add_result = intent_add_result and tmp_result
+        #TODO Check if intents all exist in datastore
+        #NOTE: Do we need to print this once the test is working?
+        #main.log.info(json.dumps(json.loads(main.ONOScli1.intents(json_format=True)),
+        #    sort_keys=True, indent=4, separators=(',', ': ') ) )
+
+    def CASE4(self,main) :
+        """
+        Ping across added host intents
+        """
+        description = " Ping across added host intents"
+        main.log.report(description)
+        main.case(description)
+        Ping_Result = main.TRUE
+        for i in range(8,18):
+            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+            Ping_Result = Ping_Result and ping
+            if ping==main.FALSE:
+                main.log.warn("Ping failed between h"+str(i)+" and h" + str(i+10))
+            elif ping==main.TRUE:
+                main.log.info("Ping test passed!")
+                Ping_Result = main.TRUE
+        if Ping_Result==main.FALSE:
+            main.log.report("Intents have not been installed correctly, pings failed.")
+        if Ping_Result==main.TRUE:
+            main.log.report("Intents have been installed correctly and verified by pings")
+        utilities.assert_equals(expect = main.TRUE,actual=Ping_Result,
+                onpass="Intents have been installed correctly and pings work",
+                onfail ="Intents have not been installed correctly, pings failed." )
+
+    def CASE5(self,main) :
+        '''
+        Reading state of ONOS
+        '''
+        import time
+        import json
+        from subprocess import Popen, PIPE
+        from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+
+        main.log.report("Setting up and gathering data for current state")
+        main.case("Setting up and gathering data for current state")
+        #The general idea for this test case is to pull the state of (intents,flows, topology,...) from each ONOS node
+        #We can then compare them with eachother and also with past states
+
+        main.step("Get the Mastership of each switch from each controller")
+        global mastership_state
+        ONOS1_mastership = main.ONOScli1.roles()
+        #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+        #TODO: Make this a meaningful check
+        if "Error" in ONOS1_mastership or not ONOS1_mastership:
+            main.log.report("Error in getting ONOS roles")
+            main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+            consistent_mastership = main.FALSE
+        else:
+            mastership_state = ONOS1_mastership
+            consistent_mastership = main.TRUE
+            main.log.report("Switch roles are consistent across all ONOS nodes")
+        utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+                onpass="Switch roles are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of switch roles")
+
+
+        main.step("Get the intents from each controller")
+        global intent_state
+        ONOS1_intents = main.ONOScli1.intents( json_format=True )
+        intent_check = main.FALSE
+        if "Error" in ONOS1_intents or not ONOS1_intents:
+            main.log.report("Error in getting ONOS intents")
+            main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+        else:
+            intent_check = main.TRUE
+            main.log.report("Intents are consistent across all ONOS nodes")
+        utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+                onpass="Intents are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of intents")
+
+
+        main.step("Get the flows from each controller")
+        global flow_state
+        ONOS1_flows = main.ONOScli1.flows( json_format=True )
+        flow_check = main.FALSE
+        if "Error" in ONOS1_flows or not ONOS1_flows:
+            main.log.report("Error in getting ONOS intents")
+            main.log.warn("ONOS1 flows repsponse: "+ ONOS1_flows)
+        else:
+            #TODO: Do a better check, maybe compare flows on switches?
+            flow_state = ONOS1_flows
+            flow_check = main.TRUE
+            main.log.report("Flow count is consistent across all ONOS nodes")
+        utilities.assert_equals(expect = main.TRUE,actual=flow_check,
+                onpass="The flow count is consistent across all ONOS nodes",
+                onfail="ONOS nodes have different flow counts")
+
+
+        main.step("Get the OF Table entries")
+        global flows
+        flows=[]
+        for i in range(1,29):
+            flows.append(main.Mininet2.get_flowTable("s"+str(i),1.0))
+
+        #TODO: Compare switch flow tables with ONOS flow tables
+
+        main.step("Start continuous pings")
+        main.Mininet2.pingLong(src=main.params['PING']['source1'],
+                            target=main.params['PING']['target1'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source2'],
+                            target=main.params['PING']['target2'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source3'],
+                            target=main.params['PING']['target3'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source4'],
+                            target=main.params['PING']['target4'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source5'],
+                            target=main.params['PING']['target5'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source6'],
+                            target=main.params['PING']['target6'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source7'],
+                            target=main.params['PING']['target7'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source8'],
+                            target=main.params['PING']['target8'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source9'],
+                            target=main.params['PING']['target9'],pingTime=500)
+        main.Mininet2.pingLong(src=main.params['PING']['source10'],
+                            target=main.params['PING']['target10'],pingTime=500)
+
+        main.step("Create TestONTopology object")
+        ctrls = []
+        count = 1
+        temp = ()
+        temp = temp + (getattr(main,('ONOS' + str(count))),)
+        temp = temp + ("ONOS"+str(count),)
+        temp = temp + (main.params['CTRL']['ip'+str(count)],)
+        temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+        ctrls.append(temp)
+        MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+        main.step("Collecting topology information from ONOS")
+        devices = []
+        devices.append( main.ONOScli1.devices() )
+        '''
+        hosts = []
+        hosts.append( main.ONOScli1.hosts() )
+        '''
+        ports = []
+        ports.append( main.ONOScli1.ports() )
+        links = []
+        links.append( main.ONOScli1.links() )
+
+
+        main.step("Comparing ONOS topology to MN")
+        devices_results = main.TRUE
+        ports_results = main.TRUE
+        links_results = main.TRUE
+        for controller in range(1): #TODO parameterize the number of controllers
+            if devices[controller] or not "Error" in devices[controller]:
+                current_devices_result =  main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+            else:
+                current_devices_result = main.FALSE
+            utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+                    onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+                    onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+            if ports[controller] or not "Error" in ports[controller]:
+                current_ports_result =  main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+            else:
+                current_ports_result = main.FALSE
+            utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+                    onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+                    onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+            if links[controller] or not "Error" in links[controller]:
+                current_links_result =  main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+            else:
+                current_links_result = main.FALSE
+            utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+                    onpass="ONOS"+str(int(controller+1))+" links view is correct",
+                    onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+
+            devices_results = devices_results and current_devices_result
+            ports_results = ports_results and current_ports_result
+            links_results = links_results and current_links_result
+
+        topo_result = devices_results and ports_results and links_results
+        utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+                onpass="Topology Check Test successful",
+                onfail="Topology Check Test NOT successful")
+
+        final_assert = main.TRUE
+        final_assert = final_assert and topo_result and flow_check \
+                and intent_check and consistent_mastership
+        utilities.assert_equals(expect=main.TRUE, actual=final_assert,
+                onpass="State check successful",
+                onfail="State check NOT successful")
+
+
+    def CASE6(self,main) :
+        '''
+        The Failure case.
+        '''
+        import time
+
+        main.log.report("Restart ONOS node")
+        main.log.case("Restart ONOS node")
+        main.ONOSbench.onos_kill(ONOS1_ip)
+        start = time.time()
+
+        main.step("Checking if ONOS is up yet")
+        count = 0
+        while count < 10
+            onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+            if onos1_isup == main.TRUE:
+                elapsed = time.time() - start
+                break
+            else:
+                count = count + 1
+
+        cli_result = main.ONOScli1.start_onos_cli(ONOS1_ip)
+
+        case_results = main.TRUE and onosi1_isup and cli_result
+        utilities.assert_equals(expect=main.TRUE, actual=case_results,
+                onpass="ONOS restart successful",
+                onfail="ONOS restart NOT successful")
+        main.log.info("ONOS took %s seconds to restart" % str(elapsed) )
+
+    def CASE7(self,main) :
+        '''
+        Check state after ONOS failure
+        '''
+        import os
+        import json
+        main.case("Running ONOS Constant State Tests")
+
+        main.step("Check if switch roles are consistent across all nodes")
+        ONOS1_mastership = main.ONOScli1.roles()
+        #FIXME: Refactor this whole case for single instance
+        #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+        if "Error" in ONOS1_mastership or not ONOS1_mastership:
+            main.log.report("Error in getting ONOS mastership")
+            main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+            consistent_mastership = main.FALSE
+        else:
+            consistent_mastership = main.TRUE
+            main.log.report("Switch roles are consistent across all ONOS nodes")
+        utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+                onpass="Switch roles are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of switch roles")
+
+
+        description2 = "Compare switch roles from before failure"
+        main.step(description2)
+
+        current_json = json.loads(ONOS1_mastership)
+        old_json = json.loads(mastership_state)
+        mastership_check = main.TRUE
+        for i in range(1,29):
+            switchDPID = str(main.Mininet1.getSwitchDPID(switch="s"+str(i)))
+
+            current = [switch['master'] for switch in current_json if switchDPID in switch['id']]
+            old = [switch['master'] for switch in old_json if switchDPID in switch['id']]
+            if current == old:
+                mastership_check = mastership_check and main.TRUE
+            else:
+                main.log.warn("Mastership of switch %s changed" % switchDPID)
+                mastership_check = main.FALSE
+        if mastership_check == main.TRUE:
+            main.log.report("Mastership of Switches was not changed")
+        utilities.assert_equals(expect=main.TRUE,actual=mastership_check,
+                onpass="Mastership of Switches was not changed",
+                onfail="Mastership of some switches changed")
+        mastership_check = mastership_check and consistent_mastership
+
+
+
+        main.step("Get the intents and compare across all nodes")
+        ONOS1_intents = main.ONOScli1.intents( json_format=True )
+        intent_check = main.FALSE
+        if "Error" in ONOS1_intents or not ONOS1_intents:
+            main.log.report("Error in getting ONOS intents")
+            main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+        else:
+            intent_state = ONOS1_intents
+            intent_check = main.TRUE
+            main.log.report("Intents are consistent across all ONOS nodes")
+        utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+                onpass="Intents are consistent across all ONOS nodes",
+                onfail="ONOS nodes have different views of intents")
+
+        main.step("Compare current intents with intents before the failure")
+        if intent_state == ONOS1_intents:
+            same_intents = main.TRUE
+            main.log.report("Intents are consistent with before failure")
+        #TODO: possibly the states have changed? we may need to figure out what the aceptable states are
+        else:
+            same_intents = main.FALSE
+        utilities.assert_equals(expect = main.TRUE,actual=same_intents,
+                onpass="Intents are consistent with before failure",
+                onfail="The Intents changed during failure")
+        intent_check = intent_check and same_intents
+
+
+
+        main.step("Get the OF Table entries and compare to before component failure")
+        Flow_Tables = main.TRUE
+        flows2=[]
+        for i in range(28):
+            main.log.info("Checking flow table on s" + str(i+1))
+            tmp_flows = main.Mininet2.get_flowTable("s"+str(i+1),1.0)
+            flows2.append(tmp_flows)
+            Flow_Tables = Flow_Tables and main.Mininet2.flow_comp(flow1=flows[i],flow2=tmp_flows)
+            if Flow_Tables == main.FALSE:
+                main.log.info("Differences in flow table for switch: "+str(i+1))
+                break
+        if Flow_Tables == main.TRUE:
+            main.log.report("No changes were found in the flow tables")
+        utilities.assert_equals(expect=main.TRUE,actual=Flow_Tables,
+                onpass="No changes were found in the flow tables",
+                onfail="Changes were found in the flow tables")
+
+        main.step("Check the continuous pings to ensure that no packets were dropped during component failure")
+        #FIXME: This check is always failing. Investigate cause
+        #NOTE:  this may be something to do with file permsissions
+        #       or slight change in format
+        main.Mininet2.pingKill(main.params['TESTONUSER'], main.params['TESTONIP'])
+        Loss_In_Pings = main.FALSE 
+        #NOTE: checkForLoss returns main.FALSE with 0% packet loss
+        for i in range(8,18):
+            main.log.info("Checking for a loss in pings along flow from s" + str(i))
+            Loss_In_Pings = Loss_In_Pings or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i))
+        if Loss_In_Pings == main.TRUE:
+            main.log.info("Loss in ping detected")
+        elif Loss_In_Pings == main.ERROR:
+            main.log.info("There are multiple mininet process running")
+        elif Loss_In_Pings == main.FALSE:
+            main.log.info("No Loss in the pings")
+            main.log.report("No loss of dataplane connectivity")
+        utilities.assert_equals(expect=main.FALSE,actual=Loss_In_Pings,
+                onpass="No Loss of connectivity",
+                onfail="Loss of dataplane connectivity detected")
+
+
+        #TODO:add topology to this or leave as a seperate case?
+        result = mastership_check and intent_check and Flow_Tables and (not Loss_In_Pings)
+        result = int(result)
+        if result == main.TRUE:
+            main.log.report("Constant State Tests Passed")
+        utilities.assert_equals(expect=main.TRUE,actual=result,
+                onpass="Constant State Tests Passed",
+                onfail="Constant state tests failed")
+
+    def CASE8 (self,main):
+        '''
+        Compare topo
+        '''
+        import sys
+        sys.path.append("/home/admin/sts") # Trying to remove some dependancies, #FIXME add this path to params
+        from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+        import json
+        import time
+
+        description ="Compare ONOS Topology view to Mininet topology"
+        main.case(description)
+        main.log.report(description)
+        main.step("Create TestONTopology object")
+        ctrls = []
+        count = 1
+        temp = ()
+        temp = temp + (getattr(main,('ONOS' + str(count))),)
+        temp = temp + ("ONOS"+str(count),)
+        temp = temp + (main.params['CTRL']['ip'+str(count)],)
+        temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+        ctrls.append(temp)
+        MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+        main.step("Comparing ONOS topology to MN")
+        devices_results = main.TRUE
+        ports_results = main.TRUE
+        links_results = main.TRUE
+        topo_result = main.FALSE
+        start_time = time.time()
+        elapsed = 0
+        count = 0
+        while topo_result == main.FALSE and elapsed < 120:
+            count = count + 1
+            try:
+                main.step("Collecting topology information from ONOS")
+                devices = []
+                devices.append( main.ONOScli1.devices() )
+                '''
+                hosts = []
+                hosts.append( main.ONOScli1.hosts() )
+                '''
+                ports = []
+                ports.append( main.ONOScli1.ports() )
+                links = []
+                links.append( main.ONOScli1.links() )
+                for controller in range(1): #TODO parameterize the number of controllers
+                    if devices[controller] or not "Error" in devices[controller]:
+                        current_devices_result =  main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+                    else:
+                        current_devices_result = main.FALSE
+                    utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+                            onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+                            onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+                    if ports[controller] or not "Error" in ports[controller]:
+                        current_ports_result =  main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+                    else:
+                        current_ports_result = main.FALSE
+                    utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+                            onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+                            onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+                    if links[controller] or not "Error" in links[controller]:
+                        current_links_result =  main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+                    else:
+                        current_links_result = main.FALSE
+                    utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+                            onpass="ONOS"+str(int(controller+1))+" links view is correct",
+                            onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+            except:
+                main.log.error("something went wrong in topo comparison")
+                main.log.warn( repr( devices ) )
+                main.log.warn( repr( ports ) )
+                main.log.warn( repr( links ) )
+
+            devices_results = devices_results and current_devices_result
+            ports_results = ports_results and current_ports_result
+            links_results = links_results and current_links_result
+            elapsed = time.time() - start_time
+        time_threshold = elapsed < 1
+        topo_result = devices_results and ports_results and links_results and time_threshold
+        #TODO make sure this step is non-blocking. IE add a timeout
+        main.log.report("Very crass estimate for topology discovery/convergence: " +\
+                str(elapsed) + " seconds, " + str(count) +" tries" )
+        utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+                onpass="Topology Check Test successful",
+                onfail="Topology Check Test NOT successful")
+        if topo_result == main.TRUE:
+            main.log.report("ONOS topology view matches Mininet topology")
+
+
+    def CASE9 (self,main):
+        '''
+        Link s3-s28 down
+        '''
+        #NOTE: You should probably run a topology check after this
+
+        link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+        description = "Turn off a link to ensure that Link Discovery is working properly"
+        main.log.report(description)
+        main.case(description)
+
+
+        main.step("Kill Link between s3 and s28")
+        Link_Down = main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
+        main.log.info("Waiting " + str(link_sleep) + " seconds for link down to be discovered")
+        time.sleep(link_sleep)
+        utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
+                onpass="Link down succesful",
+                onfail="Failed to bring link down")
+        #TODO do some sort of check here
+
+    def CASE10 (self,main):
+        '''
+        Link s3-s28 up
+        '''
+        #NOTE: You should probably run a topology check after this
+
+        link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+        description = "Restore a link to ensure that Link Discovery is working properly"
+        main.log.report(description)
+        main.case(description)
+
+        main.step("Bring link between s3 and s28 back up")
+        Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
+        main.log.info("Waiting " + str(link_sleep) + " seconds for link up to be discovered")
+        time.sleep(link_sleep)
+        utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
+                onpass="Link up succesful",
+                onfail="Failed to bring link up")
+        #TODO do some sort of check here
+
+
+    def CASE11 (self, main) :
+        '''
+        Switch Down
+        '''
+        #NOTE: You should probably run a topology check after this
+        import time
+
+        switch_sleep = int(main.params['timers']['SwitchDiscovery'])
+
+        description = "Killing a switch to ensure it is discovered correctly"
+        main.log.report(description)
+        main.case(description)
+
+        #TODO: Make this switch parameterizable
+        main.step("Kill s28 ")
+        main.log.report("Deleting s28")
+        #FIXME: use new dynamic topo functions
+        main.Mininet1.del_switch("s28")
+        main.log.info("Waiting " + str(switch_sleep) + " seconds for switch down to be discovered")
+        time.sleep(switch_sleep)
+        #Peek at the deleted switch
+        main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+        #TODO do some sort of check here
+
+    def CASE12 (self, main) :
+        '''
+        Switch Up
+        '''
+        #NOTE: You should probably run a topology check after this
+        import time
+        #FIXME: use new dynamic topo functions
+        description = "Adding a switch to ensure it is discovered correctly"
+        main.log.report(description)
+        main.case(description)
+
+        main.step("Add back s28")
+        main.log.report("Adding back s28")
+        main.Mininet1.add_switch("s28", dpid = '0000000000002800')
+        #TODO: New dpid or same? Ask Thomas?
+        main.Mininet1.add_link('s28', 's3')
+        main.Mininet1.add_link('s28', 's6')
+        main.Mininet1.add_link('s28', 'h28')
+        main.Mininet1.assign_sw_controller(sw="28",
+                ip1=ONOS1_ip,port1=ONOS1_port)
+        main.log.info("Waiting " + str(switch_sleep) + " seconds for switch up to be discovered")
+        time.sleep(switch_sleep)
+        #Peek at the added switch
+        main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+        #TODO do some sort of check here
+
+    def CASE13 (self, main) :
+        '''
+        Clean up
+        '''
+        import os
+        import time
+        description = "Test Cleanup"
+        main.log.report(description)
+        main.case(description)
+        main.step("Killing tcpdumps")
+        main.Mininet2.stop_tcpdump()
+
+        main.step("Copying MN pcap and ONOS log files to test station")
+        testname = main.TEST
+        #NOTE: MN Pcap file is being saved to ~/packet_captures
+        #       scp this file as MN and TestON aren't necessarily the same vm
+        #FIXME: scp
+        #####mn files
+        #TODO: Load these from params
+        #NOTE: must end in /
+        log_folder = "/opt/onos/log/"
+        log_files = ["karaf.log", "karaf.log.1"]
+        #NOTE: must end in /
+        dst_dir = "~/packet_captures/"
+        for f in log_files:
+            main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS1-"+f )
+
+        #std*.log's
+        #NOTE: must end in /
+        log_folder = "/opt/onos/var/"
+        log_files = ["stderr.log", "stdout.log"]
+        #NOTE: must end in /
+        dst_dir = "~/packet_captures/"
+        for f in log_files:
+            main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+                    dst_dir + str(testname) + "-ONOS1-"+f )
+
+
+        #sleep so scp can finish
+        time.sleep(10)
+        main.step("Packing and rotating pcap archives")
+        os.system("~/TestON/dependencies/rotate.sh "+ str(testname))
+
+
+        #TODO: actually check something here
+        utilities.assert_equals(expect=main.TRUE, actual=main.TRUE,
+                onpass="Test cleanup successful",
+                onfail="Test cleanup NOT successful")
diff --git a/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.topo b/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.topo
new file mode 100644
index 0000000..4d4156c
--- /dev/null
+++ b/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.topo
@@ -0,0 +1,173 @@
+<TOPOLOGY>
+    <COMPONENT>
+
+        <ONOSbench>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosDriver</type>
+            <connect_order>1</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOSbench>
+
+        <ONOScli1>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli1>
+
+        <ONOScli2>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>3</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli2>
+
+        <ONOScli3>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>4</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli3>
+
+
+        <ONOScli4>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>5</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli4>
+
+
+        <ONOScli5>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>6</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli5>
+
+
+        <ONOScli6>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>7</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli6>
+
+
+        <ONOScli7>
+            <host>10.128.30.10</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>OnosCliDriver</type>
+            <connect_order>8</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli7>
+
+        <ONOS1>
+            <host>10.128.30.11</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>9</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS1>
+
+        <ONOS2>
+            <host>10.128.30.12</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>10</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS2>
+
+        <ONOS3>
+            <host>10.128.30.13</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>11</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS3>
+
+        <ONOS4>
+            <host>10.128.30.14</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>12</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS4>
+
+        <ONOS5>
+            <host>10.128.30.15</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>13</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS5>
+
+        <ONOS6>
+            <host>10.128.30.16</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>14</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS6>
+
+        <ONOS7>
+            <host>10.128.30.17</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>15</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS7>
+
+        <Mininet1>
+            <host>10.128.30.9</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>MininetCliDriver</type>
+            <connect_order>16</connect_order>
+            <COMPONENTS>
+                #Specify the Option for mininet
+                <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+                <arg2> --topo mytopo </arg2>
+                <arg3> </arg3>
+                <controller> remote </controller>
+            </COMPONENTS>
+        </Mininet1>
+
+        <Mininet2>
+            <host>10.128.30.9</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>RemoteMininetDriver</type>
+            <connect_order>17</connect_order>
+            <COMPONENTS>
+                # Specify the Option for mininet
+                <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+                <arg2> --topo mytopo --arp</arg2>
+                <controller> remote </controller>
+             </COMPONENTS>
+        </Mininet2>
+
+    </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/SingleInstanceHATestRestart/__init__.py b/TestON/tests/SingleInstanceHATestRestart/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/SingleInstanceHATestRestart/__init__.py
diff --git a/TestON/tests/TopoConvNext/TopoConvNext.params b/TestON/tests/TopoConvNext/TopoConvNext.params
index 96cb9ad..198befb 100644
--- a/TestON/tests/TopoConvNext/TopoConvNext.params
+++ b/TestON/tests/TopoConvNext/TopoConvNext.params
@@ -1,5 +1,5 @@
 <PARAMS>
-    <testcases>1,2,3,2,3,2,3,4,2,3,2,3,2,4,2,3,2,3,2</testcases>
+    <testcases>1,2,3,2,3,2,3,2,4,2,3,2,3,2,3,2</testcases>
 
     <ENV>
         <cellName>topo_conv_test</cellName>
@@ -42,10 +42,11 @@
         <onosLogFile>/opt/onos/log/karaf*</onosLogFile>
 
         #Number of times to iterate each case
-        <numIter>5</numIter>
-        <numSwitch1>200</numSwitch1>
+        <numIter>3</numIter>
+        <numSwitch1>500</numSwitch1>
         <numSwitch2>400</numSwitch2>
-        <numSwitch3>500</numSwitch3>
+        <numSwitch3>200</numSwitch3>
+        <numSwitch4>300</numSwitch4>
         #Number of iterations to ignore initially
         <iterIgnore>1</iterIgnore>
 
diff --git a/TestON/tests/TopoConvNext/TopoConvNext.py b/TestON/tests/TopoConvNext/TopoConvNext.py
index 52a951c..68d7b5d 100644
--- a/TestON/tests/TopoConvNext/TopoConvNext.py
+++ b/TestON/tests/TopoConvNext/TopoConvNext.py
@@ -185,6 +185,8 @@
             num_sw = main.params['TEST']['numSwitch2']
         elif topo_iteration == 3:
             num_sw = main.params['TEST']['numSwitch3']
+        elif topo_iteration == 4:
+            num_sw = main.params['TEST']['numSwitch4']
         #***********
 
         #Timestamp 'keys' for json metrics output.
@@ -323,7 +325,7 @@
             #NOTE:
             #       Delay before checking devices to 
             #       help prevent timing out from CLI
-            #       due to multiple command drop
+            #       due to multiple command issuing 
             time.sleep(20)
 
             loop = True
@@ -338,6 +340,9 @@
                 device_json1 = json.loads(device_str1)
                 json_len = len(device_json1) 
                 
+                #NOTE: May want to check the rest of 
+                #      the ONOS instances for device down as well
+
                 for device1 in device_json1: 
                     temp_len = temp_len + 1
                     if device1['available'] == True:
@@ -361,73 +366,10 @@
                     
                         loop = False
                         break
-
-                #if cluster_count == 1:
-                #    device_str1 = main.ONOS1cli.devices(
-                #        node_ip=ONOS_ip_list[1])
-                #    device_json1 = json.loads(device_str1)
-                #    for device1 in device_json1:
-                #        if device1['available'] == False:
-                #            device_count += 1
-                #        else:
-                #            device_count = 0
-                #if cluster_count == 2:
-                #    device_str2 = main.ONOS2cli.devices(
-                #        node_ip=ONOS_ip_list[2])
-                #    device_json2 = json.loads(device_str2)
-                #    for device2 in device_json2:
-                #        if device2['available'] == False:
-                #            device_count += 1
-                #        else:
-                #            device_count = 0
-                #if cluster_count == 3:
-                #    device_str3 = main.ONOS3cli.devices(
-                #        node_ip=ONOS_ip_list[3])
-                #    device_json3 = json.loads(device_str3)
-                #    for device3 in device_json3:
-                #        if device3['available'] == False:
-                #            device_count += 1
-                #        else:
-                #            device_count = 0
-                #if cluster_count == 4:
-                #    device_str4 = main.ONOS4cli.devices(
-                #        node_ip=ONOS_ip_list[4])
-                #    device_json4 = json.loads(device_str4)
-                #    for device4 in device_json4:
-                #        if device4['available'] == False:
-                #            device_count += 1
-                #        else:
-                #            device_count = 0
-                #if cluster_count == 5:
-                #    device_str5 = main.ONOS5cli.devices(
-                #        node_ip=ONOS_ip_list[5])
-                #    device_json5 = json.loads(device_str5)
-                #    for device5 in device_json5:
-                #        if device5['available'] == False:
-                #            device_count += 1
-                #        else:
-                #            device_count = 0
-                #if cluster_count == 7:
-                #    device_str7 = main.ONOS7cli.devices(
-                #        node_ip=ONOS_ip_list[7])
-                #    device_json7 = json.loads(device_str7)
-                #    for device7 in device_json7:
-                #        if device7['available'] == False:
-                #            device_count += 1
-                #        else:
-                #            device_count = 0
-   
-                #If device count is greater than the 
-                #number of switches discovered by all nodes
-                #then remove iptables and measure t0 system time
-                    
                 
                 loop_count += 1
                 time.sleep(1)
 
-            if device_count < int(num_sw):
-                main.log.info("Devices down did not ")
-
             main.log.info("System time t0: "+str(t0_system))
 
             counter_loop = 0
@@ -590,7 +532,7 @@
                         else:
                             main.log.info("Switch discovery latency "+
                                 "exceeded the threshold.")
-                            main.log.info(graph_lat_1)
+                            main.log.info(str(graph_lat_1)+" ms")
                         #Break while loop 
                         break
                 if cluster_count == 2:
@@ -635,7 +577,7 @@
                         else:
                             main.log.info("Switch discovery latency "+
                                 "exceeded the threshold.")
-                            main.log.info(max_graph_lat)
+                            main.log.info(str(max_graph_lat)+" ms")
                         break
                 if cluster_count == 3:
                     if onos1_dev and onos2_dev and onos3_dev:
@@ -693,7 +635,7 @@
                         else:
                             main.log.info("Switch discovery latency "+
                                 "exceeded the threshold.")
-                            main.log.info(max_graph_lat)
+                            main.log.info(str(max_graph_lat)+" ms")
                         
                         break
                 if cluster_count == 4:
@@ -756,7 +698,7 @@
                         else:
                             main.log.info("Switch discovery latency "+
                                 "exceeded the threshold.")
-                            main.log.info(max_graph_lat)
+                            main.log.info(str(max_graph_lat)+" ms")
                 
                         break
                 if cluster_count == 5:
@@ -835,7 +777,7 @@
                         else:
                             main.log.info("Switch discovery latency "+
                                 "exceeded the threshold.")
-                            main.log.info(max_graph_lat)
+                            main.log.info(str(max_graph_lat)+" ms")
                 
                         break
                 if cluster_count == 6:
@@ -918,7 +860,7 @@
                         else:
                             main.log.info("Switch discovery latency "+
                                 "exceeded the threshold.")
-                            main.log.info(max_graph_lat)
+                            main.log.info(str(max_graph_lat)+" ms")
                         
                         break
                 if cluster_count == 7:
@@ -1018,7 +960,7 @@
                         else:
                             main.log.info("Switch discovery latency "+
                                 "exceeded the threshold.")
-                            main.log.info(max_graph_lat)
+                            main.log.info(str(max_graph_lat)+" ms")
                         
                         break
                 
@@ -1153,7 +1095,9 @@
             sw_lat_avg = sum(sw_discovery_lat_list) / \
                      len(sw_discovery_lat_list)
             sw_lat_dev = numpy.std(sw_discovery_lat_list)
-        else: 
+        else:
+            sw_lat_avg = 0
+            sw_lat_dev = 0
             assertion = main.FALSE
         
         main.log.report("Switch connection attempt time avg "+
@@ -1329,3 +1273,6 @@
         utilities.assert_equals(expect=main.TRUE, actual=assertion,
             onpass="Topology size increased successfully",
             onfail="Topology size was not increased")
+
+
+
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.params b/TestON/tests/TopoPerfNext/TopoPerfNext.params
index 42512e8..851522c 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.params
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.params
@@ -57,7 +57,9 @@
         <linkUpThreshold>0,10000</linkUpThreshold>
         <linkDownThreshold>0,10000</linkDownThreshold>
         <swDisc100Threshold>0,10000</swDisc100Threshold>
-    </TEST>
+    
+        <tabletFile>tablets_3node.json</tabletFile>
+   </TEST>
 
     <JSON>
         <deviceTimestamp>topologyDeviceEventTimestamp</deviceTimestamp>
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.py b/TestON/tests/TopoPerfNext/TopoPerfNext.py
index 49089bf..65bc7a9 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.py
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.py
@@ -47,10 +47,10 @@
         
         main.case("Setting up test environment")
         main.log.info("Copying topology event accumulator config"+\
-            " to ONOS /ppackage/etc")
+            " to ONOS /package/etc")
         main.ONOSbench.handle.sendline("cp ~/"+\
             topo_cfg_file+\
-            "~/ONOS/tools/package/etc/"+\
+            " ~/ONOS/tools/package/etc/"+\
             topo_cfg_name)
         main.ONOSbench.handle.expect("\$")
 
@@ -64,7 +64,7 @@
 
         main.step("Creating cell file")
         cell_file_result = main.ONOSbench.create_cell_file(
-                BENCH_ip, cell_name, MN1_ip, "onos-core",
+                BENCH_ip, cell_name, MN1_ip, "onos-core,onos-app-metrics",
                 ONOS1_ip, ONOS2_ip, ONOS3_ip)
 
         main.step("Applying cell file to environment")
@@ -75,7 +75,8 @@
         #      copy cat log functionality
         main.step("Removing raft/copy-cat logs from ONOS nodes")
         main.ONOSbench.onos_remove_raft_logs()
-        
+        time.sleep(30)
+
         main.step("Git checkout and pull "+checkout_branch)
         if git_pull == 'on':
             checkout_result = \
@@ -114,11 +115,6 @@
         cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
         cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
 
-        main.step("Enable metrics feature")
-        main.ONOS1cli.feature_install("onos-app-metrics")
-        main.ONOS2cli.feature_install("onos-app-metrics")
-        main.ONOS3cli.feature_install("onos-app-metrics")
-
         utilities.assert_equals(expect=main.TRUE,
                 actual= cell_file_result and cell_apply_result and\
                         verify_cell_result and checkout_result and\