blob: e7d976d021ccee1dc9c8ad8b8b5c8f196721033a [file] [log] [blame]
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +00001USERNAME=ubuntu
2CASSANDRA_DIR='/home/ubuntu/apache-cassandra-1.1.4'
3ZK_DIR='/home/ubuntu/zookeeper-3.4.5'
4ONOS_DIR='/home/ubuntu/ONOS'
5ZK_LIB='/var/lib/zookeeper'
6CASSANDRA_LIB='/var/lib/cassandra'
7
8if [ x$CLUSTER == "x" ]; then
9 echo "CLUSTER is not set. Exitting."
10 exit
11fi
12if [ x$ONOS_CLUSTER_BASENAME == "x" ]; then
13 echo "ONOS_CLUSTER_BASENAME is not set. Exitting"
14 exit
15fi
16if [ x$ONOS_CLUSTER_NR_NODES == "x" ]; then
17 echo "ONOS_CLUSTER_NR_NODES is not set. Exitting"
18 exit
19fi
20
21export basename=$ONOS_CLUSTER_BASENAME
22export nr_nodes=$ONOS_CLUSTER_NR_NODES
23
24checkcluster () {
25 dsh -g $basename 'uname -a'
26}
27
28zk () {
29 case "$1" in
30 start)
31 echo "Starting ZK.."
32 dsh -g $basename "$ZK_DIR/bin/zkServer.sh start"
33 while [ 1 ]; do
34 nup=`dsh -g $basename "$ZK_DIR/bin/zkServer.sh status" | grep "Mode" | egrep "leader|follower" | wc -l`
35 if [ $nup == $nr_nodes ]; then
36 echo "everybody's up: $nup up of of $nr_nodes"
37 echo "ZK started"
38 break;
39 fi
40 echo "waiting for everybody's up: $nup up of of $nr_nodes"
41 sleep 1
42 done
43 ;;
44 stop)
45 echo "Stopping ZK.."
46 dsh -g $basename "$ZK_DIR/bin/zkServer.sh stop"
47 ;;
48 status)
49 echo "Checking ZK Status"
50 dsh -g $basename "$ZK_DIR/bin/zkServer.sh status"
51 ;;
52 esac
53}
54
55cassandra () {
56 case "$1" in
57 start)
58 echo "Starting Cassandra.."
59 echo " start cassandra at the seed node"
60 dsh -w ${basename}1 "cd $ONOS_DIR; ./start-cassandra.sh start"
61 sleep 1
62 echo " start cassandra in rest nodes"
63 dsh -g ${basename} -x ${basename}1 "cd $ONOS_DIR; ./start-cassandra.sh start"
64 while [ 1 ]; do
65 echo $$
66 dsh -w ${basename}1 "cd $ONOS_DIR; ./start-cassandra.sh status" > .cassandra_check.$$
67 cat .cassandra_check.$$
68 nup=`cat .cassandra_check.$$ | grep Normal |grep Up| wc -l`
69 if [ $nup == $nr_nodes ]; then
70 echo "everybody's up: $nup up of of $nr_nodes"
71 echo "Cassandra started"
72 break;
73 fi
74 echo "waiting for everybody's up: $nup up of of $nr_nodes"
75 sleep 1
76 done
77 ;;
78 stop)
79 echo "Stopping Cassandra.."
80 dsh -g ${basename} "cd $ONOS_DIR; ./start-cassandra.sh stop"
81 ;;
82 cleandb)
83 echo "Removing all data in db"
84 dsh -w ${basename}1 "cd $ONOS_DIR; ./scripts/cleanup-cassandra.sh"
85 ;;
86 status)
87 echo "Checking Cassandra Status"
88 dsh -w ${basename}1 "cd $ONOS_DIR; ./start-cassandra.sh status"
89 ;;
90 esac
91}
92
93onos () {
94 case "$1" in
95 start)
96 echo "Starting ONOS"
97 dsh -g ${basename} "cd $ONOS_DIR; ./start-onos.sh start"
98 dsh -w ${basename}1 "cd $ONOS_DIR; ./start-rest.sh start"
99 ;;
100 stop)
101 echo "Stop ONOS"
102 dsh -g ${basename} "cd $ONOS_DIR; ./start-onos.sh stop"
103 ;;
104 status)
105 echo "Checking ONOS Status"
106 dsh -g ${basename} "cd $ONOS_DIR; ./start-onos.sh status"
107 ;;
108 esac
109}