583dfff7b259710df05cd20b28f8f536a7487bea
[sdc.git] / sdc-os-chef / sdc-backend / chef-repo / cookbooks / sdc-catalog-be / recipes / BE_4_create_DMaaP_keys.rb
1 http_request 'create-DMaaP-apiKeys' do
2   action :post
3   url 'http://23.253.97.75:3904/apiKeys/create'
4   message ({:some => 'data'}.to_json)
5   headers({
6     'Content-Type' => 'application/json'
7   })
8 end
9
10
11 selfEnviroment = node.chef_environment
12
13 ruby_block "create-DMaaP-apiKeys" do
14     block do
15       sleep(15)
16       #tricky way to load this Chef::Mixin::ShellOut utilities
17       Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
18       curl_command = "https://es_admin:Aa123456@#{application_host}:9200/_cluster/health?pretty=true --insecure"
19       resp = Net::HTTP.get_response URI.parse(curl_command)
20       stat = JSON.parse(resp.read_body)['status']
21
22       case stat
23          when "green"
24             printf("\033[32m%s\n\033[0m", "  ElasticSearch tests completed successfully.")
25          when "yellow"
26             printf("\033[33m%s\n\033[0m", "  ElasticSearch tests completed successfully, with warnings")
27          when "red"
28             printf("\033[31m%s\n\033[0m", "  ElasticSearch tests failed!!!")
29       end
30    end
31 end
32
33 curl  POST -d '{"email":"Grinberg.Moti","description":"New Api Key for ASDC OS"}' http://23.253.97.75:3904/apiKeys/create
34