Skip to content

Remove JRF elements during discover #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions core/src/main/python/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from wlsdeploy.aliases.wlst_modes import WlstModes
from wlsdeploy.exception import exception_helper
from wlsdeploy.logging.platform_logger import PlatformLogger
from wlsdeploy.tool.create.domain_typedef import DomainTypedef
from wlsdeploy.tool.discover import discoverer
from wlsdeploy.tool.discover.deployments_discoverer import DeploymentsDiscoverer
from wlsdeploy.tool.discover.domain_info_discoverer import DomainInfoDiscoverer
Expand All @@ -43,6 +44,7 @@
from wlsdeploy.tool.util import filter_helper
from wlsdeploy.tool.util.variable_injector import VariableInjector
from wlsdeploy.tool.validate.validator import Validator
from wlsdeploy.util import dictionary_utils
from wlsdeploy.util import getcreds
from wlsdeploy.util import model_translator
from wlsdeploy.util import tool_exit
Expand Down Expand Up @@ -85,6 +87,12 @@ def __process_args(args):
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
required_arg_map, optional_arg_map = cla_util.process_args(args)

domain_type = dictionary_utils.get_element(optional_arg_map, CommandLineArgUtil.DOMAIN_TYPE_SWITCH)
if domain_type is None:
domain_type = 'WLS'
domain_typedef = DomainTypedef(_program_name, domain_type)
optional_arg_map[CommandLineArgUtil.DOMAIN_TYPEDEF] = domain_typedef

__verify_required_args_present(required_arg_map)
__wlst_mode = __process_online_args(optional_arg_map)
__process_archive_filename_arg(required_arg_map)
Expand Down
107 changes: 107 additions & 0 deletions core/src/main/python/wlsdeploy/tool/create/domain_typedef.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class DomainTypedef(object):
__domain_typedefs_location = os.path.join(os.environ.get('WLSDEPLOY_HOME'), 'lib', 'typedefs')
__domain_typedef_extension = '.json'

__wild_card_suffix = '%%'
__wild_card_suffix_len = len(__wild_card_suffix)

def __init__(self, program_name, domain_type):
"""
The DomainTypedef constructor.
Expand Down Expand Up @@ -61,6 +64,12 @@ def __init__(self, program_name, domain_type):
self._paths_resolved = False
self._model_context = None
self._version_typedef_name = None

if 'system-elements' in self._domain_typedefs_dict:
self._system_elements = self._domain_typedefs_dict['system-elements']
else:
self._system_elements = {}

return

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

def is_system_app(self, name):
"""
Determine if the specified name matches a WLS system application.
:param name: the name to be checked
:return: True if the name matches a system application, False otherwise
"""
return self._is_system_name(name, 'apps')

def is_system_coherence_cluster(self, name):
"""
Determine if the specified name matches a WLS system Coherence cluster.
:param name: the name to be checked
:return: True if the name matches a system Coherence cluster, False otherwise
"""
return self._is_system_name(name, 'coherence-clusters')

def is_system_datasource(self, name):
"""
Determine if the specified name matches a WLS system datasource.
:param name: the name to be checked
:return: True if the name matches a system datasource, False otherwise
"""
return self._is_system_name(name, 'datasources')

def is_system_file_store(self, name):
"""
Determine if the specified name matches a WLS system file store.
:param name: the name to be checked
:return: True if the name matches a system file store, False otherwise
"""
return self._is_system_name(name, 'file-stores')

def is_system_jms(self, name):
"""
Determine if the specified name matches a WLS system JMS resource.
:param name: the name to be checked
:return: True if the name matches a system JMS resource, False otherwise
"""
return self._is_system_name(name, 'jms')

def is_system_jms_server(self, name):
"""
Determine if the specified name matches a WLS system JMS server.
:param name: the name to be checked
:return: True if the name matches a system JMS server, False otherwise
"""
return self._is_system_name(name, 'jms-servers')

def is_system_shared_library(self, name):
"""
Determine if the specified name matches a WLS system shared library.
:param name: the name to be checked
:return: True if the name matches a system shared library, False otherwise
"""
return self._is_system_name(name, 'shared-libraries')

def is_system_shutdown_class(self, name):
"""
Determine if the specified name matches a WLS system shutdown class.
:param name: the name to be checked
:return: True if the name matches a system shutdown class, False otherwise
"""
return self._is_system_name(name, 'shutdown-classes')

def is_system_startup_class(self, name):
"""
Determine if the specified name matches a WLS system startup class.
:param name: the name to be checked
:return: True if the name matches a system startup class, False otherwise
"""
return self._is_system_name(name, 'startup-classes')

def is_system_wldf(self, name):
"""
Determine if the specified name matches a WLS system WLDF resource.
:param name: the name to be checked
:return: True if the name matches a system WLDF resource, False otherwise
"""
return self._is_system_name(name, 'wldf')

def _is_system_name(self, name, key):
"""
Determine if the specified name matches a WLS name of the specified type key.
:param name: the name to be checked
:param key: the key of the type to be checked against
:return: True if the name matches a system name, False otherwise
"""
if key in self._system_elements:
system_names = self._system_elements[key]
for system_name in system_names:
if system_name.endswith(self.__wild_card_suffix):
prefix = system_name[0:0 - self.__wild_card_suffix_len]
if name.startswith(prefix):
return True
elif system_name == name:
return True
return False

def __resolve_paths(self):
"""
Resolve any tokens in the template paths.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,21 @@ def get_coherence_clusters(self):
coherence_clusters = self._find_names_in_folder(location)
if coherence_clusters is not None:
_logger.info('WLSDPLY-06311', len(coherence_clusters), class_name=_class_name, method_name=_method_name)
typedef = self._model_context.get_domain_typedef()
name_token = self._alias_helper.get_name_token(location)
for coherence_cluster in coherence_clusters:
_logger.info('WLSDPLY-06312', coherence_cluster, class_name=_class_name, method_name=_method_name)
location.add_name_token(name_token, coherence_cluster)
result[coherence_cluster] = OrderedDict()
self._populate_model_parameters(result[coherence_cluster], location)
model_subfolder_name, subfolder_result = self.get_coherence_cache_config(location)
discoverer.add_to_model_if_not_empty(result[coherence_cluster], model_subfolder_name, subfolder_result)
model_subfolder_name, subfolder_result = self.get_coherence_resource(location)
discoverer.add_to_model_if_not_empty(result[coherence_cluster], model_subfolder_name, subfolder_result)
location.remove_name_token(name_token)
if typedef.is_system_coherence_cluster(coherence_cluster):
_logger.info('WLSDPLY-06322', coherence_cluster, class_name=_class_name, method_name=_method_name)
else:
_logger.info('WLSDPLY-06312', coherence_cluster, class_name=_class_name, method_name=_method_name)
location.add_name_token(name_token, coherence_cluster)
result[coherence_cluster] = OrderedDict()
self._populate_model_parameters(result[coherence_cluster], location)
model_subfolder_name, subfolder_result = self.get_coherence_cache_config(location)
discoverer.add_to_model_if_not_empty(result[coherence_cluster], model_subfolder_name, subfolder_result)
model_subfolder_name, subfolder_result = self.get_coherence_resource(location)
discoverer.add_to_model_if_not_empty(result[coherence_cluster], model_subfolder_name, subfolder_result)
location.remove_name_token(name_token)

_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
return model_top_folder_name, result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,25 @@ def get_datasources(self):
datasources = self._find_names_in_folder(location)
if datasources is not None:
_logger.info('WLSDPLY-06340', len(datasources), class_name=_class_name, method_name=_method_name)
typedef = self._model_context.get_domain_typedef()
name_token = self._alias_helper.get_name_token(location)
for datasource in datasources:
_logger.info('WLSDPLY-06341', datasource, class_name=_class_name, method_name=_method_name)
result[datasource] = OrderedDict()
location.add_name_token(name_token, datasource)
self._populate_model_parameters(result[datasource], location)
if typedef.is_system_datasource(datasource):
_logger.info('WLSDPLY-06361', datasource, class_name=_class_name, method_name=_method_name)
else:
_logger.info('WLSDPLY-06341', datasource, class_name=_class_name, method_name=_method_name)
result[datasource] = OrderedDict()
location.add_name_token(name_token, datasource)
self._populate_model_parameters(result[datasource], location)

location.append_location(model_second_folder)
if self.wlst_cd(self._alias_helper.get_wlst_attributes_path(location), location):
result[datasource][model_second_folder] = OrderedDict()
resource_result = result[datasource][model_second_folder]
self._populate_model_parameters(resource_result, location)
self._discover_subfolders(resource_result, location)
location.remove_name_token(name_token)
location.pop_location()
location.append_location(model_second_folder)
if self.wlst_cd(self._alias_helper.get_wlst_attributes_path(location), location):
result[datasource][model_second_folder] = OrderedDict()
resource_result = result[datasource][model_second_folder]
self._populate_model_parameters(resource_result, location)
self._discover_subfolders(resource_result, location)
location.remove_name_token(name_token)
location.pop_location()
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
return model_top_folder_name, result

Expand Down Expand Up @@ -167,14 +171,18 @@ def get_file_stores(self):
file_stores = self._find_names_in_folder(location)
if file_stores is not None:
_logger.info('WLSDPLY-06346', len(file_stores), class_name=_class_name, method_name=_method_name)
typedef = self._model_context.get_domain_typedef()
name_token = self._alias_helper.get_name_token(location)
for file_store in file_stores:
_logger.info('WLSDPLY-06347', file_store, class_name=_class_name, method_name=_method_name)
result[file_store] = OrderedDict()
location.add_name_token(name_token, file_store)
self._populate_model_parameters(result[file_store], location)
self.archive_file_store_directory(file_store, result[file_store])
location.remove_name_token(name_token)
if typedef.is_system_file_store(file_store):
_logger.info('WLSDPLY-06363', file_store, class_name=_class_name, method_name=_method_name)
else:
_logger.info('WLSDPLY-06347', file_store, class_name=_class_name, method_name=_method_name)
result[file_store] = OrderedDict()
location.add_name_token(name_token, file_store)
self._populate_model_parameters(result[file_store], location)
self.archive_file_store_directory(file_store, result[file_store])
location.remove_name_token(name_token)
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
return model_top_folder_name, result

Expand Down Expand Up @@ -297,14 +305,18 @@ def get_wldf_system_resources(self):
wldf_resources = self._find_names_in_folder(location)
if wldf_resources is not None:
_logger.info('WLSDPLY-06357', len(wldf_resources), class_name=_class_name, method_name=_method_name)
typedef = self._model_context.get_domain_typedef()
name_token = self._alias_helper.get_name_token(location)
for wldf_resource in wldf_resources:
_logger.info('WLSDPLY-06358', wldf_resource, class_name=_class_name, method_name=_method_name)
location.add_name_token(name_token, wldf_resource)
result[wldf_resource] = OrderedDict()
self._populate_model_parameters(result[wldf_resource], location)
self._discover_subfolders(result[wldf_resource], location)
location.remove_name_token(name_token)
if typedef.is_system_wldf(wldf_resource):
_logger.info('WLSDPLY-06362', wldf_resource, class_name=_class_name, method_name=_method_name)
else:
_logger.info('WLSDPLY-06358', wldf_resource, class_name=_class_name, method_name=_method_name)
location.add_name_token(name_token, wldf_resource)
result[wldf_resource] = OrderedDict()
self._populate_model_parameters(result[wldf_resource], location)
self._discover_subfolders(result[wldf_resource], location)
location.remove_name_token(name_token)
_logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
return model_top_folder_name, result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,19 @@ def get_shared_libraries(self):
libraries = self._find_names_in_folder(location)
if libraries:
_logger.info('WLSDPLY-06381', len(libraries), class_name=_class_name, method_name=_method_name)
typedef = self._model_context.get_domain_typedef()
name_token = self._alias_helper.get_name_token(location)
for library in libraries:
_logger.info('WLSDPLY-06382', library, class_name=_class_name, method_name=_method_name)
location.add_name_token(name_token, library)
result[library] = OrderedDict()
self._populate_model_parameters(result[library], location)
self._add_shared_libraries_to_archive(library, result[library])
self._discover_subfolders(result[library], location)
location.remove_name_token(name_token)
if typedef.is_system_shared_library(library):
_logger.info('WLSDPLY-06401', library, class_name=_class_name, method_name=_method_name)
else:
_logger.info('WLSDPLY-06382', library, class_name=_class_name, method_name=_method_name)
location.add_name_token(name_token, library)
result[library] = OrderedDict()
self._populate_model_parameters(result[library], location)
self._add_shared_libraries_to_archive(library, result[library])
self._discover_subfolders(result[library], location)
location.remove_name_token(name_token)

_logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
return model_top_folder_name, result
Expand Down Expand Up @@ -185,15 +189,20 @@ def get_applications(self):
applications = self._find_names_in_folder(location)
if applications:
_logger.info('WLSDPLY-06391', len(applications), class_name=_class_name, method_name=_method_name)
typedef = self._model_context.get_domain_typedef()
name_token = self._alias_helper.get_name_token(location)
for application in applications:
_logger.info('WLSDPLY-06392', application, class_name=_class_name, method_name=_method_name)
location.add_name_token(name_token, application)
result[application] = OrderedDict()
self._populate_model_parameters(result[application], location)
self._add_application_to_archive(application, result[application])
self._discover_subfolders(result[application], location)
location.remove_name_token(name_token)
if typedef.is_system_app(application):
_logger.info('WLSDPLY-06400', application, class_name=_class_name, method_name=_method_name)
else:
_logger.info('WLSDPLY-06392', application, class_name=_class_name, method_name=_method_name)
print(" application: " + str(application) + ": " + str(typedef.is_system_app(application)))
location.add_name_token(name_token, application)
result[application] = OrderedDict()
self._populate_model_parameters(result[application], location)
self._add_application_to_archive(application, result[application])
self._discover_subfolders(result[application], location)
location.remove_name_token(name_token)

_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
return model_top_folder_name, result
Expand Down
Loading