def create_or_clone_volume
volume_options = Hash.new
volume_options[:name] = volume_name || default_volume_name
unless self.volume_template_name.nil?
template_volumes = connection.volumes.all(:name => self.volume_template_name)
raise Fog::Errors::Error.new("Template #{self.volume_template_name} not found") unless template_volumes.empty?
orig_volume = template_volumes.first
volume = orig_volume.clone("#{volume_options[:name]}")
self.volume_format_type = orig_volume.format_type
self.volume_path = volume.path
else
volume_options[:format_type] = self.volume_format_type if volume_format_type
volume_options[:capacity] = self.volume_capacity if volume_capacity
volume_options[:allocation] = self.volume_allocation if volume_allocation
begin
volume = connection.volumes.create(volume_options)
self.volume_path = volume.path
self.volume_format_type ||= volume.format_type
rescue
raise Fog::Errors::Error.new("Error creating the volume : #{$!}")
end
end
end