summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2015-07-10 18:04:08 -0700
committerelijah <elijah@riseup.net>2015-07-10 18:04:08 -0700
commitab406d6f9a8487b2ac837adc3eeae01788fb2a93 (patch)
treec2e748c8e219a01f7644453b7af265369ccb3d17
parentf528ccc241b88d49eb33bfc9b260a569d7651b48 (diff)
improve `leap facts update`. closes bugs #7236 and #7237
-rw-r--r--lib/leap_cli/commands/deploy.rb2
-rw-r--r--lib/leap_cli/commands/facts.rb8
-rw-r--r--lib/leap_cli/config/filter.rb3
-rw-r--r--lib/leap_cli/config/manager.rb4
-rw-r--r--lib/leap_cli/remote/leap_plugin.rb3
5 files changed, 12 insertions, 8 deletions
diff --git a/lib/leap_cli/commands/deploy.rb b/lib/leap_cli/commands/deploy.rb
index f5c47fe..c2a70af 100644
--- a/lib/leap_cli/commands/deploy.rb
+++ b/lib/leap_cli/commands/deploy.rb
@@ -34,7 +34,7 @@ module LeapCli
init_submodules
end
- nodes = manager.filter!(args)
+ nodes = manager.filter!(args, :disabled => false)
if nodes.size > 1
say "Deploying to these nodes: #{nodes.keys.join(', ')}"
if !global[:yes] && !agree("Continue? ")
diff --git a/lib/leap_cli/commands/facts.rb b/lib/leap_cli/commands/facts.rb
index 65eda61..11329cc 100644
--- a/lib/leap_cli/commands/facts.rb
+++ b/lib/leap_cli/commands/facts.rb
@@ -49,7 +49,7 @@ module LeapCli; module Commands
if overwrite || content.nil? || content.empty?
old_facts = {}
else
- old_facts = JSON.parse(content)
+ old_facts = manager.facts
end
facts = old_facts.merge(new_facts)
facts.each do |name, value|
@@ -57,7 +57,7 @@ module LeapCli; module Commands
if value == ""
value = nil
else
- value = JSON.parse(value)
+ value = JSON.parse(value) rescue JSON::ParserError
end
end
if value.is_a? Hash
@@ -69,7 +69,7 @@ module LeapCli; module Commands
value.nil? || value.empty?
end
if facts.empty?
- nil
+ "{}\n"
else
JSON.sorted_generate(facts) + "\n"
end
@@ -79,7 +79,7 @@ module LeapCli; module Commands
private
def update_facts(global_options, options, args)
- nodes = manager.filter(args, :local => false)
+ nodes = manager.filter(args, :local => false, :disabled => false)
new_facts = {}
ssh_connect(nodes) do |ssh|
ssh.leap.run_with_progress(facter_cmd) do |response|
diff --git a/lib/leap_cli/config/filter.rb b/lib/leap_cli/config/filter.rb
index 0a7e91c..2c80be8 100644
--- a/lib/leap_cli/config/filter.rb
+++ b/lib/leap_cli/config/filter.rb
@@ -97,6 +97,9 @@ module LeapCli
if @options[:local] === false
node_list = node_list[:environment => '!local']
end
+ if @options[:disabled] === false
+ node_list = node_list[:environment => '!disabled']
+ end
node_list
end
diff --git a/lib/leap_cli/config/manager.rb b/lib/leap_cli/config/manager.rb
index 2b4d0f5..b8343fe 100644
--- a/lib/leap_cli/config/manager.rb
+++ b/lib/leap_cli/config/manager.rb
@@ -255,8 +255,8 @@ module LeapCli
#
# same as filter(), but exits if there is no matching nodes
#
- def filter!(filters)
- node_list = filter(filters)
+ def filter!(filters, options={})
+ node_list = filter(filters, options)
Util::assert! node_list.any?, "Could not match any nodes from '#{filters.join ' '}'"
return node_list
end
diff --git a/lib/leap_cli/remote/leap_plugin.rb b/lib/leap_cli/remote/leap_plugin.rb
index e425842..3e33a61 100644
--- a/lib/leap_cli/remote/leap_plugin.rb
+++ b/lib/leap_cli/remote/leap_plugin.rb
@@ -184,7 +184,8 @@ module LeapCli; module Remote; module LeapPlugin
private
def progress(str='.')
- $stdout.print str; $stdout.flush;
+ print str
+ STDOUT.flush
end
#def mkdir(dir)