require 'gaptool-api' module Gaptool module API def self.client @client ||= GTAPI::GaptoolServer.new( ENV['GT_USER'], ENV['GT_KEY'], ENV['GT_URL'], ENV['GT_AWS_ZONE'] ) end def self.query_nodes(opts) instance = opts[:instance] role = opts[:role] environment = opts[:environment] params = opts[:params] if instance puts Rainbow('Ignoring role and environment as instance is set').red \ if role || environment [Gaptool::API.client.getonenode(instance)] elsif role && environment Gaptool::API.client.getenvroles(role, environment, params) elsif role Gaptool::API.client.getrolenodes(role, params) elsif environment Gaptool::API.client.getenvnodes(environment, params) else Gaptool::API.client.getallnodes(params) end end def self.get_host(node) "#{node['role']}-#{node['environment']}-#{node['instance']}" end end end