Class: Opsicle::ManageableStack
- Inherits:
-
Object
- Object
- Opsicle::ManageableStack
- Defined in:
- lib/opsicle/manageable_stack.rb
Constant Summary collapse
- STOPPABLE_STATES =
%w(start_failed stop_failed online running_setup setup_failed booting rebooting)
Instance Attribute Summary collapse
-
#cli ⇒ Object
Returns the value of attribute cli.
-
#eips ⇒ Object
Returns the value of attribute eips.
-
#id ⇒ Object
Returns the value of attribute id.
-
#opsworks_adapter ⇒ Object
Returns the value of attribute opsworks_adapter.
-
#stack ⇒ Object
Returns the value of attribute stack.
-
#vpc_id ⇒ Object
Returns the value of attribute vpc_id.
Instance Method Summary collapse
- #deleteable_instances(layer) ⇒ Object
-
#initialize(stack_id, opsworks_adapter, cli = nil) ⇒ ManageableStack
constructor
A new instance of ManageableStack.
- #instances ⇒ Object
- #stoppable_instances(layer) ⇒ Object
- #transfer_eip(moveable_eip, target_instance_id) ⇒ Object
Constructor Details
#initialize(stack_id, opsworks_adapter, cli = nil) ⇒ ManageableStack
Returns a new instance of ManageableStack.
7 8 9 10 11 12 13 |
# File 'lib/opsicle/manageable_stack.rb', line 7 def initialize(stack_id, opsworks_adapter, cli=nil) self.id = stack_id self.opsworks_adapter = opsworks_adapter self.cli = cli self.stack = @opsworks_adapter.stack(id) self.vpc_id = self.stack.vpc_id end |
Instance Attribute Details
#cli ⇒ Object
Returns the value of attribute cli.
3 4 5 |
# File 'lib/opsicle/manageable_stack.rb', line 3 def cli @cli end |
#eips ⇒ Object
Returns the value of attribute eips.
3 4 5 |
# File 'lib/opsicle/manageable_stack.rb', line 3 def eips @eips end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/opsicle/manageable_stack.rb', line 3 def id @id end |
#opsworks_adapter ⇒ Object
Returns the value of attribute opsworks_adapter.
3 4 5 |
# File 'lib/opsicle/manageable_stack.rb', line 3 def opsworks_adapter @opsworks_adapter end |
#stack ⇒ Object
Returns the value of attribute stack.
3 4 5 |
# File 'lib/opsicle/manageable_stack.rb', line 3 def stack @stack end |
#vpc_id ⇒ Object
Returns the value of attribute vpc_id.
3 4 5 |
# File 'lib/opsicle/manageable_stack.rb', line 3 def vpc_id @vpc_id end |
Instance Method Details
#deleteable_instances(layer) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/opsicle/manageable_stack.rb', line 41 def deleteable_instances(layer) instances.select do |instance| instance.auto_scaling_type.nil? && instance.status == "stopped" && instance.layer_ids.include?(layer.layer_id) end end |
#instances ⇒ Object
37 38 39 |
# File 'lib/opsicle/manageable_stack.rb', line 37 def instances @opsworks_adapter.instances_by_stack(id) end |
#stoppable_instances(layer) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/opsicle/manageable_stack.rb', line 49 def stoppable_instances(layer) instances.select do |instance| instance.elastic_ip.nil? && STOPPABLE_STATES.include?(instance.status) && instance.layer_ids.include?(layer.layer_id) end end |
#transfer_eip(moveable_eip, target_instance_id) ⇒ Object
33 34 35 |
# File 'lib/opsicle/manageable_stack.rb', line 33 def transfer_eip(moveable_eip, target_instance_id) @opsworks_adapter.associate_elastic_ip(moveable_eip[:ip_address], target_instance_id) end |