module Cumulus::ELB
Public Class Methods
Public: Provide the default available policies
Returns a Hash of Aws::ElasticLoadBalancing::Types::PolicyDescription to a policy's name
# File lib/elb/ELB.rb, line 60 def default_policies @default_policies ||= Hash[init_default_policies.map { |policy| [policy.policy_name, policy] }] end
Public: Provide the attributes for an ELB
by name, lazily loaded
Returns an array of Aws::ElasticLoadBalancing::Types::LoadBalancerAttributes
# File lib/elb/ELB.rb, line 52 def elb_attributes(elb_name) @elb_attributes ||= {} @elb_attributes[elb_name] ||= init_elb_attributes(elb_name) end
Public: Provide the policies already created on a load balancer
Returns a Hash of Aws::ElasticLoadBalancing::Types::PolicyDescription to a policy's name
# File lib/elb/ELB.rb, line 67 def elb_policies(elb_name) @elb_policies ||= {} @elb_policies[elb_name] ||= Hash[init_elb_policies(elb_name).map { |policy| [policy.policy_name, policy] }] end
Public: Provide a mapping of ELBs to their names. Lazily loads resources.
Returns the ELBs mapped to their names
# File lib/elb/ELB.rb, line 36 def elbs @elbs ||= init_elbs end
Public: Static method that will get an ELB
from AWS by its name.
name - the name of the ELB
to get
Returns the Aws::ElasticLoadBalancing::Types::LoadBalancerDescription by that name
# File lib/elb/ELB.rb, line 15 def get_aws(name) if elbs[name].nil? puts "No ELB named #{name}" exit else elbs[name] end end
Private Class Methods
Internal: Provide a mapping of ELBs to their dns names. Lazily loads resources.
Returns the ELBs mapped to their dns names
# File lib/elb/ELB.rb, line 77 def elbs_to_dns_names @elbs_to_dns_names ||= Hash[elbs.map { |_, elb| [elb.dns_name, elb] }] end
Internal: Load the default ELB
policies
Returns an array of Aws::ElasticLoadBalancing::Types::PolicyDescription
# File lib/elb/ELB.rb, line 133 def init_default_policies @@client.describe_load_balancer_policies.policy_descriptions end
Internal: Load the policies for a load balancer
Returns an array of Aws::ElasticLoadBalancing::Types::PolicyDescription
# File lib/elb/ELB.rb, line 140 def init_elb_policies(elb_name) @@client.describe_load_balancer_policies({ load_balancer_name: elb_name }).policy_descriptions end
Internal: Load ELBs and map them to their names.
Returns the ELBs mapped to their names
# File lib/elb/ELB.rb, line 84 def init_elbs elbs = [] all_records_retrieved = false next_marker = nil until all_records_retrieved response = @@client.describe_load_balancers({ marker: next_marker }.reject { |k, v| v.nil? }) elbs << response.load_balancer_descriptions next_marker = response.next_marker if next_marker == nil all_records_retrieved = true end end Hash[elbs.flatten.map { |elb| [elb.load_balancer_name, elb] }] end