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_or_snapshot_id, options = {}) ⇒ 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:.
- #reload ⇒ Object
-
#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
81 82 83 |
# File 'lib/awsum/ec2/instance.rb', line 81 def attach(volume, device = '/dev/sdh') @ec2.attach_volume volume.id, id, device end |
#create_volume(size_or_snapshot_id, options = {}) ⇒ Object
Will create and attach a Volume to this Instance You must specify a size or a snapshot_id
Options:
:tags => Hash of tags :device => Will automatically attach the volume to the specified device
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/awsum/ec2/instance.rb', line 61 def create_volume(size_or_snapshot_id, = {}) = {:device => '/dev/sdh'}.merge() if size_or_snapshot_id.is_a?(Numeric) volume = @ec2.create_volume availability_zone, :size => size_or_snapshot_id else volume = @ec2.create_volume availability_zone, :snapshot_id => size_or_snapshot_id end if [:tags] @ec2.(volume.id, [:tags]) end while volume.status != 'available' volume.reload end if [:device] attach volume, [:device] end volume end |
#reload ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/awsum/ec2/instance.rb', line 26 def reload replacement_instance = @ec2.instance id #TODO: Make this easier @image_id = replacement_instance.image_id @type = replacement_instance.type @state = replacement_instance.state @dns_name = replacement_instance.dns_name @private_dns_name = replacement_instance.private_dns_name @key_name = replacement_instance.key_name @kernel_id = replacement_instance.kernel_id @launch_time = replacement_instance.launch_time @availability_zone = replacement_instance.availability_zone @product_codes = replacement_instance.product_codes @ramdisk_id = replacement_instance.ramdisk_id @reason = replacement_instance.reason @launch_index = replacement_instance.launch_index end |
#terminate ⇒ Object
Terminates this instance
45 46 47 |
# File 'lib/awsum/ec2/instance.rb', line 45 def terminate @ec2.terminate_instances(id) end |
#volumes ⇒ Object
Lists all the Volume(s) attached to this Instance
50 51 52 53 |
# File 'lib/awsum/ec2/instance.rb', line 50 def volumes volumes = @ec2.volumes volumes.delete_if {|v| v.instance_id != id} end |