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 collapse

Instance Method Summary collapse

Instance Attribute Details

#availability_zoneString (readonly)

Returns region of the snapshot.

Returns:

  • (String)

    region of the snapshot



43
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 43

attribute :availability_zone

#created_atString (readonly)

Returns snapshot creation time.

Returns:

  • (String)

    snapshot creation time



19
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 19

attribute :created_at, :aliases => 'createdAt'

#display_descriptionString

Returns display description of snapshot.

Returns:

  • (String)

    display description of snapshot



31
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 31

attribute :display_description

#display_nameString

Returns display name of snapshot.

Returns:

  • (String)

    display name of snapshot



27
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 27

attribute :display_name

#forceBoolean (readonly)

Returns ‘force` creation flag.

Returns:

  • (Boolean)

    ‘force` creation flag



47
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 47

attribute :force

#idString (readonly)

Returns The snapshot id.

Returns:

  • (String)

    The snapshot id



15
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 15

identity :id

#sizeString

Returns size of snapshot.

Returns:

  • (String)

    size of snapshot



35
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 35

attribute :size

#stateString (readonly)

Returns snapshot status.

Returns:

  • (String)

    snapshot status



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

attribute :state, :aliases => 'status'

#volume_idString

Returns the volume_id of the snapshot.

Returns:

  • (String)

    the volume_id of the snapshot



39
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 39

attribute :volume_id

Instance Method Details

#destroyBoolean

Destroys snapshot

Returns:

  • (Boolean)

    returns true if snapshot was deleted

Raises:

See Also:



85
86
87
88
89
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 85

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

#ready?Boolean

Returns true if the snapshot is in a ready state

Returns:

  • (Boolean)

    returns true if snapshot is in a ready state



51
52
53
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 51

def ready?
  state == AVAILABLE
end

#saveBoolean

Note:

A snapshot object cannot be updated

Note:

All writes to the volume should be flushed before creating the snapshot, either by un-mounting any file systems on the volume or by detaching the volume.

Creates the snapshot

Parameters:

  • force (Boolean)

    Set to true to force service to create snapshot

Returns:

  • (Boolean)

    returns true if snapshot is being created

Raises:

See Also:



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fog/rackspace/models/block_storage/snapshot.rb', line 66

def save
  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