3636from wlsdeploy .aliases .alias_constants import MBEAN
3737from wlsdeploy .aliases .alias_constants import MERGE
3838from wlsdeploy .aliases .alias_constants import MODEL_NAME
39+ from wlsdeploy .aliases .alias_constants import PASSWORD
40+ from wlsdeploy .aliases .alias_constants import PASSWORD_TOKEN
3941from wlsdeploy .aliases .alias_constants import PREFERRED_MODEL_TYPE
4042from wlsdeploy .aliases .alias_constants import PROPERTIES
4143from 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
@@ -1037,6 +1073,27 @@ def get_model_attribute_default_value(self, location, model_attribute_name):
10371073 self ._logger .exiting (class_name = self ._class_name , method_name = _method_name , result = default_value )
10381074 return default_value
10391075
1076+ def get_model_attribute_type (self , location , model_attribute_name ):
1077+ """
1078+ Get the wlst_type for the model attribute name at the specified location
1079+ :param location:
1080+ :param model_attribute_name:
1081+ :return:
1082+ """
1083+ wlst_type = None
1084+ attribute_info = self ._alias_entries .get_alias_attribute_entry_by_model_name (location , model_attribute_name )
1085+ if attribute_info is not None :
1086+ wlst_type = attribute_info [WLST_TYPE ]
1087+ return wlst_type
1088+
1089+ def get_ignore_attribute_names (self ):
1090+ """
1091+ Return the list of attribute names that are ignored by the aliases and not defined in the alias category
1092+ json files.
1093+ :return: list of ignored attribute
1094+ """
1095+ return self ._alias_entries .IGNORE_FOR_MODEL_LIST
1096+
10401097 ####################################################################################
10411098 #
10421099 # Private methods, private inner classes and static methods only, beyond here please
@@ -1051,7 +1108,7 @@ def __decrypt_password(self, text):
10511108 :raises EncryptionException: if an error occurs while decrypting the password
10521109 """
10531110 if text is None or len (str (text )) == 0 or \
1054- not self ._model_context .is_using_encryption () or \
1111+ ( self . _model_context and not self ._model_context .is_using_encryption () ) or \
10551112 not EncryptionUtils .isEncryptedString (text ):
10561113
10571114 rtnval = text
0 commit comments