diff options
author | Yuli Shlosberg <ys9693@att.com> | 2018-01-25 13:53:36 +0200 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-02-04 10:39:20 +0000 |
commit | 0875ce0faad191c21b32cc9c95ffc20ebd57d586 (patch) | |
tree | 28520da212637e0f67697d9ff837e80da6eaa408 /asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/create_cassandra_user.sh.erb | |
parent | b676b6dcada5549348003191c09142e92de4d352 (diff) |
Cassandra OOM Alignment
Change-Id: If9792919dba17936965b45361888a44a12a76b67
Issue-ID: SDC-911
Signed-off-by: Yuli Shlosberg <ys9693@att.com>
Diffstat (limited to 'asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/create_cassandra_user.sh.erb')
-rw-r--r-- | asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/create_cassandra_user.sh.erb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/create_cassandra_user.sh.erb b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/create_cassandra_user.sh.erb new file mode 100644 index 0000000000..df4a55e34b --- /dev/null +++ b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/create_cassandra_user.sh.erb @@ -0,0 +1,33 @@ +#!/bin/bash + +CASSANDRA_IP=<%= @cassandra_ip %> +CS_PASSWORD=<%= @cassandra_pwd %> +SDC_USER=<%= @sdc_usr %> +SDC_PASSWORD=<%= @sdc_pwd %> + + +pass_changed=99 +retry_num=1 +is_up=0 +while [ $is_up -eq 0 -a $retry_num -le 100 ]; do + + echo "exit" | cqlsh -u cassandra -p $CS_PASSWORD $CASSANDRA_IP > /dev/null 2>&1 + res1=$? + + if [ $res1 -eq 0 ]; then + echo "`date` --- cqlsh is enabled to connect." + is_up=1 + else + echo "`date` --- cqlsh is NOT enabled to connect yet. sleep 5" + sleep 5 + fi + let "retry_num++" +done + +cassandra_user_exist=`echo "list users;" | cqlsh -u cassandra -p $CS_PASSWORD $CASSANDRA_IP |grep -c $SDC_USER` + if [ $cassandra_user_exist -eq 1 ] ; then + echo "cassandra user $SDC_USER already exist" + else + echo "Going to create $SDC_USER" + echo "create user $SDC_USER with password '$SDC_PASSWORD' nosuperuser;" | cqlsh -u cassandra -p $CS_PASSWORD $CASSANDRA_IP + fi
\ No newline at end of file |