Class: Standup::EC2::Volume
Class Method Summary collapse
Instance Method Summary collapse
- #attach_to(instance, device) ⇒ Object
- #destroy ⇒ Object
- #detach ⇒ Object
-
#initialize(id, info = false) ⇒ Volume
constructor
A new instance of Volume.
- #load_info ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(id, info = false) ⇒ Volume
Returns a new instance of Volume.
4 5 6 7 |
# File 'lib/standup/ec2/volume.rb', line 4 def initialize id, info = false @id = id super info end |
Class Method Details
.create(size) ⇒ Object
25 26 27 28 29 |
# File 'lib/standup/ec2/volume.rb', line 25 def self.create size response = api.create_volume :size => size.to_s, :availability_zone => Settings.aws.availability_zone list[response.volumeId] = Volume.new response.volumeId end |
.list(reload = false) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/standup/ec2/volume.rb', line 11 def self.list reload = false if !class_variable_defined?(:@@list) || reload @@list = {} response = api.describe_volumes response.volumeSet.item.each do |item| instance = item. ? Instance.new(item..item[0].instanceId) : nil @@list[item.volumeId] = Volume.new item.volumeId, :status => item.status.to_sym, :attached_to => instance end if response.volumeSet end @@list end |
Instance Method Details
#attach_to(instance, device) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/standup/ec2/volume.rb', line 36 def attach_to instance, device api.attach_volume :volume_id => @id, :instance_id => instance.id, :device => device @attached_to = instance end |
#destroy ⇒ Object
31 32 33 34 |
# File 'lib/standup/ec2/volume.rb', line 31 def destroy api.delete_volume :volume_id => @id list.delete @id end |
#detach ⇒ Object
43 44 45 46 47 |
# File 'lib/standup/ec2/volume.rb', line 43 def detach api.detach_volume :volume_id => @id, :force => 'true' @attached_to = nil end |