Class: Commands::UnarrestInstanceGroupCommand

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

Instance Attribute Summary collapse

Attributes inherited from AbstractInstanceGroupCommand

#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.



1157
1158
1159
# File 'lib/commands.rb', line 1157

def jobflow_detail
  @jobflow_detail
end

#jobflow_idObject

Returns the value of attribute jobflow_id.



1157
1158
1159
# File 'lib/commands.rb', line 1157

def jobflow_id
  @jobflow_id
end

Instance Method Details

#enact(client) ⇒ Object



1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
# File 'lib/commands.rb', line 1168

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



1159
1160
1161
1162
1163
1164
1165
1166
# File 'lib/commands.rb', line 1159

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