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:
commit
2e6a50d370
3 changed files with 13 additions and 3 deletions
|
@ -54,7 +54,7 @@ Gem::Specification.new do |s|
|
||||||
s.add_development_dependency('rdoc')
|
s.add_development_dependency('rdoc')
|
||||||
s.add_development_dependency('thor')
|
s.add_development_dependency('thor')
|
||||||
s.add_development_dependency('rspec', '~>1.3.1')
|
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('shindo', '~>0.3.4')
|
||||||
s.add_development_dependency('virtualbox', '~>0.9.1')
|
s.add_development_dependency('virtualbox', '~>0.9.1')
|
||||||
s.add_development_dependency('fission')
|
s.add_development_dependency('fission')
|
||||||
|
|
|
@ -4,6 +4,7 @@ module Fog
|
||||||
|
|
||||||
class Volume < Fog::Model
|
class Volume < Fog::Model
|
||||||
attr_accessor :raw
|
attr_accessor :raw
|
||||||
|
DISK_SIZE_TO_GB = 1073741824
|
||||||
identity :id
|
identity :id
|
||||||
|
|
||||||
attribute :storage_domain
|
attribute :storage_domain
|
||||||
|
@ -13,6 +14,15 @@ module Fog
|
||||||
attribute :interface
|
attribute :interface
|
||||||
attribute :format
|
attribute :format
|
||||||
attribute :sparse
|
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
|
def to_s
|
||||||
id
|
id
|
||||||
|
|
|
@ -2,10 +2,10 @@ module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ovirt
|
class Ovirt
|
||||||
class Real
|
class Real
|
||||||
|
DISK_SIZE_TO_GB = 1073741824
|
||||||
def add_volume(id, options = {})
|
def add_volume(id, options = {})
|
||||||
raise ArgumentError, "instance id is a required parameter" unless id
|
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)
|
client.add_volume(id, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue