Class: Commands::AbstractInstanceGroupCommand

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

Instance Attribute Summary collapse

Attributes inherited from Command

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

Instance Method Summary collapse

Methods inherited from Command

#enact, #get_field, #has_value, #have, #option, #require, #require_single_jobflow, #resolve, #validate

Constructor Details

#initialize(*args) ⇒ AbstractInstanceGroupCommand

Returns a new instance of AbstractInstanceGroupCommand.



1094
1095
1096
1097
1098
1099
1100
1101
# File 'lib/commands.rb', line 1094

def initialize(*args)
  super(*args)
  if @arg =~ /^ig-/ then
    @instance_group_id = @arg
  else
    @instance_role = @arg.upcase
  end
end

Instance Attribute Details

#bid_priceObject

Returns the value of attribute bid_price.



1091
1092
1093
# File 'lib/commands.rb', line 1091

def bid_price
  @bid_price
end

#instance_countObject

Returns the value of attribute instance_count.



1091
1092
1093
# File 'lib/commands.rb', line 1091

def instance_count
  @instance_count
end

#instance_group_idObject

Returns the value of attribute instance_group_id.



1091
1092
1093
# File 'lib/commands.rb', line 1091

def instance_group_id
  @instance_group_id
end

#instance_group_nameObject

Returns the value of attribute instance_group_name.



1091
1092
1093
# File 'lib/commands.rb', line 1091

def instance_group_name
  @instance_group_name
end

#instance_roleObject

Returns the value of attribute instance_role.



1091
1092
1093
# File 'lib/commands.rb', line 1091

def instance_role
  @instance_role
end

#instance_typeObject

Returns the value of attribute instance_type.



1091
1092
1093
# File 'lib/commands.rb', line 1091

def instance_type
  @instance_type
end

Instance Method Details

#default_instance_group_nameObject



1103
1104
1105
# File 'lib/commands.rb', line 1103

def default_instance_group_name
  get_field(:instance_role).downcase.capitalize + " Instance Group"
end

#instance_groupObject



1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
# File 'lib/commands.rb', line 1107

def instance_group
  ig =  {
    "Name" => get_field(:instance_group_name),
    "InstanceRole" => get_field(:instance_role),
    "InstanceCount" => get_field(:instance_count),
    "InstanceType"  => get_field(:instance_type)
  }
  if get_field(:bid_price, nil) != nil
    ig["BidPrice"] = get_field(:bid_price)
    ig["Market"] = "SPOT"
  else
    ig["Market"] = "ON_DEMAND"
  end
  return ig
end

#require_singleton_array(arr, msg) ⇒ Object



1123
1124
1125
1126
1127
# File 'lib/commands.rb', line 1123

def require_singleton_array(arr, msg)
  if arr.size != 1 then
    raise RuntimeError, "Expected to find one " + msg + " but found #{arr.size}."
  end
end