Skip to content

Commit

Permalink
Merge pull request #1591 from abenari/ovirt3.1
Browse files Browse the repository at this point in the history
[ovirt] fix issues with oVirt 3.1 API disk locking status.
  • Loading branch information
ohadlevy committed Feb 25, 2013
2 parents cefdf13 + bafac95 commit ba335ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/fog/ovirt/compute.rb
Expand Up @@ -42,6 +42,7 @@ class Ovirt < Fog::Service
request :list_template_volumes
request :add_volume
request :destroy_volume
request :get_api_version

module Shared
# converts an OVIRT object into an hash for fog to consume.
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/ovirt/models/compute/server.rb
Expand Up @@ -33,7 +33,7 @@ def ready?
end

def locked?
!!(status =~ /locked/i)
!!(status =~ /locked/i) || (attributes[:volumes]=nil) || volumes.any?{|v| !!(v.status =~ /locked/i)}
end

def stopped?
Expand Down Expand Up @@ -84,7 +84,7 @@ def destroy_volume attrs
end

def start(options = {})
wait_for { stopped? } if options[:blocking]
wait_for { !locked? } if options[:blocking]
service.vm_action(:id =>id, :action => :start)
reload
end
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/models/compute/volume.rb
Expand Up @@ -15,6 +15,7 @@ class Volume < Fog::Model
attribute :format
attribute :sparse
attribute :size_gb
attribute :status

def size_gb
attributes[:size_gb] ||= attributes[:size].to_i / DISK_SIZE_TO_GB if attributes[:size]
Expand Down
16 changes: 16 additions & 0 deletions lib/fog/ovirt/requests/compute/get_api_version.rb
@@ -0,0 +1,16 @@
module Fog
module Compute
class Ovirt
class Real
def api_version
client.api_version
end
end
class Mock
def api_version
"3.1"
end
end
end
end
end

0 comments on commit ba335ba

Please sign in to comment.