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
#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.
1115 1116 1117 |
# File 'lib/commands.rb', line 1115 def jobflow_detail @jobflow_detail end |
#jobflow_id ⇒ Object
Returns the value of attribute jobflow_id.
1115 1116 1117 |
# File 'lib/commands.rb', line 1115 def jobflow_id @jobflow_id end |
Instance Method Details
#enact(client) ⇒ Object
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 |
# File 'lib/commands.rb', line 1129 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
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 |
# File 'lib/commands.rb', line 1117 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 |