2009-08-13 01:33:35 -04:00
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class EC2
|
|
|
|
|
|
|
|
class KeyPair < Fog::Model
|
|
|
|
|
2009-09-05 23:50:40 -04:00
|
|
|
attribute :fingerprint, 'keyFingerprint'
|
|
|
|
attribute :material, 'keyMaterial'
|
|
|
|
attribute :name, 'keyName'
|
2009-08-13 01:33:35 -04:00
|
|
|
|
2009-09-20 12:21:03 -04:00
|
|
|
def destroy
|
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
|
|
|
|
|
2009-09-19 15:21:31 -04:00
|
|
|
def key_pairs
|
|
|
|
@key_pairs
|
|
|
|
end
|
|
|
|
|
2009-09-19 15:31:15 -04:00
|
|
|
def reload
|
2009-10-22 23:51:57 -04:00
|
|
|
if new_key_pair = key_pairs.get(@name)
|
|
|
|
merge_attributes(new_key_pair.attributes)
|
|
|
|
end
|
2009-09-19 15:31:15 -04:00
|
|
|
end
|
|
|
|
|
2009-08-13 01:33:35 -04:00
|
|
|
def save
|
2009-08-14 12:19:40 -04:00
|
|
|
data = connection.create_key_pair(@name).body
|
|
|
|
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
|
|
|
|
|
2009-09-19 15:21:31 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def key_pairs=(new_key_pairs)
|
|
|
|
@key_pairs = new_key_pairs
|
|
|
|
end
|
|
|
|
|
2009-08-13 01:33:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|