Skip to content

Commit b1ce465

Browse files
authored
port wdt 719 from 2.4 branch (#1362)
1 parent 13b5e6d commit b1ce465

File tree

5 files changed

+86
-8
lines changed

5 files changed

+86
-8
lines changed

core/src/main/python/wlsdeploy/aliases/model_constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
COHERENCE_SNAPSHOT_DIRECTORY = 'SnapshotDirectory'
7373
COHERENCE_SOCKET_ADDRESS = 'CoherenceSocketAddress'
7474
COHERENCE_TRASH_DIRECTORY = 'TrashDirectory'
75+
COHERENCE_USE_CUSTOM_CLUSTER_CONFIG = 'UsingCustomClusterConfigurationFile'
7576
COHERENCE_WELL_KNOWN_ADDRESSES = 'CoherenceClusterWellKnownAddresses'
7677
COHERENCE_WELL_KNOWN_ADDRESS = 'CoherenceClusterWellKnownAddress'
7778
CONFIGURATION_PROPERTY = 'ConfigurationProperty'

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

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2023, Oracle Corporation and/or its affiliates. All rights reserved.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55

@@ -22,10 +22,16 @@
2222
from wlsdeploy.aliases.model_constants import SINGLETON_SERVICE
2323
from wlsdeploy.aliases.model_constants import SYSTEM_COMPONENT
2424
from wlsdeploy.aliases.model_constants import MIME_MAPPING_FILE
25+
from wlsdeploy.aliases.model_constants import COHERENCE_RESOURCE
26+
from wlsdeploy.aliases.model_constants import COHERENCE_CUSTOM_CLUSTER_CONFIGURATION
27+
from wlsdeploy.aliases.model_constants import COHERENCE_USE_CUSTOM_CLUSTER_CONFIG
28+
from oracle.weblogic.deploy.util.WLSDeployArchive import ARCHIVE_COHERENCE_TARGET_DIR
29+
2530
from wlsdeploy.aliases.wlst_modes import WlstModes
2631
from wlsdeploy.tool.deploy.deployer import Deployer
2732
from wlsdeploy.util import dictionary_utils
28-
33+
from wlsdeploy.exception import exception_helper
34+
import os, shutil
2935

3036
class CommonResourcesDeployer(Deployer):
3137
"""
@@ -169,8 +175,54 @@ def add_coherence_clusters(self, parent_dict, location):
169175
:param parent_dict: the dictionary possibly containing coherence cluster elements
170176
:param location: the location to deploy the elements
171177
"""
172-
file_stores = dictionary_utils.get_dictionary_element(parent_dict, COHERENCE_CLUSTER_SYSTEM_RESOURCE)
173-
self._add_named_elements(COHERENCE_CLUSTER_SYSTEM_RESOURCE, file_stores, location)
178+
coherence_clusters = dictionary_utils.get_dictionary_element(parent_dict, COHERENCE_CLUSTER_SYSTEM_RESOURCE)
179+
self._add_named_elements(COHERENCE_CLUSTER_SYSTEM_RESOURCE, coherence_clusters, location)
180+
181+
self._make_coh_cluster_custom_config_available(coherence_clusters)
182+
183+
def _make_coh_cluster_custom_config_available(self, coherence_clusters):
184+
# The coherence cluster custom configuration file must be within the config/coherence/<cluster>
185+
# We will copy the config file over, at this point the model's attribute value is still the original value
186+
187+
_method_name = '_make_coh_cluster_custom_config_available'
188+
try:
189+
domain_home = self.model_context.get_domain_home()
190+
for coherence_cluster in coherence_clusters:
191+
cluster = coherence_clusters[coherence_cluster]
192+
use_custom_config = dictionary_utils.get_dictionary_element(cluster,
193+
COHERENCE_USE_CUSTOM_CLUSTER_CONFIG)
194+
195+
if use_custom_config:
196+
self._copy_custom_config_file_to_destination(cluster, coherence_cluster, domain_home)
197+
else:
198+
continue
199+
200+
except Exception, e:
201+
ex = exception_helper.create_deploy_exception('WLSDPLY-09406', e)
202+
self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
203+
raise ex
204+
205+
def _copy_custom_config_file_to_destination(self, cluster, coherence_cluster, domain_home):
206+
coh_resource = dictionary_utils.get_dictionary_element(cluster, COHERENCE_RESOURCE)
207+
if coh_resource:
208+
custom_path = dictionary_utils.get_dictionary_element(coh_resource,
209+
COHERENCE_CUSTOM_CLUSTER_CONFIGURATION)
210+
211+
if custom_path is not None:
212+
coh_cluster_config_path = os.path.join(domain_home, 'config', 'coherence', coherence_cluster)
213+
if not os.path.exists(coh_cluster_config_path):
214+
os.mkdir(coh_cluster_config_path)
215+
if custom_path.startswith(ARCHIVE_COHERENCE_TARGET_DIR):
216+
# this is the extracted path from the archive
217+
config_filepath = os.path.join(domain_home, custom_path)
218+
else:
219+
# absolute path
220+
config_filepath = custom_path
221+
222+
if os.path.exists(config_filepath):
223+
shutil.copy(config_filepath, coh_cluster_config_path)
224+
if custom_path.startswith(ARCHIVE_COHERENCE_TARGET_DIR):
225+
os.remove(config_filepath)
174226

175227
def add_webapp_container(self, parent_dict, location):
176228
"""

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""
2-
Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2023, Oracle Corporation and/or its affiliates. All rights reserved.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
5+
import os
56
from javax.management import ObjectName
67
from org.python.modules import jarray
78

@@ -78,7 +79,8 @@
7879
from wlsdeploy.util import model_helper
7980
import wlsdeploy.util.unicode_helper as str_helper
8081
from wlsdeploy.util.weblogic_helper import WebLogicHelper
81-
82+
from oracle.weblogic.deploy.util.WLSDeployArchive import ARCHIVE_COHERENCE_TARGET_DIR
83+
from oracle.weblogic.deploy.util.WLSDeployArchive import WLSDPLY_ARCHIVE_BINARY_DIR
8284

8385
class AttributeSetter(object):
8486
"""
@@ -662,6 +664,28 @@ def set_encrypted(self, location, key, value, wlst_value):
662664
self.__weblogic_helper.encrypt(str_helper.to_string(value), self.__model_context.get_domain_home())
663665
self.set_attribute(location, key, encrypted_value, wlst_merge_value=wlst_value)
664666

667+
def set_coherence_cluster_custom_config_file(self, location, key, value, wlst_value):
668+
"""
669+
Set the coherence cluster custom config file attribute correctly. If the path starts with archive entry
670+
location, then it should be set to coherence/<CLUSTER NAME>/<file name>
671+
:param location: location
672+
:param key: this should be CustomClusterConfigurationFileName
673+
:param value: path of the config file
674+
:param wlst_value: the existing value of the attribute from WLST
675+
:raises BundleAwareException of the specified type: if an error occurs
676+
"""
677+
if value is not None:
678+
if value.startswith(ARCHIVE_COHERENCE_TARGET_DIR + os.sep):
679+
# change from /wlsdeploy/coherence/<Cluster>/<filename> --> coherence/<Cluster>/<filename>
680+
value = value[len(WLSDPLY_ARCHIVE_BINARY_DIR + os.sep):]
681+
else:
682+
# The file will be copied to the $DOMAIN/config/coherence/<CLUSTER>
683+
# changing the attribute value to the pattern coherence/<CLUSTER>/<filename>
684+
cluster_name = location.get_name_for_token('COHERENCECLUSTER')
685+
value = 'coherence/%s/%s' % (cluster_name, os.path.basename(value))
686+
687+
self.set_attribute(location, key, value, wlst_merge_value=wlst_value)
688+
665689
#
666690
# public set_attribute convenience methods
667691
#

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"copyright": "Copyright (c) 2017, 2023, Oracle Corporation and/or its affiliates.",
2+
"copyright": "Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates.",
33
"license": "Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl",
44
"wlst_type": "CoherenceClusterSystemResource${:s}",
55
"online_bean": "weblogic.management.configuration.CoherenceClusterSystemResourceMBean",
@@ -260,7 +260,7 @@
260260
},
261261
"attributes": {
262262
"CustomClusterConfigurationFileLastUpdatedTimestamp": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "CustomClusterConfigurationFileLastUpdatedTimestamp", "wlst_path": "WP001", "default_value": 0, "wlst_type": "long", "access": "${:IGNORED}" } ],
263-
"CustomClusterConfigurationFileName": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "CustomClusterConfigurationFileName", "wlst_path": "WP001", "default_value": null, "wlst_type": "string", "access": "${:IGNORED}", "uses_path_tokens": "true" } ],
263+
"CustomClusterConfigurationFileName": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "CustomClusterConfigurationFileName", "wlst_path": "WP001", "default_value": null, "wlst_type": "string", "access": "${:IGNORED}", "set_method": "MBEAN.set_coherence_cluster_custom_config_file", "uses_path_tokens": "true" } ],
264264
"Version": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "Version", "wlst_path": "WP001", "default_value": null, "wlst_type": "string"} ]
265265
},
266266
"wlst_attributes_path": "WP001",

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
@@ -1192,6 +1192,7 @@ WLSDPLY-09402=Failed to create directory for FileStore {0} because the location
11921192
WLSDPLY-09403=Created FileStore {0} directory {1}
11931193
WLSDPLY-09404=Failed to create directory for FileStore {0} at location {1}
11941194
WLSDPLY-09405={0} resources in the model are not configured in online mode
1195+
WLSDPLY-09406=Failed to move coherence cluster custom config file {0}
11951196

11961197
# wlsdeploy/tool/deploy/jms_resources_deployer.py
11971198
WLSDPLY-09500=Creating placeholder for Template {0}

0 commit comments

Comments
 (0)