Module | MCollective::Data |
In: |
lib/mcollective/data/base.rb
lib/mcollective/data/result.rb lib/mcollective/data.rb |
# File lib/mcollective/data.rb, line 26 26: def self.[](plugin) 27: PluginManager[pluginname(plugin)] 28: end
# File lib/mcollective/data.rb, line 37 37: def self.ddl(plugin) 38: DDL.new(pluginname(plugin), :data) 39: end
# File lib/mcollective/data.rb, line 58 58: def self.ddl_has_output?(ddl, output) 59: ddl.entities[:data][:output].include?(output.to_sym) rescue false 60: end
For an input where the DDL requests a boolean or some number this will convert the input to the right type where possible else just returns the origin input unedited
if anything here goes wrong just return the input value this is not really the end of the world or anything since all that will happen is that DDL validation will fail and the user will get an error, no need to be too defensive here
# File lib/mcollective/data.rb, line 70 70: def self.ddl_transform_input(ddl, input) 71: begin 72: type = ddl.entities[:data][:input][:query][:type] 73: 74: case type 75: when :boolean 76: return DDL.string_to_boolean(input) 77: 78: when :number, :integer, :float 79: return DDL.string_to_number(input) 80: end 81: rescue 82: end 83: 84: return input 85: end
# File lib/mcollective/data.rb, line 41 41: def self.ddl_validate(ddl, argument) 42: name = ddl.meta[:name] 43: query = ddl.entities[:data] 44: 45: raise DDLValidationError, "No dataquery has been defined in the DDL for data plugin #{name}" unless query 46: 47: input = query[:input] 48: output = query[:output] 49: 50: raise DDLValidationError, "No :query input has been defined in the DDL for data plugin #{name}" unless input[:query] 51: raise DDLValidationError, "No output has been defined in the DDL for data plugin #{name}" if output.keys.empty? 52: 53: return true if argument.nil? && input[:query][:optional] 54: 55: ddl.validate_input_argument(input, :query, argument) 56: end
# File lib/mcollective/data.rb, line 6 6: def self.load_data_sources 7: PluginManager.find_and_load("data") 8: 9: PluginManager.grep(/_data$/).each do |plugin| 10: begin 11: unless PluginManager[plugin].class.activate? 12: Log.debug("Disabling data plugin %s due to plugin activation policy" % plugin) 13: PluginManager.delete(plugin) 14: end 15: rescue Exception => e 16: Log.debug("Disabling data plugin %s due to exception #{e.class}: #{e}" % plugin) 17: PluginManager.delete(plugin) 18: end 19: end 20: end
Data.package("httpd").architecture
# File lib/mcollective/data.rb, line 31 31: def self.method_missing(method, *args) 32: super unless PluginManager.include?(pluginname(method)) 33: 34: PluginManager[pluginname(method)].lookup(args.first) 35: end