Skip to content

Commit f29f7d9

Browse files
authored
Issue #352 - Create set method for SAF error handling; create placeholders for circular references; refactored placeholder code (#353)
1 parent e5354cd commit f29f7d9

File tree

6 files changed

+47
-49
lines changed

6 files changed

+47
-49
lines changed

core/src/main/python/wlsdeploy/tool/deploy/deployer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55
import javaos as os
@@ -18,6 +18,7 @@
1818
from wlsdeploy.tool.util.alias_helper import AliasHelper
1919
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
2020
from wlsdeploy.tool.util.attribute_setter import AttributeSetter
21+
from wlsdeploy.tool.util.topology_helper import TopologyHelper
2122
from wlsdeploy.tool.util.wlst_helper import WlstHelper
2223
import wlsdeploy.util.dictionary_utils as dictionary_utils
2324
from wlsdeploy.util.weblogic_helper import WebLogicHelper
@@ -46,6 +47,7 @@ def __init__(self, model, model_context, aliases, wlst_mode=WlstModes.OFFLINE):
4647
self.wls_helper = WebLogicHelper(self.logger)
4748
self.wlst_helper = WlstHelper(self.logger, ExceptionType.DEPLOY)
4849
self.attribute_setter = AttributeSetter(self.aliases, self.logger, ExceptionType.DEPLOY, wlst_mode=wlst_mode)
50+
self.topology_helper = TopologyHelper(self.aliases, ExceptionType.DEPLOY, self.logger)
4951

5052
self.archive_helper = None
5153
archive_file_name = self.model_context.get_archive_file_name()

core/src/main/python/wlsdeploy/tool/deploy/jms_resources_deployer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55
import oracle.weblogic.deploy.util.PyOrderedDict as OrderedDict
@@ -119,6 +119,9 @@ def _add_jms_resources(self, resource_nodes, location):
119119
if not self._check_location(location):
120120
return
121121

122+
# SAF imported destination may reference error handling, and vice versa
123+
self.topology_helper.create_placeholder_named_elements(location, SAF_ERROR_HANDLING, resource_nodes)
124+
122125
for element_name in self.resource_elements:
123126
model_nodes = dictionary_utils.get_dictionary_element(resource_nodes, element_name)
124127
self._add_named_elements(element_name, model_nodes, location)

core/src/main/python/wlsdeploy/tool/util/attribute_setter.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
from wlsdeploy.aliases.model_constants import RESPONSE_TIME_REQUEST_CLASS
5757
from wlsdeploy.aliases.model_constants import REST_NOTIFICATION
5858
from wlsdeploy.aliases.model_constants import SAF_AGENT
59+
from wlsdeploy.aliases.model_constants import SAF_ERROR_HANDLING
5960
from wlsdeploy.aliases.model_constants import SAF_IMPORTED_DESTINATION
6061
from wlsdeploy.aliases.model_constants import SAF_QUEUE
6162
from wlsdeploy.aliases.model_constants import SAF_TOPIC
@@ -243,7 +244,7 @@ def set_saf_remote_context_mbean(self, location, key, value, wlst_value):
243244
:raises BundleAwareException of the specified type: if SAF RemoteContext is not found
244245
"""
245246
resource_location = self.__get_parent_location(location, JMS_RESOURCE)
246-
mbean = self.__find_in_location(resource_location, SAF_REMOTE_CONTEXT, value)
247+
mbean = self.__find_in_location(resource_location, SAF_REMOTE_CONTEXT, value, required=True)
247248
self.set_attribute(location, key, mbean, wlst_merge_value=wlst_value, use_raw_value=True)
248249
return
249250

@@ -260,6 +261,20 @@ def set_saf_error_destination_mbean(self, location, key, value, wlst_value):
260261
self.set_attribute(location, key, mbean, wlst_merge_value=wlst_value, use_raw_value=True)
261262
return
262263

264+
def set_saf_error_handling_mbean(self, location, key, value, wlst_value):
265+
"""
266+
Set the SAF Error Handling MBean.
267+
:param location: the location
268+
:param key: the attribute name
269+
:param value: the string value
270+
:param wlst_value: the existing value of the attribute from WLST
271+
:raises BundleAwareException of the specified type: if destination is not found
272+
"""
273+
resource_location = self.__get_parent_location(location, JMS_RESOURCE)
274+
mbean = self.__find_in_location(resource_location, SAF_ERROR_HANDLING, value, required=True)
275+
self.set_attribute(location, key, mbean, wlst_merge_value=wlst_value, use_raw_value=True)
276+
return
277+
263278
def set_self_tuning_mbean(self, location, key, value, wlst_value):
264279
"""
265280
Set the SelfTuning MBean.

core/src/main/python/wlsdeploy/tool/util/topology_helper.py

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,7 @@ def create_placeholder_servers_in_cluster(self, topology):
7575
"""
7676
_method_name = 'create_placeholder_servers_in_cluster'
7777
self.logger.entering(class_name=self.__class_name, method_name=_method_name)
78-
original_location = self.wlst_helper.get_pwd()
79-
server_location = LocationContext().append_location(SERVER)
80-
81-
if self.alias_helper.get_wlst_mbean_type(server_location) is not None:
82-
existing_names = deployer_utils.get_existing_object_list(server_location, self.alias_helper)
83-
84-
server_nodes = dictionary_utils.get_dictionary_element(topology, SERVER)
85-
for server_name in server_nodes:
86-
if server_name not in existing_names and self.is_clustered_server(server_name, server_nodes):
87-
self.logger.info('WLSDPLY-19402', server_name, class_name=self.__class_name,
88-
method_name=_method_name)
89-
90-
server_token = self.alias_helper.get_name_token(server_location)
91-
server_location.add_name_token(server_token, server_name)
92-
deployer_utils.create_and_cd(server_location, existing_names, self.alias_helper)
93-
94-
self.wlst_helper.cd(original_location)
78+
self.create_placeholder_named_elements(LocationContext(), SERVER, topology)
9579
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
9680

9781
def create_placeholder_server_templates(self, topology):
@@ -100,46 +84,39 @@ def create_placeholder_server_templates(self, topology):
10084
This is necessary because there is a circular dependency between clusters and server templates.
10185
:param topology: the topology model nodes
10286
"""
103-
_method_name = 'create_placeholder_server_templates'
104-
original_location = self.wlst_helper.get_pwd()
105-
template_location = LocationContext().append_location(SERVER_TEMPLATE)
106-
107-
if self.alias_helper.get_wlst_mbean_type(template_location) is not None:
108-
existing_names = deployer_utils.get_existing_object_list(template_location, self.alias_helper)
109-
110-
template_nodes = dictionary_utils.get_dictionary_element(topology, SERVER_TEMPLATE)
111-
for template_name in template_nodes:
112-
if template_name not in existing_names:
113-
self.logger.info('WLSDPLY-19400', template_name, class_name=self.__class_name,
114-
method_name=_method_name)
115-
116-
template_token = self.alias_helper.get_name_token(template_location)
117-
template_location.add_name_token(template_token, template_name)
118-
deployer_utils.create_and_cd(template_location, existing_names, self.alias_helper)
119-
120-
self.wlst_helper.cd(original_location)
87+
self.create_placeholder_named_elements(LocationContext(), SERVER_TEMPLATE, topology)
12188

12289
def create_placeholder_jdbc_resources(self, resources):
12390
"""
12491
Create a placeholder JDBC resource for each name in the resources section.
12592
This is necessary because cluster attributes may reference JDBC resources.
12693
:param resources: the resource model nodes
12794
"""
128-
_method_name = 'create_placeholder_jdbc_resources'
95+
self.create_placeholder_named_elements(LocationContext(), JDBC_SYSTEM_RESOURCE, resources)
96+
97+
def create_placeholder_named_elements(self, location, model_type, model_nodes):
98+
"""
99+
Create a placeholder entry for each element in the specified named element nodes.
100+
This is necessary when there can be circular references with other elements.
101+
:param location: the location for the nodes to be added
102+
:param model_type: the type of the specified model nodes
103+
:param model_nodes: the model nodes
104+
"""
105+
_method_name = 'create_placeholder_named_elements'
129106
original_location = self.wlst_helper.get_pwd()
130-
resource_location = LocationContext().append_location(JDBC_SYSTEM_RESOURCE)
107+
resource_location = LocationContext(location).append_location(model_type)
131108

132109
if self.alias_helper.get_wlst_mbean_type(resource_location) is not None:
133110
existing_names = deployer_utils.get_existing_object_list(resource_location, self.alias_helper)
134111

135-
jdbc_nodes = dictionary_utils.get_dictionary_element(resources, JDBC_SYSTEM_RESOURCE)
136-
for jdbc_name in jdbc_nodes:
137-
if jdbc_name not in existing_names:
138-
self.logger.info('WLSDPLY-19401', jdbc_name, class_name=self.__class_name,
112+
name_nodes = dictionary_utils.get_dictionary_element(model_nodes, model_type)
113+
for name in name_nodes:
114+
if name not in existing_names:
115+
self.logger.info('WLSDPLY-19403', model_type, name, class_name=self.__class_name,
139116
method_name=_method_name)
140117

141-
jdbc_token = self.alias_helper.get_name_token(resource_location)
142-
resource_location.add_name_token(jdbc_token, jdbc_name)
118+
token = self.alias_helper.get_name_token(resource_location)
119+
resource_location.add_name_token(token, name)
143120
deployer_utils.create_and_cd(resource_location, existing_names, self.alias_helper)
144121

145122
self.wlst_helper.cd(original_location)

core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/JMSSystemResource.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@
433433
"Notes": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Notes", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
434434
"PersistentQos": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "PersistentQos", "wlst_path": "WP001", "value": {"default": "Exactly-Once" }, "wlst_type": "string", "get_method": "LSA"} ],
435435
"RemoteJndiName": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Remote${Jndi:JNDI}Name", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "get_method": "LSA"} ],
436-
"SAFErrorHandling": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SAFErrorHandling", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "get_method": "LSA", "set_method": "MBEAN.set_saf_error_destination_mbean", "set_mbean_type": "weblogic.j2ee.descriptor.wl.SAFErrorHandlingBean", "restart_required": "true" } ],
436+
"SAFErrorHandling": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SAFErrorHandling", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "get_method": "LSA", "set_method": "MBEAN.set_saf_error_handling_mbean", "set_mbean_type": "weblogic.j2ee.descriptor.wl.SAFErrorHandlingBean", "restart_required": "true" } ],
437437
"TimeToLiveDefault": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "TimeToLiveDefault", "wlst_path": "WP001", "value": {"default": "${0:3600000}" }, "wlst_type": "long" } ],
438438
"UnitOfOrderRouting": [ {"version": "[10,12.2.1.2)", "wlst_mode": "both", "wlst_name": "UnitOfOrderRouting", "wlst_path": "WP001", "value": {"default": "Hash" }, "wlst_type": "string", "get_method": "LSA", "restart_required": "true"} ,
439439
{"version": "[12.2.1.2,)", "wlst_mode": "both", "wlst_name": "UnitOfOrderRouting", "wlst_path": "WP001", "value": {"default": "${None:Hash}" }, "wlst_type": "string", "get_method": "LSA", "restart_required": "true"} ],
@@ -469,7 +469,7 @@
469469
"Notes": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Notes", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
470470
"PersistentQos": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "PersistentQos", "wlst_path": "WP001", "value": {"default": "Exactly-Once" }, "wlst_type": "string" } ],
471471
"RemoteJndiName": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Remote${Jndi:JNDI}Name", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "get_method": "LSA"} ],
472-
"SAFErrorHandling": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SAFErrorHandling", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "get_method": "LSA", "set_method": "MBEAN.set_saf_error_destination_mbean", "set_mbean_type": "weblogic.j2ee.descriptor.wl.SAFErrorHandlingBean", "restart_required": "true"} ],
472+
"SAFErrorHandling": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SAFErrorHandling", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "get_method": "LSA", "set_method": "MBEAN.set_saf_error_handling_mbean", "set_mbean_type": "weblogic.j2ee.descriptor.wl.SAFErrorHandlingBean", "restart_required": "true"} ],
473473
"TimeToLiveDefault": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "TimeToLiveDefault", "wlst_path": "WP001", "value": {"default": "${0:3600000}" }, "wlst_type": "long" } ],
474474
"UnitOfOrderRouting": [ {"version": "[10,12.2.1.2)", "wlst_mode": "both", "wlst_name": "UnitOfOrderRouting", "wlst_path": "WP001", "value": {"default": "Hash" }, "wlst_type": "string", "restart_required": "true" } ,
475475
{"version": "[12.2.1.2,)", "wlst_mode": "both", "wlst_name": "UnitOfOrderRouting", "wlst_path": "WP001", "value": {"default": "${None:Hash}" }, "wlst_type": "string", "restart_required": "true" } ],
@@ -497,7 +497,7 @@
497497
"DefaultTargetingEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "DefaultTargetingEnabled", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "boolean", "restart_required": "true"} ],
498498
"JNDIPrefix": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "JNDIPrefix", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
499499
"Notes": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Notes", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
500-
"SAFErrorHandling": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SAFErrorHandling", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "get_method": "LSA", "set_method": "MBEAN.set_saf_error_destination_mbean", "set_mbean_type": "weblogic.j2ee.descriptor.wl.SAFErrorHandlingBean", "restart_required": "true" } ],
500+
"SAFErrorHandling": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SAFErrorHandling", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "get_method": "LSA", "set_method": "MBEAN.set_saf_error_handling_mbean", "set_mbean_type": "weblogic.j2ee.descriptor.wl.SAFErrorHandlingBean", "restart_required": "true" } ],
501501
"SAFRemoteContext": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SAFRemoteContext", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "get_method": "LSA", "set_method": "MBEAN.set_saf_remote_context_mbean", "set_mbean_type": "weblogic.j2ee.descriptor.wl.SAFRemoteContextBean"} ],
502502
"SubDeploymentName": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SubDeploymentName", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "restart_required": "true" } ],
503503
"TimeToLiveDefault": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "TimeToLiveDefault", "wlst_path": "WP001", "value": {"default": "${0:3600000}" }, "wlst_type": "long" } ],

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,7 @@ WLSDPLY-19307=Unable to extract classpath libraries from archive file {0} to dom
12201220
WLSDPLY-19400=Creating placeholder for server template {0}
12211221
WLSDPLY-19401=Creating placeholder for JDBC resource {0}
12221222
WLSDPLY-19402=Creating placeholder for Server resource {0}
1223+
WLSDPLY-19403=Creating placeholder for {0} {1}
12231224

12241225
# wlsdeploy/tool/util/variable_injector.py
12251226
WLSDPLY-19500=Model variable injector values loaded from location {0}

0 commit comments

Comments
 (0)