Class: Chef::Provider::OneTemplate

Inherits:
LWRPBase
  • Object
show all
Defined in:
lib/chef/provider/one_template.rb

Overview

Implementation of Provider class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_idObject (readonly)

Returns the value of attribute current_id.



34
35
36
# File 'lib/chef/provider/one_template.rb', line 34

def current_id
  @current_id
end

#equal_modeObject (readonly)

Returns the value of attribute equal_mode.



33
34
35
# File 'lib/chef/provider/one_template.rb', line 33

def equal_mode
  @equal_mode
end

#equal_templateObject (readonly)

Returns the value of attribute equal_template.



32
33
34
# File 'lib/chef/provider/one_template.rb', line 32

def equal_template
  @equal_template
end

Instance Method Details

#load_current_resourceObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/chef/provider/one_template.rb', line 40

def load_current_resource
  driver = self.driver
  @uname = uname
  @current_resource = Chef::Resource::OneTemplate.new(new_resource.name,
                                                      run_context)
  @current_resource.name(new_resource.name)
  template = driver.one.get_resource(:template,
                                     :name => @current_resource.name,
                                     :uname => @uname)
  @current_resource.exists = !template.nil?

  return unless @current_resource.exists

  new_resource_template = if @new_resource.template_file.nil?
                            convert_types(@new_resource.template)
                          else
                            driver.one.template_from_file(@new_resource.template_file)
                          end

  @current_id = template.to_hash['VMTEMPLATE']['ID'].to_i
  @current_resource.template(template.to_hash['VMTEMPLATE']['TEMPLATE'])
  @current_resource.mode(get_mode(template))
  @equal_template = @current_resource.template == new_resource_template
  @equal_mode = @current_resource.mode == new_resource.mode
  @current_resource.equal = @equal_template && @equal_mode
end

#whyrun_supported?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/chef/provider/one_template.rb', line 36

def whyrun_supported?
  true
end