Sha256: 11ab0d802965b1f4737f6c85643b8ac0dbb471094a0c16bf108440840e63761e

Contents?: true

Size: 1.84 KB

Versions: 6

Compression:

Stored size: 1.84 KB

Contents

require 'trollop'

module SimpleDeploy
  module CLI

    class Instances
      include Shared

      def list
        @opts = Trollop::options do
          version SimpleDeploy::VERSION
          banner <<-EOS

List instances for stack.

simple_deploy instances -n STACK_NAME -e ENVIRONMENT

Using Internal / External IPs

simple_deploy defaults to using the public IP when return the IP for stacks in classic, or the private IP when in a VPC.

The internal or external flag forces simple_deploy to use the given IP address.

simple_deploy instances -n STACK_NAME -n STACK_NAME -e ENVIRONMENT -i

EOS
          opt :help, "Display Help"
          opt :environment, "Set the target environment", :type => :string
          opt :name, "Stack name to manage", :type => :string
          opt :external, "Return external IP for instances."
          opt :internal, "Return internal IP for instances."
          opt :read_from_env, "Read credentials and region from environment variables"
        end

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

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

        stack = Stack.new :name        => @opts[:name],
                          :environment => @opts[:environment],
                          :external    => @opts[:external],
                          :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 instances
        end
      end

      def command_summary
        'List instances for stack'
      end

    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
simple_deploy-0.10.2 lib/simple_deploy/cli/instances.rb
simple_deploy-0.10.1 lib/simple_deploy/cli/instances.rb
simple_deploy-0.10.0 lib/simple_deploy/cli/instances.rb
simple_deploy-0.10.0.beta.3 lib/simple_deploy/cli/instances.rb
simple_deploy-0.10.0.beta.2 lib/simple_deploy/cli/instances.rb
simple_deploy-0.10.0.beta.1 lib/simple_deploy/cli/instances.rb