2012-08-23 15:03:28 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Rackspace
|
|
|
|
class BlockStorage
|
|
|
|
class Snapshot < Fog::Model
|
|
|
|
AVAILABLE = 'available'
|
|
|
|
CREATING = 'creating'
|
|
|
|
DELETING = 'deleting'
|
|
|
|
ERROR = 'error'
|
|
|
|
ERROR_DELETING = 'error_deleting'
|
|
|
|
|
|
|
|
identity :id
|
|
|
|
|
|
|
|
attribute :created_at, :aliases => 'createdAt'
|
|
|
|
attribute :state, :aliases => 'status'
|
|
|
|
attribute :display_name
|
|
|
|
attribute :display_description
|
|
|
|
attribute :size
|
|
|
|
attribute :volume_id
|
|
|
|
attribute :availability_zone
|
|
|
|
|
|
|
|
def ready?
|
|
|
|
state == AVAILABLE
|
|
|
|
end
|
|
|
|
|
|
|
|
def save(force = false)
|
|
|
|
requires :volume_id
|
2012-12-22 21:45:05 -05:00
|
|
|
raise IdentifierTaken.new('Resaving may cause a duplicate snapshot to be created') if persisted?
|
2012-12-22 18:24:03 -05:00
|
|
|
data = service.create_snapshot(volume_id, {
|
2012-08-23 15:03:28 -04:00
|
|
|
:display_name => display_name,
|
|
|
|
:display_description => display_description,
|
|
|
|
:force => force
|
|
|
|
})
|
|
|
|
merge_attributes(data.body['snapshot'])
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :identity
|
2012-12-22 18:24:03 -05:00
|
|
|
service.delete_snapshot(identity)
|
2012-08-23 15:03:28 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|