added cho scripts in master
diff --git a/cluster-mgmt/bin/check_status_failover.py b/cluster-mgmt/bin/check_status_failover.py
new file mode 100755
index 0000000..17baa01
--- /dev/null
+++ b/cluster-mgmt/bin/check_status_failover.py
@@ -0,0 +1,13 @@
+#! /usr/bin/env python
+import json
+import os
+from check_status import *
+
+cluster_basename=os.environ.get("ONOS_CLUSTER_BASENAME")
+nr_nodes=os.environ.get("ONOS_CLUSTER_NR_NODES")
+
+if __name__ == "__main__":
+  print "%s" % check_switch()[1]
+  print "%s" % check_link()[1]
+  print "%s" % check_controllers(8)[1]
+  print "%s" % check_switch_all(8)[1]
diff --git a/cluster-mgmt/bin/cho-failover.py b/cluster-mgmt/bin/cho-failover.py
new file mode 100755
index 0000000..ad34389
--- /dev/null
+++ b/cluster-mgmt/bin/cho-failover.py
@@ -0,0 +1,127 @@
+#! /usr/bin/env python
+import json
+import sys
+import os
+import re
+from check_status import *
+import time
+
+flowdef="flowdef_8node_252.txt"
+basename="onosdevz"
+operation=["sw3-eth4 down","sw4-eth4 down","sw4-eth3 down","sw3-eth4 up","sw1-eth2 down","sw4-eth4 up","sw4-eth3 up","sw1-eth2 up"]
+
+def check_by_pingall():
+  buf = ""
+  cmd = "dsh -w %s1 \"cd ONOS/web; ./pingallm.py %s\"" % (basename, flowdef)
+  result = os.popen(cmd).read()
+  buf += result
+  
+  if re.search("fail 0", result):
+    return (0, buf)
+  else:
+    return (1, buf)
+
+def link_change_core(op):
+  cmd = "dsh -w %s1 \"sudo ifconfig %s\"" % (basename, op)
+  os.popen(cmd)
+  print cmd
+
+
+def check_flow_nmap():
+  buf = "" 
+  buf += os.popen("date").read()
+  print "dump all flows from network map"
+  cmd  = "dsh -w %s1 \"cd ONOS/web; ./get_flow.py all\"" % cluster_basename
+  buf += os.popen(cmd).read()
+  return (0, buf)
+
+def check_flow_raw():
+  buf = "" 
+  print "dump all flows from switches"
+  cmd  = "dsh \"cd ONOS/scripts; ./showflow.sh\""
+  buf += os.popen(cmd).read()
+  return (0, buf)
+
+def dump_json(url, filename):
+  f = open(filename, 'w')
+  buf = "" 
+  command = "curl -s %s" % (url)
+  result = os.popen(command).read()
+  buf += json.dumps(json.loads(result), sort_keys = True, indent = 2)
+  f.write(buf)
+  f.close()
+
+def check_rest(cycle, n):
+  url="http://%s:%s/wm/core/topology/switches/all/json" % (RestIP, RestPort)
+  filename  = "rest-sw-log.%d.%d.log" % (cycle, n)
+  dump_json(url, filename)
+
+  filename  = "rest-link-log.%d.%d.log" % (cycle, n)
+  url = "http://%s:%s/wm/core/topology/links/json" % (RestIP, RestPort)
+  dump_json(url, filename)
+
+  url = "http://%s:%s/wm/registry/switches/json" % (RestIP, RestPort)
+  filename  = "rest-reg-sw-log.%d.%d.log" % (cycle, n)
+  dump_json(url, filename)
+
+  url = "http://%s:%s/wm/registry/controllers/json" % (RestIP, RestPort)
+  filename  = "rest-reg-ctrl-log.%d.%d.log" % (cycle, n)
+  dump_json(url, filename)
+
+  url = "http://%s:%s/wm/flow/getsummary/0/0/json" % (RestIP, RestPort)
+  filename  = "rest-flow-log.%d.%d.log" % (cycle, n)
+  dump_json(url, filename)
+
+
+def log(cycle, n, nr_ctrl):
+  error = "error-log.%d.%d.log" % (cycle, n)
+  nmapflow  = "nmap-flow-log.%d.%d.log" % (cycle, n)
+  rawflow  = "raw-flow-log.%d.%d.log" % (cycle, n)
+
+  f = open(error, 'w')
+  f.write(result)
+  f.write(check_switch()[1])
+  f.write(check_link()[1])
+  f.write(check_switch_all(nr_ctrl)[1])
+  f.write(check_controllers(nr_ctrl)[1])
+  f.close()
+
+  f = open(nmapflow,'w')
+  f.write(check_flow_nmap()[1])
+  f.close()
+
+  f = open(rawflow,'w')
+  f.write(check_flow_raw()[1])
+  f.close()
+  check_rest(cycle,n)
+
+
+opration=['switch all', 'onos stop 8', 'onos stop 7', 'onos stop 6', 'onos stop 5', 'onos start 5;onos start 6;onos start 7;onos start 8', 'switch local']  
+nr_controllers=[8, 7, 6, 5, 4, 8, 8]
+
+if __name__ == "__main__":
+  print "%s" % check_switch()[1]
+  print "%s" % check_link()[1]
+  print "%s" % check_controllers(8)[1]
+  (code, result) = check_by_pingall()
+  print result
+  k = raw_input('hit any key>')
+
+  for cycle in range(1000):
+    for n, op in enumerate(operation):
+      print "==== Cycle %d operation %d ====" % (cycle, n)
+      print op 
+      os.popen(op)
+      print "wait 30 sec"
+      time.sleep(30)
+
+      print "check by pingall"
+      (code, result) = check_by_pingall()
+      if code == 0:
+        print "ping success %s" % (result)
+      else:
+        print "pingall failed (%d, %d). Collecting logs" % (cycle, n)
+        log(cycle, n, nr_controllers[n]) 
+
+
+
diff --git a/cluster-mgmt/bin/cho-link-failure.py b/cluster-mgmt/bin/cho-link-failure.py
new file mode 100755
index 0000000..7c9740e
--- /dev/null
+++ b/cluster-mgmt/bin/cho-link-failure.py
@@ -0,0 +1,116 @@
+#! /usr/bin/env python
+import json
+import sys
+import os
+import re
+from check_status import *
+import time
+
+flowdef="flowdef_8node_252.txt"
+basename="onosdevz"
+operation=["sw3-eth4 down","sw4-eth4 down","sw4-eth3 down","sw3-eth4 up","sw1-eth2 down","sw4-eth4 up","sw4-eth3 up","sw1-eth2 up"]
+
+def check_by_pingall():
+  buf = ""
+  cmd = "dsh -w %s1 \"cd ONOS/web; ./pingallm.py %s\"" % (basename, flowdef)
+  result = os.popen(cmd).read()
+  buf += result
+  
+  if re.search("fail 0", result):
+    return (0, buf)
+  else:
+    return (1, buf)
+
+def link_change_core(op):
+  cmd = "dsh -w %s1 \"sudo ifconfig %s\"" % (basename, op)
+  os.popen(cmd)
+  print cmd
+
+def check_flow_nmap():
+  buf = "" 
+  buf += os.popen("date").read()
+  print "dump all flows from network map"
+  cmd  = "dsh -w %s1 \"cd ONOS/web; ./get_flow.py all\"" % cluster_basename
+  buf += os.popen(cmd).read()
+  return (0, buf)
+
+def check_flow_raw():
+  buf = "" 
+  print "dump all flows from switches"
+  cmd  = "dsh \"cd ONOS/scripts; ./showflow.sh\""
+  buf += os.popen(cmd).read()
+  return (0, buf)
+
+def dump_json(url, filename):
+  f = open(filename, 'w')
+  buf = "" 
+  command = "curl -s %s" % (url)
+  result = os.popen(command).read()
+  buf += json.dumps(json.loads(result), sort_keys = True, indent = 2)
+  f.write(buf)
+  f.close()
+
+def check_rest(cycle, n):
+  url="http://%s:%s/wm/core/topology/switches/all/json" % (RestIP, RestPort)
+  filename  = "rest-sw-log.%d.%d.log" % (cycle, n)
+  dump_json(url, filename)
+
+  filename  = "rest-link-log.%d.%d.log" % (cycle, n)
+  url = "http://%s:%s/wm/core/topology/links/json" % (RestIP, RestPort)
+  dump_json(url, filename)
+
+  url = "http://%s:%s/wm/registry/switches/json" % (RestIP, RestPort)
+  filename  = "rest-reg-sw-log.%d.%d.log" % (cycle, n)
+  dump_json(url, filename)
+
+  url = "http://%s:%s/wm/registry/controllers/json" % (RestIP, RestPort)
+  filename  = "rest-reg-ctrl-log.%d.%d.log" % (cycle, n)
+  dump_json(url, filename)
+
+  url = "http://%s:%s/wm/flow/getsummary/0/0/json" % (RestIP, RestPort)
+  filename  = "rest-flow-log.%d.%d.log" % (cycle, n)
+  dump_json(url, filename)
+
+if __name__ == "__main__":
+  print "%s" % check_switch()[1]
+  print "%s" % check_link()[1]
+  print "%s" % check_controllers(8)[1]
+  (code, result) = check_by_pingall()
+  print result
+  k = raw_input('hit any key>')
+
+
+  for cycle in range(1000):
+    for n, op in enumerate(operation):
+      print "==== Cycle %d operation %d ====" % (cycle, n)
+      link_change_core(op)
+      print "wait 30 sec"
+      time.sleep(30)
+      print "check by pingall"
+      (code, result) = check_by_pingall()
+      if code == 0:
+        print "ping success %s" % (result)
+      else:
+        print "pingall failed (%d, %d). Collecting logs" % (cycle, n)
+        error = "error-log.%d.%d.log" % (cycle, n)
+        nmapflow  = "nmap-flow-log.%d.%d.log" % (cycle, n)
+        rawflow  = "raw-flow-log.%d.%d.log" % (cycle, n)
+
+        f = open(error, 'w')
+        f.write(result)
+        f.write(check_switch()[1])
+        f.write(check_link()[1])
+        f.write(check_switch_local()[1])
+        f.write(check_controllers(8)[1])
+        f.close()
+
+        f = open(nmapflow,'w')
+        f.write(check_flow_nmap()[1])
+        f.close()
+
+        f = open(rawflow,'w')
+        f.write(check_flow_raw()[1])
+        f.close()
+        check_rest(cycle,n)
+
+    
diff --git a/cluster-mgmt/bin/cho-link-failure.sh b/cluster-mgmt/bin/cho-link-failure.sh
new file mode 100755
index 0000000..6c5f128
--- /dev/null
+++ b/cluster-mgmt/bin/cho-link-failure.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+basename=$ONOS_CLUSTER_BASENAME
+wait=10
+
+fdef="flowdef_8node_42.txt"
+
+function log()
+{
+    date > error.$1.$2.log
+    check_status.py >> error.$1.$2.log
+    dsh -w ${basename}1 "cd ONOS/web; ./get_flow.py all" >> error.$1.$2.log
+    dsh "cd ONOS/scripts; ./showflow.sh"             >> error.$1.$2.log
+}
+
+echo "all links up"
+dsh -w ${basename}1 "cd ONOS/scripts; ./all-linkup.sh"
+echo "clean up flow"
+dsh -w ${basename}1 "cd ONOS/web; ./delete_flow.py 1 100"
+dsh -w ${basename}1 "cd ONOS/web; ./clear_flow.py 1 100"
+sleep 1
+dsh -w ${basename}1 "cd ONOS/web; ./get_flow.py all"
+dsh "cd ONOS/scripts; ./delflow.sh"
+echo "checkup status"
+check_status.py
+read -p "hit anykey> "
+
+echo "install pre-set flows"
+dsh -w ${basename}1 "cd ONOS/web; ./add_flow.py -m onos -f $fdef"
+sleep 6
+echo "check"
+dsh -w ${basename}1 "cd ONOS/web; ./pingall.py $fdef"
+
+#ports=`dsh -w ${basename}1 "cd ONOS/scripts; ./listports.sh" | awk '{print $2}' |grep -v tap`
+operation=("sw3-eth3 down" "sw4-eth4 down" "sw4-eth3 down" "sw3-eth3 up" "sw1-eth2 down" "sw4-eth4 up" "sw4-eth3 up" "sw1-eth2 up")
+
+((n=0))
+while [ 1 ] ; do
+  for (( i = 0; i< ${#operation[@]}; i ++)); do
+    echo "Test $n-$i"
+    p=`echo ${operation[$i]}`
+    echo "operation: $p"
+#  read -p "hit anykey> "
+    dsh -w ${basename}1 "sudo ifconfig $p"
+    echo "wait $wait sec"
+    sleep $wait 
+    result=`dsh -w ${basename}1 "cd ONOS/web; ./pingall.py $fdef"`
+    echo $result
+    nr_fail=`echo $result |grep fail | wc -l`
+    if [ $nr_fail -gt 0 ]; then
+      log $n $i
+    fi
+  done
+  ((n++))
+done
+
diff --git a/cluster-mgmt/bin/start.sh b/cluster-mgmt/bin/start.sh
index 23fcde7..e58e802 100755
--- a/cluster-mgmt/bin/start.sh
+++ b/cluster-mgmt/bin/start.sh
@@ -16,4 +16,5 @@
   exit
 fi
 onos start
-dsh -g $basename 'cd ONOS; ./ctrl-local.sh'
+switch local
+#dsh -g $basename 'cd ONOS; ./ctrl-local.sh'