Method: Fog::OpenStack::Compute::KeyPair#save

Defined in:
lib/fog/openstack/compute/models/key_pair.rb

#saveObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/openstack/compute/models/key_pair.rb', line 24

def save
  requires :name

  data = if public_key
           service.create_key_pair(name, public_key, user_id).body['keypair']
         else
           service.create_key_pair(name, nil, user_id).body['keypair']
         end
  new_attributes = data.reject { |key, _value| !['fingerprint', 'public_key', 'name', 'private_key', 'user_id'].include?(key) }
  merge_attributes(new_attributes)
  true
end