Skip to content

Commit 291990b

Browse files
for system testing
1 parent f7e420e commit 291990b

File tree

3 files changed

+56
-18
lines changed

3 files changed

+56
-18
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
MERGE = 'merge'
2020
MODEL_NAME = 'model_name'
2121
NAME_VALUE = 'name_value'
22+
PASSWORD_TOKEN = "--FIX ME--"
2223
PREFERRED_MODEL_TYPE = 'preferred_model_type'
2324
RESTART_REQUIRED = 'restart_required'
2425
SET_MBEAN_TYPE = 'set_mbean_type'

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

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
from wlsdeploy.aliases.alias_constants import MBEAN
3737
from wlsdeploy.aliases.alias_constants import MERGE
3838
from wlsdeploy.aliases.alias_constants import MODEL_NAME
39+
from wlsdeploy.aliases.alias_constants import PASSWORD
40+
from wlsdeploy.aliases.alias_constants import PASSWORD_TOKEN
3941
from wlsdeploy.aliases.alias_constants import PREFERRED_MODEL_TYPE
4042
from wlsdeploy.aliases.alias_constants import PROPERTIES
4143
from wlsdeploy.aliases.alias_constants import RESTART_REQUIRED
@@ -77,6 +79,20 @@ def __init__(self, model_context, wlst_mode=WlstModes.OFFLINE, wls_version=None,
7779
# Model folder navigation-related methods #
7880
###########################################################################
7981

82+
def get_mode_string(self):
83+
"""
84+
Return WlstModes ONLINE or OFFLINE in string representation for this Aliases.
85+
:return: 'ONLINE' or 'OFFLINE'
86+
"""
87+
return WlstModes.from_value(self._wlst_mode)
88+
89+
def get_mode_enum(self):
90+
"""
91+
Return the WlstModes enum value for this Aliases.
92+
:return: WlstModes.ONLINE or WlstModes.OFFLINE
93+
"""
94+
return self._wlst_mode
95+
8096
def get_model_top_level_folder_names(self):
8197
"""
8298
Returns a list of the recognized top-level model folders corresponding to the known WLST top-level folders.
@@ -349,7 +365,7 @@ def get_wlst_attribute_name_and_value(self, location, model_attribute_name, mode
349365
else:
350366
wlst_attribute_name = attribute_info[WLST_NAME]
351367

352-
if USES_PATH_TOKENS in attribute_info and string_utils.to_boolean(attribute_info[USES_PATH_TOKENS]):
368+
if self._model_context and USES_PATH_TOKENS in attribute_info and string_utils.to_boolean(attribute_info[USES_PATH_TOKENS]):
353369
model_attribute_value = self._model_context.replace_token_string(model_attribute_value)
354370

355371
data_type = attribute_info[WLST_TYPE]
@@ -387,7 +403,6 @@ def get_wlst_attribute_name_and_value(self, location, model_attribute_name, mode
387403
else:
388404
merged_value = model_attribute_value
389405

390-
391406
if data_type == JARRAY:
392407
subtype = 'java.lang.String'
393408
if SET_MBEAN_TYPE in attribute_info:
@@ -774,6 +789,28 @@ def get_model_merge_required_attribute_names(self, location):
774789

775790
return model_attribute_names
776791

792+
def get_model_password_attribute_names(self, location):
793+
"""
794+
Get the list of attribute names for the current location that are marked as password.
795+
:param location: current location context
796+
:return: list of password attributes
797+
"""
798+
_method_name = 'get_model_password_attribute_names'
799+
800+
model_attribute_names = list()
801+
module_folder = self._alias_entries.get_dictionary_for_location(location, resolve=False)
802+
803+
if ATTRIBUTES not in module_folder:
804+
ex = exception_helper.create_alias_exception('WLSDPLY-08400', location.get_folder_path())
805+
self._logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
806+
raise ex
807+
808+
for key, value in module_folder[ATTRIBUTES].iteritems():
809+
if WLST_TYPE in value and value[WLST_TYPE] == PASSWORD:
810+
model_attribute_names.append(key)
811+
812+
return model_attribute_names
813+
777814
def get_model_uses_path_tokens_attribute_names(self, location):
778815
"""
779816
Get the list of attribute names that "use path tokens" (i.e., ones whose values are file system paths).
@@ -821,7 +858,7 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst
821858
if attribute_info is not None and not self.__is_model_attribute_read_only(location, attribute_info):
822859
data_type, preferred_type, delimiter = \
823860
alias_utils.compute_read_data_type_for_wlst_and_delimiter_from_attribute_info(attribute_info,
824-
wlst_attribute_value)
861+
wlst_attribute_value)
825862

826863
converted_value = alias_utils.convert_from_type(data_type, wlst_attribute_value, delimiter=delimiter,
827864
preferred=preferred_type)
@@ -843,7 +880,7 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst
843880
if string_utils.is_empty(wlst_attribute_value) or converted_value == default_value:
844881
model_attribute_value = None
845882
else:
846-
model_attribute_value = "--FIX ME--"
883+
model_attribute_value = PASSWORD_TOKEN
847884
elif data_type == 'boolean':
848885
wlst_val = alias_utils.convert_boolean(converted_value)
849886
default_val = alias_utils.convert_boolean(default_value)
@@ -860,21 +897,20 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst
860897
model_attribute_value = None
861898
else:
862899
model_attribute_value = converted_value
863-
if USES_PATH_TOKENS in attribute_info:
900+
if self._model_context and USES_PATH_TOKENS in attribute_info:
864901
model_attribute_value = self._model_context.tokenize_path(model_attribute_value)
865902
self._logger.exiting(class_name=self._class_name, method_name=_method_name,
866903
result={model_attribute_name: model_attribute_value})
867904
return model_attribute_name, model_attribute_value
868905

869906
def get_model_attribute_name(self, location, wlst_attribute_name):
870907
"""
871-
Returns the model attribute name for the specified WLST attribute name and value.
908+
Returns the model attribute name for the specified WLST attribute name and value. If the model attribute name
909+
is not valid for the version or the attribute is marked as read-only, return None
872910
873-
model_attribute_value will be set to None, if value assigned to wlst_attribute_value arg
874-
is the default value for model_attribute_name.
875911
:param location: the location
876912
:param wlst_attribute_name: the WLST attribute name
877-
:return: the name and value
913+
:return: matching model attribute name
878914
:raises: AliasException: if an error occurs
879915
"""
880916
_method_name = 'get_model_attribute_name'
@@ -884,7 +920,7 @@ def get_model_attribute_name(self, location, wlst_attribute_name):
884920
model_attribute_name = None
885921

886922
attribute_info = self._alias_entries.get_alias_attribute_entry_by_wlst_name(location, wlst_attribute_name)
887-
if attribute_info is not None:
923+
if attribute_info is not None and not self.__is_model_attribute_read_only(location, attribute_info):
888924
model_attribute_name = attribute_info[MODEL_NAME]
889925

890926
self._logger.exiting(class_name=self._class_name, method_name=_method_name,
@@ -964,8 +1000,8 @@ def attribute_values_are_equal(self, location, model_attribute_name, model_attri
9641000
if key == model_attribute_name:
9651001
attribute_info = module_folder[ATTRIBUTES][key]
9661002
if attribute_info and VALUE in attribute_info and DEFAULT in attribute_info[VALUE]:
967-
result = (model_attribute_value == wlst_attribute_value
968-
and model_attribute_value == attribute_info[VALUE][DEFAULT])
1003+
result = (model_attribute_value == wlst_attribute_value and
1004+
model_attribute_value == attribute_info[VALUE][DEFAULT])
9691005

9701006
return result
9711007

@@ -1051,7 +1087,7 @@ def __decrypt_password(self, text):
10511087
:raises EncryptionException: if an error occurs while decrypting the password
10521088
"""
10531089
if text is None or len(str(text)) == 0 or \
1054-
not self._model_context.is_using_encryption() or\
1090+
(self._model_context and not self._model_context.is_using_encryption()) or\
10551091
not EncryptionUtils.isEncryptedString(text):
10561092

10571093
rtnval = text

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,19 +239,20 @@ def lsa(path=None, log_throwing=True):
239239
"""
240240
_method_name = 'lsa'
241241
result = _ls(_method_name, 'a', path, log_throwing)
242-
if wlst.WLS_ON.isConnected() and result and len(result) > 1:
243-
make_dict = dict()
242+
make_dict = dict()
243+
if result and len(result) > 1:
244244
for entry in result.entrySet():
245245
key = entry.getKey()
246246
value = entry.getValue()
247-
if value is not None and type(value) is str:
247+
if value and type(value) is str:
248248
new_value = value.rstrip()
249249
if new_value == 'null' or new_value == 'none':
250250
make_dict[key] = None
251251
else:
252252
make_dict[key] = new_value
253-
result = make_dict
254-
return result
253+
else:
254+
make_dict[key] = value
255+
return make_dict
255256

256257

257258
def lsc(path=None, log_throwing=True):

0 commit comments

Comments
 (0)