summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-12-18 15:43:23 -0800
committerdanielsdeleo <dan@opscode.com>2014-01-02 12:32:08 -0800
commitecb8c0e706c8664d0a9b31b39b811da397724320 (patch)
treeaf0606ad54903596d10ae04461fe78dfd0ade062
parent9203d686473ade1ff3b6f2909f04b532c856cc03 (diff)
downloadohai-cli-run-mode.tar.gz
Pass user-requested attributes from CLI to whitelistcli-run-mode
This greatly speeds up running ohai from the command line when given a set of attributes to display (like `ohai ec2`). Prior to this patch, ohai would run all plugins and then filter out the data. With this patch, ohai only runs relevant plugins. As an unscientific test `bin/ohai network` on my laptop takes ~4s without this patch compared to ~1.1s with the patch.
-rw-r--r--lib/ohai/application.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/ohai/application.rb b/lib/ohai/application.rb
index 023cfdb8..e1640e8c 100644
--- a/lib/ohai/application.rb
+++ b/lib/ohai/application.rb
@@ -77,6 +77,7 @@ class Ohai::Application
def configure_ohai
@attributes = parse_options
+ @attributes = nil if @attributes.empty?
Ohai::Config.merge!(config)
if Ohai::Config[:directory]
@@ -94,9 +95,9 @@ class Ohai::Application
if Ohai::Config[:file]
ohai.from_file(Ohai::Config[:file])
else
- ohai.all_plugins
+ ohai.all_plugins(@attributes)
end
- if @attributes.length > 0
+ if @attributes
@attributes.each do |a|
puts ohai.attributes_print(a)
end