Skip to content

Commit ee5be80

Browse files
adding check for derived value and moving restart-related errors to warnings (#1222)
* adding check for derived value and moving restart-related errors to warnings * change test for default value * removing derived default check from the wrong location * adding back the corrected logic accounting for derived defaults Co-authored-by: Carolyn Rountree <[email protected]>
1 parent bb35384 commit ee5be80

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

core/src/main/python/wlsdeploy/aliases/aliases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,11 +1305,11 @@ def is_derived_default(self, location, model_attribute):
13051305
:param model_attribute: model name of attribute to check
13061306
:return: True if the default is derived
13071307
"""
1308-
_method_name = "get_derived_default"
1308+
_method_name = "is_derived_default"
13091309
self._logger.entering(model_attribute, class_name=self._class_name, method_name=_method_name)
13101310
result = False
13111311
try:
1312-
attribute_info = self._alias_entries.get_alias_attribute_entry_by_wlst_name(location, model_attribute)
1312+
attribute_info = self._alias_entries.get_alias_attribute_entry_by_model_name(location, model_attribute)
13131313
if attribute_info is not None and DERIVED_DEFAULT in attribute_info:
13141314
result = attribute_info[DERIVED_DEFAULT]
13151315
except AliasException, ae:

integration-tests/alias-test/verify/src/test/python/aliastest/verify/alias_helper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,5 @@ def get_preferred_model_type(self, location, model_name):
138138
def get_wlst_read_type(self, location, model_name):
139139
return self.__aliases.get_wlst_read_type(location, model_name)
140140

141+
def is_derived_default(self, location, model_name):
142+
return self.__aliases.is_derived_default(location, model_name)

integration-tests/alias-test/verify/src/test/python/aliastest/verify/verifier.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,12 +730,19 @@ def _is_valid_default_value(self, location, generated_attribute, generated_attri
730730
match = True
731731
model_name = None
732732
model_value = None
733-
# aliases will automatically return None for a None in value
733+
is_derived_default = False
734734
if generated_default is not None:
735735
try:
736+
# This code is sort of non-intuitive because the method was written for a different
737+
# purpose. This get_model_attribute_name_and_value() function compared the value
738+
# we pass in with the alias default (accounting for type conversion). If the value
739+
# passed in matches the alias default value, it returns None for model_value.
740+
# Otherwise, it returns the passed in value converted to the alias type, if necessary.
741+
#
736742
model_name, model_value = \
737743
self._alias_helper.get_model_attribute_name_and_value(location, generated_attribute,
738744
generated_default)
745+
is_derived_default = self._alias_helper.is_derived_default(location, model_name)
739746
except TypeError, te:
740747
self._add_error(location, ERROR_ATTRIBUTE_WRONG_DEFAULT_VALUE,
741748
message=te, attribute=generated_attribute)
@@ -747,8 +754,10 @@ def _is_valid_default_value(self, location, generated_attribute, generated_attri
747754
else:
748755
model_value = model_default_value
749756

750-
if match and model_value is not None:
751-
match = False
757+
# This if statement will be true if the default values do not match and the alias attribute
758+
# is not marked as a derived_default.
759+
#
760+
if match and model_value is not None and not is_derived_default:
752761
attr_type = type(generated_default)
753762
if CMO_TYPE in generated_attribute_info and \
754763
(generated_attribute_info[CMO_TYPE] == alias_constants.BOOLEAN or
@@ -799,7 +808,8 @@ def _is_valid_restart(self, location, generated_attribute, generated_attribute_i
799808
self._add_error(location, ERROR_ATTRIBUTE_NOT_RESTART, attribute=model_attribute_name)
800809
valid = False
801810
elif RESTART in generated_attribute_info and generated_attribute_info[RESTART] == 'true':
802-
self._add_error(location, ERROR_ATTRIBUTE_RESTART, attribute=generated_attribute)
811+
# TODO - temporary change to warning until we decide what to do about the restart attributes of the aliases.
812+
self._add_warning(location, ERROR_ATTRIBUTE_RESTART, attribute=generated_attribute)
803813
valid = False
804814

805815
_logger.exiting(result=verify_utils.bool_to_string(valid), class_name=CLASS_NAME, method_name=_method_name)

0 commit comments

Comments
 (0)