module Gaptool::API

Public Class Methods

client() click to toggle source
# File lib/gaptool_client/api.rb, line 6
def self.client
  @client ||= new
end
get_host(node) click to toggle source
# File lib/gaptool_client/api.rb, line 38
def self.get_host(node)
  "#{node['role']}-#{node['environment']}-#{node['instance']}"
end
new() click to toggle source
# File lib/gaptool_client/api.rb, line 10
def self.new
  GTAPI::GaptoolServer.new(
    ENV['GT_USER'], ENV['GT_KEY'],
    ENV['GT_URL'], ENV['GT_AWS_ZONE']
  )
end
query_nodes(opts) click to toggle source
# File lib/gaptool_client/api.rb, line 17
def self.query_nodes(opts)
  instance = opts.delete(:instance)
  role = opts.delete(:role)
  environment = opts.delete(:environment)
  cl = opts.delete(:client) || client

  if instance
    puts Rainbow('Ignoring role and environment as instance is set').red \
      if role || environment
    [cl.getonenode(instance)]
  elsif role && environment
    cl.getenvroles(role, environment, opts)
  elsif role
    cl.getrolenodes(role, opts)
  elsif environment
    cl.getenvnodes(environment, opts)
  else
    cl.getallnodes(opts)
  end
end