Class: Opsicle::CreateInstance
- Inherits:
-
Object
- Object
- Opsicle::CreateInstance
- Defined in:
- lib/opsicle/commands/create_instance.rb
Instance Method Summary collapse
- #create_instance(layer, options) ⇒ Object
- #execute(options = {}) ⇒ Object
-
#initialize(environment) ⇒ CreateInstance
constructor
A new instance of CreateInstance.
- #select_layer ⇒ Object
Constructor Details
#initialize(environment) ⇒ CreateInstance
Returns a new instance of CreateInstance.
12 13 14 15 16 17 18 19 |
# File 'lib/opsicle/commands/create_instance.rb', line 12 def initialize(environment) @client = Client.new(environment) @ec2_adapter = Ec2Adapter.new(@client) @opsworks_adapter = OpsworksAdapter.new(@client) stack_id = @client.config.opsworks_config[:stack_id] @stack = ManageableStack.new(stack_id, @opsworks_adapter) @cli = HighLine.new end |
Instance Method Details
#create_instance(layer, options) ⇒ Object
30 31 32 |
# File 'lib/opsicle/commands/create_instance.rb', line 30 def create_instance(layer, ) CreatableInstance.new(layer, @stack, @opsworks_adapter.client, @ec2_adapter.client, @cli).create() end |
#execute(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/opsicle/commands/create_instance.rb', line 21 def execute(={}) puts "Stack ID = #{@stack.id}" layer = select_layer layer.get_cloneable_instances create_instance(layer, ) layer.ami_id = nil layer.agent_version = nil end |
#select_layer ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/opsicle/commands/create_instance.rb', line 34 def select_layer puts "\nLayers:\n" ops_layers = @opsworks_adapter.layers(@stack.id) layers = [] ops_layers.each do |layer| layers << ManageableLayer.new(layer.name, layer.layer_id, @stack, @opsworks_adapter.client, @ec2_adapter.client, @cli) end layers.each_with_index { |layer, index| puts "#{index.to_i + 1}) #{layer.name}" } layer_index = @cli.ask("Layer?\n", Integer) { |q| q.in = 1..layers.length.to_i } - 1 layers[layer_index] end |