1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #855 from abenari/master

[oVirt] volume size in GB accessor
This commit is contained in:
Ohad Levy 2012-04-16 06:12:11 -07:00
commit 2e6a50d370
3 changed files with 13 additions and 3 deletions

View file

@ -54,7 +54,7 @@ Gem::Specification.new do |s|
s.add_development_dependency('rdoc')
s.add_development_dependency('thor')
s.add_development_dependency('rspec', '~>1.3.1')
s.add_development_dependency('rbovirt', '>=0.0.10')
s.add_development_dependency('rbovirt', '>=0.0.11')
s.add_development_dependency('shindo', '~>0.3.4')
s.add_development_dependency('virtualbox', '~>0.9.1')
s.add_development_dependency('fission')

View file

@ -4,6 +4,7 @@ module Fog
class Volume < Fog::Model
attr_accessor :raw
DISK_SIZE_TO_GB = 1073741824
identity :id
attribute :storage_domain
@ -13,6 +14,15 @@ module Fog
attribute :interface
attribute :format
attribute :sparse
attribute :size_gb
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
id

View file

@ -2,10 +2,10 @@ module Fog
module Compute
class Ovirt
class Real
DISK_SIZE_TO_GB = 1073741824
def add_volume(id, options = {})
raise ArgumentError, "instance id is a required parameter" unless id
options[:size]=options[:size_gb].to_i*DISK_SIZE_TO_GB if options[:size_gb]
client.add_volume(id, options)
end