Skip to content

Allow missing archive for prepareModel, extractDomainResource #763

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 1 commit into from
Nov 2, 2020
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
19 changes: 7 additions & 12 deletions core/src/main/python/compare_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def __process_args(args):
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
argument_map = cla_util.process_args(args, trailing_arg_count=2)

return ModelContext(_program_name, argument_map)
model_context = ModelContext(_program_name, argument_map)
model_context.set_ignore_missing_archive_entries(True)
return model_context


class ModelDiffer:
Expand Down Expand Up @@ -505,21 +507,14 @@ def compare(self):

variables.substitute(model_dictionary, variable_map, self.model_context)

# Run this utility in stand-alone mode instead of tool mode,
# which has stricter checks for the tools.
# An archive is not used with the compare models and if the model
# references a file in an archive, the compareModel will fail if
# running in the stricter tool mode (even with lax).
#
arg_map = dict()
arg_map[CommandLineArgUtil.MODEL_FILE_SWITCH] = model_file_name
model_context_copy = self.model_context.copy(arg_map)
val_copy = Validator(model_context_copy, aliases, wlst_mode=WlstModes.OFFLINE)

# any variables should have been substituted at this point
validate_variables = {}
return_code = val_copy.validate_in_standalone_mode(model_dictionary, validate_variables,
archive_file_name=None)
return_code = val_copy.validate_in_tool_mode(model_dictionary, variables_file_name=None,
archive_file_name=None)

if return_code == Validator.ReturnCode.STOP:
_logger.severe('WLSDPLY-05705', model_file_name)
Expand All @@ -534,8 +529,8 @@ def compare(self):
arg_map[CommandLineArgUtil.MODEL_FILE_SWITCH] = model_file_name
model_context_copy = self.model_context.copy(arg_map)
val_copy = Validator(model_context_copy, aliases, wlst_mode=WlstModes.OFFLINE)
return_code = val_copy.validate_in_standalone_mode(model_dictionary, validate_variables,
archive_file_name=None)
return_code = val_copy.validate_in_tool_mode(model_dictionary, variables_file_name=None,
archive_file_name=None)

if return_code == Validator.ReturnCode.STOP:
_logger.severe('WLSDPLY-05705', model_file_name)
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/python/extract_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ def __process_args(args):
cla_helper.validate_variable_file_exists(_program_name, argument_map)
cla_helper.process_encryption_args(argument_map)

return model_context_helper.create_context(_program_name, argument_map)
model_context = model_context_helper.create_context(_program_name, argument_map)
model_context.set_ignore_missing_archive_entries(True)
return model_context


def __extract_resource(model, model_context, aliases):
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/python/prepare_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def __process_args(args):

target_configuration_helper.process_target_arguments(argument_map)

return ModelContext(_program_name, argument_map)
model_context = ModelContext(_program_name, argument_map)
model_context.set_ignore_missing_archive_entries(True)
return model_context


class PrepareModel:
Expand Down
10 changes: 6 additions & 4 deletions core/src/main/python/wlsdeploy/tool/validate/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,10 +825,12 @@ def __validate_single_path_in_archive(self, path, attribute_name, model_folder_p
self._logger.severe('WLSDPLY-05024', attribute_name, model_folder_path, path,
self._archive_file_name, class_name=_class_name, method_name=_method_name)
else:
# If running in standalone mode, and the archive was not supplied, simply
# alert the user to the references but don't fail validation because of
# the dangling references. In TOOL mode, this is an error.
if self._validation_mode == _ValidationModes.STANDALONE:
# If running in STANDALONE mode, or configured to ignore missing archive entries,
# log an INFO message identifying missing entries, and allow validation to succeed.
# In TOOL mode, unless the ignore flag is set, log a SEVERE message that will cause
# validation to fail.
ignore_missing_entries = self._model_context.get_ignore_missing_archive_entries()
if self._validation_mode == _ValidationModes.STANDALONE or ignore_missing_entries:
self._logger.info('WLSDPLY-05025', attribute_name, model_folder_path, path,
class_name=_class_name, method_name=_method_name)
elif self._validation_mode == _ValidationModes.TOOL:
Expand Down
20 changes: 19 additions & 1 deletion core/src/main/python/wlsdeploy/util/model_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def __init__(self, program_name, arg_map):
self._rcu_db_user = 'SYS'
self._discard_current_edit = False
self._model_config = None
self._ignore_missing_archive_entries = False

self._trailing_args = []

Expand Down Expand Up @@ -325,7 +326,10 @@ def __copy__(self):
arg_map[CommandLineArgUtil.VARIABLE_KEYWORDS_FILE_SWITCH] = self._variable_keywords_file
if self._variable_properties_file is not None:
arg_map[CommandLineArgUtil.VARIABLE_PROPERTIES_FILE_SWITCH] = self._variable_properties_file
return ModelContext(self._program_name, arg_map)

model_context = ModelContext(self._program_name, arg_map)
model_context._ignore_missing_archive_entries = self._ignore_missing_archive_entries
return model_context

def get_model_config(self):
"""
Expand Down Expand Up @@ -696,6 +700,20 @@ def get_trailing_argument(self, index):
"""
return self._trailing_args[index]

def get_ignore_missing_archive_entries(self):
"""
Determine if the tool should ignore missing archive entries during validation.
:return: True if the tool should ignore missing entries
"""
return self._ignore_missing_archive_entries

def set_ignore_missing_archive_entries(self, ignore):
"""
Configure the tool to ignore missing archive entries during validation.
:param ignore: True if the tool should ignore missing entries, False otherwise
"""
self._ignore_missing_archive_entries = ignore

def is_wlst_online(self):
"""
Determine if the tool was started using WLST online mode
Expand Down