2010-10-04 17:02:08 -04:00
|
|
|
require 'fog/core/model'
|
2010-03-16 18:46:21 -04:00
|
|
|
|
2009-08-13 01:33:35 -04:00
|
|
|
module Fog
|
|
|
|
module AWS
|
2010-09-08 17:40:02 -04:00
|
|
|
class Compute
|
2009-08-13 01:33:35 -04:00
|
|
|
|
|
|
|
class KeyPair < Fog::Model
|
2010-09-22 15:06:25 -04:00
|
|
|
extend Fog::Deprecation
|
|
|
|
deprecate(:material, :private_key)
|
2009-08-13 01:33:35 -04:00
|
|
|
|
2010-09-07 14:30:02 -04:00
|
|
|
identity :name, :aliases => 'keyName'
|
2009-10-24 01:23:55 -04:00
|
|
|
|
2010-09-07 14:30:02 -04:00
|
|
|
attribute :fingerprint, :aliases => 'keyFingerprint'
|
2010-09-22 15:06:25 -04:00
|
|
|
attribute :private_key, :aliases => 'keyMaterial'
|
|
|
|
|
|
|
|
attr_accessor :public_key
|
2009-08-13 01:33:35 -04:00
|
|
|
|
2009-09-20 12:21:03 -04:00
|
|
|
def destroy
|
2009-11-21 16:56:39 -05:00
|
|
|
requires :name
|
|
|
|
|
2009-08-13 01:33:35 -04:00
|
|
|
connection.delete_key_pair(@name)
|
2009-09-05 23:50:40 -04:00
|
|
|
true
|
2009-08-13 01:33:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2009-11-21 16:56:39 -05:00
|
|
|
requires :name
|
|
|
|
|
2010-09-22 15:06:25 -04:00
|
|
|
data = if public_key
|
|
|
|
connection.import_key_pair(name, public_key).body
|
|
|
|
else
|
|
|
|
connection.create_key_pair(name).body
|
|
|
|
end
|
2009-08-14 12:19:40 -04:00
|
|
|
new_attributes = data.reject {|key,value| !['keyFingerprint', 'keyMaterial', 'keyName'].include?(key)}
|
2009-09-28 00:31:15 -04:00
|
|
|
merge_attributes(new_attributes)
|
2009-09-05 23:50:40 -04:00
|
|
|
true
|
2009-08-13 01:33:35 -04:00
|
|
|
end
|
|
|
|
|
2010-09-22 15:06:25 -04:00
|
|
|
private
|
|
|
|
|
2009-08-13 01:33:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|