Class: Interferon::HostSources::AwsElasticache
- Inherits:
-
Object
- Object
- Interferon::HostSources::AwsElasticache
- Defined in:
- lib/interferon/host_sources/aws_elasticache.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ AwsElasticache
constructor
A new instance of AwsElasticache.
- #list_hosts ⇒ Object
Constructor Details
#initialize(options) ⇒ AwsElasticache
Returns a new instance of AwsElasticache.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/interferon/host_sources/aws_elasticache.rb', line 5 def initialize() missing = %w{access_key_id secret_access_key}.reject{|r| .key?(r)} AWS.config({ :access_key_id => ['access_key_id'], :secret_access_key => ['secret_access_key'] }) if missing.empty? # initialize a list of regions to check if ['regions'] && !['regions'].empty? @regions = ['regions'] else @regions = AWS::regions.map(&:name) end end |
Instance Method Details
#list_hosts ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/interferon/host_sources/aws_elasticache.rb', line 21 def list_hosts hosts = [] @regions.each do |region| clusters = [] client = AWS::ElastiCache.new(:region => region).client AWS.memoize do # read the list of cache clusters; we have to do our own pagination clusters = [] = {:show_cache_node_info => true} loop do r = client.describe_cache_clusters() clusters += r.data[:cache_clusters] break unless r.data[:marker] [:marker] = r.data[:marker] end # iterate over the nodes in each cluster and add each one to hosts clusters.each do |cluster| cluster[:cache_nodes].each do |node| hosts << { :source => 'aws_elasticache', :region => region, :cluster_id => cluster[:cache_cluster_id], :cluster_status => cluster[:cache_cluster_status], :node_type => cluster[:cache_node_type], :peer_nodes => cluster[:num_cache_nodes], :node_status => node[:cache_node_status], # elasticache does not support tagging :owners => [], :owner_groups => [], } end end end end return hosts end |