|
1 | 1 | """
|
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. |
3 | 3 | Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
4 | 4 | """
|
5 | 5 |
|
|
22 | 22 | from wlsdeploy.aliases.model_constants import SINGLETON_SERVICE
|
23 | 23 | from wlsdeploy.aliases.model_constants import SYSTEM_COMPONENT
|
24 | 24 | 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 | + |
25 | 30 | from wlsdeploy.aliases.wlst_modes import WlstModes
|
26 | 31 | from wlsdeploy.tool.deploy.deployer import Deployer
|
27 | 32 | from wlsdeploy.util import dictionary_utils
|
28 |
| - |
| 33 | +from wlsdeploy.exception import exception_helper |
| 34 | +import os, shutil |
29 | 35 |
|
30 | 36 | class CommonResourcesDeployer(Deployer):
|
31 | 37 | """
|
@@ -169,8 +175,54 @@ def add_coherence_clusters(self, parent_dict, location):
|
169 | 175 | :param parent_dict: the dictionary possibly containing coherence cluster elements
|
170 | 176 | :param location: the location to deploy the elements
|
171 | 177 | """
|
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) |
174 | 226 |
|
175 | 227 | def add_webapp_container(self, parent_dict, location):
|
176 | 228 | """
|
|
0 commit comments