From 7c07e0cb5f9be38ee58f7e2b9b9654604438c94d Mon Sep 17 00:00:00 2001 From: Douglas Thrift Date: Mon, 10 Nov 2014 11:23:06 -0800 Subject: [PATCH] Don't pass volume type with snapshot ID on Cloudstack - On Cloudstack restoring a volume gets mad when you pass a volume type as well. - Remove redundant check. - Fix documentation for get_volume_type_href method. --- libraries/provider_rightscale_volume.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/provider_rightscale_volume.rb b/libraries/provider_rightscale_volume.rb index 0498fcd..4d71e9e 100644 --- a/libraries/provider_rightscale_volume.rb +++ b/libraries/provider_rightscale_volume.rb @@ -313,10 +313,11 @@ def create_volume(name, size, description = "", snapshot_id = nil, options = {}) params[:volume][:datacenter_href] = datacenter_href["href"] if datacenter_href volume_type_href = get_volume_type_href(node['cloud']['provider'], size, options) - if node['cloud']['provider'] == 'vsphere' && volume_type_href.nil? - raise "An existing volume type is required for this cloud." + + # Pass the volume type HREF if it was returned except when restoring from a snapshot on cloudstack + unless volume_type_href.nil? || (snapshot_id && node['cloud']['provider'] == 'cloudstack') + params[:volume][:volume_type_href] = volume_type_href end - params[:volume][:volume_type_href] = volume_type_href unless volume_type_href.nil? # If description parameter is nil or empty do not pass it to the API params[:volume][:description] = description unless (description.nil? || description.empty?) @@ -366,7 +367,8 @@ def create_volume(name, size, description = "", snapshot_id = nil, options = {}) # # @param cloud [Symbol] the cloud which supports volume types # @param size [Integer] the volume size (used by CloudStack to select appropriate volume type) - # @param options [Hash] the optional parameters required to choose volume type + # + # @option options [String] :volume_type the name of the volume type to use # # @return [String, nil] the volume type href #