Skip to content
This repository has been archived by the owner on Aug 27, 2020. It is now read-only.

Commit

Permalink
add id to show and warning to add node
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Vermaak committed Apr 12, 2012
1 parent f388aae commit bda116f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/chef/knife/rackspace_load_balancer_add_node.rb
Expand Up @@ -121,6 +121,8 @@ def run
target_load_balancers.each do |lb|
ui.output("Opening #{lb[:name]}")
balancer = lb_connection.get_load_balancer(lb[:id])
lb_nodes = balancer.list_nodes
lb_node_ips = lb_nodes.map {|lbn| lbn[:address]}

if config[:auto_resolve_port]
nodes_for_balancer = nodes.dup
Expand All @@ -136,11 +138,15 @@ def run
end

nodes_for_balancer.each do |node|
ui.output("Adding node #{node[:address]}")
if balancer.create_node(node)
ui.output(ui.color("Success", :green))
if lb_node_ips.include?(node[:address])
ui.warn("Skipping node #{node[:address]}")
else
ui.output(ui.color("Failed", :red))
ui.output("Adding node #{node[:address]}")
if balancer.create_node(node)
ui.output(ui.color("Success", :green))
else
ui.output(ui.color("Failed", :red))
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/chef/knife/rackspace_load_balancer_show.rb
Expand Up @@ -24,6 +24,7 @@ def run

load_balancer_info = {
:name => load_balancer.name,
:id => load_balancer.id,
:protocol => load_balancer.protocol,
:port => load_balancer.port,
:status => ui.color(load_balancer.status, load_balancer.status == "ACTIVE" ? :green : :red)
Expand Down

0 comments on commit bda116f

Please sign in to comment.