Class: Puppet_X::EnterpriseModules::WebLogic::Tree
- Inherits:
-
Object
- Object
- Puppet_X::EnterpriseModules::WebLogic::Tree
- Defined in:
- lib/puppet_x/enterprisemodules/weblogic/tree.rb
Instance Method Summary collapse
- #admin_server ⇒ Object abstract
- #children(path, &default_proc) ⇒ Object abstract
- #clear(path) ⇒ Object
- #create(bean_type, path, name) ⇒ Object abstract
- #create_property(path) ⇒ Object abstract
- #default_value(path, &default_proc) ⇒ Object abstract
- #destroy(bean_type, path, name) ⇒ Object abstract
- #edit ⇒ Object
- #execute(script) ⇒ Object
- #exists?(path) ⇒ Boolean abstract
- #get(path, runtime = 'serverConfig', &default_proc) ⇒ Object abstract
- #get_encrypted(path, &default_proc) ⇒ Object abstract
- #get_security_policy(resource_type, name, action = '', &default_proc) ⇒ Object abstract
-
#initialize(domain, provider = WlstProvider.new, logger = Puppet) ⇒ Tree
constructor
A new instance of Tree.
- #managed_servers ⇒ Object abstract
- #needs_restart? ⇒ Boolean abstract
- #properties(path, &default_proc) ⇒ Object abstract
- #realm ⇒ Object abstract
- #save(message = 'Saving current edits') ⇒ Object
- #set(path, value) ⇒ Object
- #set_array(path, value) ⇒ Object
- #set_property(path, value) ⇒ Object
- #set_property_tree(path, value, bean_type = 'Property') ⇒ Object
- #set_reference(path, parent, value) ⇒ Object
- #set_references(path, parent, value) ⇒ Object
- #set_security_policy(resource_type, name, action, policy = '', &default_proc) ⇒ Object abstract
- #set_target(path, target, type) ⇒ Object
- #start_server(name) ⇒ Object
- #state_for(server) ⇒ Object
- #stop_server(name) ⇒ Object
- #validate ⇒ Object abstract
Constructor Details
#initialize(domain, provider = WlstProvider.new, logger = Puppet) ⇒ Tree
Returns a new instance of Tree.
14 15 16 17 18 19 20 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 14 def initialize(domain, provider = WlstProvider.new, logger = Puppet) @provider = provider @domain = domain @provider.set_domain(domain) @provider_name = @provider.class.name @logger = logger end |
Instance Method Details
#admin_server ⇒ Object
This method is abstract.
Get the name of the Adminserver
58 59 60 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 58 def admin_server @provider.get('/Name', 'serverRuntime') end |
#children(path, &default_proc) ⇒ Object
This method is abstract.
Fetch all directories from a specified path
174 175 176 177 178 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 174 def children(path, &default_proc) on_error("fetching children from #{path}", default_proc) do @provider.children(path) end end |
#clear(path) ⇒ Object
235 236 237 238 239 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 235 def clear(path) on_error("clearing #{path}") do @provider.clear(path) end end |
#create(bean_type, path, name) ⇒ Object
This method is abstract.
Create a bean with a specified name and type
195 196 197 198 199 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 195 def create(bean_type, path, name) on_error("creating bean #{bean_type} in path #{path} with name #{name}") do @provider.create(bean_type, path, name) end end |
#create_property(path) ⇒ Object
This method is abstract.
Create a property with a specified path
206 207 208 209 210 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 206 def create_property(path) on_error("creating property at path #{path}") do @provider.create_property(path) end end |
#default_value(path, &default_proc) ⇒ Object
This method is abstract.
Get the default value for the path
125 126 127 128 129 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 125 def default_value(path, &default_proc) on_error("fetching default value for #{path}", default_proc) do @provider.default_value(path) end end |
#destroy(bean_type, path, name) ⇒ Object
This method is abstract.
Create a bean with a specified name and type
217 218 219 220 221 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 217 def destroy(bean_type, path, name) on_error("destroying bean #{name} at #{path} of type #{bean_type}") do @provider.destroy(bean_type, path, name) end end |
#edit ⇒ Object
229 230 231 232 233 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 229 def edit on_error('Start edit session') do @provider.edit end end |
#execute(script) ⇒ Object
301 302 303 304 305 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 301 def execute(script) on_error("executing script #{script}") do @provider.execute(script) end end |
#exists?(path) ⇒ Boolean
This method is abstract.
Check if a path or a value exists.
76 77 78 79 80 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 76 def exists?(path) on_error("Checking if path #{path} exists ") do @provider.exists?(path) end end |
#get(path, runtime = 'serverConfig', &default_proc) ⇒ Object
This method is abstract.
Get a value from WLST.
113 114 115 116 117 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 113 def get(path, runtime = 'serverConfig', &default_proc) on_error("fetching value from #{path}", default_proc) do @provider.get(path, runtime) end end |
#get_encrypted(path, &default_proc) ⇒ Object
This method is abstract.
Get an encrypted value from WLST.
164 165 166 167 168 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 164 def get_encrypted(path, &default_proc) on_error("fetching value from #{path}", default_proc) do @provider.get_encrypted(path) end end |
#get_security_policy(resource_type, name, action = '', &default_proc) ⇒ Object
This method is abstract.
Get a security policy for a resource from WLST.
138 139 140 141 142 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 138 def get_security_policy(resource_type, name, action = '', &default_proc) on_error("fetching security policy for #{resource_type} #{name}:#{action}", default_proc) do @provider.get_security_policy(resource_type, name, action) end end |
#managed_servers ⇒ Object
This method is abstract.
Get all managed servers including the AdminServer
66 67 68 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 66 def managed_servers @provider.children('/Servers') end |
#needs_restart? ⇒ Boolean
This method is abstract.
Check if we need a restart
88 89 90 91 92 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 88 def needs_restart? on_error('checking if we need a restart') do @provider.needs_restart? end end |
#properties(path, &default_proc) ⇒ Object
This method is abstract.
Fetch all properties from a specified path
184 185 186 187 188 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 184 def properties(path, &default_proc) on_error("fetching properties from #{path}", default_proc) do @provider.properties(path) end end |
#realm ⇒ Object
This method is abstract.
Get the realm name and realm path value from WLST.
100 101 102 103 104 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 100 def realm on_error('fetching realm_name and realm_path') do @provider.realm end end |
#save(message = 'Saving current edits') ⇒ Object
223 224 225 226 227 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 223 def save( = 'Saving current edits') on_error() do @provider.save end end |
#set(path, value) ⇒ Object
253 254 255 256 257 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 253 def set(path, value) on_error("setting #{path} to #{value}") do @provider.set(path, value) end end |
#set_array(path, value) ⇒ Object
265 266 267 268 269 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 265 def set_array(path, value) on_error("setting #{path} to array with values #{value}") do @provider.set_array(path, value) end end |
#set_property(path, value) ⇒ Object
277 278 279 280 281 282 283 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 277 def set_property(path, value) on_error("setting #{path} to property with values #{value}") do raise ArgumentError, 'absent value not suppported on properties' if value.to_s == 'absent' @provider.set_property(path, value) end end |
#set_property_tree(path, value, bean_type = 'Property') ⇒ Object
285 286 287 288 289 290 291 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 285 def set_property_tree(path, value, bean_type = 'Property') on_error("setting #{path} to property tree with values #{value}") do raise ArgumentError, 'absent value not suppported on property trees' if value.to_s == 'absent' @provider.set_property_tree(path, value, bean_type) end end |
#set_reference(path, parent, value) ⇒ Object
259 260 261 262 263 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 259 def set_reference(path, parent, value) on_error("setting #{path} to reference of #{value} in #{parent}") do @provider.set_reference(path, parent, value) end end |
#set_references(path, parent, value) ⇒ Object
271 272 273 274 275 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 271 def set_references(path, parent, value) on_error("setting #{path} to array of referenced with values #{value}") do @provider.set_references(path, parent, value) end end |
#set_security_policy(resource_type, name, action, policy = '', &default_proc) ⇒ Object
This method is abstract.
Set a security policy for a resource through WLST.
152 153 154 155 156 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 152 def set_security_policy(resource_type, name, action, policy = '', &default_proc) on_error("Setting security policy for #{resource_type} #{name}:#{action} to #{policy}", default_proc) do @provider.set_security_policy(resource_type, name, action, policy) end end |
#set_target(path, target, type) ⇒ Object
293 294 295 296 297 298 299 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 293 def set_target(path, target, type) on_error("setting target on path #{path} to #{target} with type #{type}") do raise ArgumentError, 'absent value not suppported on targets' if target == 'absent' || target.include?('absent') @provider.set_target(path, target, type) end end |
#start_server(name) ⇒ Object
241 242 243 244 245 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 241 def start_server(name) on_error("Starting server #{name}") do @provider.start_server(name) end end |
#state_for(server) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 39 def state_for(server) # rubocop:disable Style/RedundantBegin begin # rubocop:enable Style/RedundantBegin @provider.get("/ServerLifeCycleRuntimes/#{server}/State", 'domainRuntime') rescue CSV::MalformedCSVError # Sometimes there temporary is a special case where this property returns # somthing strange that cannot be parsed by the CSV. This rescue, takes # care of this special case and returns an empty string. This is nether started # nor stopped, so the loop getting the state is executed at least once more # '' end end |
#stop_server(name) ⇒ Object
247 248 249 250 251 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 247 def stop_server(name) on_error("Stopping server #{name}") do @provider.stop_server(name) end end |
#validate ⇒ Object
This method is abstract.
Validate the tree object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/puppet_x/enterprisemodules/weblogic/tree.rb', line 26 def validate # rubocop:disable Style/RedundantBegin begin # rubocop:enable Style/RedundantBegin # Check if the domain exists @provider.get('/Name', 'serverRuntime') rescue NoMethodError raise ArgumentError, "Domain #{@domain} doesn't exist on this node." rescue RuntimeError raise "Error connecting to domain. AdminServer for Domain #{@domain} probably not running." end end |