2012-04-27 08:25:40 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Serverlove
|
|
|
|
|
2012-04-27 09:43:52 -04:00
|
|
|
class Drive < Fog::Model
|
2012-04-27 08:25:40 -04:00
|
|
|
|
2012-04-27 09:01:42 -04:00
|
|
|
identity :drive
|
2012-04-27 08:25:40 -04:00
|
|
|
|
|
|
|
attribute :name
|
|
|
|
attribute :user
|
|
|
|
attribute :size
|
2012-04-27 09:01:42 -04:00
|
|
|
attribute :claimed
|
|
|
|
attribute :status
|
2012-04-27 09:55:06 -04:00
|
|
|
attribute :encryption_cipher, :aliases => 'encryption:cipher'
|
2012-04-27 08:25:40 -04:00
|
|
|
|
|
|
|
def save
|
2012-04-29 12:00:13 -04:00
|
|
|
attributes = {}
|
|
|
|
|
|
|
|
if(identity)
|
|
|
|
attributes = connection.update_drive(identity, allowed_attributes).body
|
|
|
|
else
|
|
|
|
requires :name
|
|
|
|
requires :size
|
|
|
|
attributes = connection.create_drive(allowed_attributes).body
|
|
|
|
end
|
|
|
|
|
|
|
|
merge_attributes(attributes)
|
2012-04-29 12:11:19 -04:00
|
|
|
self
|
2012-04-27 16:53:39 -04:00
|
|
|
end
|
|
|
|
|
2012-04-27 08:25:40 -04:00
|
|
|
def destroy
|
|
|
|
requires :identity
|
2012-04-27 09:43:52 -04:00
|
|
|
connection.destroy_drive(identity)
|
2012-04-29 12:11:19 -04:00
|
|
|
self
|
2012-04-29 09:14:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def allowed_attributes
|
|
|
|
allowed = [:name, :size]
|
|
|
|
attributes.select {|k,v| allowed.include? k}
|
|
|
|
end
|
|
|
|
|
2012-04-27 08:25:40 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|