Skip to content

Commit

Permalink
Merge pull request fog#855 from abenari/master
Browse files Browse the repository at this point in the history
[oVirt] volume size in GB accessor
  • Loading branch information
ohadlevy committed Apr 16, 2012
2 parents 350899e + 8a8b7e8 commit 2e6a50d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fog.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
10 changes: 10 additions & 0 deletions lib/fog/ovirt/models/compute/volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Ovirt

class Volume < Fog::Model
attr_accessor :raw
DISK_SIZE_TO_GB = 1073741824
identity :id

attribute :storage_domain
Expand All @@ -13,6 +14,15 @@ class Volume < Fog::Model
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
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/ovirt/requests/compute/add_volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2e6a50d

Please sign in to comment.