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

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

Instance Attribute Summary

Attributes inherited from OpenStack::Collection

#response

Instance Method Summary collapse

Methods inherited from OpenStack::Collection

#destroy, #find_by_id, #load_response, #summary

Instance Method Details

#all(options = {}) ⇒ Object



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

def all(options = {})
  items = []
  service.list_key_pairs(options).body['keypairs'].each do |kp|
    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/compute/openstack/models/key_pairs.rb', line 19

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