Class: Interferon::HostSources::AwsRds
- Inherits:
-
Object
- Object
- Interferon::HostSources::AwsRds
- Defined in:
- lib/interferon/host_sources/aws_rds.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ AwsRds
constructor
A new instance of AwsRds.
- #list_hosts ⇒ Object
Constructor Details
#initialize(options) ⇒ AwsRds
Returns a new instance of AwsRds.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/interferon/host_sources/aws_rds.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 65 66 67 |
# File 'lib/interferon/host_sources/aws_rds.rb', line 21 def list_hosts hosts = [] @regions.each do |region| rds = AWS::RDS.new(:region => region) AWS.memoize do rds.instances.each do |instance| # get the tags for the instance arn = arn(region, instance.id) tag_list = rds.client.(:resource_name => arn)[:tag_list] = Hash[ tag_list.map { |h| [h[:key], h[:value]] } ] ['owners'] ||= '' ['owner_groups'] ||= '' # build the host data for this instance hosts << { :source => 'aws_rds', :region => region, :instance_id => instance.id, :db_name => instance.db_name, :engine => instance.engine, :engine_version => instance.engine_version, # metrics :allocated_storage => instance.allocated_storage, :iops => instance.iops, # replication info :is_replica => !instance.read_replica_source_db_instance_identifier.nil?, :replica_source_name => instance.read_replica_source_db_instance_identifier, :replica_names => instance.read_replica_db_instance_identifiers.join(','), :replicas => instance.read_replica_db_instance_identifiers.count, :owners => ['owners'].split(','), :owner_groups => ['owner_groups'].split(','), :db_env => ['db_env'], :db_role => ['db_role'], } end end end return hosts end |