Class: Inventory::Keypair

Inherits:
Base
  • Object
show all
Defined in:
lib/inventory/keypair.rb

Instance Method Summary collapse

Methods inherited from Base

eager_load!, inherited, #initialize, #report, #show, subclasses, #test_mode

Methods included from AwsServices

#acm, #cfn, #cw, #eb, #ec2, #ecs, #elbv1, #elbv2, #iam, #pricing, #rds, #route53

Methods included from Shared

#instances, #security_groups

Constructor Details

This class inherits a constructor from Inventory::Base

Instance Method Details

#dataObject



6
7
8
9
10
11
12
# File 'lib/inventory/keypair.rb', line 6

def data
  key_pairs.map do |key|
    instance_count = instance_count(key)

    [key.key_name, instance_count]
  end
end

#headerObject



2
3
4
# File 'lib/inventory/keypair.rb', line 2

def header
  ["Key Name", "Instance Count"]
end

#instance_count(key) ⇒ Object



22
23
24
# File 'lib/inventory/keypair.rb', line 22

def instance_count(key)
  instances.count { |i| i.key_name == key.key_name }
end

#key_pairsObject



18
19
20
# File 'lib/inventory/keypair.rb', line 18

def key_pairs
  @key_pairs ||= ec2.describe_key_pairs.key_pairs
end

#sort(data) ⇒ Object



14
15
16
# File 'lib/inventory/keypair.rb', line 14

def sort(data)
  data.sort_by { |i| i[1] }.reverse
end