mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #3198 from epienbroek/ovirt_update_volume
[ovirt] Add interface for updating volumes
This commit is contained in:
commit
bef68f361c
6 changed files with 70 additions and 1 deletions
4
Rakefile
4
Rakefile
|
@ -65,6 +65,10 @@ namespace :test do
|
|||
task :openvz do
|
||||
sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/openvz")
|
||||
end
|
||||
task :ovirt do
|
||||
sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/ovirt")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc 'Run mocked tests for a specific provider'
|
||||
|
|
|
@ -46,6 +46,7 @@ module Fog
|
|||
request :list_template_volumes
|
||||
request :add_volume
|
||||
request :destroy_volume
|
||||
request :update_volume
|
||||
request :get_api_version
|
||||
request :list_quotas
|
||||
request :get_quota
|
||||
|
|
|
@ -79,6 +79,11 @@ module Fog
|
|||
service.add_volume(id, attrs)
|
||||
end
|
||||
|
||||
def update_volume attrs
|
||||
wait_for { stopped? } if attrs[:blocking]
|
||||
service.update_volume(id, attrs)
|
||||
end
|
||||
|
||||
def destroy_volume attrs
|
||||
wait_for { stopped? } if attrs[:blocking]
|
||||
service.destroy_volume(id, attrs)
|
||||
|
|
39
lib/fog/ovirt/requests/compute/update_volume.rb
Normal file
39
lib/fog/ovirt/requests/compute/update_volume.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ovirt
|
||||
|
||||
module Shared
|
||||
def check_arguments(id, options)
|
||||
raise ArgumentError, "instance id is a required parameter" unless id
|
||||
raise ArgumentError, "disk id is a required parameter for update-volume" unless options.has_key? :id
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class Real
|
||||
extend ::Fog::Compute::Ovirt::Shared
|
||||
|
||||
def update_volume(id, options)
|
||||
check_arguments(id, options)
|
||||
|
||||
disk_id = options[:id]
|
||||
options.delete(:id)
|
||||
|
||||
client.update_volume(id, disk_id, options)
|
||||
true # If we come here, expect success and return true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
extend ::Fog::Compute::Ovirt::Shared
|
||||
|
||||
def update_volume(id, options)
|
||||
check_arguments(id, options)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -18,7 +18,7 @@ Shindo.tests('Fog::Compute[:ovirt]', ['ovirt']) do
|
|||
%w{ add_interface create_vm datacenters destroy_interface destroy_vm get_cluster get_template
|
||||
get_virtual_machine list_clusters list_networks list_template_interfaces list_templates
|
||||
list_virtual_machines list_vm_interfaces storage_domains update_interface update_vm vm_action
|
||||
api_version}.each do |collection|
|
||||
api_version update_volume}.each do |collection|
|
||||
test("it should respond to #{collection}") { compute.respond_to? collection }
|
||||
end
|
||||
end
|
||||
|
|
20
tests/ovirt/requests/compute/update_volume_tests.rb
Normal file
20
tests/ovirt/requests/compute/update_volume_tests.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
Shindo.tests('Fog::Compute[:ovirt] | update_volume request', ['ovirt']) do
|
||||
|
||||
compute = Fog::Compute[:ovirt]
|
||||
if compute.servers.all(:search => 'fog-*').empty?
|
||||
compute.create_vm(:name => 'fog-'+Time.now.to_i.to_s, :cluster_name => 'Default')
|
||||
end
|
||||
vm_id = compute.servers.all(:search => 'fog-*').last
|
||||
|
||||
tests('The expected options') do
|
||||
raises(ArgumentError, 'raises ArgumentError when vm id is missing') { compute.update_volume(nil, {:id => 1}) }
|
||||
raises(ArgumentError, 'raises ArgumentError when disk_id option is missing') { compute.update_volume(1, {:any => 1}) }
|
||||
end
|
||||
|
||||
tests('The response should') do
|
||||
response = compute.update_volume(vm_id, :id => 1)
|
||||
test('be a success') { response ? true: false }
|
||||
end
|
||||
|
||||
|
||||
end
|
Loading…
Reference in a new issue