Class: Puppet::Parameter::WlsProperty

Inherits:
Puppet::Property
  • Object
show all
Extended by:
Puppet_X::EnterpriseModules::WebLogic::Functions
Includes:
EasyType
Defined in:
lib/puppet_x/enterprisemodules/weblogic/wls_property.rb

Constant Summary

Constants included from Puppet_X::EnterpriseModules::WebLogic::Access

Puppet_X::EnterpriseModules::WebLogic::Access::DEFAULT_FILE

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Puppet_X::EnterpriseModules::WebLogic::Access

#child_of, included, #puppet_version_higher_or_equal_then, #wlst

Methods included from Puppet_X::EnterpriseModules::WebLogic::Settings

#configuration, included, #read_from_yaml, #setting_for, #settings

Class Method Details

.actual_path(resource) ⇒ Object



161
162
163
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 161

def self.actual_path(resource)
  actual_paths(resource).first
end

.actual_paths(resource) ⇒ Object



151
152
153
154
155
156
157
158
159
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 151

def self.actual_paths(resource)
  wls_path.collect do |p|
    if p[0] == '/' # Fullk path
      p.to_s % resource.to_hash
    else
      Kernel.format("#{type_path}/#{resource[key_name]}/#{p}", resource.to_hash)
    end
  end
end

.array_separator(value = nil) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 50

def self.array_separator(value = nil)
  if value
    @array_separator = value
  else
    @array_separator ||= ','
  end
end

.class_from_string(str) ⇒ Object



182
183
184
185
186
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 182

def self.class_from_string(str)
  str.split('::').inject(Object) do |mod, class_name|
    mod.const_get(class_name)
  end
end

.is_folder?(path) ⇒ Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)


146
147
148
149
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 146

def self.is_folder?(path)
  # rubocop:enable Naming/PredicateName
  path[-1, 1] == '/'
end

.key_nameObject



173
174
175
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 173

def self.key_name
  type_class.key_name
end

.maps_to(path, &default_path) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 13

def self.maps_to(path, &default_path)
  @wls_path = if path.is_a?(String)
                [path]
              else
                path
              end
  @default_path = default_path
end

.translate_to_resource(raw_resource, resource) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 58

def self.translate_to_resource(raw_resource, resource)
  my_resource = raw_resource.merge(resource) # Merge raw with what we got
  wls_config = Puppet_X::EnterpriseModules::WebLogic::Tree.new(my_resource[:domain])
  value = if is_folder?(actual_path(my_resource))
            wls_config.children(actual_path(my_resource), &@default_path)
          else
            wls_config.get(actual_path(my_resource), &@default_path)
          end
  if array_matching == :all && value.is_a?(String)
    value.split(array_separator)
  #
  # If the value is an Array but no array_matching is specified,
  # we are probably a reference
  #
  elsif array_matching != :all && value.is_a?(Array)
    value.first
  else
    value
  end
end

.type_classObject



177
178
179
180
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 177

def self.type_class
  type_class_name = to_s.split('::')[0..2].join('::')
  class_from_string(type_class_name)
end

.type_pathObject

This magic returns the bean path specified for the type



169
170
171
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 169

def self.type_path
  type_class.bean_path
end

.wls_pathObject



26
27
28
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 26

def self.wls_path
  @wls_path || fail("Internal Error. Property #{name} needs to be mapped with 'maps_to' function")
end

Instance Method Details

#actual_path(resource) ⇒ Object



141
142
143
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 141

def actual_path(resource)
  self.class.actual_path(resource)
end

#actual_paths(resource) ⇒ Object



137
138
139
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 137

def actual_paths(resource)
  self.class.actual_paths(resource)
end

#apply_paths(value) ⇒ Object



83
84
85
86
87
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 83

def apply_paths(value)
  actual_paths(resource.to_hash).each do |path|
    wls_config.set(path, value)
  end
end

#apply_paths_with_array(value) ⇒ Object



101
102
103
104
105
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 101

def apply_paths_with_array(value)
  actual_paths(resource.to_hash).each do |path|
    wls_config.set_array(path, value)
  end
end

#apply_paths_with_property(value) ⇒ Object



107
108
109
110
111
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 107

def apply_paths_with_property(value)
  actual_paths(resource.to_hash).each do |path|
    wls_config.set_property(path, value)
  end
end

#apply_paths_with_property_tree(value, property_type) ⇒ Object



113
114
115
116
117
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 113

def apply_paths_with_property_tree(value, property_type)
  actual_paths(resource.to_hash).each do |path|
    wls_config.set_property_tree(path, value, property_type)
  end
end

#apply_paths_with_reference(parent, value) ⇒ Object



89
90
91
92
93
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 89

def apply_paths_with_reference(parent, value)
  actual_paths(resource.to_hash).each do |path|
    wls_config.set_reference(path, parent, value)
  end
end

#apply_paths_with_references(parent, value) ⇒ Object



95
96
97
98
99
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 95

def apply_paths_with_references(parent, value)
  actual_paths(resource.to_hash).each do |path|
    wls_config.set_references(path, parent, value)
  end
end

#apply_paths_with_target(value, type) ⇒ Object



119
120
121
122
123
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 119

def apply_paths_with_target(value, type)
  actual_paths(resource.to_hash).each do |path|
    wls_config.set_target(path, value, type)
  end
end

#default_valueObject

rubocop:enable Naming/MethodParameterName



46
47
48
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 46

def default_value
  @default_value ||= wls_config.default_value(actual_path(resource.to_hash))
end

#insync?(is) ⇒ Boolean

rubocop:disable Naming/MethodParameterName

Returns:

  • (Boolean)


35
36
37
38
39
40
41
42
43
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 35

def insync?(is)
  if should.to_s == 'absent' && is.to_s != 'absent'
    is.to_s == default_value.to_s
  elsif should.to_s == 'absent' && is.to_s == 'absent'
    true
  else
    is.to_s == should.to_s
  end
end

#key_nameObject



133
134
135
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 133

def key_name
  self.class.key_name
end

#path_for(key) ⇒ Object



125
126
127
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 125

def path_for(key)
  Kernel.format("#{type_path}/#{resource[key_name]}/#{key}", resource.to_hash)
end

#type_pathObject



129
130
131
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 129

def type_path
  self.class.type_path
end

#wls_configObject



22
23
24
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 22

def wls_config
  @wls_config ||= Puppet_X::EnterpriseModules::WebLogic::Tree.new(resource[:domain])
end

#wls_pathObject



30
31
32
# File 'lib/puppet_x/enterprisemodules/weblogic/wls_property.rb', line 30

def wls_path
  self.class.wls_path
end