Class: ZAWS::External::AWSCLI::Commands::EC2::DescribeInstances

Inherits:
Object
  • Object
show all
Defined in:
lib/zaws/external/awscli/commands/ec2/describe_instances.rb

Instance Method Summary collapse

Constructor Details

#initialize(shellout = nil, awscli = nil) ⇒ DescribeInstances

Returns a new instance of DescribeInstances.



8
9
10
11
12
13
# File 'lib/zaws/external/awscli/commands/ec2/describe_instances.rb', line 8

def initialize(shellout=nil, awscli=nil)
  #super(shellout, awscli)
  @shellout=shellout
  @awscli=awscli
  clear_settings
end

Instance Method Details

#awsObject



15
16
17
18
# File 'lib/zaws/external/awscli/commands/ec2/describe_instances.rb', line 15

def aws
  @aws ||= ZAWS::External::AWSCLI::Commands::AWS.new(self)
  @aws
end

#clear_settingsObject



25
26
27
28
# File 'lib/zaws/external/awscli/commands/ec2/describe_instances.rb', line 25

def clear_settings
  @aws=nil
  @filter=nil
end

#execute(region, view, filters = {}, textout = nil, verbose = nil, profile = nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/zaws/external/awscli/commands/ec2/describe_instances.rb', line 36

def execute(region, view, filters={}, textout=nil, verbose=nil, profile=nil)
  comline = "aws"
  comline = comline + " --output #{view}"
  comline = comline + " --region #{region} ec2 describe-instances"
  comline = comline + " --profile #{profile}" if profile
  comline = comline + " --filter" if filters.length > 0
  filters.each do |key, item|
    comline = comline + " \"Name=#{key},Values=#{item}\""
  end
  unless @awscli.data_ec2.instance.load_cached(comline, verbose)
    @awscli.data_ec2.instance.load(comline, @shellout.cli(comline, verbose), verbose)
  end
end

#filterObject



20
21
22
23
# File 'lib/zaws/external/awscli/commands/ec2/describe_instances.rb', line 20

def filter
  @filter ||= ZAWS::External::AWSCLI::Commands::EC2::Filter.new()
  @filter
end

#get_commandObject



30
31
32
33
34
# File 'lib/zaws/external/awscli/commands/ec2/describe_instances.rb', line 30

def get_command
  command = "ec2 describe-instances"
  command = "#{command} #{@filter.get_command}" if @filter
  return command
end