Class: Worker
Direct Known Subclasses
Class Method Summary collapse
- .client(environment, client_id) ⇒ Object
- .client_list(environment) ⇒ Object
- .ip(auth_code, host, environment, subdomain, type, subpath) ⇒ Object
- .worker_ip(subpath) ⇒ Object
Methods inherited from Machine
Class Method Details
.client(environment, client_id) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/proboscis_cli.rb', line 79 def self.client(environment, client_id) response = HTTParty.get("#{@host}/api/web/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) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/proboscis_cli.rb', line 70 def self.client_list(environment) response = HTTParty.get("#{@host}/api/web/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) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# 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) ⇒ Object
63 64 65 66 67 68 |
# 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 |