class Proboscis
Public Class Methods
connect(environment, subdomain, target, type, subpath='araneae')
click to toggle source
# File lib/proboscis_cli.rb, line 114 def self.connect(environment, subdomain, target, type, subpath='araneae') type = type == 'b' ? 'BUSY_BEE' : (type == 'i' ? 'INSTANT_HONEY' : 'CASH_REPLENISHMENT') @host = self.host(environment) self.login environment machine = self.get_machine target, type ip = machine.ip @auth_code, @host, environment, subdomain, type, subpath if(!ip) puts "Unable to find target #{ip}. Is the machine up?" exit -1 end user = ENV["proboscis_#{environment}_target_user"] || "root" port = machine.port environment, type, subpath puts "Executing ssh #{user}@#{ip} -p #{port}" system "ssh #{user}@#{ip} -p #{port}" end
get_machine(target, type)
click to toggle source
# File lib/proboscis_cli.rb, line 130 def self.get_machine(target, type) puts type if type == 'CASH_REPLENISHMENT' target == 'server' ? CashServer : CashWorker else target == 'server' ? Server : Worker end end
host(environment)
click to toggle source
# File lib/proboscis_cli.rb, line 106 def self.host(environment) ENV["proboscis_#{environment}"] end
login(environment)
click to toggle source
# File lib/proboscis_cli.rb, line 139 def self.login(environment) response = HTTParty.post("#{@host}/api/login", body: {phoneNumber: self.param(environment, 'user'), password: self.param(environment, 'pass')}.to_json, headers: { 'Content-Type' => 'application/json' }) if response.code != 200 puts "Unable to login to proboscis.." exit -1 end @auth_code = Base64.strict_encode64(JSON::parse(response.body)["accessToken"]) end
param(environment, lookup)
click to toggle source
# File lib/proboscis_cli.rb, line 110 def self.param(environment, lookup) ENV["proboscis_#{environment}_#{lookup}"] end