2009-08-12 22:33:35 -07:00
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class EC2
|
|
|
|
|
|
|
|
class KeyPair < Fog::Model
|
|
|
|
|
2009-08-14 09:19:40 -07:00
|
|
|
attr_accessor :fingerprint,
|
2009-08-19 09:11:26 -07:00
|
|
|
:material,
|
|
|
|
:name
|
2009-08-12 22:33:35 -07:00
|
|
|
|
|
|
|
def initialize(attributes = {})
|
|
|
|
remap_attributes(attributes, {
|
|
|
|
'keyFingerprint' => :fingerprint,
|
|
|
|
'keyMaterial' => :material,
|
|
|
|
'keyName' => :name
|
|
|
|
})
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def delete
|
|
|
|
connection.delete_key_pair(@name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2009-08-14 09:19:40 -07:00
|
|
|
data = connection.create_key_pair(@name).body
|
|
|
|
new_attributes = data.reject {|key,value| !['keyFingerprint', 'keyMaterial', 'keyName'].include?(key)}
|
2009-08-12 22:33:35 -07:00
|
|
|
update_attributes(new_attributes)
|
2009-08-14 09:19:40 -07:00
|
|
|
data
|
2009-08-12 22:33:35 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|