Sha256: c9d98cf648aeea07d7e794ee2a7131c6c996cca14b21abf9bfd84c8dc47cd0e4

Contents?: true

Size: 1001 Bytes

Versions: 1

Compression:

Stored size: 1001 Bytes

Contents

# coding: utf-8
require 'gaptool-api'

module Gaptool
  module API
    def self.client
      @client ||= new
    end

    def self.new
      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]
      cl = opts[: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, params)
      elsif role
        cl.getrolenodes(role, params)
      elsif environment
        cl.getenvnodes(environment, params)
      else
        cl.getallnodes(params)
      end
    end

    def self.get_host(node)
      "#{node['role']}-#{node['environment']}-#{node['instance']}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gaptool-client-0.8.0.pre.alpha10 lib/gaptool_client/api.rb