2013-07-17 03:18:27 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class RackspaceV2
|
|
|
|
class Keypair < Fog::Model
|
|
|
|
attribute :public_key
|
|
|
|
attribute :private_key
|
|
|
|
attribute :user_id
|
|
|
|
identity :name
|
|
|
|
attribute :fingerprint
|
|
|
|
|
|
|
|
def save
|
|
|
|
requires :name
|
|
|
|
data = service.create_keypair(name, public_key)
|
|
|
|
merge_attributes(data.body['keypair'])
|
|
|
|
data.body['keypair']['name'] == name
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2013-07-26 02:57:02 -04:00
|
|
|
begin
|
|
|
|
service.delete_keypair(identity)
|
|
|
|
rescue Fog::Compute::RackspaceV2::NotFound
|
|
|
|
end
|
2013-07-25 16:58:05 -04:00
|
|
|
true
|
2013-07-17 03:18:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|