diff --git a/lib/fog/ovirt/compute.rb b/lib/fog/ovirt/compute.rb index 10a5322abf..8defc02077 100644 --- a/lib/fog/ovirt/compute.rb +++ b/lib/fog/ovirt/compute.rb @@ -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. diff --git a/lib/fog/ovirt/models/compute/server.rb b/lib/fog/ovirt/models/compute/server.rb index 5fb902cc44..7256878ee9 100644 --- a/lib/fog/ovirt/models/compute/server.rb +++ b/lib/fog/ovirt/models/compute/server.rb @@ -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? @@ -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 diff --git a/lib/fog/ovirt/models/compute/volume.rb b/lib/fog/ovirt/models/compute/volume.rb index 5a35dc96f8..af4712ac4e 100644 --- a/lib/fog/ovirt/models/compute/volume.rb +++ b/lib/fog/ovirt/models/compute/volume.rb @@ -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] diff --git a/lib/fog/ovirt/requests/compute/get_api_version.rb b/lib/fog/ovirt/requests/compute/get_api_version.rb new file mode 100644 index 0000000000..3a4799bd10 --- /dev/null +++ b/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 \ No newline at end of file