Class: Elasticity::InstanceGroup
- Inherits:
-
Object
- Object
- Elasticity::InstanceGroup
- Defined in:
- lib/elasticity/instance_group.rb
Constant Summary collapse
- ROLES =
%w(MASTER CORE TASK)
Instance Attribute Summary collapse
-
#bid_price ⇒ Object
readonly
Returns the value of attribute bid_price.
-
#count ⇒ Object
Returns the value of attribute count.
-
#market ⇒ Object
readonly
Returns the value of attribute market.
-
#role ⇒ Object
Returns the value of attribute role.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize ⇒ InstanceGroup
constructor
A new instance of InstanceGroup.
- #set_on_demand_instances ⇒ Object
- #set_spot_instances(bid_price) ⇒ Object
- #to_aws_instance_config ⇒ Object
Constructor Details
#initialize ⇒ InstanceGroup
Returns a new instance of InstanceGroup.
14 15 16 17 18 19 |
# File 'lib/elasticity/instance_group.rb', line 14 def initialize @count = 1 @type = 'm1.small' @market = 'ON_DEMAND' @role = 'CORE' end |
Instance Attribute Details
#bid_price ⇒ Object (readonly)
Returns the value of attribute bid_price.
11 12 13 |
# File 'lib/elasticity/instance_group.rb', line 11 def bid_price @bid_price end |
#count ⇒ Object
Returns the value of attribute count.
7 8 9 |
# File 'lib/elasticity/instance_group.rb', line 7 def count @count end |
#market ⇒ Object (readonly)
Returns the value of attribute market.
12 13 14 |
# File 'lib/elasticity/instance_group.rb', line 12 def market @market end |
#role ⇒ Object
Returns the value of attribute role.
9 10 11 |
# File 'lib/elasticity/instance_group.rb', line 9 def role @role end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/elasticity/instance_group.rb', line 8 def type @type end |
Instance Method Details
#set_on_demand_instances ⇒ Object
47 48 49 50 |
# File 'lib/elasticity/instance_group.rb', line 47 def set_on_demand_instances @bid_price = nil @market = 'ON_DEMAND' end |
#set_spot_instances(bid_price) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/elasticity/instance_group.rb', line 39 def set_spot_instances(bid_price) if bid_price < 0 raise ArgumentError, "The bid price for spot instances should be greater than 0 (#{bid_price} requested)" end @bid_price = "#{bid_price}" @market = 'SPOT' end |
#to_aws_instance_config ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/elasticity/instance_group.rb', line 52 def to_aws_instance_config { :market => @market, :instance_count => @count, :instance_type => @type, :instance_role => @role, }.tap do |config| config.merge!(:bid_price => @bid_price) if @market == 'SPOT' end end |