Class: Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/proboscis_cli.rb

Class Method Summary collapse

Class Method Details

.client(environment, client_id) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/proboscis_cli.rb', line 44

def self.client(environment, client_id)
 response = HTTParty.get("#{@host}/api/api/clients/#{client_id["id"]}/products", headers: {"X-Authorization" => @auth_code})
 if response.code != 200
   puts "Unable to fetch details of client with id #{client_id}"
   exit -1
 end
 infra_info = JSON::parse(response.body)
 if infra_info.empty?
   puts "No Products Mapped!"
   exit -1
 end
 @infra_info = JSON::parse(infra_info.first["infrastructureInfo"])
end

.client_list(environment) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/proboscis_cli.rb', line 35

def self.client_list(environment)
  response = HTTParty.get("#{@host}/api/api/clients", headers: {"X-Authorization" => @auth_code})
   if response.code != 200
    puts "Unable to get the client list.."
    exit -1
   end
  @client_list = JSON::parse(response.body)["content"]
end

.ip(auth_code, host, environment, subdomain, type) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/proboscis_cli.rb', line 19

def self.ip(auth_code, host, environment, subdomain, type)
  @auth_code = auth_code
  @host = host
  self.client_list environment
  client_id = @client_list.select {|c| c["domain"] == subdomain}
  if client_id.empty?
    puts "Unable to find client with subdomain #{subdomain}"
    exit -1
  end
  self.client environment, client_id.first
  if(!@infra_info["WORKER_IP"])
    puts "Unable to find target WORKER_IP in #{@infra_info}. Is the machine up?"
  end
  @infra_info["WORKER_IP"]
end