Skip to content

Commit 4eda897

Browse files
committed
Merge branch 'validate-log-fixes' into 'main'
Avoid logging credentials, remove FINE/FINER validate logger, clean up logging See merge request weblogic-cloud/weblogic-deploy-tooling!1528
2 parents dfe47f8 + e50a67e commit 4eda897

File tree

4 files changed

+30
-84
lines changed

4 files changed

+30
-84
lines changed

core/src/main/python/update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def __update_online(model, model_context, aliases):
138138
try:
139139

140140
if model_context.is_remote():
141-
model_validator = Validator(model_context, aliases, logger=__logger, wlst_mode=WlstModes.ONLINE)
141+
model_validator = Validator(model_context, aliases, wlst_mode=WlstModes.ONLINE)
142142
model_validator.validate_in_tool_mode(model.get_model(), None,
143143
model_context.get_archive_file_name())
144144

core/src/main/python/validate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def __perform_model_file_validation(model_file_name, model_context):
119119
try:
120120
wlst_mode = model_context.get_target_wlst_mode()
121121
aliases = Aliases(model_context=model_context, wlst_mode=wlst_mode, exception_type=ExceptionType.VALIDATE)
122-
model_validator = Validator(model_context, aliases, logger=__logger)
122+
model_validator = Validator(model_context, aliases)
123123
variable_map = model_validator.load_variables(model_context.get_variable_file())
124124
model_dictionary = cla_helper.merge_model_files(model_file_name, variable_map)
125125

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

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
2323
from wlsdeploy.tool.validate import validation_utils
2424
from wlsdeploy.tool.validate.crd_sections_validator import CrdSectionsValidator
25-
from wlsdeploy.tool.validate.validator_logger import ValidatorLogger
2625
from wlsdeploy.util import dictionary_utils
2726
from wlsdeploy.util import model
2827
import wlsdeploy.util.unicode_helper as str_helper
@@ -40,8 +39,7 @@
4039
from wlsdeploy.aliases.model_constants import WLS_ROLES
4140

4241
_class_name = 'Validator'
43-
_logger = ValidatorLogger('wlsdeploy.validate')
44-
_info_logger = PlatformLogger('wlsdeploy.validate')
42+
_logger = PlatformLogger('wlsdeploy.validate')
4543
_ModelNodeTypes = Enum(['FOLDER_TYPE', 'NAME_TYPE', 'ATTRIBUTE', 'ARTIFICIAL_TYPE'])
4644
_ValidationModes = Enum(['STANDALONE', 'TOOL'])
4745
_ROOT_LEVEL_VALIDATION_AREA = validation_utils.format_message('WLSDPLY-05000')
@@ -60,24 +58,18 @@ class Validator(object):
6058
ValidationStatus = Enum(['VALID', 'INFOS_VALID', 'WARNINGS_INVALID', 'INVALID'])
6159
ReturnCode = Enum(['PROCEED', 'STOP'])
6260

63-
def __init__(self, model_context, aliases, logger=None, wlst_mode=None, validate_crd_sections=True):
61+
def __init__(self, model_context, aliases, wlst_mode=None, validate_crd_sections=True):
6462
"""
6563
Create a validator instance.
6664
:param model_context: used to get command-line options
6765
:param aliases: used to validate folders, attributes. also determines exception type
68-
:param logger: alternate logger to use
6966
:param wlst_mode: online or offline mode
7067
:param validate_crd_sections: True if CRD sections (such as kubernetes) should be validated
7168
"""
7269
self._model_context = model_context
7370
self._validate_configuration = model_context.get_validate_configuration()
7471

75-
if logger is None:
76-
# No logger specified, so use the one declared at the module level
77-
self._logger = _logger
78-
else:
79-
self._logger = logger
80-
72+
self._logger = _logger
8173
self._validation_mode = None
8274
self._variable_properties = {}
8375
self._wls_helper = WebLogicHelper(self._logger)
@@ -124,7 +116,6 @@ def validate_in_standalone_mode(self, model_dict, variable_map, archive_file_nam
124116
# If standalone, log file will not be passed, so get a new logger with correct mode type
125117
self._validation_mode = _ValidationModes.STANDALONE
126118
return_code = Validator.ReturnCode.STOP
127-
self._logger = ValidatorLogger(self._logger.get_name(), _ValidationModes.from_value(self._validation_mode))
128119
self._logger.entering(archive_file_name, class_name=_class_name, method_name=_method_name)
129120

130121
# We need to make a deep copy of model_dict here, to ensure it's
@@ -467,15 +458,15 @@ def __validate_section_folder(self, model_node, validation_location):
467458
validation_location.add_name_token(path_token, '%s-0' % path_token)
468459

469460
model_folder_path = self._aliases.get_model_folder_path(validation_location)
470-
self._logger.finest('1 model_folder_path={0}', model_folder_path,
461+
self._logger.finest('model_folder_path={0}', model_folder_path,
471462
class_name=_class_name, method_name=_method_name)
472463

473464
if not isinstance(model_node, dict):
474465
self._logger.severe('WLSDPLY-05038', model_folder_path, class_name=_class_name, method_name=_method_name)
475466
return
476467

477468
if self._aliases.supports_multiple_mbean_instances(validation_location):
478-
self._logger.finer('2 model_node_type={0}',
469+
self._logger.finer('model_node_type={0}',
479470
_ModelNodeTypes.from_value(_ModelNodeTypes.NAME_TYPE),
480471
class_name=_class_name, method_name=_method_name)
481472

@@ -484,7 +475,7 @@ def __validate_section_folder(self, model_node, validation_location):
484475
if variables.has_variables(name):
485476
expanded_name = self.__validate_variable_substitution(name, model_folder_path)
486477

487-
self._logger.finest('2 expanded_name={0}', expanded_name,
478+
self._logger.finest('expanded_name={0}', expanded_name,
488479
class_name=_class_name, method_name=_method_name)
489480

490481
new_location = LocationContext(validation_location)
@@ -496,15 +487,15 @@ def __validate_section_folder(self, model_node, validation_location):
496487
if name_token is not None:
497488
new_location.add_name_token(name_token, expanded_name)
498489

499-
self._logger.finest('2 new_location={0}', str_helper.to_string(new_location),
490+
self._logger.finest('new_location={0}', str_helper.to_string(new_location),
500491
class_name=_class_name, method_name=_method_name)
501492

502493
value_dict = model_node[name]
503494

504495
self.__process_model_node(value_dict, new_location)
505496

506497
elif self._aliases.requires_artificial_type_subfolder_handling(validation_location):
507-
self._logger.finer('3 model_node_type={0}',
498+
self._logger.finer('model_node_type={0}',
508499
_ModelNodeTypes.from_value(_ModelNodeTypes.ARTIFICIAL_TYPE),
509500
class_name=_class_name, method_name=_method_name)
510501

@@ -513,32 +504,32 @@ def __validate_section_folder(self, model_node, validation_location):
513504
if variables.has_variables(name):
514505
self._report_unsupported_variable_usage(name, model_folder_path)
515506

516-
self._logger.finest('3 expanded_name={0}', expanded_name,
507+
self._logger.finest('expanded_name={0}', expanded_name,
517508
class_name=_class_name, method_name=_method_name)
518509

519510
new_location = LocationContext(validation_location)
520511

521512
name_token = self._aliases.get_name_token(new_location)
522-
self._logger.finest('3 name_token={0}', name_token,
513+
self._logger.finest('name_token={0}', name_token,
523514
class_name=_class_name, method_name=_method_name)
524515

525516
if name_token is not None:
526517
new_location.add_name_token(name_token, expanded_name)
527518

528-
self._logger.finest('3 new_location={0}', new_location,
519+
self._logger.finest('new_location={0}', new_location,
529520
class_name=_class_name, method_name=_method_name)
530521

531522
value_dict = model_node[name]
532523

533524
self.__process_model_node(value_dict, new_location)
534525

535526
else:
536-
self._logger.finer('4 model_node_type={0}',
527+
self._logger.finer('model_node_type={0}',
537528
_ModelNodeTypes.from_value(_ModelNodeTypes.FOLDER_TYPE),
538529
class_name=_class_name, method_name=_method_name)
539530

540531
name_token = self._aliases.get_name_token(validation_location)
541-
self._logger.finest('4 name_token={0}', name_token,
532+
self._logger.finest('name_token={0}', name_token,
542533
class_name=_class_name, method_name=_method_name)
543534

544535
if name_token is not None:
@@ -547,10 +538,10 @@ def __validate_section_folder(self, model_node, validation_location):
547538
if name is None:
548539
name = '%s-0' % name_token
549540

550-
self._logger.finest('4 name={0}', name,
541+
self._logger.finest('name={0}', name,
551542
class_name=_class_name, method_name=_method_name)
552543
validation_location.add_name_token(name_token, name)
553-
self._logger.finest('4 validation_location={0}', validation_location,
544+
self._logger.finest('validation_location={0}', validation_location,
554545
class_name=_class_name, method_name=_method_name)
555546

556547
self.__process_model_node(model_node, validation_location)
@@ -567,34 +558,30 @@ def __process_model_node(self, model_node, validation_location):
567558
valid_folder_keys = self._aliases.get_model_subfolder_names(validation_location)
568559
valid_attr_infos = self._aliases.get_model_attribute_names_and_types(validation_location)
569560

570-
self._logger.finest('5 model_node={0}', str_helper.to_string(model_node),
571-
class_name=_class_name, method_name=_method_name)
572-
self._logger.finest('5 aliases.get_model_subfolder_names(validation_location) returned: {0}',
561+
self._logger.finest('aliases.get_model_subfolder_names(validation_location) returned: {0}',
573562
str_helper.to_string(valid_folder_keys),
574563
class_name=_class_name, method_name=_method_name)
575-
self._logger.finest('5 aliases.get_model_attribute_names_and_types(validation_location) returned: {0}',
564+
self._logger.finest('aliases.get_model_attribute_names_and_types(validation_location) returned: {0}',
576565
str_helper.to_string(valid_attr_infos),
577566
class_name=_class_name, method_name=_method_name)
578-
self._logger.finest('5 model_folder_path={0}', model_folder_path, class_name=_class_name,
567+
self._logger.finest('model_folder_path={0}', model_folder_path, class_name=_class_name,
579568
method_name=_method_name)
580569

581570
for key, value in model_node.iteritems():
582571
if variables.has_variables(key):
583572
self._report_unsupported_variable_usage(key, model_folder_path)
584573

585-
self._logger.finer('5 key={0}', key,
586-
class_name=_class_name, method_name=_method_name)
587-
self._logger.finer('5 value={0}', value,
574+
self._logger.finer('key={0}', key,
588575
class_name=_class_name, method_name=_method_name)
589576

590577
if key in valid_folder_keys:
591578
new_location = LocationContext(validation_location).append_location(key)
592-
self._logger.finer('6 new_location={0}', new_location,
579+
self._logger.finer('new_location={0}', new_location,
593580
class_name=_class_name, method_name=_method_name)
594581

595582
if self._aliases.is_artificial_type_folder(new_location):
596583
# key is an ARTIFICIAL_TYPE folder
597-
self._logger.finest('6 is_artificial_type_folder=True',
584+
self._logger.finest('is_artificial_type_folder=True',
598585
class_name=_class_name, method_name=_method_name)
599586
valid_attr_infos = self._aliases.get_model_attribute_names_and_types(new_location)
600587

@@ -662,8 +649,7 @@ def __process_model_node(self, model_node, validation_location):
662649
def __validate_attributes(self, attributes_dict, valid_attr_infos, validation_location):
663650
_method_name = '__validate_attributes'
664651

665-
self._logger.finest('validation_location={0}, attributes_dict={0}', str_helper.to_string(validation_location),
666-
str_helper.to_string(attributes_dict),
652+
self._logger.finest('validation_location={0}', str_helper.to_string(validation_location),
667653
class_name=_class_name, method_name=_method_name)
668654

669655
model_folder_path = self._aliases.get_model_folder_path(validation_location)
@@ -722,7 +708,7 @@ def __validate_attribute(self, attribute_name, attribute_value, valid_attr_infos
722708
def __validate_properties(self, properties_dict, valid_prop_infos, validation_location):
723709
_method_name = '__validate_properties'
724710

725-
self._logger.entering(str_helper.to_string(properties_dict), str_helper.to_string(validation_location),
711+
self._logger.entering(str_helper.to_string(validation_location),
726712
class_name=_class_name, method_name=_method_name)
727713

728714
for property_name, property_value in properties_dict.iteritems():
@@ -735,7 +721,7 @@ def __validate_property(self, property_name, property_value, valid_prop_infos, m
735721

736722
_method_name = '__validate_property'
737723

738-
self._logger.entering(property_name, property_value, str_helper.to_string(valid_prop_infos),
724+
self._logger.entering(property_name, str_helper.to_string(valid_prop_infos),
739725
model_folder_path, class_name=_class_name, method_name=_method_name)
740726

741727
if variables.has_variables(property_name):
@@ -759,7 +745,7 @@ def __validate_property(self, property_name, property_value, valid_prop_infos, m
759745
def __validate_variable_substitution(self, tokenized_value, model_folder_path):
760746
_method_name = '__validate_variable_substitution'
761747

762-
self._logger.entering(tokenized_value, model_folder_path, class_name=_class_name, method_name=_method_name)
748+
self._logger.entering(model_folder_path, class_name=_class_name, method_name=_method_name)
763749
untokenized_value = tokenized_value
764750

765751
if not isinstance(untokenized_value, dict):
@@ -774,7 +760,7 @@ def __validate_variable_substitution(self, tokenized_value, model_folder_path):
774760
else:
775761
logger_method = self._logger.warning
776762
if self._validate_configuration.allow_unresolved_variable_tokens():
777-
logger_method = _info_logger.info
763+
logger_method = self._logger.info
778764

779765
variables_file_name = self._model_context.get_variable_file()
780766

@@ -831,7 +817,7 @@ def __validate_single_path_in_archive(self, path, attribute_name, model_folder_p
831817
# Otherwise, log SEVERE messages that will cause validation to fail.
832818
log_method = self._logger.severe
833819
if self._validate_configuration.allow_unresolved_archive_references():
834-
log_method = _info_logger.info
820+
log_method = self._logger.info
835821

836822
if self._archive_helper is not None:
837823
archive_has_file = self._archive_helper.contains_file_or_path(path)
@@ -956,5 +942,5 @@ def _log_version_invalid(self, message, method_name):
956942
"""
957943
log_method = self._logger.warning
958944
if self._validate_configuration.allow_version_invalid_attributes():
959-
log_method = _info_logger.info
945+
log_method = self._logger.info
960946
log_method('WLSDPLY-05027', message, class_name=_class_name, method_name=method_name)

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

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)