Module: AwsAuditor::InstanceHelper
- Included in:
- CacheInstance, EC2Instance, RDSInstance
- Defined in:
- lib/aws_auditor/instance_helper.rb
Instance Method Summary collapse
Instance Method Details
#compare ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/aws_auditor/instance_helper.rb', line 16 def compare differences = Hash.new() instances = instance_count_hash(get_instances) ris = instance_count_hash(get_reserved_instances) instances.keys.concat(ris.keys).uniq.each do |key| instance_count = instances.has_key?(key) ? instances[key] : 0 ris_count = ris.has_key?(key) ? ris[key] : 0 differences[key] = ris_count - instance_count end differences end |
#instance_count_hash(instances) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/aws_auditor/instance_helper.rb', line 7 def instance_count_hash(instances) instance_hash = Hash.new() instances.each do |instance| next if instance.nil? instance_hash[instance.to_s] = instance_hash.has_key?(instance.to_s) ? instance_hash[instance.to_s] + instance.count : instance.count end if instances instance_hash end |
#instance_hash ⇒ Object
3 4 5 |
# File 'lib/aws_auditor/instance_helper.rb', line 3 def instance_hash Hash[get_instances.map { |instance| instance.nil? ? next : [instance.id, instance]}.compact] end |