class Ohai::Application
Public Class Methods
exit!(msg, err = -1)
click to toggle source
# File lib/ohai/application.rb, line 116 def exit!(msg, err = -1) Ohai::Log.debug(msg) Process.exit err end
fatal!(msg, err = -1)
click to toggle source
Log a fatal error message to both STDERR and the Logger, exit the application
# File lib/ohai/application.rb, line 110 def fatal!(msg, err = -1) STDERR.puts("FATAL: #{msg}") Ohai::Log.fatal(msg) Process.exit err end
new()
click to toggle source
Calls superclass method
# File lib/ohai/application.rb, line 69 def initialize super # Always switch to a readable directory. Keeps subsequent Dir.chdir() {} # from failing due to permissions when launched as a less privileged user. Dir.chdir("/") end
Public Instance Methods
configure_ohai()
click to toggle source
# File lib/ohai/application.rb, line 85 def configure_ohai @attributes = parse_options @attributes = nil if @attributes.empty? load_workstation_config Ohai::Log.init(Ohai.config[:log_location]) end
run()
click to toggle source
# File lib/ohai/application.rb, line 77 def run elapsed = Benchmark.measure do configure_ohai run_application end Ohai::Log.debug("Ohai took #{elapsed.total} total seconds to run.") end
run_application()
click to toggle source
# File lib/ohai/application.rb, line 94 def run_application config[:invoked_from_cli] = true ohai = Ohai::System.new(config) ohai.all_plugins(@attributes) if @attributes @attributes.each do |a| puts ohai.attributes_print(a) end else puts ohai.json_pretty_print end end
Private Instance Methods
load_workstation_config()
click to toggle source
# File lib/ohai/application.rb, line 124 def load_workstation_config config_loader = ChefConfig::WorkstationConfigLoader.new( config[:config_file], Ohai::Log ) begin config_loader.load rescue ChefConfig::ConfigurationError => config_error Ohai::Application.fatal!(config_error.message) end end