Skip to content

Commit 50ed3ee

Browse files
authored
Merge pull request #81 from oracle/issue#80-create-domain-fails-with-coherence-attribute
Issue#80 - Create placeholder Coherence clusters for references in to…
2 parents f780037 + eee8979 commit 50ed3ee

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from wlsdeploy.aliases.location_context import LocationContext
1010
from wlsdeploy.exception import exception_helper
1111
from wlsdeploy.tool.create.creator import Creator
12+
from wlsdeploy.tool.deploy import deployer_utils
1213
from wlsdeploy.tool.deploy import model_deployer
1314
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
1415
from wlsdeploy.util import dictionary_utils
@@ -26,6 +27,7 @@
2627
from wlsdeploy.aliases.model_constants import AUTHORIZER
2728
from wlsdeploy.aliases.model_constants import CERT_PATH_PROVIDER
2829
from wlsdeploy.aliases.model_constants import CLUSTER
30+
from wlsdeploy.aliases.model_constants import COHERENCE_CLUSTER_SYSTEM_RESOURCE
2931
from wlsdeploy.aliases.model_constants import CREDENTIAL_MAPPER
3032
from wlsdeploy.aliases.model_constants import DEFAULT_ADJUDICATOR_NAME
3133
from wlsdeploy.aliases.model_constants import DEFAULT_ADJUDICATOR_TYPE
@@ -95,6 +97,8 @@ def __init__(self, model_dictionary, model_context, aliases):
9597
_method_name = '__init__'
9698
Creator.__init__(self, model_dictionary, model_context, aliases)
9799

100+
self._coherence_cluster_elements = [CLUSTER, SERVER, SERVER_TEMPLATE]
101+
98102
# domainInfo section is required to get the admin password, everything else
99103
# is optional and will use the template defaults
100104
if model_helper.get_model_domain_info_key() not in model_dictionary:
@@ -158,6 +162,22 @@ def create(self):
158162
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
159163
return
160164

165+
# Override
166+
def _create_named_mbeans(self, type_name, model_nodes, base_location, log_created=False):
167+
"""
168+
Override default behavior to create placeholders for referenced Coherence clusters.
169+
:param type_name: the model folder type
170+
:param model_nodes: the model dictionary of the specified model folder type
171+
:param base_location: the base location object to use to create the MBeans
172+
:param log_created: whether or not to log created at INFO level, by default it is logged at the FINE level
173+
:raises: CreateException: if an error occurs
174+
"""
175+
if type_name in self._coherence_cluster_elements:
176+
self._check_coherence_cluster_references(model_nodes, base_location)
177+
# continue with regular processing
178+
179+
Creator._create_named_mbeans(self, type_name, model_nodes, base_location)
180+
161181
def __run_rcu(self):
162182
"""
163183
The method that runs RCU to drop and then create the schemas.
@@ -1152,3 +1172,38 @@ def __fix_up_model_default_identity_asserter(self, base_location, model_name, mo
11521172
default_value = self.alias_helper.get_model_attribute_default_value(location, ACTIVE_TYPE)
11531173
subtype_dict[ACTIVE_TYPE] = default_value
11541174
return
1175+
1176+
def _check_coherence_cluster_references(self, named_nodes, location):
1177+
"""
1178+
If a named element has the Coherence cluster system resource attribute, confirm that the resource exists.
1179+
If the resource does not exist, create a placeholder resource to allow assignment.
1180+
:param named_nodes: a dictionary containing the named model elements
1181+
:param location: the location of the cluster
1182+
:return:
1183+
"""
1184+
for name in named_nodes:
1185+
child_nodes = dictionary_utils.get_dictionary_element(named_nodes, name)
1186+
resource_name = dictionary_utils.get_element(child_nodes, COHERENCE_CLUSTER_SYSTEM_RESOURCE)
1187+
if resource_name is not None:
1188+
self._create_placeholder_coherence_cluster(resource_name)
1189+
1190+
def _create_placeholder_coherence_cluster(self, cluster_name):
1191+
"""
1192+
Create a placeholder Coherence cluster system resource to be referenced from a topology element.
1193+
The new cluster will be created at the root domain level.
1194+
Clusters referenced from the model's resources section should not require placeholder entries.
1195+
:param cluster_name: the name of the Coherence cluster system resource to be added
1196+
"""
1197+
_method_name = '_create_placeholder_coherence_cluster'
1198+
original_location = self.wlst_helper.get_pwd()
1199+
cluster_location = LocationContext().append_location(COHERENCE_CLUSTER_SYSTEM_RESOURCE)
1200+
existing_names = deployer_utils.get_existing_object_list(cluster_location, self.alias_helper)
1201+
1202+
if cluster_name not in existing_names:
1203+
self.logger.info('WLSDPLY-12230', cluster_name, class_name=self.__class_name, method_name=_method_name)
1204+
1205+
cluster_token = self.alias_helper.get_name_token(cluster_location)
1206+
cluster_location.add_name_token(cluster_token, cluster_name)
1207+
deployer_utils.create_and_cd(cluster_location, existing_names, self.alias_helper)
1208+
1209+
self.wlst_helper.cd(original_location)

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
@@ -924,6 +924,7 @@ WLSDPLY-12226=Did not find {0}[{1}] in the model so setting domain option {1} to
924924
WLSDPLY-12227=Changing domain name from {0} to {1}
925925
WLSDPLY-12228=The model does not define the required attribute {0} in the {1} section of the model
926926
WLSDPLY-12229=Changing the administration server name from {0} to {1}
927+
WLSDPLY-12230=Creating placeholder for Coherence cluster {0}
927928

928929
# domain_typedef.py
929930
WLSDPLY-12300=={0} got the domain type {1} but the domain type definition file {2} was not valid: {3}

0 commit comments

Comments
 (0)