Module: AwsAuditor::InstanceHelper
- Included in:
- CacheInstance, EC2Instance, RDSInstance
- Defined in:
- lib/aws_auditor/instance_helper.rb
Instance Method Summary collapse
- #compare ⇒ Object
- #instance_count_hash(instances) ⇒ Object
- #instance_hash ⇒ Object
- #reserved_instance_hash ⇒ Object
Instance Method Details
#compare ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/aws_auditor/instance_helper.rb', line 21 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
12 13 14 15 16 17 18 19 |
# File 'lib/aws_auditor/instance_helper.rb', line 12 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
4 5 6 |
# File 'lib/aws_auditor/instance_helper.rb', line 4 def instance_hash Hash[get_instances.map { |instance| instance.nil? ? next : [instance.id, instance]}.compact] end |
#reserved_instance_hash ⇒ Object
8 9 10 |
# File 'lib/aws_auditor/instance_helper.rb', line 8 def reserved_instance_hash Hash[get_reserved_instances.map { |instance| instance.nil? ? next : [instance.id, instance]}.compact] end |