Class: Blender::Discovery::Chef
- Inherits:
-
Object
- Object
- Blender::Discovery::Chef
- Defined in:
- lib/blender/discoveries/chef.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Chef
constructor
A new instance of Chef.
- #search(opts = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Chef
Returns a new instance of Chef.
25 26 27 |
# File 'lib/blender/discoveries/chef.rb', line 25 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'lib/blender/discoveries/chef.rb', line 23 def @options end |
Instance Method Details
#search(opts = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/blender/discoveries/chef.rb', line 29 def search(opts = {}) attr = [:attribute] || 'fqdn' case opts when String search_term = opts when Hash search_term = opts[:search_term] attr = opts[:attribute] if opts.key?(:attribute) else raise ArgumentError, "Invalid argument type #{opts.class}" end search_term ||= '*:*' ::Chef::Config.from_file([:config_file]) if [:config_file] ::Chef::Config[:node_name] = [:node_name] if [:node_name] ::Chef::Config[:client_key] = [:client_key] if [:client_key] ::Chef::Config[:chef_server_url] = [:chef_server_url] if [:chef_server_url] q = ::Chef::Search::Query.new res = q.search(:node, search_term, filter_result: {attribute: attr.split('.')}) res.first.collect{|node_data| node_data['attribute']} end |