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.
-
#ebs_configuration ⇒ Object
readonly
Returns the value of attribute ebs_configuration.
-
#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_ebs_configuration(ebs_configuration) ⇒ Object
- #set_on_demand_instances ⇒ Object
- #set_spot_instances(bid_price) ⇒ Object
- #to_aws_instance_config ⇒ Object
Constructor Details
permalink #initialize ⇒ InstanceGroup
Returns a new instance of InstanceGroup.
15 16 17 18 19 20 |
# File 'lib/elasticity/instance_group.rb', line 15 def initialize @count = 1 @type = 'm1.small' @market = 'ON_DEMAND' @role = 'CORE' end |
Instance Attribute Details
permalink #bid_price ⇒ Object (readonly)
Returns the value of attribute bid_price.
12 13 14 |
# File 'lib/elasticity/instance_group.rb', line 12 def bid_price @bid_price end |
permalink #count ⇒ Object
Returns the value of attribute count.
7 8 9 |
# File 'lib/elasticity/instance_group.rb', line 7 def count @count end |
permalink #ebs_configuration ⇒ Object (readonly)
Returns the value of attribute ebs_configuration.
11 12 13 |
# File 'lib/elasticity/instance_group.rb', line 11 def ebs_configuration @ebs_configuration end |
permalink #market ⇒ Object (readonly)
Returns the value of attribute market.
13 14 15 |
# File 'lib/elasticity/instance_group.rb', line 13 def market @market end |
permalink #role ⇒ Object
Returns the value of attribute role.
9 10 11 |
# File 'lib/elasticity/instance_group.rb', line 9 def role @role end |
permalink #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
permalink #set_ebs_configuration(ebs_configuration) ⇒ Object
[View source]
53 54 55 56 57 |
# File 'lib/elasticity/instance_group.rb', line 53 def set_ebs_configuration(ebs_configuration) if ebs_configuration.is_a?(Elasticity::EbsConfiguration) @ebs_configuration = ebs_configuration end end |
permalink #set_on_demand_instances ⇒ Object
[View source]
48 49 50 51 |
# File 'lib/elasticity/instance_group.rb', line 48 def set_on_demand_instances @bid_price = nil @market = 'ON_DEMAND' end |
permalink #set_spot_instances(bid_price) ⇒ Object
[View source]
40 41 42 43 44 45 46 |
# File 'lib/elasticity/instance_group.rb', line 40 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 |
permalink #to_aws_instance_config ⇒ Object
[View source]
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/elasticity/instance_group.rb', line 59 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' config.merge!(:ebs_configuration => @ebs_configuration.to_aws_ebs_config) if @ebs_configuration != nil end end |