Upgrade SDC to use common cassandra cluster

Change-Id: Ib6a45de3b10cb57466b7b3ef2e18b2fe07639c0f
Issue-ID: SDC-2199
Signed-off-by: mahendrr <mahendra.raghuwanshi@amdocs.com>
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 c9a4087..a516c71 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
@@ -5,7 +5,7 @@
     variables({
       :cassandra_ip     => node['Nodes']['CS'].first,
       :cassandra_port   => node['cassandra']['cassandra_port'],
-      :DC_NAME          => node['cassandra']['datacenter_name']+node.chef_environment,
+      :DC_NAME          => node['cassandra']['datacenter_name'],
       :cassandra_pwd    => node['cassandra'][:cassandra_password],
       :cassandra_usr    => node['cassandra'][:cassandra_user]
     })
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 b48eecd..fbfcb2e 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
@@ -18,11 +18,12 @@
   source "titan.properties.erb"
   mode "0755"
   variables({
-     :DC_NAME      => node['cassandra']['datacenter_name']+node.chef_environment,
+     :DC_NAME      => node['cassandra']['datacenter_name'],
      :cassandra_ip  => node['Nodes']['CS'].first,
      :cassandra_pwd => node['cassandra'][:cassandra_password],
      :cassandra_usr => node['cassandra'][:cassandra_user],
-     :titan_connection_timeout => node['cassandra']['titan_connection_timeout']
+     :titan_connection_timeout => node['cassandra']['titan_connection_timeout'],
+     :replication_factor => node['cassandra']['replication_factor']
   })
 end
 
@@ -37,8 +38,8 @@
       :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,
+      :rep_factor             => node['cassandra']['replication_factor'],
+      :DC_NAME                => node['cassandra']['datacenter_name'],
       :titan_Path             => "/tmp/sdctool/config/",
       :socket_connect_timeout => node['cassandra']['socket_connect_timeout'],
       :socket_read_timeout    => node['cassandra']['socket_read_timeout'],
diff --git a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/titan.properties.erb b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/titan.properties.erb
index 0f31341..20a97be 100644
--- a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/titan.properties.erb
+++ b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/titan.properties.erb
@@ -14,7 +14,7 @@
 storage.cassandra.read-consistency-level=LOCAL_QUORUM
 storage.cassandra.write-consistency-level=LOCAL_QUORUM
 storage.cassandra.replication-strategy-class=org.apache.cassandra.locator.NetworkTopologyStrategy
-storage.cassandra.replication-strategy-options=<%= @DC_NAME %>,1
+storage.cassandra.replication-strategy-options=<%= @DC_NAME %>,<%= @replication_factor %>
 storage.cassandra.astyanax.local-datacenter=<%= @DC_NAME %>
 
 cache.db-cache = false
diff --git a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_2_setup_configuration.rb b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_2_setup_configuration.rb
index 335271f..5d83cdb 100644
--- a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_2_setup_configuration.rb
+++ b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_2_setup_configuration.rb
@@ -1,21 +1,12 @@
 # Set the cassandra replica number
-cassandra_nodes = node['Nodes']['CS']
-if cassandra_nodes.length <=2
-   replication_factor=1
-elsif cassandra_nodes.length >2 && cassandra_nodes.length <=4
-   replication_factor=3
-else
-   replication_factor=4
-end
-
-
+replication_factor=node['cassandra']['replication_factor']
 
 if node['Pair_EnvName'] == ""
-    titan_dcname_with_rep = node['cassandra']['datacenter_name'] + node.chef_environment + ","   + replication_factor.to_s
-    conf_dcname_with_rep  = node['cassandra']['datacenter_name'] + node.chef_environment + "','" + replication_factor.to_s
+    titan_dcname_with_rep = node['cassandra']['datacenter_name'] + ","   + replication_factor.to_s
+    conf_dcname_with_rep  = node['cassandra']['datacenter_name'] + "','" + replication_factor.to_s
 else
-    titan_dcname_with_rep = node['cassandra']['datacenter_name'] + node.chef_environment + ","   + replication_factor.to_s + "," + node['cassandra']['cluster_name']   + node['Pair_EnvName'] + ","   + replication_factor.to_s
-    conf_dcname_with_rep  = node['cassandra']['datacenter_name'] + node.chef_environment + "','" + replication_factor.to_s + "','" + node['cassandra']['cluster_name'] + node['Pair_EnvName'] + "','" + replication_factor.to_s
+    titan_dcname_with_rep = node['cassandra']['datacenter_name'] + ","   + replication_factor.to_s + "," + node['cassandra']['cluster_name']   + node['Pair_EnvName'] + ","   + replication_factor.to_s
+    conf_dcname_with_rep  = node['cassandra']['datacenter_name'] + "','" + replication_factor.to_s + "','" + node['cassandra']['cluster_name'] + node['Pair_EnvName'] + "','" + replication_factor.to_s
 end
 
 
@@ -31,7 +22,7 @@
       :cassandra_pwd            => node['cassandra'][:cassandra_password],
       :cassandra_usr            => node['cassandra'][:cassandra_user],
       :rep_factor               => replication_factor,
-      :DC_NAME                  => node['cassandra']['datacenter_name']+node.chef_environment,
+      :DC_NAME                  => node['cassandra']['datacenter_name'],
       :DC_NAME_WITH_REP         => titan_dcname_with_rep,
       :titan_connection_timeout => node['cassandra']['titan_connection_timeout'],
       :cassandra_truststore_password => node['cassandra'][:truststore_password],
@@ -53,7 +44,7 @@
       :cassandra_ip           => node['Nodes']['CS'].join(",").gsub(/[|]/,''),
       :cassandra_port         => node['cassandra']['cassandra_port'],
       :rep_factor             => replication_factor,
-      :DC_NAME                => node['cassandra']['datacenter_name']+node.chef_environment,
+      :DC_NAME                => node['cassandra']['datacenter_name'],
       :REP_STRING             => conf_dcname_with_rep,
       :titan_Path             => "/var/lib/jetty/config/catalog-be/",
       :socket_connect_timeout => node['cassandra']['socket_connect_timeout'],
diff --git a/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/recipes/ON_5_setup_configuration.rb b/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/recipes/ON_5_setup_configuration.rb
index 5f7e5e6..80fc57e 100644
--- a/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/recipes/ON_5_setup_configuration.rb
+++ b/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/recipes/ON_5_setup_configuration.rb
@@ -10,7 +10,7 @@
       :ssl_port                        => node['ONBOARDING_BE'][:https_port],
       :cassandra_ip                    => node['Nodes']['CS'].join(",").gsub(/[|]/,''),
       :cassandra_port                  => node['cassandra']['cassandra_port'],
-      :DC_NAME                         => node['cassandra']['datacenter_name']+node.chef_environment,
+      :DC_NAME                         => node['cassandra']['datacenter_name'],
       :socket_connect_timeout          => node['cassandra']['socket_connect_timeout'],
       :socket_read_timeout             => node['cassandra']['socket_read_timeout'],
       :cassandra_pwd                   => node['cassandra'][:cassandra_password],
diff --git a/sdc-os-chef/environments/Template.json b/sdc-os-chef/environments/Template.json
index 3fee2a2..8b5866b 100644
--- a/sdc-os-chef/environments/Template.json
+++ b/sdc-os-chef/environments/Template.json
@@ -79,8 +79,8 @@
             "cassandra_user": "asdc_user",
             "cassandra_password": "Aa1234%^!",
             "concurrent_writes": "32",
-            "cluster_name": "SDC-CS-",
-            "datacenter_name": "SDC-CS-",
+            "cluster_name": "SDC-CS",
+            "datacenter_name": "SDC-CS",
             "multithreaded_compaction": "false",
             "cache_dir": "/var/lib/cassandra/saved_caches",
             "log_file": "/var/lib/cassandra/log/system.log",
@@ -88,7 +88,8 @@
             "commitlog_dir": "/var/lib/cassandra/commitlog",
             "socket_read_timeout": "20000",
             "socket_connect_timeout": "20000",
-            "titan_connection_timeout": "10000"
+            "titan_connection_timeout": "10000",
+            "replication_factor": "1"
         }
     }
 }
diff --git a/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/recipes/01-configureCassandra.rb b/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/recipes/01-configureCassandra.rb
index 47ab456..5b05e9b 100644
--- a/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/recipes/01-configureCassandra.rb
+++ b/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/recipes/01-configureCassandra.rb
@@ -1,5 +1,5 @@
 cluster_name = ''
-cluster_name = node['cassandra'][:cluster_name]+node.chef_environment
+cluster_name = node['cassandra'][:cluster_name]
 
 cas_ips=''
 cas_ips=node['Nodes'][:CS]
@@ -45,7 +45,7 @@
     group "cassandra"
     mode "0755"
     variables ({
-        :dc => cluster_name,
-        :rack => "Rack"+"#{rackNum}-"+node.chef_environment
+        :dc => node['cassandra']['datacenter_name'],
+        :rack => "Rack"+"#{rackNum}"
     })
-end
\ No newline at end of file
+end
diff --git a/test-apis-ci/sdc-api-tests/chef-repo/cookbooks/sdc-api-tests/recipes/sanityApiTests_2_setup_configuration.rb b/test-apis-ci/sdc-api-tests/chef-repo/cookbooks/sdc-api-tests/recipes/sanityApiTests_2_setup_configuration.rb
index 595b24a..5fdc55f 100644
--- a/test-apis-ci/sdc-api-tests/chef-repo/cookbooks/sdc-api-tests/recipes/sanityApiTests_2_setup_configuration.rb
+++ b/test-apis-ci/sdc-api-tests/chef-repo/cookbooks/sdc-api-tests/recipes/sanityApiTests_2_setup_configuration.rb
@@ -26,7 +26,6 @@
     })
 end
 
-replication_factor=1
 template "titan.properties" do
    path "/#{tests_base}/conf/titan.properties"
    source "BE-titan.properties.erb"
@@ -37,8 +36,8 @@
       :CASSANDRA_IP => node['Nodes']['CS'].join(",").gsub(/[|]/,''),
       :CASSANDRA_PWD => node['cassandra'][:cassandra_password],
       :CASSANDRA_USR => node['cassandra'][:cassandra_user],
-      :rep_factor => replication_factor,
-      :DC_NAME      => node['cassandra']['datacenter_name']+node.chef_environment
+      :rep_factor => node['cassandra']['replication_factor'],
+      :DC_NAME      => node['cassandra']['datacenter_name']
    })
 end
 
diff --git a/ui-ci/sdc-ui-tests/chef-repo/cookbooks/sdc-ui-tests/recipes/sanityUiTests_2_setup_configuration.rb b/ui-ci/sdc-ui-tests/chef-repo/cookbooks/sdc-ui-tests/recipes/sanityUiTests_2_setup_configuration.rb
index 8bef97c..1d4c6d6 100644
--- a/ui-ci/sdc-ui-tests/chef-repo/cookbooks/sdc-ui-tests/recipes/sanityUiTests_2_setup_configuration.rb
+++ b/ui-ci/sdc-ui-tests/chef-repo/cookbooks/sdc-ui-tests/recipes/sanityUiTests_2_setup_configuration.rb
@@ -26,7 +26,6 @@
     })
 end
 
-replication_factor=1
 template "titan.properties" do
    path "/#{tests_base}/conf/titan.properties"
    source "BE-titan.properties.erb"
@@ -37,7 +36,7 @@
       :CASSANDRA_IP => node['Nodes']['CS'].join(",").gsub(/[|]/,''),
       :CASSANDRA_PWD => node['cassandra'][:cassandra_password],
       :CASSANDRA_USR => node['cassandra'][:cassandra_user],
-      :rep_factor => replication_factor,
-      :DC_NAME      => node['cassandra']['datacenter_name']+node.chef_environment
+      :rep_factor => node['cassandra']['replication_factor'],
+      :DC_NAME      => node['cassandra']['datacenter_name']
    })
 end