Class: Fog::Rackspace::BlockStorage::Volume

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

Constant Summary collapse

AVAILABLE =
'available'
ATTACHING =
'attaching'
CREATING =
'creating'
DELETING =
'deleting'
ERROR =
'error'
ERROR_DELETING =
'error_deleting'
IN_USE =
'in-use'

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

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 Attributes::InstanceMethods

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

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#attached?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 30

def attached?
  state == IN_USE
end

#destroyObject



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

def destroy
  requires :identity
  connection.delete_volume(identity)
  true
end

#ready?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 26

def ready?
  state == AVAILABLE
end

#saveObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 38

def save
  requires :size
  data = connection.create_volume(size, {
    :display_name => display_name,
    :display_description => display_description,
    :volume_type => volume_type,
    :availability_zone => availability_zone
  })
  merge_attributes(data.body['volume'])
  true
end

#snapshotsObject



34
35
36
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 34

def snapshots
  connection.snapshots.select { |s| s.volume_id == identity }
end