class Chef::Resource::ChefNode

Public Instance Methods

augment_new_json(json) click to toggle source
# File lib/chef/resource/chef_node.rb, line 50
def augment_new_json(json)
  # Preserve tags even if "attributes" was overwritten directly
  json["normal"]["tags"] = current_json["normal"]["tags"] unless json["normal"]["tags"]
  # Apply modifiers
  json["run_list"] = apply_run_list_modifiers(new_resource.run_list_modifiers, new_resource.run_list_removers, json["run_list"])
  json["normal"] = apply_modifiers(new_resource.attribute_modifiers, json["normal"])
  # Preserve default/override/automatic even when "complete true"
  json["default"] = current_json["default"]
  json["override"] = current_json["override"]
  json["automatic"] = current_json["automatic"]
  json
end
data_handler() click to toggle source
# File lib/chef/resource/chef_node.rb, line 71
def data_handler
  Chef::ChefFS::DataHandler::NodeDataHandler.new
end
keys() click to toggle source
# File lib/chef/resource/chef_node.rb, line 75
def keys
  {
    "name" => :name,
    "chef_environment" => :chef_environment,
    "run_list" => :run_list,
    "normal" => :attributes,
  }
end
load_current_resource() click to toggle source
# File lib/chef/resource/chef_node.rb, line 40
def load_current_resource
  @current_resource = json_to_resource(rest.get("nodes/#{new_resource.name}"))
rescue Net::HTTPClientException => e
  if e.response.code == "404"
    @current_resource = not_found_resource
  else
    raise
  end
end
resource_class() click to toggle source

Helpers

# File lib/chef/resource/chef_node.rb, line 67
def resource_class
  Chef::Resource::ChefNode
end