Skip to content

Instantly share code, notes, and snippets.

@krames
Created September 9, 2013 21:16
Show Gist options
  • Select an option

  • Save krames/6501645 to your computer and use it in GitHub Desktop.

Select an option

Save krames/6501645 to your computer and use it in GitHub Desktop.
This patch addresses an issue where the `snapshot_id` is not being passed onto the Rackspace Cloud from the Fog Block Storage Service. Note that this patch will only work with Fog 1.15.0. To install it, save the patch in the same directory as your script and name it `volume_patch`. You will also need to include this line at the top of your scrip…
if Fog::VERSION == "1.15.0"
require 'rubygems'
require 'fog'
require 'fog/rackspace/models/block_storage/volume'
Fog::Logger.warning "PATCHING Fog::Rackspace::BlockStorage::Volume to honor snapshot_id attribute"
module Fog
module Rackspace
class BlockStorage
class Volume < Fog::Model
# Creates volume
# @raise [Fog::Rackspace::BlockStorage::IdentifierTaken] if the volume has been previously saved.
# @return [Boolean] returns true if volume was successfully created
# @raise [Fog::Rackspace::BlockStorage::NotFound] - HTTP 404
# @raise [Fog::Rackspace::BlockStorage::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::BlockStorage::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::BlockStorage::ServiceError]
# @note A volume object cannot be updated
# @see http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/POST_createVolume__v1__tenant_id__volumes.html
def save
requires :size
raise IdentifierTaken.new('Resaving may cause a duplicate volume to be created') if persisted?
data = service.create_volume(size, {
:display_name => display_name,
:display_description => display_description,
:volume_type => volume_type,
:availability_zone => availability_zone,
:snapshot_id => attributes[:snapshot_id]
})
merge_attributes(data.body['volume'])
true
end
end
end
end
end
else
Fog::Logger.warning "PATCHING Fog::Rackspace::BlockStorage::Volume - does not apply for #{Fog::VERSION}. Please remove it."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment