Skip to content

Commit 901fc02

Browse files
committed
JIRA WDT-276 - Fix problems in WLDF alias file; Fix problems discovering lists with ObjectName elements
1 parent 006d854 commit 901fc02

File tree

4 files changed

+50
-45
lines changed

4 files changed

+50
-45
lines changed

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

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from wlsdeploy.exception import exception_helper
2929
from wlsdeploy.logging.platform_logger import PlatformLogger
3030

31+
from wlsdeploy.aliases.alias_constants import ALIAS_DELIMITED_TYPES
3132
from wlsdeploy.aliases.alias_constants import ATTRIBUTES
3233
from wlsdeploy.aliases.alias_constants import COMMA_DELIMITED_STRING
3334
from wlsdeploy.aliases.alias_constants import DELIMITED_STRING
@@ -661,17 +662,16 @@ def get_number_of_directories_to_strip(desired_path_type, actual_path_type):
661662
return result
662663

663664

664-
def convert_from_type(data_type, value, preferred=None, delimiter=None):
665+
def convert_to_model_type(data_type, value, delimiter=None):
665666
"""
666667
Convert WLST value to model representation type
667668
:param data_type: the target data type for the model
668669
:param value: value to be converted
669-
:param preferred: the preferred data type to be represented in the model (optional)
670670
:param delimiter: the delimiter for parsing the WLST representation of the data value (optional)
671671
:return: converted value
672672
"""
673673

674-
_method_name = 'convert_from_type'
674+
_method_name = 'convert_to_model_type'
675675
new_value = None
676676
if value is not None and data_type == 'password':
677677
# The password is an array of bytes coming back from the WLST get() method and only
@@ -682,10 +682,7 @@ def convert_from_type(data_type, value, preferred=None, delimiter=None):
682682
elif value is not None and isinstance(value, ObjectName):
683683
new_value = value.getKeyProperty('Name')
684684
else:
685-
model_type = data_type
686-
if preferred:
687-
model_type = preferred
688-
new_value = _jconvert_to_type(model_type, value, delimiter)
685+
new_value = _convert_value_to_model_type(data_type, value, delimiter)
689686

690687
return new_value
691688

@@ -731,8 +728,7 @@ def convert_to_type(data_type, value, subtype=None, delimiter=None):
731728
new_value = _create_mbean_array(new_value, subtype)
732729
elif data_type == LIST:
733730
new_value = list(new_value)
734-
elif data_type in (COMMA_DELIMITED_STRING, DELIMITED_STRING, SEMI_COLON_DELIMITED_STRING,
735-
SPACE_DELIMITED_STRING, PATH_SEPARATOR_DELIMITED_STRING):
731+
elif data_type in ALIAS_DELIMITED_TYPES:
736732
#
737733
# This code intentionally ignores the delimiter value passed in and computes it from the data type.
738734
# This is required to handle the special case where the value we read from WLST might have a
@@ -834,7 +830,7 @@ def get_dictionary_mode(alias_dict):
834830
###############################################################################
835831

836832

837-
def _jconvert_to_type(data_type, value, delimiter):
833+
def _convert_value_to_model_type(data_type, value, delimiter):
838834
"""
839835
Convert WLST value to model representation type.
840836
Assumes that empty values and password data types have been converted elsewhere.
@@ -843,7 +839,7 @@ def _jconvert_to_type(data_type, value, delimiter):
843839
:param delimiter: the delimiter for parsing the WLST representation of the data value (optional)
844840
:return: converted value
845841
"""
846-
_method_name = '_jconvert_to_type'
842+
_method_name = '_convert_value_to_model_type'
847843
try:
848844
converted = TypeUtils.convertToType(data_type, value, delimiter)
849845
except NumberFormatException, nfe:
@@ -861,19 +857,17 @@ def _jconvert_to_type(data_type, value, delimiter):
861857
# new_value = _jconvert_to_type(preferred, new_value, delimiter)
862858
elif data_type == LIST:
863859
if converted:
860+
# convert any object elements to str, especially ObjectNames
861+
converted = _create_array(converted, delimiter)
864862
converted = list(converted)
865-
elif data_type in (COMMA_DELIMITED_STRING, DELIMITED_STRING, SEMI_COLON_DELIMITED_STRING,
866-
SPACE_DELIMITED_STRING, PATH_SEPARATOR_DELIMITED_STRING):
867-
#
868-
# This code intentionally ignores the delimiter value passed in and computes it from the data type.
869-
# This is required to handle the special case where the value we read from WLST might have a
870-
# different delimiter than the model value. In this use case, the value passed into the method
871-
# is the WLST value delimiter and the data_type is the preferred_model_type, so we compute the
872-
# model delimiter from the data_type directly.
873-
#
874-
delimiter = compute_delimiter_from_data_type(data_type, converted)
875-
if delimiter and converted:
876-
converted = delimiter.join(converted)
863+
elif data_type in ALIAS_DELIMITED_TYPES:
864+
# Use the delimiter from the target type to join the elements of the list.
865+
# This can be different from the delimiter passed in, which was used to parse the WLST value.
866+
model_delimiter = compute_delimiter_from_data_type(data_type, converted)
867+
if model_delimiter and converted:
868+
# convert any object elements to str, especially ObjectNames
869+
converted = _create_array(converted, model_delimiter)
870+
converted = model_delimiter.join(converted)
877871
except TypeError, te:
878872
ex = exception_helper.create_alias_exception('WLSDPLY-08021', value, data_type, delimiter, str(te))
879873
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -896,46 +896,51 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst
896896
data_type, preferred_type, delimiter = \
897897
alias_utils.compute_read_data_type_for_wlst_and_delimiter_from_attribute_info(attribute_info,
898898
wlst_attribute_value)
899+
model_type = data_type
900+
if preferred_type:
901+
model_type = preferred_type
902+
903+
converted_value = alias_utils.convert_to_model_type(model_type, wlst_attribute_value, delimiter=delimiter)
899904

900-
converted_value = alias_utils.convert_from_type(data_type, wlst_attribute_value, delimiter=delimiter,
901-
preferred=preferred_type)
902905
model_attribute_name = attribute_info[MODEL_NAME]
903906
default_value = attribute_info[VALUE][DEFAULT]
904-
if preferred_type:
905-
data_type = preferred_type
906-
# never use anything but model default delimiter
907-
delimiter = MODEL_LIST_DELIMITER
907+
908908
#
909909
# The logic below to compare the str() representation of the converted value and the default value
910910
# only works for lists/maps if both the converted value and the default value are the same data type...
911911
#
912-
if (data_type in ALIAS_LIST_TYPES or data_type in ALIAS_MAP_TYPES) \
912+
if (model_type in ALIAS_LIST_TYPES or model_type in ALIAS_MAP_TYPES) \
913913
and not (default_value == '[]' or default_value == 'None'):
914-
default_value = alias_utils.convert_to_type(data_type, default_value, delimiter=delimiter)
914+
# always the model delimiter
915+
default_value = alias_utils.convert_to_type(model_type, default_value, delimiter=MODEL_LIST_DELIMITER)
915916

916-
if data_type == 'password':
917+
if model_type == 'password':
917918
if string_utils.is_empty(wlst_attribute_value) or converted_value == default_value:
918919
model_attribute_value = None
919920
else:
920921
model_attribute_value = PASSWORD_TOKEN
921-
elif data_type == 'boolean':
922+
923+
elif model_type == 'boolean':
922924
wlst_val = alias_utils.convert_boolean(converted_value)
923925
default_val = alias_utils.convert_boolean(default_value)
924926
if wlst_val == default_val:
925927
model_attribute_value = None
926928
else:
927929
model_attribute_value = converted_value
928-
elif (data_type in ALIAS_LIST_TYPES or data_type in ALIAS_MAP_TYPES) and \
930+
931+
elif (model_type in ALIAS_LIST_TYPES or data_type in ALIAS_MAP_TYPES) and \
929932
(converted_value is None or len(converted_value) == 0):
930933
if default_value == '[]' or default_value == 'None':
931934
model_attribute_value = None
935+
932936
elif str(converted_value) != str(default_value):
933937
if _strings_are_empty(converted_value, default_value):
934938
model_attribute_value = None
935939
else:
936940
model_attribute_value = converted_value
937941
if self._model_context and USES_PATH_TOKENS in attribute_info:
938942
model_attribute_value = self._model_context.tokenize_path(model_attribute_value)
943+
939944
self._logger.exiting(class_name=self._class_name, method_name=_method_name,
940945
result={model_attribute_name: model_attribute_value})
941946
return model_attribute_name, model_attribute_value

core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/WLDFSystemResource.json

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"folders" : {
1010
"Harvester": {
1111
"wlst_type": "Harvester",
12+
"child_folders_type": "single_unpredictable",
13+
"default_name_value": "${NO_NAME_0:%WLDFRESOURCE%}",
1214
"folders": {
1315
"HarvestedType": {
1416
"wlst_type": "HarvestedType${:s}",
@@ -23,7 +25,7 @@
2325
},
2426
"wlst_attributes_path": "WP001",
2527
"wlst_paths": {
26-
"WP001": "/WLDFSystemResource${:s}/%WLDFRESOURCE%/WLDFResource/%WLDFRESOURCE%/Harvester/${NO_NAME_0:%WLDFRESOURCE%}/HarvestedType${:s}/%HARVESTEDTYPE%"
28+
"WP001": "/WLDFSystemResource${:s}/%WLDFRESOURCE%/WLDFResource/%WLDFRESOURCE%/Harvester/%HARVESTER%/HarvestedType${:s}/%HARVESTEDTYPE%"
2729
}
2830
}
2931
},
@@ -33,11 +35,13 @@
3335
},
3436
"wlst_attributes_path": "WP001",
3537
"wlst_paths": {
36-
"WP001": "/WLDFSystemResource${:s}/%WLDFRESOURCE%/WLDFResource/%WLDFRESOURCE%/Harvester/${NO_NAME_0:%WLDFRESOURCE%}"
38+
"WP001": "/WLDFSystemResource${:s}/%WLDFRESOURCE%/WLDFResource/%WLDFRESOURCE%/Harvester/%HARVESTER%"
3739
}
3840
},
3941
"Instrumentation": {
4042
"wlst_type": "Instrumentation",
43+
"child_folders_type": "single_unpredictable",
44+
"default_name_value": "${NO_NAME_0:%WLDFRESOURCE%}",
4145
"folders": {
4246
"WLDFInstrumentationMonitor": {
4347
"wlst_type": "WLDFInstrumentationMonitor${:s}",
@@ -53,11 +57,11 @@
5357
"Include": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Include${:s}", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "delimited_string", "get_method": "LSA" } ],
5458
"LocationType": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "LocationType", "wlst_path": "WP001", "value": {"default": "${None:before}" }, "wlst_type": "string" } ],
5559
"Pointcut": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Pointcut", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
56-
"Properties": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Properties", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "delimited_string[semicolon]" } ]
60+
"Properties": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Properties", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "delimited_string[semicolon]", "preferred_model_type": "delimited_string" } ]
5761
},
5862
"wlst_attributes_path": "WP001",
5963
"wlst_paths": {
60-
"WP001": "/WLDFSystemResource${:s}/%WLDFRESOURCE%/WLDFResource/%WLDFRESOURCE%/Instrumentation/${NO_NAME_0:%WLDFRESOURCE%}/WLDFInstrumentationMonitor${:s}/%INSTRUMENTATIONMONITOR%"
64+
"WP001": "/WLDFSystemResource${:s}/%WLDFRESOURCE%/WLDFResource/%WLDFRESOURCE%/Instrumentation/%INSTRUMENTATION%/WLDFInstrumentationMonitor${:s}/%INSTRUMENTATIONMONITOR%"
6165
}
6266
}
6367
},
@@ -68,7 +72,7 @@
6872
},
6973
"wlst_attributes_path": "WP001",
7074
"wlst_paths": {
71-
"WP001": "/WLDFSystemResource${:s}/%WLDFRESOURCE%/WLDFResource/%WLDFRESOURCE%/Instrumentation/${NO_NAME_0:%WLDFRESOURCE%}"
75+
"WP001": "/WLDFSystemResource${:s}/%WLDFRESOURCE%/WLDFResource/%WLDFRESOURCE%/Instrumentation/%INSTRUMENTATION%"
7276
}
7377
},
7478
"WatchNotification": {
@@ -276,6 +280,8 @@
276280
"folders": {
277281
"Schedule": {
278282
"wlst_type": "Schedule",
283+
"child_folders_type": "single_unpredictable",
284+
"default_name_value": "${NO_NAME_0:%WATCH%}",
279285
"version": "[12.2.1,)",
280286
"folders": {},
281287
"attributes": {
@@ -291,7 +297,7 @@
291297
},
292298
"wlst_attributes_path": "WP001",
293299
"wlst_paths": {
294-
"WP001": "/WLDFSystemResource${:s}/%WLDFRESOURCE%/WLDFResource/%WLDFRESOURCE%/WatchNotification/%WATCHNOTIFICATION%/Watch${:es}/%WATCH%/Schedule/${NO_NAME_0:%WATCH%}"
300+
"WP001": "/WLDFSystemResource${:s}/%WLDFRESOURCE%/WLDFResource/%WLDFRESOURCE%/WatchNotification/%WATCHNOTIFICATION%/Watch${:es}/%WATCH%/Schedule/%SCHEDULE%"
295301
}
296302
}
297303
},
@@ -300,8 +306,8 @@
300306
"AlarmType": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "AlarmType", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
301307
"Enabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Enabled", "wlst_path": "WP001", "value": {"default": "true" }, "wlst_type": "boolean" } ],
302308
"ExpressionLanguage": [ {"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "ExpressionLanguage", "wlst_path": "WP001", "value": {"default": "${None:WLDF}" }, "wlst_type": "string" } ],
303-
"Notification": [ {"version": "[10,)", "wlst_mode": "offline", "wlst_name": "Notification", "wlst_path": "WP001", "value": {"default": "${None:[]}" }, "wlst_type": "jarray", "preferred_model_type": "delimited_string[semicolon]", "get_method": "LSA", "set_method": "MBEAN.set_wldf_action_mbeans" },
304-
{"version": "[10,)", "wlst_mode": "online", "wlst_name": "Notifications", "wlst_path": "WP001", "value": {"default": "${None:[]}" }, "wlst_type": "jarray", "get_method": "GET", "preferred_model_type": "delimited_string[semicolon]", "set_method": "MBEAN.set_wldf_action_mbeans" } ],
309+
"Notification": [ {"version": "[10,)", "wlst_mode": "offline", "wlst_name": "Notification", "wlst_path": "WP001", "value": {"default": "${None:[]}" }, "wlst_type": "jarray", "get_method": "LSA", "wlst_read_type": "delimited_string[comma]", "preferred_model_type": "delimited_string", "set_method": "MBEAN.set_wldf_action_mbeans" },
310+
{"version": "[10,)", "wlst_mode": "online", "wlst_name": "Notifications", "wlst_path": "WP001", "value": {"default": "${None:[]}" }, "wlst_type": "jarray", "get_method": "GET", "preferred_model_type": "delimited_string", "set_method": "MBEAN.set_wldf_action_mbeans" } ],
305311
"RuleExpression": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RuleExpression", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
306312
"RuleType": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RuleType", "wlst_path": "WP001", "value": {"default": "${None:Harvester}"}, "wlst_type": "string" } ],
307313
"Severity": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Severity", "wlst_path": "WP001", "value": {"default": "${None:Notice}" }, "wlst_type": "string" } ]
@@ -343,8 +349,8 @@
343349
},
344350
"wlst_attributes_path": "WP001",
345351
"wlst_paths": {
346-
"WP001": "/WLDFSystemResource${:s}/%WLDFRESOURC/SubDeployment${:s}/%SUBDEPLOYMENT%",
347-
"WP002": "/WLDFSystemResource${:s}/%WLDFRESOURC/SubDeployment${:s}/%SUBDEPLOYMENT%/Targets"
352+
"WP001": "/WLDFSystemResource${:s}/%WLDFRESOURCE%/SubDeployment${:s}/%SUBDEPLOYMENT%",
353+
"WP002": "/WLDFSystemResource${:s}/%WLDFRESOURCE%/SubDeployment${:s}/%SUBDEPLOYMENT%/Targets"
348354
}
349355
}
350356
},

core/src/test/python/alias_utils_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def testWindowsPathSeparators(self):
110110

111111
def testDelimitedListToList(self):
112112
value = 'one;two;three'
113-
actual = alias_utils.convert_from_type("invalid", value, preferred='list', delimiter=';')
113+
actual = alias_utils.convert_to_model_type("list", value, delimiter=';')
114114
expected = ['one', 'two', 'three']
115115
lists_equal, message = self.__lists_are_equal(actual, expected)
116116
self.assertEqual(lists_equal, True, message)

0 commit comments

Comments
 (0)