Class: Fog::Compute::OpenStack::KeyPairs

Inherits:
OpenStack::Collection show all
Defined in:
lib/fog/openstack/models/compute/key_pairs.rb

Instance Attribute Summary

Attributes inherited from OpenStack::Collection

#response

Instance Method Summary collapse

Methods inherited from OpenStack::Collection

#destroy, #load_response, #summary

Instance Method Details

#all(options = {}) ⇒ Object


10
11
12
13
14
15
16
17
# File 'lib/fog/openstack/models/compute/key_pairs.rb', line 10

def all(options = {})
  items = Array.new
  service.list_key_pairs(options).body['keypairs'].each do |kp|
    items = items + kp.values
  end
  # TODO convert to load_response?
  load(items)
end

#get(key_pair_name) ⇒ Object


19
20
21
22
23
24
25
# File 'lib/fog/openstack/models/compute/key_pairs.rb', line 19

def get(key_pair_name)
  if key_pair_name
    self.all.select {|kp| kp.name == key_pair_name}.first
  end
rescue Fog::Compute::OpenStack::NotFound
  nil
end