Class: Commands::AbstractListCommand

Inherits:
Command show all
Defined in:
lib/commands.rb

Direct Known Subclasses

DescribeActionCommand, ListActionCommand

Instance Attribute Summary collapse

Attributes inherited from Command

#arg, #commands, #description, #logger, #name

Instance Method Summary collapse

Methods inherited from Command

#get_field, #has_value, #have, #initialize, #option, #require, #require_single_jobflow, #resolve, #validate

Constructor Details

This class inherits a constructor from Commands::Command

Instance Attribute Details

#activeObject

Returns the value of attribute active.



934
935
936
# File 'lib/commands.rb', line 934

def active
  @active
end

#allObject

Returns the value of attribute all.



934
935
936
# File 'lib/commands.rb', line 934

def all
  @all
end

#max_resultsObject

Returns the value of attribute max_results.



934
935
936
# File 'lib/commands.rb', line 934

def max_results
  @max_results
end

#no_stepsObject

Returns the value of attribute no_steps.



934
935
936
# File 'lib/commands.rb', line 934

def no_steps
  @no_steps
end

#stateObject

Returns the value of attribute state.



934
935
936
# File 'lib/commands.rb', line 934

def state
  @state
end

Instance Method Details

#enact(client) ⇒ Object



936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
# File 'lib/commands.rb', line 936

def enact(client)
  options = {}
  states = []
  if get_field(:jobflow, []).size > 0 then
    options = { 'JobFlowIds' => get_field(:jobflow) }
  else 
    if get_field(:active) then
      states = %w(RUNNING SHUTTING_DOWN STARTING WAITING BOOTSTRAPPING)
    end
    if get_field(:states) then
      states += get_field(states)
    end
    if get_field(:active) || get_field(:states) then
      options = { 'JobFlowStates' => states }
    elsif get_field(:all) then
      options = { }
    else
      options = { 'CreatedAfter' => (Time.now - (2 * 24 * 3600)).xmlschema }
    end
  end
  result = client.describe_jobflow(options)
  # add the described jobflow to the supplied jobflows
  commands.global_options[:jobflow] += result['JobFlows'].map { |x| x['JobFlowId'] }
  commands.global_options[:jobflow].uniq!

  return result
end