|
1 | 1 | """
|
2 |
| -Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. |
| 2 | +Copyright (c) 2017, 2024, Oracle and/or its affiliates. |
3 | 3 | Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
4 | 4 | """
|
| 5 | +from wlsdeploy.aliases.model_constants import CUSTOM_RESOURCE |
| 6 | +from wlsdeploy.aliases.model_constants import DESCRIPTOR_BEAN_CLASS |
| 7 | +from wlsdeploy.aliases.model_constants import DESCRIPTOR_FILE_NAME |
5 | 8 | from wlsdeploy.aliases.model_constants import EJB_CONTAINER
|
6 | 9 | from wlsdeploy.aliases.model_constants import FILE_STORE
|
7 | 10 | from wlsdeploy.aliases.model_constants import FOREIGN_JNDI_PROVIDER
|
|
13 | 16 | from wlsdeploy.aliases.model_constants import MESSAGING_BRIDGE
|
14 | 17 | from wlsdeploy.aliases.model_constants import OHS
|
15 | 18 | from wlsdeploy.aliases.model_constants import PATH_SERVICE
|
| 19 | +from wlsdeploy.aliases.model_constants import RESOURCE_CLASS |
16 | 20 | from wlsdeploy.aliases.model_constants import SAF_AGENT
|
17 | 21 | from wlsdeploy.aliases.model_constants import SELF_TUNING
|
18 | 22 | from wlsdeploy.aliases.model_constants import SNMP_AGENT
|
|
24 | 28 | from wlsdeploy.aliases.model_constants import SYSTEM_COMPONENT
|
25 | 29 |
|
26 | 30 | from wlsdeploy.aliases.wlst_modes import WlstModes
|
| 31 | +from wlsdeploy.exception import exception_helper |
27 | 32 | from wlsdeploy.tool.deploy.deployer import Deployer
|
28 | 33 | from wlsdeploy.util import dictionary_utils
|
29 | 34 |
|
@@ -63,6 +68,27 @@ def _add_subfolders(self, model_nodes, location, excludes=None):
|
63 | 68 |
|
64 | 69 | Deployer._add_subfolders(self, model_nodes, location, excludes=excludes)
|
65 | 70 |
|
| 71 | + # Override |
| 72 | + def _create_and_cd(self, location, existing_names, child_nodes): |
| 73 | + """ |
| 74 | + Override the base method for custom resources. |
| 75 | + These have to be created using cmo.createCustomResource(...) . |
| 76 | + """ |
| 77 | + parent_type = self.get_location_type(location) |
| 78 | + if parent_type == CUSTOM_RESOURCE and (self.wlst_mode == WlstModes.ONLINE): |
| 79 | + self.__create_custom_resource_online_and_cd(location, existing_names, child_nodes) |
| 80 | + else: |
| 81 | + Deployer._create_and_cd(self, location, existing_names, child_nodes) |
| 82 | + |
| 83 | + def add_custom_resources(self, parent_dict, location): |
| 84 | + """ |
| 85 | + Deploy the custom resource elements in the dictionary at the specified location. |
| 86 | + :param parent_dict: the dictionary possibly containing custom resource elements |
| 87 | + :param location: the location to deploy the elements |
| 88 | + """ |
| 89 | + resources = dictionary_utils.get_dictionary_element(parent_dict, CUSTOM_RESOURCE) |
| 90 | + self._add_named_elements(CUSTOM_RESOURCE, resources, location) |
| 91 | + |
66 | 92 | def add_ejb_container(self, parent_dict, location):
|
67 | 93 | """
|
68 | 94 | Deploy the EJB container elements in the dictionary at the specified location.
|
@@ -180,8 +206,7 @@ def add_snmp_agent_deployments(self, parent_dict, location):
|
180 | 206 | :param location: the location to deploy the elements
|
181 | 207 | """
|
182 | 208 | deployments = dictionary_utils.get_dictionary_element(parent_dict, SNMP_AGENT_DEPLOYMENT)
|
183 |
| - if len(deployments) != 0: |
184 |
| - self._add_named_elements(SNMP_AGENT_DEPLOYMENT, deployments, location) |
| 209 | + self._add_named_elements(SNMP_AGENT_DEPLOYMENT, deployments, location) |
185 | 210 |
|
186 | 211 | def add_self_tuning(self, parent_dict, location):
|
187 | 212 | """
|
@@ -244,3 +269,38 @@ def add_ohs_components(self, parent_dict, location):
|
244 | 269 | self.logger.warning('WLSDPLY-09405', OHS, class_name=self._class_name, method_name=_method_name)
|
245 | 270 | else:
|
246 | 271 | self._add_named_elements(OHS, system_components, location)
|
| 272 | + |
| 273 | + def __create_custom_resource_online_and_cd(self, location, existing_names, child_nodes): |
| 274 | + """ |
| 275 | + Create the custom resource at the specified location if it does not exist, |
| 276 | + and change to the new directory. |
| 277 | + :param location: the location of the custom resource to create |
| 278 | + :param existing_names: existing names at the specified location |
| 279 | + :param child_nodes: used to gather information to create |
| 280 | + """ |
| 281 | + _method_name = '__create_custom_resource_online_and_cd' |
| 282 | + |
| 283 | + mbean_name = self.aliases.get_wlst_mbean_name(location) |
| 284 | + if mbean_name not in existing_names: |
| 285 | + create_path = self.aliases.get_wlst_create_path(location) |
| 286 | + self.wlst_helper.cd(create_path) |
| 287 | + resource_class = dictionary_utils.get_element(child_nodes, RESOURCE_CLASS) |
| 288 | + if not resource_class: |
| 289 | + ex = exception_helper.create_deploy_exception( |
| 290 | + 'WLSDPLY-09426', CUSTOM_RESOURCE, mbean_name, RESOURCE_CLASS) |
| 291 | + self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) |
| 292 | + raise ex |
| 293 | + |
| 294 | + bean_descriptor_class = dictionary_utils.get_element(child_nodes, DESCRIPTOR_BEAN_CLASS) |
| 295 | + if not bean_descriptor_class: |
| 296 | + ex = exception_helper.create_deploy_exception( |
| 297 | + 'WLSDPLY-09426', CUSTOM_RESOURCE, mbean_name, DESCRIPTOR_BEAN_CLASS) |
| 298 | + self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) |
| 299 | + raise ex |
| 300 | + |
| 301 | + descriptor_file_name = dictionary_utils.get_element(child_nodes, DESCRIPTOR_FILE_NAME) |
| 302 | + self.wlst_helper.create_custom_resource(mbean_name, resource_class, bean_descriptor_class, |
| 303 | + descriptor_file_name) |
| 304 | + |
| 305 | + wlst_path = self.aliases.get_wlst_attributes_path(location) |
| 306 | + self.wlst_helper.cd(wlst_path) |
0 commit comments