Class: SimpleDeploy::CLI::Instances

Inherits:
Object
  • Object
show all
Includes:
Shared
Defined in:
lib/simple_deploy/cli/instances.rb

Instance Method Summary collapse

Methods included from Shared

#command_name, #parse_attributes, #rescue_exceptions_and_exit, #valid_options?

Instance Method Details

#command_summaryObject



46
47
48
# File 'lib/simple_deploy/cli/instances.rb', line 46

def command_summary
  'List instances for stack'
end

#listObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/simple_deploy/cli/instances.rb', line 9

def list
  @opts = Trollop::options do
    version SimpleDeploy::VERSION
    banner "\nList instances for stack.\n\nsimple_deploy instances -n STACK_NAME -e ENVIRONMENT\n\n"
    opt :help, "Display Help"
    opt :environment, "Set the target environment", :type => :string
    opt :name, "Stack name to manage", :type => :string
    opt :internal, "Use internal IP for ssh commands"
  end

  valid_options? :provided => @opts,
                 :required => [:environment, :name]

  SimpleDeploy.create_config @opts[:environment]
  logger = SimpleDeploy.logger @opts[:log_level]

  stack = Stack.new :name        => @opts[:name],
                    :environment => @opts[:environment],
                    :internal    => @opts[:internal]

  exit 1 unless stack.exists?

  instances = stack.instances

  if instances.nil? || instances.empty?
    logger.info "Stack '#{@opts[:name]}' does not have any instances."
  else
    puts stack.instances
  end
end