Skip to content

Instantly share code, notes, and snippets.

@thattommyhall
Created April 1, 2011 12:09
Show Gist options
  • Select an option

  • Save thattommyhall/898048 to your computer and use it in GitHub Desktop.

Select an option

Save thattommyhall/898048 to your computer and use it in GitHub Desktop.
lb_add and lb_remove take a list of dns_names and remove them from ELB
require 'fog'
ELB = Fog::AWS::ELB.new
COMPUTE = Fog::Compute.new( :provider => 'AWS')
def server_from_dns_name dns_name
COMPUTE.servers.all.find {|server| server.dns_name == dns_name}
end
def id_from_dns_name dns_name
(server_from_dns_name dns_name).id
end
def dns_name_to_id servers
servers.map {|server| id_from_dns_name server}
end
def lb_remove servers
ELB.deregister_instances_from_load_balancer(dns_name_to_id(servers), "TOMTEST")
end
def lb_add servers
ELB.register_instances_with_load_balancer(dns_name_to_id(servers), "TOMTEST")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment