2012-01-10 17:20:56 -05:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class IBM
|
|
|
|
class Key < Fog::Model
|
|
|
|
identity :name, :aliases => 'keyName'
|
|
|
|
attribute :default
|
|
|
|
attribute :public_key, :aliases => 'keyMaterial'
|
2012-02-13 10:11:50 -05:00
|
|
|
attribute :instance_ids, :aliases => 'instanceIds'
|
|
|
|
attribute :modified_at, :aliases => 'lastModifiedTime'
|
2012-01-10 17:20:56 -05:00
|
|
|
|
|
|
|
def save
|
2012-02-13 10:11:50 -05:00
|
|
|
requires :name
|
2012-12-22 18:26:06 -05:00
|
|
|
data = service.create_key(name, public_key)
|
2012-01-10 17:20:56 -05:00
|
|
|
merge_attributes(data.body)
|
2012-02-13 10:11:50 -05:00
|
|
|
data.body['keyName'] == name
|
2012-01-10 17:20:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2012-12-22 18:26:06 -05:00
|
|
|
data = service.delete_key(identity)
|
2012-01-10 17:20:56 -05:00
|
|
|
data.body['success']
|
|
|
|
end
|
|
|
|
|
2012-02-13 10:11:50 -05:00
|
|
|
def default?
|
|
|
|
default
|
|
|
|
end
|
|
|
|
|
|
|
|
def instances
|
|
|
|
instance_ids.map { Fog::Compute[:ibm].servers.get(instance_id) }
|
|
|
|
end
|
2012-01-10 17:20:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|