Skip to content

Commit a20c226

Browse files
committed
Issue #343 Clear targeting of JDBC placeholders that were created
1 parent 3aa5c17 commit a20c226

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

core/src/main/python/wlsdeploy/tool/create/domain_creator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ def __create_clusters_and_servers(self, location):
738738

739739
# create placeholders for JDBC resources that may be referenced in cluster definition.
740740
resources_dict = self.model.get_model_resources()
741-
self.topology_helper.create_placeholder_jdbc_resources(resources_dict)
741+
jdbc_names = self.topology_helper.create_placeholder_jdbc_resources(resources_dict)
742742
cluster_nodes = dictionary_utils.get_dictionary_element(self._topology, CLUSTER)
743743
if len(cluster_nodes) > 0:
744744
self._create_named_mbeans(CLUSTER, cluster_nodes, location, log_created=True)
@@ -760,7 +760,7 @@ def __create_clusters_and_servers(self, location):
760760
self._create_named_mbeans(SERVER, server_nodes, location, log_created=True)
761761

762762
# targets may have been inadvertently assigned when clusters were added
763-
self.topology_helper.clear_jdbc_placeholder_targeting(resources_dict)
763+
self.topology_helper.clear_jdbc_placeholder_targeting(jdbc_names)
764764

765765
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
766766
return

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

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ def create_placeholder_jdbc_resources(self, resources):
9393
Create a placeholder JDBC resource for each name in the resources section.
9494
This is necessary because cluster attributes may reference JDBC resources.
9595
:param resources: the resource model nodes
96+
:return: a list of names of created placeholders
9697
"""
97-
self.create_placeholder_named_elements(LocationContext(), JDBC_SYSTEM_RESOURCE, resources)
98+
return self.create_placeholder_named_elements(LocationContext(), JDBC_SYSTEM_RESOURCE, resources)
9899

99100
def create_placeholder_named_elements(self, location, model_type, model_nodes):
100101
"""
@@ -103,8 +104,10 @@ def create_placeholder_named_elements(self, location, model_type, model_nodes):
103104
:param location: the location for the nodes to be added
104105
:param model_type: the type of the specified model nodes
105106
:param model_nodes: the model nodes
107+
:return: a list of names of created placeholders
106108
"""
107109
_method_name = 'create_placeholder_named_elements'
110+
holder_names = []
108111
original_location = self.wlst_helper.get_pwd()
109112
resource_location = LocationContext(location).append_location(model_type)
110113

@@ -125,8 +128,10 @@ def create_placeholder_named_elements(self, location, model_type, model_nodes):
125128
resource_location.add_name_token(token, name)
126129
deployer_utils.create_and_cd(resource_location, existing_names, self.alias_helper)
127130
self._update_placeholder(model_type, name, resource_location)
131+
holder_names.append(name)
128132

129133
self.wlst_helper.cd(original_location)
134+
return holder_names
130135

131136
def _update_placeholder(self, type_name, name, location):
132137
"""
@@ -148,31 +153,25 @@ def _update_placeholder(self, type_name, name, location):
148153
self.wlst_helper.set('Name', name)
149154
self.wlst_helper.cd(original_location)
150155

151-
def clear_jdbc_placeholder_targeting(self, resources):
156+
def clear_jdbc_placeholder_targeting(self, jdbc_names):
152157
"""
153-
Remove any targets for the JDBC resources in the specified dictionary.
158+
Remove any targets for the JDBC resources in the specified list of names.
154159
Targets may have been inadvertently assigned when clusters were added after JDBC placeholders.
155-
:param resources: dictionary containing the resources section of the model
160+
:param jdbc_names: names of placeholders to clear
156161
"""
157162
_method_name = 'clear_jdbc_placeholder_targeting'
158163
resource_location = LocationContext().append_location(JDBC_SYSTEM_RESOURCE)
159164
token = self.alias_helper.get_name_token(resource_location)
160165

161-
if self.alias_helper.get_wlst_mbean_type(resource_location) is not None:
162-
name_nodes = dictionary_utils.get_dictionary_element(resources, JDBC_SYSTEM_RESOURCE)
163-
for name in name_nodes.keys():
164-
if model_helper.is_delete_name(name):
165-
# don't clear placeholder for delete names
166-
continue
167-
168-
self.logger.info('WLSDPLY-19404', JDBC_SYSTEM_RESOURCE, name, class_name=self.__class_name,
169-
method_name=_method_name)
166+
for name in jdbc_names:
167+
self.logger.info('WLSDPLY-19404', JDBC_SYSTEM_RESOURCE, name, class_name=self.__class_name,
168+
method_name=_method_name)
170169

171-
resource_location.add_name_token(token, name)
172-
wlst_path = self.alias_helper.get_wlst_attributes_path(resource_location)
173-
if self.wlst_helper.path_exists(wlst_path):
174-
mbean = self.wlst_helper.get_mbean_for_wlst_path(wlst_path)
175-
mbean.setTargets(None)
170+
resource_location.add_name_token(token, name)
171+
wlst_path = self.alias_helper.get_wlst_attributes_path(resource_location)
172+
if self.wlst_helper.path_exists(wlst_path):
173+
mbean = self.wlst_helper.get_mbean_for_wlst_path(wlst_path)
174+
mbean.setTargets(None)
176175

177176
def qualify_nm_properties(self, type_name, model_nodes, base_location, model_context, attribute_setter):
178177
"""

0 commit comments

Comments
 (0)