Class: Chef::Provider::ChefNode

Inherits:
Cheffish::ChefProviderBase
  • Object
show all
Defined in:
lib/chef/provider/chef_node.rb

Instance Method Summary collapse

Instance Method Details

#augment_new_json(json) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/chef/provider/chef_node.rb', line 49

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_handlerObject



70
71
72
# File 'lib/chef/provider/chef_node.rb', line 70

def data_handler
  Chef::ChefFS::DataHandler::NodeDataHandler.new
end

#keysObject



74
75
76
77
78
79
80
81
# File 'lib/chef/provider/chef_node.rb', line 74

def keys
  {
    'name' => :name,
    'chef_environment' => :chef_environment,
    'run_list' => :run_list,
    'normal' => :attributes
  }
end

#load_current_resourceObject



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/chef/provider/chef_node.rb', line 37

def load_current_resource
  begin
    @current_resource = json_to_resource(rest.get("nodes/#{new_resource.name}"))
  rescue Net::HTTPServerException => e
    if e.response.code == "404"
      @current_resource = not_found_resource
    else
      raise
    end
  end
end

#resource_classObject

Helpers



66
67
68
# File 'lib/chef/provider/chef_node.rb', line 66

def resource_class
  Chef::Resource::ChefNode
end

#whyrun_supported?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/chef/provider/chef_node.rb', line 7

def whyrun_supported?
  true
end