Make Cassandra port configurable.

SDC-BE & Onboarding - BE.
Reviewer: Evgenia A & Areli F.

Change-Id: Iaf86d647b0560764ef65d9148c85bffaf934992d
Issue-ID: SDC-2077
Signed-off-by: Tal Gitelman <tal.gitelman@att.com>
diff --git a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/attributes/version.rb b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/attributes/version.rb
new file mode 100644
index 0000000..8ba0564
--- /dev/null
+++ b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/attributes/version.rb
@@ -0,0 +1 @@
+normal['version'] ="1.4.0"
diff --git a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/01-createCsUser.rb b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/01-createCsUser.rb
index d14e9a2..84b0cb2 100644
--- a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/01-createCsUser.rb
+++ b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/01-createCsUser.rb
@@ -3,10 +3,11 @@
   sensitive true
   mode 0755
   variables({
-     :cassandra_ip => node['Nodes']['CS'].first,
-     :cassandra_pwd => ENV['CS_PASSWORD'],
-     :sdc_usr => ENV['SDC_USER'],
-     :sdc_pwd => ENV['SDC_PASSWORD']
+     :cassandra_ip      => node['Nodes']['CS'].first,
+     :cassandra_port    => node['cassandra']['cassandra_port'],
+     :cassandra_pwd     => ENV['CS_PASSWORD'],
+     :sdc_usr           => ENV['SDC_USER'],
+     :sdc_pwd           => ENV['SDC_PASSWORD']
   })
 end
 
diff --git a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/02-createDoxKeyspace.rb b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/02-createDoxKeyspace.rb
index 782358b..c9a4087 100644
--- a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/02-createDoxKeyspace.rb
+++ b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/02-createDoxKeyspace.rb
@@ -3,10 +3,11 @@
     sensitive true
     mode 0755
     variables({
-      :cassandra_ip => node['Nodes']['CS'].first,
-      :DC_NAME      => node['cassandra']['datacenter_name']+node.chef_environment,
-      :cassandra_pwd => node['cassandra'][:cassandra_password],
-      :cassandra_usr => node['cassandra'][:cassandra_user]
+      :cassandra_ip     => node['Nodes']['CS'].first,
+      :cassandra_port   => node['cassandra']['cassandra_port'],
+      :DC_NAME          => node['cassandra']['datacenter_name']+node.chef_environment,
+      :cassandra_pwd    => node['cassandra'][:cassandra_password],
+      :cassandra_usr    => node['cassandra'][:cassandra_user]
     })
 end
 
diff --git a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/03-schemaCreation.rb b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/03-schemaCreation.rb
index d2c7a8c..b48eecd 100644
--- a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/03-schemaCreation.rb
+++ b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/03-schemaCreation.rb
@@ -36,6 +36,7 @@
       :catalog_port           => node['BE'][:http_port],
       :ssl_port               => node['BE'][:https_port],
       :cassandra_ip           => node['Nodes']['CS'].first,
+      :cassandra_port         => node['cassandra']['cassandra_port'],
       :rep_factor             => 1,
       :DC_NAME                => node['cassandra']['datacenter_name']+node.chef_environment,
       :titan_Path             => "/tmp/sdctool/config/",
diff --git a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb
index 67a0503c..b72f520 100644
--- a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb
+++ b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb
@@ -72,6 +72,7 @@
 
 cassandraConfig:
     cassandraHosts: [<%= @cassandra_ip %>]
+    cassandraPort: <%= @cassandra_port %>
     localDataCenter: <%= @DC_NAME %>
     reconnectTimeout : 30000
     socketReadTimeout: <%= @socket_read_timeout %>
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
index df4a55e..bbd048c 100644
--- 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
@@ -1,6 +1,8 @@
 #!/bin/bash
 
 CASSANDRA_IP=<%= @cassandra_ip %>
+#Port for Cassandra Thrift to listen for clients on
+CASSANDRA_PORT=9160
 CS_PASSWORD=<%= @cassandra_pwd %>
 SDC_USER=<%= @sdc_usr %>
 SDC_PASSWORD=<%= @sdc_pwd %>
@@ -11,7 +13,7 @@
 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
+   echo "exit" | cqlsh -u cassandra -p $CS_PASSWORD $CASSANDRA_IP $CASSANDRA_PORT  > /dev/null 2>&1
    res1=$?
 
    if [ $res1 -eq 0 ]; then
@@ -24,10 +26,10 @@
    let "retry_num++"
 done
 
-cassandra_user_exist=`echo "list users;" | cqlsh -u cassandra -p $CS_PASSWORD $CASSANDRA_IP  |grep -c $SDC_USER`
+cassandra_user_exist=`echo "list users;" | cqlsh -u cassandra -p $CS_PASSWORD $CASSANDRA_IP $CASSANDRA_PORT | 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
+                echo "create user $SDC_USER with password '$SDC_PASSWORD' nosuperuser;" | cqlsh -u cassandra -p $CS_PASSWORD $CASSANDRA_IP $CASSANDRA_PORT
         fi
\ No newline at end of file
diff --git a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/create_dox_keyspace.sh.erb b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/create_dox_keyspace.sh.erb
index c350704..e9d10af 100644
--- a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/create_dox_keyspace.sh.erb
+++ b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/create_dox_keyspace.sh.erb
@@ -3,6 +3,7 @@
 CASSANDRA_USER='<%= @cassandra_usr %>'
 CASSANDRA_PASS='<%= @cassandra_pwd %>'
 CASSANDRA_IP='<%= @cassandra_ip %>'
+CASSANDRA_PORT=<%= @cassandra_port %>
 
 KEYSPACE="CREATE KEYSPACE IF NOT EXISTS dox WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', '<%= @DC_NAME %>': '1'};"
 KEYSPACE1="CREATE KEYSPACE IF NOT EXISTS zusammen_dox WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', '<%= @DC_NAME %>': '1'};"
@@ -11,10 +12,10 @@
 echo -e "$KEYSPACE\n$KEYSPACE1" > /tmp/create_dox_keyspace.cql
 
 chmod 755 /tmp/create_dox_keyspace.cql
-cqlsh -u $CASSANDRA_USER -p $CASSANDRA_PASS $CASSANDRA_IP -f /tmp/create_dox_keyspace.cql > /dev/null 2>&1
+cqlsh -u $CASSANDRA_USER -p $CASSANDRA_PASS $CASSANDRA_IP $CASSANDRA_PORT -f /tmp/create_dox_keyspace.cql > /dev/null 2>&1
 
 
-res=`echo "select keyspace_name from system.schema_keyspaces ;" | cqlsh -u $CASSANDRA_USER -p $CASSANDRA_PASS $CASSANDRA_IP |grep -c dox 2>/dev/null`
+res=`echo "select keyspace_name from system.schema_keyspaces ;" | cqlsh -u $CASSANDRA_USER -p $CASSANDRA_PASS $CASSANDRA_IP $CASSANDRA_PORT |grep -c dox 2>/dev/null`
 
 if [ $res -gt 0 ]; then
         echo "`date` --- dox keyspace was created "
@@ -25,11 +26,11 @@
 
 echo "run create_dox_db.cql"
 chmod 755 /tmp/tools/build/scripts/create_dox_db.cql
-cqlsh -u $CASSANDRA_USER -p $CASSANDRA_PASS $CASSANDRA_IP -f /tmp/tools/build/scripts/create_dox_db.cql > /dev/null 2>&1
+cqlsh -u $CASSANDRA_USER -p $CASSANDRA_PASS $CASSANDRA_IP $CASSANDRA_PORT -f /tmp/tools/build/scripts/create_dox_db.cql > /dev/null 2>&1
 
 sleep 10
 
 echo "run alter_dox_db.cql"
 chmod 755 /tmp/tools/build/scripts/alter_dox_db.cql
-cqlsh -u $CASSANDRA_USER -p $CASSANDRA_PASS $CASSANDRA_IP -f /tmp/tools/build/scripts/alter_dox_db.cql > /dev/null 2>&1
+cqlsh -u $CASSANDRA_USER -p $CASSANDRA_PASS $CASSANDRA_IP $CASSANDRA_PORT -f /tmp/tools/build/scripts/alter_dox_db.cql > /dev/null 2>&1