Class: Awsum::Ec2::Volume

Inherits:
Object show all
Defined in:
lib/ec2/volume.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ec2, id, instance_id, size, status, create_time, snapshot_id, device, attach_time, availability_zone, attachment_status) ⇒ Volume

:nodoc:



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ec2/volume.rb', line 6

def initialize(ec2, id, instance_id, size, status, create_time, snapshot_id, device, attach_time, availability_zone, attachment_status) #:nodoc:
  @ec2 = ec2
  @id = id
  @instance_id = instance_id
  @size = size
  @status = status
  @create_time = create_time
  @snapshot_id = snapshot_id
  @device = device
  @attach_time = attach_time
  @availability_zone = availability_zone
  @attachment_status = attachment_status
end

Instance Attribute Details

#attach_timeObject (readonly)

Returns the value of attribute attach_time.



4
5
6
# File 'lib/ec2/volume.rb', line 4

def attach_time
  @attach_time
end

#attachment_statusObject (readonly)

Returns the value of attribute attachment_status.



4
5
6
# File 'lib/ec2/volume.rb', line 4

def attachment_status
  @attachment_status
end

#availability_zoneObject (readonly)

Returns the value of attribute availability_zone.



4
5
6
# File 'lib/ec2/volume.rb', line 4

def availability_zone
  @availability_zone
end

#create_timeObject (readonly)

Returns the value of attribute create_time.



4
5
6
# File 'lib/ec2/volume.rb', line 4

def create_time
  @create_time
end

#deviceObject (readonly)

Returns the value of attribute device.



4
5
6
# File 'lib/ec2/volume.rb', line 4

def device
  @device
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/ec2/volume.rb', line 4

def id
  @id
end

#instance_idObject (readonly)

Returns the value of attribute instance_id.



4
5
6
# File 'lib/ec2/volume.rb', line 4

def instance_id
  @instance_id
end

#sizeObject (readonly)

Returns the value of attribute size.



4
5
6
# File 'lib/ec2/volume.rb', line 4

def size
  @size
end

#snapshot_idObject (readonly)

Returns the value of attribute snapshot_id.



4
5
6
# File 'lib/ec2/volume.rb', line 4

def snapshot_id
  @snapshot_id
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/ec2/volume.rb', line 4

def status
  @status
end

Instance Method Details

#create_snapshotObject

Creates a Snapshot of this Volume



52
53
54
# File 'lib/ec2/volume.rb', line 52

def create_snapshot
  @ec2.create_snapshot id
end

#deleteObject

Delete this volume



47
48
49
# File 'lib/ec2/volume.rb', line 47

def delete
  @ec2.delete_volume id
end

#detach(force = false) ⇒ Object

Detach this volume



42
43
44
# File 'lib/ec2/volume.rb', line 42

def detach(force = false)
  @ec2.detach_volume id, :force => force
end

#reloadObject

Will reload the information about this Volume

Useful for when a volume has just been created but is not yet available

while volume.status != 'available'
  volume.reload
end


26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ec2/volume.rb', line 26

def reload
  reloaded_volume = @ec2.volume id

  @id = id
  @instance_id = reloaded_volume.instance_id
  @size = reloaded_volume.size
  @status = reloaded_volume.status
  @create_time = reloaded_volume.create_time
  @snapshot_id = reloaded_volume.snapshot_id
  @device = reloaded_volume.device
  @attach_time = reloaded_volume.attach_time
  @availability_zone = reloaded_volume.availability_zone
  @attachment_status = reloaded_volume.attachment_status
end

#snapshotsObject

Lists the Snapshot(s) of this Volume



57
58
59
60
# File 'lib/ec2/volume.rb', line 57

def snapshots
  snapshots = @ec2.snapshots
  snapshots.delete_if {|s| s.volume_id != id}
end