Skip to content

Commit 8114227

Browse files
Wdt alias integration test methods (#706)
* WDT alias test readd missing methods to aliases * WDT alias test readd missing methods to aliases * Wrap methods in try clause for aliases
1 parent 6013c75 commit 8114227

File tree

2 files changed

+71
-4
lines changed

2 files changed

+71
-4
lines changed

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

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55
from java.lang import String
@@ -40,6 +40,7 @@
4040
from wlsdeploy.aliases.alias_constants import USES_PATH_TOKENS
4141
from wlsdeploy.aliases.alias_constants import VALUE
4242
from wlsdeploy.aliases.alias_constants import WLST_NAME
43+
from wlsdeploy.aliases.alias_constants import WLST_READ_TYPE
4344
from wlsdeploy.aliases.alias_constants import WLST_TYPE
4445
from wlsdeploy.aliases.alias_entries import AliasEntries
4546
from wlsdeploy.aliases.model_constants import MODEL_LIST_DELIMITER
@@ -503,8 +504,8 @@ def get_wlst_attribute_name_and_value(self, location, model_attribute_name, mode
503504
delimiter=MODEL_LIST_DELIMITER)
504505

505506
_read_type, read_delimiter = \
506-
alias_utils.compute_read_data_type_and_delimiter_from_attribute_info(attribute_info,
507-
existing_wlst_value)
507+
alias_utils.compute_read_data_type_and_delimiter_from_attribute_info(
508+
attribute_info, existing_wlst_value)
508509
existing_val = alias_utils.convert_to_type(LIST, existing_wlst_value,
509510
delimiter=read_delimiter)
510511
merged_value = alias_utils.merge_model_and_existing_lists(model_val, existing_val)
@@ -1112,6 +1113,25 @@ def is_valid_model_attribute_name(self, location, model_attribute_name):
11121113
self._raise_exception(ae, _method_name, 'WLSDPLY-19031', model_attribute_name, location.get_folder_path(),
11131114
ae.getLocalizedMessage())
11141115

1116+
def get_model_attribute_type(self, location, model_attribute_name):
1117+
"""
1118+
Get the wlst_type for the model attribute name at the specified location
1119+
:param location:
1120+
:param model_attribute_name:
1121+
:return: WLST attribute type
1122+
"""
1123+
_method_name = 'get_model_attribute_type'
1124+
wlst_type = None
1125+
try:
1126+
attribute_info = self._alias_entries.get_alias_attribute_entry_by_model_name(location, model_attribute_name)
1127+
if attribute_info is not None:
1128+
wlst_type = attribute_info[WLST_TYPE]
1129+
except AliasException, ae:
1130+
self._raise_exception(ae, _method_name, 'WLSDPLY-19015', model_attribute_name, location.get_folder_path(),
1131+
ae.getLocalizedMessage())
1132+
1133+
return wlst_type
1134+
11151135
def get_model_attribute_default_value(self, location, model_attribute_name):
11161136
"""
11171137
Get the default value for the specified attribute
@@ -1132,7 +1152,8 @@ def get_model_attribute_default_value(self, location, model_attribute_name):
11321152
default_value = None
11331153
else:
11341154
data_type, delimiter = \
1135-
alias_utils.compute_read_data_type_and_delimiter_from_attribute_info(attribute_info, default_value)
1155+
alias_utils.compute_read_data_type_and_delimiter_from_attribute_info(
1156+
attribute_info, default_value)
11361157

11371158
default_value = alias_utils.convert_to_type(data_type, default_value, delimiter=delimiter)
11381159
self._logger.exiting(class_name=self._class_name, method_name=_method_name, result=default_value)
@@ -1152,6 +1173,50 @@ def get_ignore_attribute_names(self):
11521173
self._logger.finest('WLSDPLY-19038', names, class_name=self._class_name, method_name=_method_name)
11531174
return names
11541175

1176+
def get_preferred_model_type(self, location, model_attribute_name):
1177+
"""
1178+
Return the preferred model type, if present, for the alias attribute definition.
1179+
:param location: current location context
1180+
:param model_attribute_name: name of the attribute to look up in model representation
1181+
:return: alias attribute preferred model type or None if not present or attribute not found
1182+
:raises: Tool Exception if an AliasException encountered
1183+
"""
1184+
_method_name = 'get_preferred_model_type'
1185+
self._logger.entering(str(location), model_attribute_name,
1186+
class_name=self._class_name, method_name=_method_name)
1187+
result = None
1188+
try:
1189+
attribute_info = self._alias_entries.get_alias_attribute_entry_by_model_name(location, model_attribute_name)
1190+
if attribute_info is not None and PREFERRED_MODEL_TYPE in attribute_info:
1191+
result = attribute_info[PREFERRED_MODEL_TYPE]
1192+
except AliasException, ae:
1193+
self._raise_exception(ae, _method_name, 'WLSDPLY-19042', model_attribute_name, location.get_folder_path(),
1194+
ae.getLocalizedMessage())
1195+
self._logger.exiting(class_name=self._class_name, method_name=_method_name, result=result)
1196+
return result
1197+
1198+
def get_wlst_read_type(self, location, model_attribute_name):
1199+
"""
1200+
Return the aliases attribute WLST_READ_TYPE, which overrides the WLST_TYPE when retrieving the attribute value.
1201+
:param location: The context for the current location in WLST
1202+
:param model_attribute_name: the model name for the WLST attribute
1203+
:return: WLST_READ_TYPE or None if not defined for the attribute in the alias definitions
1204+
:raises: Tool Exception when AliasException occurs retrieving read type
1205+
"""
1206+
_method_name = 'get_wlst_read_type'
1207+
self._logger.entering(str(location), model_attribute_name,
1208+
class_name=self._class_name, method_name=_method_name)
1209+
result = None
1210+
try:
1211+
attribute_info = self._alias_entries.get_alias_attribute_entry_by_model_name(location, model_attribute_name)
1212+
if attribute_info is not None and WLST_READ_TYPE in attribute_info:
1213+
result = attribute_info[WLST_READ_TYPE]
1214+
except AliasException, ae:
1215+
self._raise_exception(ae, _method_name, 'WLSDPLY-19043', model_attribute_name, location.get_folder_path(),
1216+
ae.getLocalizedMessage())
1217+
self._logger.exiting(class_name=self._class_name, method_name=_method_name, result=result)
1218+
return result
1219+
11551220
def decrypt_password(self, text):
11561221
"""
11571222
Decrypt the specified password if model encryption is used and the password is encrypted.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,8 @@ WLSDPLY-19038=List of attribute names to ignore for all MBeans {0}
13871387
WLSDPLY-19039=Failed to convert the wlst attribute name to the model name at location ({0}) : {1}
13881388
WLSDPLY-19040=Failed to determine if the model attributes {0} is a password for location ({0}): {1}
13891389
WLSDPLY-19041=Failed to get the flattened folder information for location ({0}): {1}
1390+
WLSDPLY-19042=Failed to get the preferred model type for attribute {0} at location {1} : {2}
1391+
WLSDPLY-19043=Failed to get the read type for attribute {0} at location {1} : {2}
13901392

13911393
# wlsdeploy/tool/util/attribute_setter.py
13921394
WLSDPLY-19200=No target found with name {0}

0 commit comments

Comments
 (0)