11"""
2- Copyright (c) 2017, 2019 , Oracle Corporation and/or its affiliates. All rights reserved.
2+ Copyright (c) 2017, 2020 , Oracle Corporation and/or its affiliates. All rights reserved.
33Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44"""
55import os
@@ -236,14 +236,8 @@ def __validate_model_file(self, model_dict, variables_map, archive_file_name):
236236 if self ._model_file_name is not None :
237237 self ._logger .info ('WLSDPLY-05003' , self ._model_file_name , class_name = _class_name , method_name = _method_name )
238238
239- try :
240- self ._variable_properties = variables_map
241- variables .substitute (model_dict , self ._variable_properties , self ._model_context )
242- except VariableException , ve :
243- ex = exception_helper .create_validate_exception ('WLSDPLY-20004' , 'validateModel' ,
244- ve .getLocalizedMessage (), error = ve )
245- self ._logger .throwing (ex , class_name = _class_name , method_name = _method_name )
246- raise ex
239+ self ._variable_properties = variables_map
240+ # don't substitute model here, it should be validated with variables intact
247241
248242 if archive_file_name is not None :
249243 self ._logger .info ('WLSDPLY-05005' , archive_file_name , class_name = _class_name , method_name = _method_name )
@@ -394,7 +388,7 @@ def __validate_model_section(self, model_section_key, model_dict, valid_section_
394388
395389 model_folder_path = model_section_key + ":/"
396390
397- if '${' in section_dict_key :
391+ if variables . has_variables ( section_dict_key ) :
398392 self ._report_unsupported_variable_usage (section_dict_key , model_folder_path )
399393
400394 self ._logger .finer ('WLSDPLY-05011' , section_dict_key , section_dict_value ,
@@ -474,7 +468,7 @@ def __validate_section_folder(self, model_node, validation_location):
474468
475469 for name in model_node :
476470 expanded_name = name
477- if '${' in name :
471+ if variables . has_variables ( name ) :
478472 expanded_name = self .__validate_variable_substitution (name , model_folder_path )
479473
480474 self ._logger .finest ('2 expanded_name={0}' , expanded_name ,
@@ -503,7 +497,7 @@ def __validate_section_folder(self, model_node, validation_location):
503497
504498 for name in model_node :
505499 expanded_name = name
506- if '${' in name :
500+ if variables . has_variables ( name ) :
507501 self ._report_unsupported_variable_usage (name , model_folder_path )
508502
509503 self ._logger .finest ('3 expanded_name={0}' , expanded_name ,
@@ -566,7 +560,7 @@ def __process_model_node(self, model_node, validation_location):
566560 method_name = _method_name )
567561
568562 for key , value in model_node .iteritems ():
569- if '${' in key :
563+ if variables . has_variables ( key ) :
570564 self ._report_unsupported_variable_usage (key , model_folder_path )
571565
572566 self ._logger .finer ('5 key={0}' , key ,
@@ -673,10 +667,10 @@ def __validate_attribute(self, attribute_name, attribute_value, valid_attr_infos
673667 model_folder_path , str (validation_location ),
674668 class_name = _class_name , method_name = _method_name )
675669
676- if '${' in attribute_name :
670+ if variables . has_variables ( attribute_name ) :
677671 self ._report_unsupported_variable_usage (attribute_name , model_folder_path )
678672
679- if '${' in str (attribute_value ):
673+ if variables . has_variables ( str (attribute_value ) ):
680674 attribute_value = self .__validate_variable_substitution (attribute_value , model_folder_path )
681675
682676 if attribute_name in valid_attr_infos :
@@ -720,10 +714,10 @@ def __validate_property(self, property_name, property_value, valid_prop_infos, m
720714 self ._logger .entering (property_name , property_value , str (valid_prop_infos ), model_folder_path ,
721715 class_name = _class_name , method_name = _method_name )
722716
723- if '${' in property_name :
717+ if variables . has_variables ( property_name ) :
724718 property_name = self .__validate_variable_substitution (property_name , model_folder_path )
725719
726- if '${' in str (property_value ):
720+ if variables . has_variables ( str (property_value ) ):
727721 property_value = self .__validate_variable_substitution (property_value , model_folder_path )
728722
729723 if property_name in valid_prop_infos :
@@ -750,9 +744,8 @@ def __validate_variable_substitution(self, tokenized_value, model_folder_path):
750744
751745 if not isinstance (untokenized_value , dict ):
752746 # Extract the variable substitution variables from tokenized_value
753- tokens = validation_utils .extract_substitution_tokens (tokenized_value )
754- for token in tokens :
755- property_name = token [2 :len (token )- 1 ]
747+ matches = variables .get_variable_matches (tokenized_value )
748+ for token , property_name in matches :
756749 property_value = None
757750 if property_name in self ._variable_properties :
758751 property_value = self ._variable_properties [property_name ]
@@ -761,13 +754,18 @@ def __validate_variable_substitution(self, tokenized_value, model_folder_path):
761754 else :
762755 # FIXME(mwooten) - the cla_utils should be fixing all windows paths to use forward slashes already
763756 # assuming that the value is not None
757+
758+ logger_method = self ._logger .info
759+ if self ._model_context .get_validation_method () == 'strict' :
760+ logger_method = self ._logger .warning
761+
764762 variables_file_name = self ._model_context .get_variable_file ()
765763 if variables_file_name is None :
766- self . _logger . warning ('WLSDPLY-05021' , model_folder_path , property_name ,
767- class_name = _class_name , method_name = _method_name )
764+ logger_method ('WLSDPLY-05021' , model_folder_path , property_name ,
765+ class_name = _class_name , method_name = _method_name )
768766 else :
769- self . _logger . warning ('WLSDPLY-05022' , model_folder_path , property_name , variables_file_name ,
770- class_name = _class_name , method_name = _method_name )
767+ logger_method ('WLSDPLY-05022' , model_folder_path , property_name , variables_file_name ,
768+ class_name = _class_name , method_name = _method_name )
771769
772770 self ._logger .exiting (class_name = _class_name , method_name = _method_name , result = untokenized_value )
773771 return untokenized_value
@@ -882,7 +880,7 @@ def __validate_server_group_targeting_limits(self, attribute_key, attribute_valu
882880 self ._logger .severe ('WLSDPLY-05033' , key , model_folder_path , str (type (key )),
883881 class_name = _class_name , method_name = __method_name )
884882 else :
885- if '${' in key :
883+ if variables . has_variables ( key ) :
886884 self ._report_unsupported_variable_usage (key , model_folder_path )
887885
888886 if isinstance (value , basestring ) and MODEL_LIST_DELIMITER in value :
@@ -904,7 +902,7 @@ def _validate_single_server_group_target_limits_value(self, key, value, model_fo
904902 _method_name = '_validate_single_server_group_target_limits_value'
905903
906904 if type (value ) is str :
907- if '${' in str (value ):
905+ if variables . has_variables ( str (value ) ):
908906 self ._report_unsupported_variable_usage (str (value ), model_folder_path )
909907 else :
910908 self ._logger .severe ('WLSDPLY-05035' , key , str (value ), model_folder_path , str (type (value )),
@@ -922,7 +920,7 @@ def __validate_wlsroles_section(self, attribute_value):
922920
923921 def _report_unsupported_variable_usage (self , tokenized_value , model_folder_path ):
924922 _method_name = '_report_unsupported_variable_usage'
925- tokens = validation_utils . extract_substitution_tokens (tokenized_value )
923+ tokens = variables . get_variable_names (tokenized_value )
926924 for token in tokens :
927925 self ._logger .severe ('WLSDPLY-05030' , model_folder_path , token ,
928926 class_name = _class_name , method_name = _method_name )
0 commit comments