1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/vsphere/models/compute/volume.rb
Ohad Levy b70e972a58 VMWare vsphere provider refactor
missing:
- new model tests
- templates model
- clone

this patch includes a lot of changes and cleanups, exposing more fog
collections/models and rewriting most requests
it includes valuable feedback from endzyme <nick.huanca@gmail.com>
2012-11-14 15:31:02 +02:00

45 lines
874 B
Ruby

module Fog
module Compute
class Vsphere
class Volume < Fog::Model
DISK_SIZE_TO_GB = 1048576
identity :id
attribute :datastore
attribute :mode
attribute :size
attribute :thin
attribute :name
attribute :filename
attribute :size_gb
def initialize(attributes={} )
super defaults.merge(attributes)
end
def size_gb
attributes[:size_gb] ||= attributes[:size].to_i / DISK_SIZE_TO_GB if attributes[:size]
end
def size_gb= s
attributes[:size] = s.to_i * DISK_SIZE_TO_GB if s
end
def to_s
name
end
private
def defaults
{
:thin=>true,
:name=>"Hard disk",
:mode=>"persistent"
}
end
end
end
end
end