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.



970
971
972
# File 'lib/commands.rb', line 970

def active
  @active
end

#allObject

Returns the value of attribute all.



970
971
972
# File 'lib/commands.rb', line 970

def all
  @all
end

#created_afterObject

Returns the value of attribute created_after.



970
971
972
# File 'lib/commands.rb', line 970

def created_after
  @created_after
end

#created_beforeObject

Returns the value of attribute created_before.



970
971
972
# File 'lib/commands.rb', line 970

def created_before
  @created_before
end

#max_resultsObject

Returns the value of attribute max_results.



970
971
972
# File 'lib/commands.rb', line 970

def max_results
  @max_results
end

#no_stepsObject

Returns the value of attribute no_steps.



970
971
972
# File 'lib/commands.rb', line 970

def no_steps
  @no_steps
end

#stateObject

Returns the value of attribute state.



970
971
972
# File 'lib/commands.rb', line 970

def state
  @state
end

Instance Method Details

#enact(client) ⇒ Object



972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# File 'lib/commands.rb', line 972

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(:state) then
      states << get_field(:state)
    end

    if get_field(:all) then
      options = { 'CreatedAfter' => (Time.now - (58 * 24 * 3600)).xmlschema }
    else
      options = {}
      options['CreatedAfter']  = get_field(:created_after) if get_field(:created_after)
      options['CreatedBefore'] = get_field(:created_before) if get_field(:created_before)
      options['JobFlowStates'] = states if states.size > 0
    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