Manipulation
# File lib/ironfan/provider/ec2/elastic_load_balancer.rb, line 55 def self.aggregate!(computers) ec2_computers = computers.select { |c| Ec2.applicable c } return if ec2_computers.empty? load! # Find out which ELBs already exist in EC2 running_computers = ec2_computers.select { |c| c.running? } elbs_for_running_computers = running_computers.map { |c| self.expected_ids(c) }.flatten.uniq elbs_for_stopped_computers = ec2_computers.select { |c| not c.running? }.map { |c| self.expected_ids(c) }.flatten.uniq elbs_to_start = [ elbs_for_running_computers ].flatten.compact.reject { |elb_name| recall? elb_name } elbs_to_stop = [ elbs_for_stopped_computers - elbs_for_running_computers ].flatten.compact.select { |elb_name| recall? elb_name } elbs_to_stop.each do |elb_name| Ironfan.step(elb_name, "stopping unused elastic load balancer #{elb_name}", :blue) Ec2.elb.delete_load_balancer(elb_name) forget elb_name end [ elbs_to_start, elbs_for_running_computers ].flatten.sort.uniq.each do |elb_name| computers_using_this_elb = running_computers.select { |c| self.expected_ids(c).include?(elb_name) } self.start_or_sync_elb(elb_name, computers_using_this_elb, elbs_to_start.include?(elb_name)) end load! end
# File lib/ironfan/provider/ec2/elastic_load_balancer.rb, line 22 def self.expected_ids(computer) ec2 = computer.server.cloud(:ec2) ec2.elastic_load_balancers.values.map { |elb| self.full_name(computer, elb) }.uniq end
Discovery
# File lib/ironfan/provider/ec2/elastic_load_balancer.rb, line 34 def self.load!(cluster=nil) Ec2.elb.load_balancers.each do |raw| next if raw.blank? elb = ElasticLoadBalancer.new(:adaptee => raw) remember(elb) Chef::Log.debug("Loaded #{elb}: #{elb.inspect}") end end
# File lib/ironfan/provider/ec2/elastic_load_balancer.rb, line 27 def name() adaptee.id end
Generated with the Darkfish Rdoc Generator 2.