Class: Fog::Rackspace::BlockStorage::Snapshot

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/rackspace/models/block_storage/snapshot.rb

Constant Summary collapse

AVAILABLE =
'available'
CREATING =
'creating'
DELETING =
'deleting'
ERROR =
'error'
ERROR_DELETING =
'error_deleting'

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject



39
40
41
42
43
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 39

def destroy
  requires :identity
  service.delete_snapshot(identity)
  true
end

#ready?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 23

def ready?
  state == AVAILABLE
end

#save(force = false) ⇒ Object

Raises:



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 27

def save(force = false)
  requires :volume_id
  raise IdentifierTaken.new('Resaving may cause a duplicate snapshot to be created') if persisted?
  data = service.create_snapshot(volume_id, {
    :display_name => display_name,
    :display_description => display_description,
    :force => force
  })
  merge_attributes(data.body['snapshot'])
  true
end