Class: Awsum::Ec2::Instance
Instance Attribute Summary collapse
-
#availability_zone ⇒ Object
readonly
Returns the value of attribute availability_zone.
-
#dns_name ⇒ Object
readonly
Returns the value of attribute dns_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#image_id ⇒ Object
readonly
Returns the value of attribute image_id.
-
#kernel_id ⇒ Object
readonly
Returns the value of attribute kernel_id.
-
#key_name ⇒ Object
readonly
Returns the value of attribute key_name.
-
#launch_index ⇒ Object
readonly
Returns the value of attribute launch_index.
-
#launch_time ⇒ Object
readonly
Returns the value of attribute launch_time.
-
#private_dns_name ⇒ Object
readonly
Returns the value of attribute private_dns_name.
-
#product_codes ⇒ Object
readonly
Returns the value of attribute product_codes.
-
#ramdisk_id ⇒ Object
readonly
Returns the value of attribute ramdisk_id.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#attach(volume, device = '/dev/sdh') ⇒ Object
Will attach a Volume to this Instance.
-
#create_volume(size = nil, snapshot_id = nil, device = '/dev/sdh') ⇒ Object
Will create and attach a Volume to this Instance You must specify a size or a snapshot_id.
-
#initialize(ec2, id, image_id, type, state, dns_name, private_dns_name, key_name, kernel_id, launch_time, availability_zone, product_codes, ramdisk_id, reason, launch_index) ⇒ Instance
constructor
:nodoc:.
-
#terminate ⇒ Object
Terminates this instance.
-
#volumes ⇒ Object
Lists all the Volume(s) attached to this Instance.
Constructor Details
#initialize(ec2, id, image_id, type, state, dns_name, private_dns_name, key_name, kernel_id, launch_time, availability_zone, product_codes, ramdisk_id, reason, launch_index) ⇒ Instance
:nodoc:
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/awsum/ec2/instance.rb', line 8 def initialize(ec2, id, image_id, type, state, dns_name, private_dns_name, key_name, kernel_id, launch_time, availability_zone, product_codes, ramdisk_id, reason, launch_index) #:nodoc: @ec2 = ec2 @id = id @image_id = image_id @type = type @state = state @dns_name = dns_name @private_dns_name = private_dns_name @key_name = key_name @kernel_id = kernel_id @launch_time = launch_time @availability_zone = availability_zone @product_codes = product_codes @ramdisk_id = ramdisk_id @reason = reason @launch_index = launch_index end |
Instance Attribute Details
#availability_zone ⇒ Object (readonly)
Returns the value of attribute availability_zone.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def availability_zone @availability_zone end |
#dns_name ⇒ Object (readonly)
Returns the value of attribute dns_name.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def dns_name @dns_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def id @id end |
#image_id ⇒ Object (readonly)
Returns the value of attribute image_id.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def image_id @image_id end |
#kernel_id ⇒ Object (readonly)
Returns the value of attribute kernel_id.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def kernel_id @kernel_id end |
#key_name ⇒ Object (readonly)
Returns the value of attribute key_name.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def key_name @key_name end |
#launch_index ⇒ Object (readonly)
Returns the value of attribute launch_index.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def launch_index @launch_index end |
#launch_time ⇒ Object (readonly)
Returns the value of attribute launch_time.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def launch_time @launch_time end |
#private_dns_name ⇒ Object (readonly)
Returns the value of attribute private_dns_name.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def private_dns_name @private_dns_name end |
#product_codes ⇒ Object (readonly)
Returns the value of attribute product_codes.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def product_codes @product_codes end |
#ramdisk_id ⇒ Object (readonly)
Returns the value of attribute ramdisk_id.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def ramdisk_id @ramdisk_id end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def reason @reason end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def state @state end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/awsum/ec2/instance.rb', line 6 def type @type end |
Instance Method Details
#attach(volume, device = '/dev/sdh') ⇒ Object
Will attach a Volume to this Instance
52 53 54 |
# File 'lib/awsum/ec2/instance.rb', line 52 def attach(volume, device = '/dev/sdh') @ec2.attach_volume volume.id, id, device end |
#create_volume(size = nil, snapshot_id = nil, device = '/dev/sdh') ⇒ Object
Will create and attach a Volume to this Instance You must specify a size or a snapshot_id
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/awsum/ec2/instance.rb', line 39 def create_volume(size = nil, snapshot_id = nil, device = '/dev/sdh') raise ArgumentError.new('You must specify a size if not creating a volume from a snapshot') if size.blank? && snapshot_id.blank? raise ArgumentError.new('You must specify a device to attach the volume to') unless device volume = @ec2.create_volume availability_zone, :size => size, :snapshot_id => snapshot_id while volume.status != 'available' volume.reload end attach volume, device volume end |
#terminate ⇒ Object
Terminates this instance
27 28 29 |
# File 'lib/awsum/ec2/instance.rb', line 27 def terminate @ec2.terminate_instances(id) end |
#volumes ⇒ Object
Lists all the Volume(s) attached to this Instance
32 33 34 35 |
# File 'lib/awsum/ec2/instance.rb', line 32 def volumes volumes = @ec2.volumes volumes.delete_if {|v| v.instance_id != id} end |