lib/ohai/dsl/plugin/versionvii.rb in ohai-13.12.6 vs lib/ohai/dsl/plugin/versionvii.rb in ohai-14.0.28
- old
+ new
@@ -22,12 +22,12 @@
class Plugin
class VersionVII < Plugin
attr_reader :version
attr_reader :source
- def initialize(data)
- super(data)
+ def initialize(data, logger)
+ super(data, logger)
@source = self.class.sources
@version = :version7
end
def name
@@ -64,10 +64,18 @@
attrs.each do |attr|
depends_attrs << attr unless depends_attrs.include?(attr)
end
end
+ def self.optional(opt = true)
+ @optional = opt
+ end
+
+ def self.optional?
+ !!@optional
+ end
+
def self.collect_data(platform = :default, *other_platforms, &block)
[platform, other_platforms].flatten.each do |plat|
if data_collector.has_key?(plat)
raise Ohai::Exceptions::IllegalPluginDefinition, "collect_data already defined on platform #{plat}"
else
@@ -87,19 +95,23 @@
if collector.has_key?(platform)
instance_eval(&collector[platform])
elsif collector.has_key?(:default)
instance_eval(&collector[:default])
else
- Ohai::Log.debug("Plugin #{name}: No data to collect. Skipping...")
+ logger.trace("Plugin #{name}: No data to collect. Skipping...")
end
end
+ def optional?
+ self.class.optional?
+ end
+
def provides(*paths)
- Ohai::Log.warn("[UNSUPPORTED OPERATION] \'provides\' is no longer supported in a \'collect_data\' context. Please specify \'provides\' before collecting plugin data. Ignoring command \'provides #{paths.join(", ")}")
+ logger.warn("[UNSUPPORTED OPERATION] \'provides\' is no longer supported in a \'collect_data\' context. Please specify \'provides\' before collecting plugin data. Ignoring command \'provides #{paths.join(", ")}")
end
def require_plugin(*args)
- Ohai::Log.warn("[UNSUPPORTED OPERATION] \'require_plugin\' is no longer supported. Please use \'depends\' instead.\nIgnoring plugin(s) #{args.join(", ")}")
+ logger.warn("[UNSUPPORTED OPERATION] \'require_plugin\' is no longer supported. Please use \'depends\' instead.\nIgnoring plugin(s) #{args.join(", ")}")
end
def configuration(option, *options)
return nil if plugin_config.nil? || !plugin_config.key?(option)
value = plugin_config[option]