diff options
author | danielsdeleo <dan@chef.io> | 2015-10-01 10:58:00 -0700 |
---|---|---|
committer | danielsdeleo <dan@chef.io> | 2015-10-01 10:58:00 -0700 |
commit | 33d6cebdc92e0d5e0c8186480947b9672ae541ed (patch) | |
tree | 79d052c30c3a78a0937240dc05958403f24adb00 /lib/chef/policy_builder | |
parent | 8c042622fbf94acca813bd6d84d967d2ea08ec43 (diff) | |
download | chef-33d6cebdc92e0d5e0c8186480947b9672ae541ed.tar.gz |
Un-remove ExpandNodeObject#load_node, deprecate itpolicybuilder-load-node-unremove
Some third-party tools are using this, we need it to work.
Diffstat (limited to 'lib/chef/policy_builder')
-rw-r--r-- | lib/chef/policy_builder/expand_node_object.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/chef/policy_builder/expand_node_object.rb b/lib/chef/policy_builder/expand_node_object.rb index 26b98afa52..933960a429 100644 --- a/lib/chef/policy_builder/expand_node_object.rb +++ b/lib/chef/policy_builder/expand_node_object.rb @@ -33,6 +33,9 @@ class Chef # expands the run_list on a node object and then queries the chef-server # to find the correct set of cookbooks, given version constraints of the # node's environment. + # + # Note that this class should only be used via PolicyBuilder::Dynamic and + # not instantiated directly. class ExpandNodeObject attr_reader :events @@ -94,6 +97,33 @@ class Chef run_context end + # DEPRECATED: As of Chef 12.5, chef selects either policyfile mode or + # "expand node" mode dynamically, based on the content of the node + # object, first boot JSON, and config. This happens in + # PolicyBuilder::Dynamic, which selects the implementation during + # #load_node and then delegates to either ExpandNodeObject or Policyfile + # implementations as appropriate. Tools authors should update their code + # to create a PolicyBuilder::Dynamc policy builder and allow it to select + # the proper implementation. + def load_node + Chef.log_deprecation("ExpandNodeObject#load_node is deprecated. Please use Chef::PolicyBuilder::Dynamic instead of using ExpandNodeObject directly") + + events.node_load_start(node_name, config) + Chef::Log.debug("Building node object for #{node_name}") + + @node = + if Chef::Config[:solo] + Chef::Node.build(node_name) + else + Chef::Node.find_or_create(node_name) + end + finish_load_node(node) + node + rescue Exception => e + events.node_load_failed(node_name, e, config) + raise + end + def finish_load_node(node) @node = node end |