class Fog::OpenStack::Compute::KeyPair
Attributes
public_key[RW]
Public Instance Methods
destroy()
click to toggle source
# File lib/fog/openstack/compute/models/key_pair.rb, line 17 def destroy requires :name service.delete_key_pair(name) true end
save()
click to toggle source
# 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
writable?()
click to toggle source
# File lib/fog/openstack/compute/models/key_pair.rb, line 50 def writable? !!(private_key && ENV.key?('HOME')) end
write(path = "
click to toggle source
# File lib/fog/openstack/compute/models/key_pair.rb, line 37 def write(path = "#{ENV['HOME']}/.ssh/fog_#{Fog.credential}_#{name}.pem") if writable? split_private_key = private_key.split(/\n/) File.open(path, "w") do |f| split_private_key.each { |line| f.puts line } f.chmod 0600 end "Key file built: #{path}" else "Invalid private key" end end