Skip to content

Commit aac160d

Browse files
authored
JIRA WDT-487 - Allow missing archive for prepareModel, extractDomainResource, also compareModel in tool mode (#763)
1 parent e73eb2d commit aac160d

File tree

5 files changed

+38
-19
lines changed

5 files changed

+38
-19
lines changed

core/src/main/python/compare_model.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def __process_args(args):
8686
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
8787
argument_map = cla_util.process_args(args, trailing_arg_count=2)
8888

89-
return ModelContext(_program_name, argument_map)
89+
model_context = ModelContext(_program_name, argument_map)
90+
model_context.set_ignore_missing_archive_entries(True)
91+
return model_context
9092

9193

9294
class ModelDiffer:
@@ -505,21 +507,14 @@ def compare(self):
505507

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

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

519515
# any variables should have been substituted at this point
520-
validate_variables = {}
521-
return_code = val_copy.validate_in_standalone_mode(model_dictionary, validate_variables,
522-
archive_file_name=None)
516+
return_code = val_copy.validate_in_tool_mode(model_dictionary, variables_file_name=None,
517+
archive_file_name=None)
523518

524519
if return_code == Validator.ReturnCode.STOP:
525520
_logger.severe('WLSDPLY-05705', model_file_name)
@@ -534,8 +529,8 @@ def compare(self):
534529
arg_map[CommandLineArgUtil.MODEL_FILE_SWITCH] = model_file_name
535530
model_context_copy = self.model_context.copy(arg_map)
536531
val_copy = Validator(model_context_copy, aliases, wlst_mode=WlstModes.OFFLINE)
537-
return_code = val_copy.validate_in_standalone_mode(model_dictionary, validate_variables,
538-
archive_file_name=None)
532+
return_code = val_copy.validate_in_tool_mode(model_dictionary, variables_file_name=None,
533+
archive_file_name=None)
539534

540535
if return_code == Validator.ReturnCode.STOP:
541536
_logger.severe('WLSDPLY-05705', model_file_name)

core/src/main/python/extract_resource.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def __process_args(args):
6666
cla_helper.validate_variable_file_exists(_program_name, argument_map)
6767
cla_helper.process_encryption_args(argument_map)
6868

69-
return model_context_helper.create_context(_program_name, argument_map)
69+
model_context = model_context_helper.create_context(_program_name, argument_map)
70+
model_context.set_ignore_missing_archive_entries(True)
71+
return model_context
7072

7173

7274
def __extract_resource(model, model_context, aliases):

core/src/main/python/prepare_model.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def __process_args(args):
8888

8989
target_configuration_helper.process_target_arguments(argument_map)
9090

91-
return ModelContext(_program_name, argument_map)
91+
model_context = ModelContext(_program_name, argument_map)
92+
model_context.set_ignore_missing_archive_entries(True)
93+
return model_context
9294

9395

9496
class PrepareModel:

core/src/main/python/wlsdeploy/tool/validate/validator.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,10 +825,12 @@ def __validate_single_path_in_archive(self, path, attribute_name, model_folder_p
825825
self._logger.severe('WLSDPLY-05024', attribute_name, model_folder_path, path,
826826
self._archive_file_name, class_name=_class_name, method_name=_method_name)
827827
else:
828-
# If running in standalone mode, and the archive was not supplied, simply
829-
# alert the user to the references but don't fail validation because of
830-
# the dangling references. In TOOL mode, this is an error.
831-
if self._validation_mode == _ValidationModes.STANDALONE:
828+
# If running in STANDALONE mode, or configured to ignore missing archive entries,
829+
# log an INFO message identifying missing entries, and allow validation to succeed.
830+
# In TOOL mode, unless the ignore flag is set, log a SEVERE message that will cause
831+
# validation to fail.
832+
ignore_missing_entries = self._model_context.get_ignore_missing_archive_entries()
833+
if self._validation_mode == _ValidationModes.STANDALONE or ignore_missing_entries:
832834
self._logger.info('WLSDPLY-05025', attribute_name, model_folder_path, path,
833835
class_name=_class_name, method_name=_method_name)
834836
elif self._validation_mode == _ValidationModes.TOOL:

core/src/main/python/wlsdeploy/util/model_context.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def __init__(self, program_name, arg_map):
9090
self._rcu_db_user = 'SYS'
9191
self._discard_current_edit = False
9292
self._model_config = None
93+
self._ignore_missing_archive_entries = False
9394

9495
self._trailing_args = []
9596

@@ -325,7 +326,10 @@ def __copy__(self):
325326
arg_map[CommandLineArgUtil.VARIABLE_KEYWORDS_FILE_SWITCH] = self._variable_keywords_file
326327
if self._variable_properties_file is not None:
327328
arg_map[CommandLineArgUtil.VARIABLE_PROPERTIES_FILE_SWITCH] = self._variable_properties_file
328-
return ModelContext(self._program_name, arg_map)
329+
330+
model_context = ModelContext(self._program_name, arg_map)
331+
model_context._ignore_missing_archive_entries = self._ignore_missing_archive_entries
332+
return model_context
329333

330334
def get_model_config(self):
331335
"""
@@ -696,6 +700,20 @@ def get_trailing_argument(self, index):
696700
"""
697701
return self._trailing_args[index]
698702

703+
def get_ignore_missing_archive_entries(self):
704+
"""
705+
Determine if the tool should ignore missing archive entries during validation.
706+
:return: True if the tool should ignore missing entries
707+
"""
708+
return self._ignore_missing_archive_entries
709+
710+
def set_ignore_missing_archive_entries(self, ignore):
711+
"""
712+
Configure the tool to ignore missing archive entries during validation.
713+
:param ignore: True if the tool should ignore missing entries, False otherwise
714+
"""
715+
self._ignore_missing_archive_entries = ignore
716+
699717
def is_wlst_online(self):
700718
"""
701719
Determine if the tool was started using WLST online mode

0 commit comments

Comments
 (0)