aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-os-chef/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_Number_create_DMaaP_keys.rb-NotUsed
blob: 583dfff7b259710df05cd20b28f8f536a7487bea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
http_request 'create-DMaaP-apiKeys' do
  action :post
  url 'http://23.253.97.75:3904/apiKeys/create'
  message ({:some => 'data'}.to_json)
  headers({
    'Content-Type' => 'application/json'
  })
end


selfEnviroment = node.chef_environment

ruby_block "create-DMaaP-apiKeys" do
    block do
      sleep(15)
      #tricky way to load this Chef::Mixin::ShellOut utilities
      Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
      curl_command = "https://es_admin:Aa123456@#{application_host}:9200/_cluster/health?pretty=true --insecure"
      resp = Net::HTTP.get_response URI.parse(curl_command)
      stat = JSON.parse(resp.read_body)['status']

      case stat
         when "green"
            printf("\033[32m%s\n\033[0m", "  ElasticSearch tests completed successfully.")
         when "yellow"
            printf("\033[33m%s\n\033[0m", "  ElasticSearch tests completed successfully, with warnings")
         when "red"
            printf("\033[31m%s\n\033[0m", "  ElasticSearch tests failed!!!")
      end
   end
end

curl  POST -d '{"email":"Grinberg.Moti","description":"New Api Key for ASDC OS"}' http://23.253.97.75:3904/apiKeys/create