Skip to content

Commit 9f31bef

Browse files
committed
Log version-invalid fields at INFO for lax validation; improve logging for targeted injectors
1 parent bc83b36 commit 9f31bef

File tree

4 files changed

+44
-21
lines changed

4 files changed

+44
-21
lines changed

core/src/main/python/wlsdeploy/tool/util/variable_injector.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,17 @@ def inject_variables_keyword_file(self, append_option=None):
190190
_method_name = 'inject_variables_keyword_file'
191191
_logger.entering(class_name=_class_name, method_name=_method_name)
192192

193-
# check for file location overrides from command line
194-
195-
injector_file_override = self.__model_context.get_variable_injector_file()
196-
if injector_file_override is not None:
197-
variable_injector_location_file = injector_file_override
198-
_logger.info('WLSDPLY-19600', injector_file_override, class_name=_class_name, method_name=_method_name)
193+
if self.__model_context.is_targetted_config():
194+
# this is mostly used for logging, so put the target config path here
195+
variable_injector_location_file = self.__model_context.get_target_configuration_file()
199196
else:
200-
variable_injector_location_file = path_utils.find_config_path(VARIABLE_INJECTOR_FILE_NAME)
197+
# check for file location overrides from command line
198+
injector_file_override = self.__model_context.get_variable_injector_file()
199+
if injector_file_override is not None:
200+
variable_injector_location_file = injector_file_override
201+
_logger.info('WLSDPLY-19600', injector_file_override, class_name=_class_name, method_name=_method_name)
202+
else:
203+
variable_injector_location_file = path_utils.find_config_path(VARIABLE_INJECTOR_FILE_NAME)
201204

202205
keywords_file_override = self.__model_context.get_variable_keywords_file()
203206
if keywords_file_override is not None:

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

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from wlsdeploy.aliases.wlst_modes import WlstModes
1919
from wlsdeploy.exception.expection_types import ExceptionType
2020
from wlsdeploy.exception import exception_helper
21+
from wlsdeploy.logging.platform_logger import PlatformLogger
2122
from wlsdeploy.tool.create import wlsroles_helper
2223
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
2324
from wlsdeploy.tool.validate import validation_utils
@@ -40,6 +41,7 @@
4041

4142
_class_name = 'Validator'
4243
_logger = ValidatorLogger('wlsdeploy.validate')
44+
_info_logger = PlatformLogger('wlsdeploy.validate')
4345
_ModelNodeTypes = Enum(['FOLDER_TYPE', 'NAME_TYPE', 'ATTRIBUTE', 'ARTIFICIAL_TYPE'])
4446
_ValidationModes = Enum(['STANDALONE', 'TOOL'])
4547
_ROOT_LEVEL_VALIDATION_AREA = validation_utils.format_message('WLSDPLY-05000')
@@ -412,8 +414,7 @@ def __validate_model_section(self, model_section_key, model_dict, valid_section_
412414
result, message = self._aliases.is_valid_model_folder_name(validation_location,
413415
section_dict_key)
414416
if result == ValidationCodes.VERSION_INVALID:
415-
# key is a VERSION_INVALID folder
416-
self._logger.warning('WLSDPLY-05027', message, class_name=_class_name, method_name=_method_name)
417+
self._log_version_invalid(message, _method_name)
417418
elif result == ValidationCodes.INVALID:
418419
self._logger.severe('WLSDPLY-05026', section_dict_key, 'folder', model_folder_path,
419420
'%s' % ', '.join(valid_section_folders), class_name=_class_name,
@@ -423,8 +424,7 @@ def __validate_model_section(self, model_section_key, model_dict, valid_section_
423424
result, message = self._aliases.is_valid_model_attribute_name(attribute_location,
424425
section_dict_key)
425426
if result == ValidationCodes.VERSION_INVALID:
426-
self._logger.warning('WLSDPLY-05027', message, class_name=_class_name,
427-
method_name=_method_name)
427+
self._log_version_invalid(message, _method_name)
428428
elif result == ValidationCodes.INVALID:
429429
self._logger.severe('WLSDPLY-05029', section_dict_key, model_folder_path,
430430
'%s' % ', '.join(valid_attr_infos), class_name=_class_name,
@@ -440,7 +440,7 @@ def __validate_section_folder(self, model_node, validation_location):
440440

441441
result, message = self._aliases.is_version_valid_location(validation_location)
442442
if result == ValidationCodes.VERSION_INVALID:
443-
self._logger.warning('WLSDPLY-05027', message, class_name=_class_name, method_name=_method_name)
443+
self._log_version_invalid(message, _method_name)
444444
return
445445
elif result == ValidationCodes.INVALID:
446446
self._logger.severe('WLSDPLY-05027', message, class_name=_class_name, method_name=_method_name)
@@ -623,8 +623,7 @@ def __process_model_node(self, model_node, validation_location):
623623
# See if it's a version invalid folder
624624
result, message = self._aliases.is_valid_model_folder_name(validation_location, key)
625625
if result == ValidationCodes.VERSION_INVALID:
626-
# key is a VERSION_INVALID folder
627-
self._logger.warning('WLSDPLY-05027', message, class_name=_class_name, method_name=_method_name)
626+
self._log_version_invalid(message, _method_name)
628627
elif result == ValidationCodes.INVALID:
629628
# key is an INVALID folder
630629
self._logger.severe('WLSDPLY-05026', key, 'folder', model_folder_path,
@@ -638,8 +637,7 @@ def __process_model_node(self, model_node, validation_location):
638637
# See if it's a version invalid attribute
639638
result, message = self._aliases.is_valid_model_attribute_name(validation_location, key)
640639
if result == ValidationCodes.VERSION_INVALID:
641-
# key is a VERSION_INVALID attribute
642-
self._logger.warning('WLSDPLY-05027', message, class_name=_class_name, method_name=_method_name)
640+
self._log_version_invalid(message, _method_name)
643641
elif result == ValidationCodes.INVALID:
644642
# key is an INVALID attribute
645643
self._logger.severe('WLSDPLY-05029', key, model_folder_path,
@@ -695,7 +693,7 @@ def __validate_attribute(self, attribute_name, attribute_value, valid_attr_infos
695693
else:
696694
result, message = self._aliases.is_valid_model_attribute_name(validation_location, attribute_name)
697695
if result == ValidationCodes.VERSION_INVALID:
698-
self._logger.warning('WLSDPLY-05027', message, class_name=_class_name, method_name=_method_name)
696+
self._log_version_invalid(message, _method_name)
699697
elif result == ValidationCodes.INVALID:
700698
self._logger.severe('WLSDPLY-05029', attribute_name, model_folder_path,
701699
'%s' % ', '.join(valid_attr_infos), class_name=_class_name,
@@ -935,3 +933,18 @@ def _report_unsupported_variable_usage(self, tokenized_value, model_folder_path)
935933
for token in tokens:
936934
self._logger.severe('WLSDPLY-05030', model_folder_path, token,
937935
class_name=_class_name, method_name=_method_name)
936+
937+
def _log_version_invalid(self, message, method_name):
938+
"""
939+
Log a message indicating that an attribute is not valid for the current WLS version and WLST mode.
940+
Log INFO if validation method is "lax", otherwise log WARNING.
941+
"""
942+
if self._model_context.is_targetted_config():
943+
validation_method = self._model_context.get_target_configuration().get_validation_method()
944+
else:
945+
validation_method = self._model_context.get_validation_method()
946+
947+
log_method = self._logger.warning
948+
if validation_method == 'lax':
949+
log_method = _info_logger.info
950+
log_method('WLSDPLY-05027', message, class_name=_class_name, method_name=method_name)

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,7 @@ def get_target_configuration(self):
618618
configuration_dict = {}
619619

620620
if self._target:
621-
target_path = os.path.join('targets', self._target, 'target.json')
622-
target_configuration_file = path_utils.find_config_path(target_path)
621+
target_configuration_file = self.get_target_configuration_file()
623622
if os.path.exists(target_configuration_file):
624623
file_handle = open(target_configuration_file)
625624
configuration_dict = eval(file_handle.read())
@@ -628,6 +627,12 @@ def get_target_configuration(self):
628627

629628
return self._target_configuration
630629

630+
def get_target_configuration_file(self):
631+
if self._target:
632+
target_path = os.path.join('targets', self._target, 'target.json')
633+
return path_utils.find_config_path(target_path)
634+
return None
635+
631636
def get_target(self):
632637
return self._target
633638

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,8 +1558,7 @@ WLSDPLY-19529=Variable {0} was inserted into the model string {1} for attribute
15581558
WLSDPLY-19530=Segment was not found in attribute {0} value so entire variable value was replaced by {1}
15591559
WLSDPLY-19531=Invalid location {0} for variable injection into attribute {1} : {2}
15601560
WLSDPLY-19532=No model variable injector file {0}
1561-
WLSDPLY-19533=Will inject variable replacement strings into model using keyword directions found in model \
1562-
variable injector file {0}
1561+
WLSDPLY-19533=Will inject variable replacement strings into model using keyword directions found in file {0}
15631562
WLSDPLY-19534=Update existing variable file {0} with injected variables
15641563
WLSDPLY-19535=Create new variable file {0} for injected variables
15651564
WLSDPLY-19536=Append existing variable file {0} with injected variables
@@ -1634,6 +1633,9 @@ WLSDPLY-20029=Specified validation method to use was empty or null
16341633
WLSDPLY-20030=Specified validation method {0} is invalid, must be one of: {1}
16351634
WLSDPLY-20031={0} specified Variable File {1} is not a valid file: {2}
16361635
WLSDPLY-20032=No model specified and no model in archive, no validation performed
1636+
WLSDPLY-20033=Unsupported attribute {0} at location {1} removed from model
1637+
WLSDPLY-20034=Applying filter with ID "{0}"
1638+
WLSDPLY-20035=Applying filter with name "{0}"
16371639

16381640
# Common messages used for tool exit and clean-up
16391641
WLSDPLY-21000={0} Messages:

0 commit comments

Comments
 (0)