Class: CfAsGroup

Inherits:
Object
  • Object
show all
Includes:
CfBase
Defined in:
lib/cf_factory/as/cf_as_group.rb

Instance Method Summary collapse

Methods included from CfBase

#generate, #generate_ref, #get_deletion_policy, #get_name, #hash_to_string, #retrieve_attribute, #set_meta_data, #set_quotes

Constructor Details

#initialize(name, availability_zones, launch_config, load_balancers, max_size, min_size, options) ⇒ CfAsGroup

Returns a new instance of CfAsGroup.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cf_factory/as/cf_as_group.rb', line 7

def initialize(name, availability_zones, launch_config, load_balancers, max_size, min_size, options)
  @name = name
  @availability_zones = availability_zones
  @launch_config = launch_config
  @load_balancers  = load_balancers
  @max_size = max_size
  @min_size = min_size
  
  @cooldown = options[:cooldown]
  @desired_capacity = options[:desired_capacity]
  @health_check_grace_period = options[:health_check_grace_period]
  @health_check_type = options[:health_check_type]
  #TODO: NotificationConfiguration      
  @subnets = options[:subnets]
  validate()
end

Instance Method Details

#add_egress_rule(egress_rule) ⇒ Object



71
72
73
# File 'lib/cf_factory/as/cf_as_group.rb', line 71

def add_egress_rule(egress_rule)
  @egress_rules << egress_rule
end

#add_ingress_rule(ingress_rule) ⇒ Object



67
68
69
# File 'lib/cf_factory/as/cf_as_group.rb', line 67

def add_ingress_rule(ingress_rule)
  @ingress_rules << ingress_rule
end

#get_cf_attributesObject



48
49
50
# File 'lib/cf_factory/as/cf_as_group.rb', line 48

def get_cf_attributes
  {}
end

#get_cf_propertiesObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/cf_factory/as/cf_as_group.rb', line 52

def get_cf_properties
  result = {"AvailabilityZones" => @availability_zones,
    "LaunchConfigurationName" => @launch_config.generate_ref,
    "LoadBalancerNames" => CfHelper.generate_ref_array(@load_balancers),
    "MaxSize" => @max_size,
    "MinSize" => @min_size
  }
  result["Cooldown"] = @cooldown unless @cooldown.nil?
  result["DesiredCapacity"] = @desired_capacity unless @desired_capacity.nil?
  result["HealthCheckGracePeriod"] = @health_check_grace_period.to_i unless @health_check_grace_period.nil?
  result["HealthCheckType"] = @health_check_type unless @health_check_type.nil?  
  result["VPCZoneIdentifier"] = CfHelper.generate_ref_array(@subnets) unless @subnets.nil?
  result
end

#get_cf_typeObject



44
45
46
# File 'lib/cf_factory/as/cf_as_group.rb', line 44

def get_cf_type
  "AWS::AutoScaling::AutoScalingGroup"
end

#set_tags(tag_list) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/cf_factory/as/cf_as_group.rb', line 24

def set_tags(tag_list)
  @tag_list = []
  tag_list.each() {|tg|
    tg2 = tg.clone
    tg2.set_propagate_at_launch(true)
    puts ">>>>>>>>>>>>>>>>>>>>> "+tg2.inspect
    @tag_list << tg2
  }
  @tag_list
end

#validateObject



35
36
37
38
39
40
41
42
# File 'lib/cf_factory/as/cf_as_group.rb', line 35

def validate
  if @max_size < @min_size
    raise Exception.new("max size (#{@max_size}) must be equal or larger min size (#{@min_size})")
  end
  if @health_check_type == "ELB" && @health_check_grace_period.nil? 
    raise Exception.new("HealthCheckGracePeriod must be specified for ElasticLoadBalancer based health checks.")
  end
end