36
36
from wlsdeploy .aliases .alias_constants import MBEAN
37
37
from wlsdeploy .aliases .alias_constants import MERGE
38
38
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
39
41
from wlsdeploy .aliases .alias_constants import PREFERRED_MODEL_TYPE
40
42
from wlsdeploy .aliases .alias_constants import PROPERTIES
41
43
from wlsdeploy .aliases .alias_constants import RESTART_REQUIRED
@@ -77,6 +79,20 @@ def __init__(self, model_context, wlst_mode=WlstModes.OFFLINE, wls_version=None,
77
79
# Model folder navigation-related methods #
78
80
###########################################################################
79
81
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
+
80
96
def get_model_top_level_folder_names (self ):
81
97
"""
82
98
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
349
365
else :
350
366
wlst_attribute_name = attribute_info [WLST_NAME ]
351
367
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 ]):
353
369
model_attribute_value = self ._model_context .replace_token_string (model_attribute_value )
354
370
355
371
data_type = attribute_info [WLST_TYPE ]
@@ -387,7 +403,6 @@ def get_wlst_attribute_name_and_value(self, location, model_attribute_name, mode
387
403
else :
388
404
merged_value = model_attribute_value
389
405
390
-
391
406
if data_type == JARRAY :
392
407
subtype = 'java.lang.String'
393
408
if SET_MBEAN_TYPE in attribute_info :
@@ -774,6 +789,28 @@ def get_model_merge_required_attribute_names(self, location):
774
789
775
790
return model_attribute_names
776
791
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
+
777
814
def get_model_uses_path_tokens_attribute_names (self , location ):
778
815
"""
779
816
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
821
858
if attribute_info is not None and not self .__is_model_attribute_read_only (location , attribute_info ):
822
859
data_type , preferred_type , delimiter = \
823
860
alias_utils .compute_read_data_type_for_wlst_and_delimiter_from_attribute_info (attribute_info ,
824
- wlst_attribute_value )
861
+ wlst_attribute_value )
825
862
826
863
converted_value = alias_utils .convert_from_type (data_type , wlst_attribute_value , delimiter = delimiter ,
827
864
preferred = preferred_type )
@@ -843,7 +880,7 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst
843
880
if string_utils .is_empty (wlst_attribute_value ) or converted_value == default_value :
844
881
model_attribute_value = None
845
882
else :
846
- model_attribute_value = "--FIX ME--"
883
+ model_attribute_value = PASSWORD_TOKEN
847
884
elif data_type == 'boolean' :
848
885
wlst_val = alias_utils .convert_boolean (converted_value )
849
886
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
860
897
model_attribute_value = None
861
898
else :
862
899
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 :
864
901
model_attribute_value = self ._model_context .tokenize_path (model_attribute_value )
865
902
self ._logger .exiting (class_name = self ._class_name , method_name = _method_name ,
866
903
result = {model_attribute_name : model_attribute_value })
867
904
return model_attribute_name , model_attribute_value
868
905
869
906
def get_model_attribute_name (self , location , wlst_attribute_name ):
870
907
"""
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
872
910
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.
875
911
:param location: the location
876
912
:param wlst_attribute_name: the WLST attribute name
877
- :return: the name and value
913
+ :return: matching model attribute name
878
914
:raises: AliasException: if an error occurs
879
915
"""
880
916
_method_name = 'get_model_attribute_name'
@@ -884,7 +920,7 @@ def get_model_attribute_name(self, location, wlst_attribute_name):
884
920
model_attribute_name = None
885
921
886
922
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 ) :
888
924
model_attribute_name = attribute_info [MODEL_NAME ]
889
925
890
926
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
964
1000
if key == model_attribute_name :
965
1001
attribute_info = module_folder [ATTRIBUTES ][key ]
966
1002
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 ])
969
1005
970
1006
return result
971
1007
@@ -1037,6 +1073,27 @@ def get_model_attribute_default_value(self, location, model_attribute_name):
1037
1073
self ._logger .exiting (class_name = self ._class_name , method_name = _method_name , result = default_value )
1038
1074
return default_value
1039
1075
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
+
1040
1097
####################################################################################
1041
1098
#
1042
1099
# Private methods, private inner classes and static methods only, beyond here please
@@ -1051,7 +1108,7 @@ def __decrypt_password(self, text):
1051
1108
:raises EncryptionException: if an error occurs while decrypting the password
1052
1109
"""
1053
1110
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 \
1055
1112
not EncryptionUtils .isEncryptedString (text ):
1056
1113
1057
1114
rtnval = text
0 commit comments