Skip to content

Commit

Permalink
Merge pull request #18 from rightscale-cookbooks/st_14_16_acu185861_n…
Browse files Browse the repository at this point in the history
…o_volume_type_with_snapshot_id_cloudstack

Don't pass volume type with snapshot ID on Cloudstack
  • Loading branch information
Lopaka Delp committed Nov 10, 2014
2 parents a332d6c + 7c07e0c commit 7781651
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libraries/provider_rightscale_volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
Expand Down Expand Up @@ -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
#
Expand Down

0 comments on commit 7781651

Please sign in to comment.