Class: Commands::ModifyInstanceGroupCommand
- Inherits:
-
AbstractInstanceGroupCommand
- Object
- Command
- AbstractInstanceGroupCommand
- Commands::ModifyInstanceGroupCommand
- Defined in:
- lib/commands.rb
Instance Attribute Summary collapse
-
#jobflow_detail ⇒ Object
Returns the value of attribute jobflow_detail.
-
#jobflow_id ⇒ Object
Returns the value of attribute jobflow_id.
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_detail ⇒ Object
Returns the value of attribute jobflow_detail.
1159 1160 1161 |
# File 'lib/commands.rb', line 1159 def jobflow_detail @jobflow_detail end |
#jobflow_id ⇒ Object
Returns the value of attribute jobflow_id.
1159 1160 1161 |
# File 'lib/commands.rb', line 1159 def jobflow_id @jobflow_id end |
Instance Method Details
#enact(client) ⇒ Object
1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 |
# File 'lib/commands.rb', line 1173 def enact(client) if get_field(:instance_group_id) == nil then self.jobflow_id = require_single_jobflow self.jobflow_detail = client.describe_jobflow_with_id(self.jobflow_id) matching_instance_groups = jobflow_detail['Instances']['InstanceGroups'].select { |x| x['InstanceRole'] == instance_role } require_singleton_array(matching_instance_groups, "instance group with role #{instance_role}") self.instance_group_id = matching_instance_groups.first['InstanceGroupId'] end = { 'InstanceGroups' => [{ 'InstanceGroupId' => get_field(:instance_group_id), 'InstanceCount' => get_field(:instance_count) }] } client.modify_instance_groups() ig_modified = nil if get_field(:instance_role) != nil then ig_modified = get_field(:instance_role) else ig_modified = get_field(:instance_group_id) end logger.puts("Modified instance group " + ig_modified) end |
#validate ⇒ Object
1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 |
# File 'lib/commands.rb', line 1161 def validate 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 if get_field(:jobflow, []).size == 0 then raise RuntimeError, "You must specify a jobflow when using #{name} and specifying a role #{instance_role}" end end require(:instance_count, "Option #{name} is missing --instance-count") end |