Class: Commands::UnarrestInstanceGroupCommand

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

Instance Attribute Summary collapse

Attributes inherited from AbstractInstanceGroupCommand

#bid_price, #instance_count, #instance_group_id, #instance_group_name, #instance_role, #instance_type

Attributes inherited from Command

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

Instance Method Summary collapse

Methods inherited from AbstractInstanceGroupCommand

#default_instance_group_name, #initialize, #instance_group, #require_singleton_array

Methods inherited from Command

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

Constructor Details

This class inherits a constructor from Commands::AbstractInstanceGroupCommand

Instance Attribute Details

#jobflow_detailObject

Returns the value of attribute jobflow_detail.



1201
1202
1203
# File 'lib/commands.rb', line 1201

def jobflow_detail
  @jobflow_detail
end

#jobflow_idObject

Returns the value of attribute jobflow_id.



1201
1202
1203
# File 'lib/commands.rb', line 1201

def jobflow_id
  @jobflow_id
end

Instance Method Details

#enact(client) ⇒ Object



1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
# File 'lib/commands.rb', line 1212

def enact(client)
  self.jobflow_id = require_single_jobflow
  self.jobflow_detail = client.describe_jobflow_with_id(self.jobflow_id)

  matching_instance_groups = nil
  if get_field(:instance_group_id) == nil then
    matching_instance_groups = 
      jobflow_detail['Instances']['InstanceGroups'].select { |x| x['InstanceRole'] == instance_role }
  else
    matching_instance_groups = 
      jobflow_detail['Instances']['InstanceGroups'].select { |x| x['InstanceGroupId'] == get_field(:instance_group_id) }
  end

  require_singleton_array(matching_instance_groups, "instance group with role #{instance_role}")
  instance_group_detail = matching_instance_groups.first
    self.instance_group_id = instance_group_detail['InstanceGroupId']
    self.instance_count = instance_group_detail['InstanceRequestCount']
  
  options = {
    'InstanceGroups' => [{ 
      'InstanceGroupId' => get_field(:instance_group_id), 
      'InstanceCount' => get_field(:instance_count) 
    }]
  }
  client.modify_instance_groups(options)
  logger.puts "Unarrested instance group #{get_field(:instance_group_id)}."
end

#validateObject



1203
1204
1205
1206
1207
1208
1209
1210
# File 'lib/commands.rb', line 1203

def validate
  require_single_jobflow
  if get_field(:instance_group_id) == nil then
    if ! ["CORE", "TASK"].include?(get_field(:instance_role)) then
      raise RuntimeError, "Invalid argument to #{name}, #{@arg} is not valid"
    end
  end
end