Skip to content

Commit 33d00b4

Browse files
Merge pull request #200 from oracle/remove-jrf-elements-during-discover
Remove JRF elements during discover
2 parents 144e847 + 557827c commit 33d00b4

File tree

9 files changed

+335
-72
lines changed

9 files changed

+335
-72
lines changed

core/src/main/python/discover.py

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from wlsdeploy.aliases.wlst_modes import WlstModes
3535
from wlsdeploy.exception import exception_helper
3636
from wlsdeploy.logging.platform_logger import PlatformLogger
37+
from wlsdeploy.tool.create.domain_typedef import DomainTypedef
3738
from wlsdeploy.tool.discover import discoverer
3839
from wlsdeploy.tool.discover.deployments_discoverer import DeploymentsDiscoverer
3940
from wlsdeploy.tool.discover.domain_info_discoverer import DomainInfoDiscoverer
@@ -43,6 +44,7 @@
4344
from wlsdeploy.tool.util import filter_helper
4445
from wlsdeploy.tool.util.variable_injector import VariableInjector
4546
from wlsdeploy.tool.validate.validator import Validator
47+
from wlsdeploy.util import dictionary_utils
4648
from wlsdeploy.util import getcreds
4749
from wlsdeploy.util import model_translator
4850
from wlsdeploy.util import tool_exit
@@ -85,6 +87,12 @@ def __process_args(args):
8587
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
8688
required_arg_map, optional_arg_map = cla_util.process_args(args)
8789

90+
domain_type = dictionary_utils.get_element(optional_arg_map, CommandLineArgUtil.DOMAIN_TYPE_SWITCH)
91+
if domain_type is None:
92+
domain_type = 'WLS'
93+
domain_typedef = DomainTypedef(_program_name, domain_type)
94+
optional_arg_map[CommandLineArgUtil.DOMAIN_TYPEDEF] = domain_typedef
95+
8896
__verify_required_args_present(required_arg_map)
8997
__wlst_mode = __process_online_args(optional_arg_map)
9098
__process_archive_filename_arg(required_arg_map)

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

+107
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class DomainTypedef(object):
2424
__domain_typedefs_location = os.path.join(os.environ.get('WLSDEPLOY_HOME'), 'lib', 'typedefs')
2525
__domain_typedef_extension = '.json'
2626

27+
__wild_card_suffix = '%%'
28+
__wild_card_suffix_len = len(__wild_card_suffix)
29+
2730
def __init__(self, program_name, domain_type):
2831
"""
2932
The DomainTypedef constructor.
@@ -61,6 +64,12 @@ def __init__(self, program_name, domain_type):
6164
self._paths_resolved = False
6265
self._model_context = None
6366
self._version_typedef_name = None
67+
68+
if 'system-elements' in self._domain_typedefs_dict:
69+
self._system_elements = self._domain_typedefs_dict['system-elements']
70+
else:
71+
self._system_elements = {}
72+
6473
return
6574

6675
def set_model_context(self, model_context):
@@ -110,6 +119,104 @@ def get_rcu_schemas(self):
110119
# resolution for create.py argument processing.
111120
return list(self._domain_typedef['rcuSchemas'])
112121

122+
def is_system_app(self, name):
123+
"""
124+
Determine if the specified name matches a WLS system application.
125+
:param name: the name to be checked
126+
:return: True if the name matches a system application, False otherwise
127+
"""
128+
return self._is_system_name(name, 'apps')
129+
130+
def is_system_coherence_cluster(self, name):
131+
"""
132+
Determine if the specified name matches a WLS system Coherence cluster.
133+
:param name: the name to be checked
134+
:return: True if the name matches a system Coherence cluster, False otherwise
135+
"""
136+
return self._is_system_name(name, 'coherence-clusters')
137+
138+
def is_system_datasource(self, name):
139+
"""
140+
Determine if the specified name matches a WLS system datasource.
141+
:param name: the name to be checked
142+
:return: True if the name matches a system datasource, False otherwise
143+
"""
144+
return self._is_system_name(name, 'datasources')
145+
146+
def is_system_file_store(self, name):
147+
"""
148+
Determine if the specified name matches a WLS system file store.
149+
:param name: the name to be checked
150+
:return: True if the name matches a system file store, False otherwise
151+
"""
152+
return self._is_system_name(name, 'file-stores')
153+
154+
def is_system_jms(self, name):
155+
"""
156+
Determine if the specified name matches a WLS system JMS resource.
157+
:param name: the name to be checked
158+
:return: True if the name matches a system JMS resource, False otherwise
159+
"""
160+
return self._is_system_name(name, 'jms')
161+
162+
def is_system_jms_server(self, name):
163+
"""
164+
Determine if the specified name matches a WLS system JMS server.
165+
:param name: the name to be checked
166+
:return: True if the name matches a system JMS server, False otherwise
167+
"""
168+
return self._is_system_name(name, 'jms-servers')
169+
170+
def is_system_shared_library(self, name):
171+
"""
172+
Determine if the specified name matches a WLS system shared library.
173+
:param name: the name to be checked
174+
:return: True if the name matches a system shared library, False otherwise
175+
"""
176+
return self._is_system_name(name, 'shared-libraries')
177+
178+
def is_system_shutdown_class(self, name):
179+
"""
180+
Determine if the specified name matches a WLS system shutdown class.
181+
:param name: the name to be checked
182+
:return: True if the name matches a system shutdown class, False otherwise
183+
"""
184+
return self._is_system_name(name, 'shutdown-classes')
185+
186+
def is_system_startup_class(self, name):
187+
"""
188+
Determine if the specified name matches a WLS system startup class.
189+
:param name: the name to be checked
190+
:return: True if the name matches a system startup class, False otherwise
191+
"""
192+
return self._is_system_name(name, 'startup-classes')
193+
194+
def is_system_wldf(self, name):
195+
"""
196+
Determine if the specified name matches a WLS system WLDF resource.
197+
:param name: the name to be checked
198+
:return: True if the name matches a system WLDF resource, False otherwise
199+
"""
200+
return self._is_system_name(name, 'wldf')
201+
202+
def _is_system_name(self, name, key):
203+
"""
204+
Determine if the specified name matches a WLS name of the specified type key.
205+
:param name: the name to be checked
206+
:param key: the key of the type to be checked against
207+
:return: True if the name matches a system name, False otherwise
208+
"""
209+
if key in self._system_elements:
210+
system_names = self._system_elements[key]
211+
for system_name in system_names:
212+
if system_name.endswith(self.__wild_card_suffix):
213+
prefix = system_name[0:0 - self.__wild_card_suffix_len]
214+
if name.startswith(prefix):
215+
return True
216+
elif system_name == name:
217+
return True
218+
return False
219+
113220
def __resolve_paths(self):
114221
"""
115222
Resolve any tokens in the template paths.

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

+13-9
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,21 @@ def get_coherence_clusters(self):
7474
coherence_clusters = self._find_names_in_folder(location)
7575
if coherence_clusters is not None:
7676
_logger.info('WLSDPLY-06311', len(coherence_clusters), class_name=_class_name, method_name=_method_name)
77+
typedef = self._model_context.get_domain_typedef()
7778
name_token = self._alias_helper.get_name_token(location)
7879
for coherence_cluster in coherence_clusters:
79-
_logger.info('WLSDPLY-06312', coherence_cluster, class_name=_class_name, method_name=_method_name)
80-
location.add_name_token(name_token, coherence_cluster)
81-
result[coherence_cluster] = OrderedDict()
82-
self._populate_model_parameters(result[coherence_cluster], location)
83-
model_subfolder_name, subfolder_result = self.get_coherence_cache_config(location)
84-
discoverer.add_to_model_if_not_empty(result[coherence_cluster], model_subfolder_name, subfolder_result)
85-
model_subfolder_name, subfolder_result = self.get_coherence_resource(location)
86-
discoverer.add_to_model_if_not_empty(result[coherence_cluster], model_subfolder_name, subfolder_result)
87-
location.remove_name_token(name_token)
80+
if typedef.is_system_coherence_cluster(coherence_cluster):
81+
_logger.info('WLSDPLY-06322', coherence_cluster, class_name=_class_name, method_name=_method_name)
82+
else:
83+
_logger.info('WLSDPLY-06312', coherence_cluster, class_name=_class_name, method_name=_method_name)
84+
location.add_name_token(name_token, coherence_cluster)
85+
result[coherence_cluster] = OrderedDict()
86+
self._populate_model_parameters(result[coherence_cluster], location)
87+
model_subfolder_name, subfolder_result = self.get_coherence_cache_config(location)
88+
discoverer.add_to_model_if_not_empty(result[coherence_cluster], model_subfolder_name, subfolder_result)
89+
model_subfolder_name, subfolder_result = self.get_coherence_resource(location)
90+
discoverer.add_to_model_if_not_empty(result[coherence_cluster], model_subfolder_name, subfolder_result)
91+
location.remove_name_token(name_token)
8892

8993
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
9094
return model_top_folder_name, result

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

+36-24
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,25 @@ def get_datasources(self):
8383
datasources = self._find_names_in_folder(location)
8484
if datasources is not None:
8585
_logger.info('WLSDPLY-06340', len(datasources), class_name=_class_name, method_name=_method_name)
86+
typedef = self._model_context.get_domain_typedef()
8687
name_token = self._alias_helper.get_name_token(location)
8788
for datasource in datasources:
88-
_logger.info('WLSDPLY-06341', datasource, class_name=_class_name, method_name=_method_name)
89-
result[datasource] = OrderedDict()
90-
location.add_name_token(name_token, datasource)
91-
self._populate_model_parameters(result[datasource], location)
89+
if typedef.is_system_datasource(datasource):
90+
_logger.info('WLSDPLY-06361', datasource, class_name=_class_name, method_name=_method_name)
91+
else:
92+
_logger.info('WLSDPLY-06341', datasource, class_name=_class_name, method_name=_method_name)
93+
result[datasource] = OrderedDict()
94+
location.add_name_token(name_token, datasource)
95+
self._populate_model_parameters(result[datasource], location)
9296

93-
location.append_location(model_second_folder)
94-
if self.wlst_cd(self._alias_helper.get_wlst_attributes_path(location), location):
95-
result[datasource][model_second_folder] = OrderedDict()
96-
resource_result = result[datasource][model_second_folder]
97-
self._populate_model_parameters(resource_result, location)
98-
self._discover_subfolders(resource_result, location)
99-
location.remove_name_token(name_token)
100-
location.pop_location()
97+
location.append_location(model_second_folder)
98+
if self.wlst_cd(self._alias_helper.get_wlst_attributes_path(location), location):
99+
result[datasource][model_second_folder] = OrderedDict()
100+
resource_result = result[datasource][model_second_folder]
101+
self._populate_model_parameters(resource_result, location)
102+
self._discover_subfolders(resource_result, location)
103+
location.remove_name_token(name_token)
104+
location.pop_location()
101105
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
102106
return model_top_folder_name, result
103107

@@ -167,14 +171,18 @@ def get_file_stores(self):
167171
file_stores = self._find_names_in_folder(location)
168172
if file_stores is not None:
169173
_logger.info('WLSDPLY-06346', len(file_stores), class_name=_class_name, method_name=_method_name)
174+
typedef = self._model_context.get_domain_typedef()
170175
name_token = self._alias_helper.get_name_token(location)
171176
for file_store in file_stores:
172-
_logger.info('WLSDPLY-06347', file_store, class_name=_class_name, method_name=_method_name)
173-
result[file_store] = OrderedDict()
174-
location.add_name_token(name_token, file_store)
175-
self._populate_model_parameters(result[file_store], location)
176-
self.archive_file_store_directory(file_store, result[file_store])
177-
location.remove_name_token(name_token)
177+
if typedef.is_system_file_store(file_store):
178+
_logger.info('WLSDPLY-06363', file_store, class_name=_class_name, method_name=_method_name)
179+
else:
180+
_logger.info('WLSDPLY-06347', file_store, class_name=_class_name, method_name=_method_name)
181+
result[file_store] = OrderedDict()
182+
location.add_name_token(name_token, file_store)
183+
self._populate_model_parameters(result[file_store], location)
184+
self.archive_file_store_directory(file_store, result[file_store])
185+
location.remove_name_token(name_token)
178186
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
179187
return model_top_folder_name, result
180188

@@ -297,14 +305,18 @@ def get_wldf_system_resources(self):
297305
wldf_resources = self._find_names_in_folder(location)
298306
if wldf_resources is not None:
299307
_logger.info('WLSDPLY-06357', len(wldf_resources), class_name=_class_name, method_name=_method_name)
308+
typedef = self._model_context.get_domain_typedef()
300309
name_token = self._alias_helper.get_name_token(location)
301310
for wldf_resource in wldf_resources:
302-
_logger.info('WLSDPLY-06358', wldf_resource, class_name=_class_name, method_name=_method_name)
303-
location.add_name_token(name_token, wldf_resource)
304-
result[wldf_resource] = OrderedDict()
305-
self._populate_model_parameters(result[wldf_resource], location)
306-
self._discover_subfolders(result[wldf_resource], location)
307-
location.remove_name_token(name_token)
311+
if typedef.is_system_wldf(wldf_resource):
312+
_logger.info('WLSDPLY-06362', wldf_resource, class_name=_class_name, method_name=_method_name)
313+
else:
314+
_logger.info('WLSDPLY-06358', wldf_resource, class_name=_class_name, method_name=_method_name)
315+
location.add_name_token(name_token, wldf_resource)
316+
result[wldf_resource] = OrderedDict()
317+
self._populate_model_parameters(result[wldf_resource], location)
318+
self._discover_subfolders(result[wldf_resource], location)
319+
location.remove_name_token(name_token)
308320
_logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
309321
return model_top_folder_name, result
310322

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

+23-14
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,19 @@ def get_shared_libraries(self):
6464
libraries = self._find_names_in_folder(location)
6565
if libraries:
6666
_logger.info('WLSDPLY-06381', len(libraries), class_name=_class_name, method_name=_method_name)
67+
typedef = self._model_context.get_domain_typedef()
6768
name_token = self._alias_helper.get_name_token(location)
6869
for library in libraries:
69-
_logger.info('WLSDPLY-06382', library, class_name=_class_name, method_name=_method_name)
70-
location.add_name_token(name_token, library)
71-
result[library] = OrderedDict()
72-
self._populate_model_parameters(result[library], location)
73-
self._add_shared_libraries_to_archive(library, result[library])
74-
self._discover_subfolders(result[library], location)
75-
location.remove_name_token(name_token)
70+
if typedef.is_system_shared_library(library):
71+
_logger.info('WLSDPLY-06401', library, class_name=_class_name, method_name=_method_name)
72+
else:
73+
_logger.info('WLSDPLY-06382', library, class_name=_class_name, method_name=_method_name)
74+
location.add_name_token(name_token, library)
75+
result[library] = OrderedDict()
76+
self._populate_model_parameters(result[library], location)
77+
self._add_shared_libraries_to_archive(library, result[library])
78+
self._discover_subfolders(result[library], location)
79+
location.remove_name_token(name_token)
7680

7781
_logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
7882
return model_top_folder_name, result
@@ -185,15 +189,20 @@ def get_applications(self):
185189
applications = self._find_names_in_folder(location)
186190
if applications:
187191
_logger.info('WLSDPLY-06391', len(applications), class_name=_class_name, method_name=_method_name)
192+
typedef = self._model_context.get_domain_typedef()
188193
name_token = self._alias_helper.get_name_token(location)
189194
for application in applications:
190-
_logger.info('WLSDPLY-06392', application, class_name=_class_name, method_name=_method_name)
191-
location.add_name_token(name_token, application)
192-
result[application] = OrderedDict()
193-
self._populate_model_parameters(result[application], location)
194-
self._add_application_to_archive(application, result[application])
195-
self._discover_subfolders(result[application], location)
196-
location.remove_name_token(name_token)
195+
if typedef.is_system_app(application):
196+
_logger.info('WLSDPLY-06400', application, class_name=_class_name, method_name=_method_name)
197+
else:
198+
_logger.info('WLSDPLY-06392', application, class_name=_class_name, method_name=_method_name)
199+
print(" application: " + str(application) + ": " + str(typedef.is_system_app(application)))
200+
location.add_name_token(name_token, application)
201+
result[application] = OrderedDict()
202+
self._populate_model_parameters(result[application], location)
203+
self._add_application_to_archive(application, result[application])
204+
self._discover_subfolders(result[application], location)
205+
location.remove_name_token(name_token)
197206

198207
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
199208
return model_top_folder_name, result

0 commit comments

Comments
 (0)