Class: Chef::Provider::DscScript

Inherits:
Chef::Provider show all
Defined in:
lib/chef/provider/dsc_script.rb

Instance Attribute Summary

Attributes inherited from Chef::Provider

#action, #cookbook_name, #current_resource, #new_resource, #recipe_name, #run_context

Instance Method Summary collapse

Methods inherited from Chef::Provider

#action_nothing, #cleanup_after_converge, #converge_by, #define_resource_requirements, #events, #node, #process_resource_requirements, #requirements, #resource_collection, #resource_updated?, #run_action, #set_updated_status, #whyrun_mode?

Methods included from DSL::Recipe

#build_resource, #declare_resource, #describe_self_for_error, #evaluate_resource_definition, #has_resource_definition?, #have_resource_class_for?, #method_missing, #resource_class_for

Methods included from Mixin::ConvertToClassName

#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename

Constructor Details

#initialize(dsc_resource, run_context) ⇒ DscScript

Returns a new instance of DscScript.



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/chef/provider/dsc_script.rb', line 26

def initialize(dsc_resource, run_context)
  super(dsc_resource, run_context)
  @dsc_resource = dsc_resource
  @resource_converged = false
  @operations = {
    :set => Proc.new { |config_manager, document|
      config_manager.set_configuration(document)
    },
    :test => Proc.new { |config_manager, document|
      config_manager.test_configuration(document)
    }}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Chef::DSL::Recipe

Instance Method Details

#action_runObject



39
40
41
42
43
44
45
46
# File 'lib/chef/provider/dsc_script.rb', line 39

def action_run
  if ! @resource_converged
    converge_by(generate_description) do
      run_configuration(:set)
      Chef::Log.info("DSC resource configuration completed successfully")
    end
  end
end

#load_current_resourceObject



48
49
50
51
52
53
# File 'lib/chef/provider/dsc_script.rb', line 48

def load_current_resource
  @dsc_resources_info = run_configuration(:test)
  @resource_converged = @dsc_resources_info.all? do |resource|
    !resource.changes_state?
  end
end

#whyrun_supported?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/chef/provider/dsc_script.rb', line 55

def whyrun_supported?
  true
end