diff options
Diffstat (limited to 'asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions')
6 files changed, 35 insertions, 61 deletions
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 84b0cb2b40..3c67715922 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 @@ -11,9 +11,8 @@ template "/tmp/create_cassandra_user.sh" do }) end - -bash "create-sdc-user" do - code <<-EOH - cd /tmp ; /tmp/create_cassandra_user.sh - EOH -end +execute "create-sdc-user" do + command "/tmp/create_cassandra_user.sh" + cwd "/tmp/" + action :run +end
\ No newline at end of file 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 38de1e8844..5f740a8909 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 @@ -19,21 +19,16 @@ remote_directory '/tmp/tools' do action :create end - -bash "onboard-db-schema-creation" do +execute "onboard-db-schema-creation" do ignore_failure true - code <<-EOH - cd /tmp/tools/build/scripts - chmod +x onboard-db-schema-creation.sh - bash /tmp/tools/build/scripts/onboard-db-schema-creation.sh - EOH + command "chmod +x onboard-db-schema-creation.sh && sh -x /tmp/tools/build/scripts/onboard-db-schema-creation.sh" + cwd "/tmp/tools/build/scripts" + action :run end - -bash "create-DOX-schema" do + +execute "create-DOX-schema" do ignore_failure true - code <<-EOH - cd /tmp - chmod +x /tmp/create_dox_keyspace.sh - /tmp/create_dox_keyspace.sh - EOH -end + command "chmod +x /tmp/create_dox_keyspace.sh && /tmp/create_dox_keyspace.sh" + cwd "/tmp" + action :run +end
\ No newline at end of file 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 a62550eeae..e60740fb3d 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 @@ -3,15 +3,12 @@ cookbook_file "/tmp/sdctool.tar" do mode 0755 end -## extract sdctool.tar -bash "install tar" do +execute "install tar" do + command "/bin/tar xf /tmp/sdctool.tar -C /tmp" cwd "/tmp" - code <<-EOH - /bin/tar xf /tmp/sdctool.tar -C /tmp - EOH + action :run end - template "janusgraph.properties" do sensitive true path "/tmp/sdctool/config/janusgraph.properties" @@ -49,19 +46,13 @@ template "/tmp/sdctool/config/configuration.yaml" do }) end - - -bash "executing-schema-creation" do - code <<-EOH - cd /tmp - chmod +x /tmp/sdctool/scripts/schemaCreation.sh - /tmp/sdctool/scripts/schemaCreation.sh /tmp/sdctool/config - EOH +execute "executing-schema-creation" do + command "chmod +x /tmp/sdctool/scripts/schemaCreation.sh && /tmp/sdctool/scripts/schemaCreation.sh /tmp/sdctool/config" + cwd "/tmp" + action :run end -bash "executing-janusGraphSchemaCreation.sh" do - code <<-EOH - chmod +x /tmp/sdctool/scripts/janusGraphSchemaCreation.sh - /tmp/sdctool/scripts/janusGraphSchemaCreation.sh /tmp/sdctool/config - EOH -end +execute "executing-janusGraphSchemaCreation.sh" do + command "chmod +x /tmp/sdctool/scripts/janusGraphSchemaCreation.sh && /tmp/sdctool/scripts/janusGraphSchemaCreation.sh /tmp/sdctool/config" + action :run +end
\ No newline at end of file diff --git a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/04-importConformance.rb b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/04-importConformance.rb index 0490c89668..8c2ee505be 100644 --- a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/04-importConformance.rb +++ b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/recipes/04-importConformance.rb @@ -2,19 +2,8 @@ working_directory = "/tmp" cl_release=node['version'].split('.')[0..2].join('.').split('-')[0] printf("\033[33mcl_release=[%s]\n\033[0m", cl_release) - - -bash "import-Conformance" do +execute "import-Conformance" do + command "conf_dir=/tmp/sdctool/config && tosca_dir=/tmp/sdctool/tosca && cl_version=`grep 'toscaConformanceLevel:' $conf_dir/configuration.yaml |awk '{print $2}'` && cd /tmp/sdctool/scripts && /bin/chmod +x sdcSchemaFileImport.sh && echo \"execute /tmp/sdctool/scripts/sdcSchemaFileImport.sh ${tosca_dir} #{cl_release} ${cl_version} ${conf_dir} onap\" && ./sdcSchemaFileImport.sh ${tosca_dir} #{cl_release} ${cl_version} ${conf_dir} onap" cwd "#{working_directory}" - code <<-EOH - conf_dir=/tmp/sdctool/config - tosca_dir=/tmp/sdctool/tosca - - cl_version=`grep 'toscaConformanceLevel:' $conf_dir/configuration.yaml |awk '{print $2}'` - - cd /tmp/sdctool/scripts - /bin/chmod +x sdcSchemaFileImport.sh - echo "execute /tmp/sdctool/scripts/sdcSchemaFileImport.sh ${tosca_dir} #{cl_release} ${cl_version} ${conf_dir} onap" - ./sdcSchemaFileImport.sh ${tosca_dir} #{cl_release} ${cl_version} ${conf_dir} onap - EOH + action :run end
\ No newline at end of file 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 426eed83df..9fa3130542 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,4 +1,4 @@ -#!/bin/bash +#!/bin/sh CASSANDRA_IP=<%= @cassandra_ip %> CASSANDRA_PORT=<%= @cassandra_port %> @@ -12,17 +12,17 @@ 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 $CASSANDRA_PORT > /dev/null 2>&1 + echo "exit" | cqlsh -u cassandra -p $CS_PASSWORD $CASSANDRA_IP $CASSANDRA_PORT res1=$? if [ $res1 -eq 0 ]; then - echo "`date` --- cqlsh is enabled to connect." + echo "`date` --- cqlsh is able to connect." is_up=1 else - echo "`date` --- cqlsh is NOT enabled to connect yet. sleep 5" + echo "`date` --- cqlsh is NOT able to connect yet. sleep 5" sleep 5 fi - let "retry_num++" + retry_num=$((retry_num+1)) done cassandra_user_exist=`echo "list users;" | cqlsh -u cassandra -p $CS_PASSWORD $CASSANDRA_IP $CASSANDRA_PORT | grep -c $SDC_USER` 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 e9d10af10e..9b20c6f15c 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 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh CASSANDRA_USER='<%= @cassandra_usr %>' CASSANDRA_PASS='<%= @cassandra_pwd %>' |