Revert "Fix JVM monitoring scripts"
[integration/test.git] / csit / scripts / set_jvm_common_attribute.sh
index dab360db0d288cf39719ef15d9b1bc3dadcaf00c..408910d943cac7e8e7b908fae71d7eb4bb06dc94 100644 (file)
@@ -1,12 +1,4 @@
 #!/bin/bash
-echo "Setup common config to ${ODL_SYSTEM_IP}"
-
-cat > ${WORKSPACE}/org.apache.karaf.decanter.appender.elasticsearch.cfg <<EOF
-host=${ODL_SYSTEM_IP}
-port=9300
-clusterName=elasticsearch
-
-EOF
 
 cat > ${WORKSPACE}/org.apache.karaf.decanter.collector.jmx-local.cfg <<EOF
 type=jmx-local
@@ -22,33 +14,66 @@ object.name=java.lang:type=*
 
 EOF
 
-echo "Copying config files to ${ODL_SYSTEM_IP}"
 
-scp ${WORKSPACE}/org.apache.karaf.decanter.appender.elasticsearch.cfg ${ODL_SYSTEM_IP}:/tmp/${BUNDLEFOLDER}/etc/
-scp ${WORKSPACE}/org.apache.karaf.decanter.collector.jmx-local.cfg ${ODL_SYSTEM_IP}:/tmp/${BUNDLEFOLDER}/etc/
-scp ${WORKSPACE}/org.apache.karaf.decanter.collector.jmx-others.cfg ${ODL_SYSTEM_IP}:/tmp/${BUNDLEFOLDER}/etc/
+for i in `seq 1 ${NUM_ODL_SYSTEM}`
+do
+    CONTROLLERIP=ODL_SYSTEM_${i}_IP
+    CLUSTERNAME=`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 12`
 
-cat > ${WORKSPACE}/elasticsearch.yml <<EOF
-cluster.name: elasticsearch
-network.host: ${ODL_SYSTEM_IP}
+    cat > ${WORKSPACE}/elasticsearch.yml <<EOF
+    cluster.name: ${CLUSTERNAME}
+    network.host: ${!CONTROLLERIP}
+    discovery.zen.ping.multicast.enabled: false
 
 EOF
+    cat > ${WORKSPACE}/org.apache.karaf.decanter.appender.elasticsearch.cfg <<EOF
+    host=${!CONTROLLERIP}
+    port=9300
+    clusterName=${CLUSTERNAME}
+
+EOF
+
+    cat > ${WORKSPACE}/elasticsearch_startup.sh <<EOF
+    cd /tmp/elasticsearch/elasticsearch-1.7.5
+    ls -al
+
+    if [ -d "data" ]; then
+        echo "data directory exists, deleting...."
+        rm -r data
+    else
+        echo "data directory does not exist"
+    fi
 
-scp ${WORKSPACE}/elasticsearch.yml ${ODL_SYSTEM_IP}:/tmp/
-ssh ${ODL_SYSTEM_IP} "sudo mv /tmp/elasticsearch.yml /tmp/elasticsearch/elasticsearch-1.7.5/config/"
-ssh ${ODL_SYSTEM_IP} "cat /tmp/elasticsearch/elasticsearch-1.7.5/config/elasticsearch.yml"
+    cd /tmp/elasticsearch
+    ls -al
 
-cat > ${WORKSPACE}/elasticsearch_startup.sh <<EOF
-cd /tmp/elasticsearch
-echo "Starting Elasticsearch node"
-export JAVA_HOME=/usr
-sudo /tmp/elasticsearch/elasticsearch-1.7.5/bin/elasticsearch > /dev/null 2>&1 &
-ls -al /tmp/elasticsearch/elasticsearch-1.7.5/bin/elasticsearch
+    echo "Starting Elasticsearch node"
+    sudo /tmp/elasticsearch/elasticsearch-1.7.5/bin/elasticsearch > /dev/null 2>&1 &
+    ls -al /tmp/elasticsearch/elasticsearch-1.7.5/bin/elasticsearch
 
 EOF
+    echo "Setup ODL_SYSTEM_IP specific config files for ${!CONTROLLERIP} "
+
+    cat ${WORKSPACE}/org.apache.karaf.decanter.appender.elasticsearch.cfg
+    cat ${WORKSPACE}/elasticsearch.yml
+
+
+    echo "Copying config files to ${!CONTROLLERIP}"
+
+    scp ${WORKSPACE}/org.apache.karaf.decanter.appender.elasticsearch.cfg ${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/etc/
+    scp ${WORKSPACE}/org.apache.karaf.decanter.collector.jmx-local.cfg ${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/etc/
+    scp ${WORKSPACE}/org.apache.karaf.decanter.collector.jmx-others.cfg ${!CONTROLLERIP}:/tmp/${BUNDLEFOLDER}/etc/
+
+    scp ${WORKSPACE}/elasticsearch.yml ${!CONTROLLERIP}:/tmp/
+
+    ssh ${!CONTROLLERIP} "sudo ls -al /tmp/elasticsearch/"
+
+    ssh ${!CONTROLLERIP} "sudo mv /tmp/elasticsearch.yml /tmp/elasticsearch/elasticsearch-1.7.5/config/"
+    ssh ${!CONTROLLERIP} "cat /tmp/elasticsearch/elasticsearch-1.7.5/config/elasticsearch.yml"
 
-echo "Copying the elasticsearch_startup script to ${ODL_SYSTEM_IP}"
-cat ${WORKSPACE}/elasticsearch_startup.sh
-scp ${WORKSPACE}/elasticsearch_startup.sh ${ODL_SYSTEM_IP}:/tmp
-ssh ${ODL_SYSTEM_IP} 'bash /tmp/elasticsearch_startup.sh'
-ssh ${ODL_SYSTEM_IP} 'ps aux | grep elasticsearch'
+    echo "Copying the elasticsearch_startup script to ${!CONTROLLERIP}"
+    cat ${WORKSPACE}/elasticsearch_startup.sh
+    scp ${WORKSPACE}/elasticsearch_startup.sh ${!CONTROLLERIP}:/tmp
+    ssh ${!CONTROLLERIP} 'bash /tmp/elasticsearch_startup.sh'
+    ssh ${!CONTROLLERIP} 'ps aux | grep elasticsearch'
+done