Class: Rivet::AutoscaleConfig

Inherits:
BaseConfig show all
Defined in:
lib/rivet/as/autoscale_config.rb

Instance Attribute Summary

Attributes inherited from BaseConfig

#bootstrap, #name

Attributes inherited from OpenState

#generated_attributes, #required_fields

Instance Method Summary collapse

Methods inherited from BaseConfig

from_file, #normalize_security_groups, #path, #post

Methods inherited from OpenState

#install_get_or_set, #method_missing, #validate

Constructor Details

#initialize(name, load_path = '.', &block) ⇒ AutoscaleConfig

Returns a new instance of AutoscaleConfig.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rivet/as/autoscale_config.rb', line 6

def initialize(name, load_path='.', &block)
  @required_fields = {
    :min_size => nil,
    :max_size => nil,
    :availability_zones => nil,
    :default_cooldown => 300,
    :desired_capacity => 0,
    :health_check_grace_period => 0,
    :health_check_type => :ec2,
    :load_balancers => [],
    :tags => [],
    :termination_policies => ['Default']
  }
  super(name,load_path, &block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rivet::OpenState

Instance Method Details

#normalize_availability_zonesObject



22
23
24
# File 'lib/rivet/as/autoscale_config.rb', line 22

def normalize_availability_zones
  availability_zones.map { |zone| region + zone }.sort
end

#normalize_load_balancersObject



26
27
28
# File 'lib/rivet/as/autoscale_config.rb', line 26

def normalize_load_balancers
  load_balancers.sort
end

#normalize_subnetsObject



30
31
32
# File 'lib/rivet/as/autoscale_config.rb', line 30

def normalize_subnets
  subnets.sort
end

#normalize_tagsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rivet/as/autoscale_config.rb', line 34

def normalize_tags
  normalized_tags = []
  tags.each do |t|
    normalized_hash = {}

    if t.has_key? :propagate_at_launch
      normalized_hash[:propagate_at_launch] = t[:propagate_at_launch]
    else
      normalized_hash[:propagate_at_launch] = true
    end

    [:value, :key].each do |k|
      if t.has_key? k
        normalized_hash[k] = t[k]
      else
        normalized_hash[k] = nil
      end
    end
    normalized_tags << normalized_hash
  end
  normalized_tags.sort_by { |h| h[:key] }
end