Skip to content

Commit a68adc8

Browse files
committed
Merge branch 'wdt-748-typedef' into 'main'
Extended discover-filters mechanism to replace system-elements See merge request weblogic-cloud/weblogic-deploy-tooling!1456
2 parents c3c9034 + a47891d commit a68adc8

File tree

20 files changed

+423
-351
lines changed

20 files changed

+423
-351
lines changed

core/src/main/python/create.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
from wlsdeploy.logging.platform_logger import PlatformLogger
3636
from wlsdeploy.tool.create.rcudbinfo_helper import RcuDbInfo
3737
from wlsdeploy.tool.create.domain_creator import DomainCreator
38-
from wlsdeploy.tool.create.domain_typedef import CREATE_DOMAIN
3938
from wlsdeploy.tool.util import model_context_helper
4039
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
4140
from wlsdeploy.tool.util.wlst_helper import WlstHelper
@@ -54,7 +53,7 @@
5453

5554
wlst_helper.wlst_functions = globals()
5655

57-
_program_name = CREATE_DOMAIN
56+
_program_name = 'createDomain'
5857

5958
_class_name = 'create'
6059
__logger = PlatformLogger('wlsdeploy.create')

core/src/main/python/discover.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,6 @@ def __check_and_customize_model(model, model_context, aliases, credential_inject
500500

501501
filter_helper.apply_final_filters(model.get_model(), model.get_model(), model_context)
502502

503-
# target config always present in model context, default config if not declared
504-
target_configuration = model_context.get_target_configuration()
505-
506503
credential_cache = None
507504
if credential_injector is not None:
508505
# filter variables or secrets that are no longer in the model

core/src/main/python/update.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from oracle.weblogic.deploy.deploy import DeployException
1111
from oracle.weblogic.deploy.exception import BundleAwareException
12+
from oracle.weblogic.deploy.validate import ValidateException
1213

1314
sys.path.insert(0, os.path.dirname(os.path.realpath(sys.argv[0])))
1415

@@ -17,7 +18,6 @@
1718
from wlsdeploy.aliases.wlst_modes import WlstModes
1819
from wlsdeploy.exception.expection_types import ExceptionType
1920
from wlsdeploy.logging.platform_logger import PlatformLogger
20-
from wlsdeploy.tool.create.domain_typedef import UPDATE_DOMAIN
2121
from wlsdeploy.tool.deploy import deployer_utils
2222
from wlsdeploy.tool.deploy import model_deployer
2323
from wlsdeploy.tool.deploy.topology_updater import TopologyUpdater
@@ -33,12 +33,11 @@
3333
from wlsdeploy.util.model import Model
3434
from wlsdeploy.util.weblogic_helper import WebLogicHelper
3535
from wlsdeploy.tool.validate.validator import Validator
36-
from oracle.weblogic.deploy.validate import ValidateException
3736

3837

3938
wlst_helper.wlst_functions = globals()
4039

41-
_program_name = UPDATE_DOMAIN
40+
_program_name = 'updateDomain'
4241
_class_name = 'update'
4342
__logger = PlatformLogger('wlsdeploy.update')
4443
__wls_helper = WebLogicHelper(__logger)

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

Lines changed: 67 additions & 107 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.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55
import os
@@ -19,9 +19,15 @@
1919
from wlsdeploy.util.weblogic_helper import WebLogicHelper
2020

2121
CREATE_DOMAIN = 'createDomain'
22-
UPDATE_DOMAIN = 'updateDomain'
22+
DISCOVER_DOMAIN = 'discoverDomain'
2323
NOT_SUPPORTED = 'NOT_SUPPORTED'
2424

25+
def _get_logger_name(program_name):
26+
logger_name = 'wlsdeploy.create'
27+
if program_name == DISCOVER_DOMAIN:
28+
logger_name = 'wlsdeploy.discover'
29+
return logger_name
30+
2531

2632
class DomainTypedef(object):
2733
"""
@@ -35,6 +41,19 @@ class DomainTypedef(object):
3541
RESTRICTED_JRF_TEMPLATE_REGEX = "^(Oracle Restricted JRF)$"
3642
JRF_SERVER_GROUP = 'JRF-MAN-SVR'
3743

44+
__key_mapping_table = {
45+
'apps': '/Application',
46+
'coherence-clusters': '/CoherenceClusterSystemResource',
47+
'datasources': '/JDBCSystemResource',
48+
'file-stores': '/FileStore',
49+
'jms': '/JMSSystemResource',
50+
'jms-server': '/JMSServer',
51+
'shared-libraries': '/Library',
52+
'shutdown-classes': '/ShutdownClass',
53+
'startup-classes': '/StartupClass',
54+
'wldf': '/WLDFSystemResource'
55+
}
56+
3857
def __init__(self, program_name, domain_type):
3958
"""
4059
The DomainTypedef constructor.
@@ -43,7 +62,7 @@ def __init__(self, program_name, domain_type):
4362
"""
4463
_method_name = '__init__'
4564

46-
self._logger = PlatformLogger('wlsdeploy.create')
65+
self._logger = PlatformLogger(_get_logger_name(program_name))
4766
self._program_name = program_name
4867
self._domain_type = domain_type
4968
self.wls_helper = WebLogicHelper(self._logger)
@@ -77,10 +96,15 @@ def __init__(self, program_name, domain_type):
7796

7897
self._targeting_type = self._resolve_targeting_type()
7998

80-
if 'system-elements' in self._domain_typedefs_dict:
81-
self._system_elements = self._domain_typedefs_dict['system-elements']
99+
if 'discover-filters' in self._domain_typedefs_dict:
100+
if 'system-elements' in self._domain_typedefs_dict:
101+
self._logger.notification('WLSDPLY-12317', self._domain_typedef_filename)
102+
self._discover_filters = self._domain_typedefs_dict['discover-filters']
103+
elif 'system-elements' in self._domain_typedefs_dict:
104+
self._logger.deprecation('WLSDPLY-12318', self._domain_typedef_filename)
105+
self._discover_filters = self._translate_system_elements(self._domain_typedefs_dict['system-elements'])
82106
else:
83-
self._system_elements = {}
107+
self._discover_filters = {}
84108

85109
self._topology_profile = self._resolve_topology_profile()
86110

@@ -108,13 +132,6 @@ def get_topology_profile(self):
108132
"""
109133
return self._topology_profile
110134

111-
def has_jrf_resources(self):
112-
"""
113-
Determine if the domain type has domain resources from either the JRF or Restricted JRF templates.
114-
:return: True if the domain type has resources from one of the JRF type
115-
"""
116-
return self.is_jrf_domain_type() or self.is_restricted_jrf_domain_type()
117-
118135
def is_jrf_domain_type(self):
119136
"""
120137
Determine if this is a JRF domain type by checking for the JRF extension template or
@@ -220,111 +237,54 @@ def get_targeting(self):
220237
"""
221238
return self._targeting_type
222239

223-
def is_system_app(self, name):
224-
"""
225-
Determine if the specified name matches a WLS system application.
226-
:param name: the name to be checked
227-
:return: True if the name matches a system application, False otherwise
228-
"""
229-
return self._is_system_name(name, 'apps')
230-
231-
def is_system_coherence_cluster(self, name):
232-
"""
233-
Determine if the specified name matches a WLS system Coherence cluster.
234-
:param name: the name to be checked
235-
:return: True if the name matches a system Coherence cluster, False otherwise
236-
"""
237-
return self._is_system_name(name, 'coherence-clusters')
238-
239-
def is_system_datasource(self, name):
240-
"""
241-
Determine if the specified name matches a WLS system datasource.
242-
:param name: the name to be checked
243-
:return: True if the name matches a system datasource, False otherwise
244-
"""
245-
return self._is_system_name(name, 'datasources')
246-
247-
def is_system_file_store(self, name):
248-
"""
249-
Determine if the specified name matches a WLS system file store.
250-
:param name: the name to be checked
251-
:return: True if the name matches a system file store, False otherwise
252-
"""
253-
return self._is_system_name(name, 'file-stores')
254-
255-
def is_system_jms(self, name):
256-
"""
257-
Determine if the specified name matches a WLS system JMS resource.
258-
:param name: the name to be checked
259-
:return: True if the name matches a system JMS resource, False otherwise
260-
"""
261-
return self._is_system_name(name, 'jms')
262-
263-
def is_system_jms_server(self, name):
264-
"""
265-
Determine if the specified name matches a WLS system JMS server.
266-
:param name: the name to be checked
267-
:return: True if the name matches a system JMS server, False otherwise
240+
def is_filtered(self, location, name=None):
268241
"""
269-
return self._is_system_name(name, 'jms-servers')
242+
Determine if the named object at the specified location is filtered.
270243
271-
def is_system_shared_library(self, name):
244+
:param location: the alias location object
245+
:param name: the name of the object
246+
:return: true, if the object should be filtered; false otherwise
272247
"""
273-
Determine if the specified name matches a WLS system shared library.
274-
:param name: the name to be checked
275-
:return: True if the name matches a system shared library, False otherwise
276-
"""
277-
return self._is_system_name(name, 'shared-libraries')
278-
279-
def is_system_shutdown_class(self, name):
280-
"""
281-
Determine if the specified name matches a WLS system shutdown class.
282-
:param name: the name to be checked
283-
:return: True if the name matches a system shutdown class, False otherwise
284-
"""
285-
return self._is_system_name(name, 'shutdown-classes')
286-
287-
def is_system_startup_class(self, name):
288-
"""
289-
Determine if the specified name matches a WLS system startup class.
290-
:param name: the name to be checked
291-
:return: True if the name matches a system startup class, False otherwise
292-
"""
293-
return self._is_system_name(name, 'startup-classes')
248+
key = location.get_folder_path()
249+
if key in self._discover_filters:
250+
# Global filter to remove the entire section
251+
if name is None:
252+
return True
294253

295-
def is_system_wldf(self, name):
296-
"""
297-
Determine if the specified name matches a WLS system WLDF resource.
298-
:param name: the name to be checked
299-
:return: True if the name matches a system WLDF resource, False otherwise
300-
"""
301-
return self._is_system_name(name, 'wldf')
254+
discover_filters = self._discover_filters[key]
255+
for discover_filter in discover_filters:
256+
matched = re.match(discover_filter, name)
257+
if matched is not None:
258+
return True
259+
return False
302260

303-
def is_security_configuration_supported(self):
261+
def _translate_system_elements(self, system_elements_dict):
304262
"""
305-
Determine if the security configuration can be configured. Currently, update domain does not
306-
support configuration of the SecurityConfiguration, and 11g create domain does not support
307-
configuration of the SecurityConfiguration
263+
Convert the old system-elements format to the new discover-filters format.
308264
309-
:return: True if the security realm can be configured
265+
:param system_elements_dict: the system-elements dictionary
266+
:return:
310267
"""
311-
return self._program_name != UPDATE_DOMAIN
268+
discover_filters_dict = dict()
269+
for key, value in system_elements_dict.iteritems():
270+
new_key = self._convert_system_elements_key_name(key)
271+
discover_filters_dict[new_key] = value
272+
return discover_filters_dict
312273

313-
def _is_system_name(self, name, key):
274+
def _convert_system_elements_key_name(self, key):
314275
"""
315-
Determine if the specified name matches a WLS name of the specified type key.
316-
:param name: the name to be checked
317-
:param key: the key of the type to be checked against
318-
:return: True if the name matches a system name, False otherwise
276+
Convert the old system-elements key names to the new discover-filters key names.
277+
:param key: the system-elements key
278+
:return: the equivalent discover-filters key
319279
"""
320-
if key in self._system_elements:
321-
system_names = self._system_elements[key]
322-
for system_name in system_names:
323-
matched = re.match(system_name, name)
324-
if matched is not None:
325-
return True
326-
327-
return False
280+
if key in self.__key_mapping_table:
281+
return self.__key_mapping_table[key]
282+
else:
283+
if self._program_name == DISCOVER_DOMAIN:
284+
ex = exception_helper.create_discover_exception('WLSDPLY-12316', key, self._domain_typedef_filename)
285+
else:
286+
ex = exception_helper.create_create_exception('WLSDPLY-12316', key, self._domain_typedef_filename)
287+
raise ex
328288

329289
def __resolve_paths(self):
330290
"""

core/src/main/python/wlsdeploy/tool/discover/coherence_resources_discoverer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def get_coherence_clusters(self):
7575
typedef = self._model_context.get_domain_typedef()
7676
name_token = self._aliases.get_name_token(location)
7777
for coherence_cluster in coherence_clusters:
78-
if typedef.is_system_coherence_cluster(coherence_cluster):
78+
if typedef.is_filtered(location, coherence_cluster):
7979
_logger.info('WLSDPLY-06322', typedef.get_domain_type(), coherence_cluster, class_name=_class_name,
8080
method_name=_method_name)
8181
else:

0 commit comments

Comments
 (0)