Class: Puppet::Provider::PacemakerNoop

Inherits:
Puppet::Provider
  • Object
show all
Defined in:
lib/puppet/provider/pacemaker_noop.rb

Overview

this is the abstract provider to create “noop” providers for pacemaker types if a “noop” provider is used for a resource it will do nothing when applied neither the retrieving nor the modification phase

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#property_hashObject

Returns the value of attribute property_hash.



5
6
7
# File 'lib/puppet/provider/pacemaker_noop.rb', line 5

def property_hash
  @property_hash
end

#resourceObject

Returns the value of attribute resource.



6
7
8
# File 'lib/puppet/provider/pacemaker_noop.rb', line 6

def resource
  @resource
end

Instance Method Details

#createObject

stub “creat” method method cleans the property hash should never be actually called because exists? always returns true



20
21
22
23
# File 'lib/puppet/provider/pacemaker_noop.rb', line 20

def create
  debug 'Call: create'
  self.property_hash = {}
end

#destroyObject

stub “destroy” method cleans the property hash



26
27
28
29
# File 'lib/puppet/provider/pacemaker_noop.rb', line 26

def destroy
  debug 'Call: destroy'
  self.property_hash = {}
end

#exists?true

stub “exists?” method that returns “true” and logs its calls

Returns:

  • (true)


10
11
12
13
14
15
16
# File 'lib/puppet/provider/pacemaker_noop.rb', line 10

def exists?
  debug 'Call: exists?'
  make_property_methods
  out = true
  debug "Return: #{out}"
  out
end

#flushObject

stub “flush” method does nothing



32
33
34
# File 'lib/puppet/provider/pacemaker_noop.rb', line 32

def flush
  debug 'Call: flush'
end

#make_property_methodsObject

this method creates getters and setters for each of the resource properties works directly with resource parameter values instead of property_hash



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/puppet/provider/pacemaker_noop.rb', line 39

def make_property_methods
  properties = resource.properties.map(&:name)
  properties.each do |property|
    next if property == :ensure
    self.class.send :define_method, property do
      debug "Call: #{property}"
      out = resource[property]
      debug "Return: #{out.inspect}"
      out
    end
    self.class.send :define_method, "#{property}=" do |value|
      debug "Call: #{property}=#{value.inspect}"
      resource[property] = value
    end
  end
end