class Worker

Public Class Methods

client(environment, client_id) click to toggle source
# File lib/proboscis_cli.rb, line 79
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["infrastructureInfo"])
 end
client_list(environment) click to toggle source
# File lib/proboscis_cli.rb, line 70
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)
end
ip(auth_code, host, environment, subdomain, type, subpath) click to toggle source
# File lib/proboscis_cli.rb, line 50
def self.ip(auth_code, host, environment, subdomain, type, subpath)
  @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
  self.worker_ip subpath
end
worker_ip(subpath) click to toggle source
# File lib/proboscis_cli.rb, line 63
def self.worker_ip(subpath)
  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