From 6bfb4551e79d2e3dfe71d6209ce3bda4e85646fd Mon Sep 17 00:00:00 2001 From: elijah Date: Mon, 27 May 2013 16:46:55 -0700 Subject: disabled nodes -- ensure the disabled nodes are also removed from the services and tags node lists. --- lib/leap_cli/config/manager.rb | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'lib/leap_cli/config/manager.rb') diff --git a/lib/leap_cli/config/manager.rb b/lib/leap_cli/config/manager.rb index dc74b6c..a88f7d0 100644 --- a/lib/leap_cli/config/manager.rb +++ b/lib/leap_cli/config/manager.rb @@ -47,18 +47,8 @@ module LeapCli @nodes[name] = apply_inheritance(node) end - # remove disabled nodes - @disabled_nodes = Config::ObjectList.new unless options[:include_disabled] - @nodes.select! do |name, node| - if node.enabled - true - else - log 2, :skipping, "disabled node #{name}." - @disabled_nodes[name] = node - false - end - end + remove_disabled_nodes end # validate @@ -293,6 +283,30 @@ module LeapCli return new_node end + def remove_disabled_nodes + @disabled_nodes = Config::ObjectList.new + @nodes.select! do |name, node| + if node.enabled + true + else + log 2, :skipping, "disabled node #{name}." + @disabled_nodes[name] = node + if node['services'] + node['services'].to_a.each do |node_service| + @services[node_service].node_list.delete(node.name) + end + end + if node['tags'] + node['tags'].to_a.each do |node_tag| + @tags[node_tag].node_list.delete(node.name) + end + end + false + end + end + end + + # # returns a set of nodes corresponding to a single name, where name could be a node name, service name, or tag name. # -- cgit v1.2.3