mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
f23abc0955
i.e. drive = Fog::Compute[:serverlove].drives.create(name: 'FooFoo', size: 12345) drive.name = "BarBar" drive.save
47 lines
1 KiB
Ruby
47 lines
1 KiB
Ruby
require 'fog/core/model'
|
|
|
|
module Fog
|
|
module Compute
|
|
class Serverlove
|
|
|
|
class Drive < Fog::Model
|
|
|
|
identity :drive
|
|
|
|
attribute :name
|
|
attribute :user
|
|
attribute :size
|
|
attribute :claimed
|
|
attribute :status
|
|
attribute :encryption_cipher, :aliases => 'encryption:cipher'
|
|
|
|
def save
|
|
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)
|
|
true
|
|
end
|
|
|
|
def destroy
|
|
requires :identity
|
|
connection.destroy_drive(identity)
|
|
true
|
|
end
|
|
|
|
def allowed_attributes
|
|
allowed = [:name, :size]
|
|
attributes.select {|k,v| allowed.include? k}
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|