Sha256: b66317593d4805030370c6cbc2892681c1bbb83fdec5dd9668dc72ebbc6f0f8a
Contents?: true
Size: 1.3 KB
Versions: 8
Compression:
Stored size: 1.3 KB
Contents
module Opsicle class Instances attr_accessor :client class <<self attr_accessor :client end def initialize(client) @client = client end def data instances(reload: true) end def self.pretty_ip(instance) instance[:elastic_ip] ? "#{instance[:elastic_ip]} EIP" : instance[:public_ip] end def self.find_by_ip(client, ips) instances = new(client).data.reject { |instance| instances_matching_ips(instance, ips) } instances.empty? ? nil : instances end def self.instances_matching_ips(instance, ip_addresses) instance_ips = [instance[:public_ip], instance[:elastic_ip], instance[:private_ip]].compact (ip_addresses & instance_ips).empty? end private_class_method :instances_matching_ips def self.find_by_eip(client) instances = new(client).data.reject { |instance| instance[:elastic_ip] == nil } instances.empty? ? nil : instances end def instances(options={}) # Only call the API again if you need to @instances = nil if options[:reload] @instances ||= client.api_call('describe_instances', :stack_id => client.config.opsworks_config[:stack_id] )[:instances] end private :instances end end
Version data entries
8 entries across 8 versions & 1 rubygems