class Rivet::AwsAutoscaleWrapper

Constants

OPTIONS

Attributes

name[R]

Public Class Methods

new(name) click to toggle source
# File lib/rivet/as/aws_autoscale_wrapper.rb, line 24
def initialize(name)
  Rivet::Log.debug "Initializing AWS Autoscale Wrapper for #{name}"
  @name = name
  @group = AWS::AutoScaling.new.groups[@name]

  if @group.exists?
    OPTIONS.each do |o|
      normalize_method = "normalize_#{o}".to_sym
      if respond_to?(normalize_method)
        Rivet::Log.debug "Calling #{normalize_method} in AWS autoscale wrapper"
        value = send(normalize_method)
      else
        value = @group.send(o)
      end
      instance_variable_set("@#{o}", value)
    end
  end

end

Public Instance Methods

normalize_availability_zones() click to toggle source
# File lib/rivet/as/aws_autoscale_wrapper.rb, line 52
def normalize_availability_zones
  @group.availability_zone_names.to_a.sort
end
normalize_launch_configuration() click to toggle source
# File lib/rivet/as/aws_autoscale_wrapper.rb, line 44
def normalize_launch_configuration
  @group.launch_configuration_name
end
normalize_load_balancers() click to toggle source
# File lib/rivet/as/aws_autoscale_wrapper.rb, line 48
def normalize_load_balancers
  @group.load_balancer_names.to_a.sort
end
normalize_subnets() click to toggle source
# File lib/rivet/as/aws_autoscale_wrapper.rb, line 62
def normalize_subnets
  @group.subnets.empty? ? nil : @group.subnets.map(&:id).sort
end
normalize_tags() click to toggle source
# File lib/rivet/as/aws_autoscale_wrapper.rb, line 56
def normalize_tags
  @group.tags.to_a.inject([]) do |normalized_tags, current|
    normalized_tags << normalize_tag(current)
  end
end
normalize_termination_policies() click to toggle source
# File lib/rivet/as/aws_autoscale_wrapper.rb, line 66
def normalize_termination_policies
  @group.termination_policies.to_a.sort
end

Protected Instance Methods

normalize_tag(tag) click to toggle source
# File lib/rivet/as/aws_autoscale_wrapper.rb, line 72
def normalize_tag(tag)
  normalized_tag = {}
  tag.each_pair do |k, v|
    unless (k == :resource_id || k == :resource_type)
      normalized_tag[k] = v
    end
  end
  normalized_tag
end