1
1
"""
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.
3
3
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4
4
"""
5
5
import os
@@ -236,14 +236,8 @@ def __validate_model_file(self, model_dict, variables_map, archive_file_name):
236
236
if self ._model_file_name is not None :
237
237
self ._logger .info ('WLSDPLY-05003' , self ._model_file_name , class_name = _class_name , method_name = _method_name )
238
238
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
247
241
248
242
if archive_file_name is not None :
249
243
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_
394
388
395
389
model_folder_path = model_section_key + ":/"
396
390
397
- if '${' in section_dict_key :
391
+ if variables . has_variables ( section_dict_key ) :
398
392
self ._report_unsupported_variable_usage (section_dict_key , model_folder_path )
399
393
400
394
self ._logger .finer ('WLSDPLY-05011' , section_dict_key , section_dict_value ,
@@ -474,7 +468,7 @@ def __validate_section_folder(self, model_node, validation_location):
474
468
475
469
for name in model_node :
476
470
expanded_name = name
477
- if '${' in name :
471
+ if variables . has_variables ( name ) :
478
472
expanded_name = self .__validate_variable_substitution (name , model_folder_path )
479
473
480
474
self ._logger .finest ('2 expanded_name={0}' , expanded_name ,
@@ -503,7 +497,7 @@ def __validate_section_folder(self, model_node, validation_location):
503
497
504
498
for name in model_node :
505
499
expanded_name = name
506
- if '${' in name :
500
+ if variables . has_variables ( name ) :
507
501
self ._report_unsupported_variable_usage (name , model_folder_path )
508
502
509
503
self ._logger .finest ('3 expanded_name={0}' , expanded_name ,
@@ -566,7 +560,7 @@ def __process_model_node(self, model_node, validation_location):
566
560
method_name = _method_name )
567
561
568
562
for key , value in model_node .iteritems ():
569
- if '${' in key :
563
+ if variables . has_variables ( key ) :
570
564
self ._report_unsupported_variable_usage (key , model_folder_path )
571
565
572
566
self ._logger .finer ('5 key={0}' , key ,
@@ -673,10 +667,10 @@ def __validate_attribute(self, attribute_name, attribute_value, valid_attr_infos
673
667
model_folder_path , str (validation_location ),
674
668
class_name = _class_name , method_name = _method_name )
675
669
676
- if '${' in attribute_name :
670
+ if variables . has_variables ( attribute_name ) :
677
671
self ._report_unsupported_variable_usage (attribute_name , model_folder_path )
678
672
679
- if '${' in str (attribute_value ):
673
+ if variables . has_variables ( str (attribute_value ) ):
680
674
attribute_value = self .__validate_variable_substitution (attribute_value , model_folder_path )
681
675
682
676
if attribute_name in valid_attr_infos :
@@ -720,10 +714,10 @@ def __validate_property(self, property_name, property_value, valid_prop_infos, m
720
714
self ._logger .entering (property_name , property_value , str (valid_prop_infos ), model_folder_path ,
721
715
class_name = _class_name , method_name = _method_name )
722
716
723
- if '${' in property_name :
717
+ if variables . has_variables ( property_name ) :
724
718
property_name = self .__validate_variable_substitution (property_name , model_folder_path )
725
719
726
- if '${' in str (property_value ):
720
+ if variables . has_variables ( str (property_value ) ):
727
721
property_value = self .__validate_variable_substitution (property_value , model_folder_path )
728
722
729
723
if property_name in valid_prop_infos :
@@ -750,9 +744,8 @@ def __validate_variable_substitution(self, tokenized_value, model_folder_path):
750
744
751
745
if not isinstance (untokenized_value , dict ):
752
746
# 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 :
756
749
property_value = None
757
750
if property_name in self ._variable_properties :
758
751
property_value = self ._variable_properties [property_name ]
@@ -761,13 +754,18 @@ def __validate_variable_substitution(self, tokenized_value, model_folder_path):
761
754
else :
762
755
# FIXME(mwooten) - the cla_utils should be fixing all windows paths to use forward slashes already
763
756
# 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
+
764
762
variables_file_name = self ._model_context .get_variable_file ()
765
763
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 )
768
766
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 )
771
769
772
770
self ._logger .exiting (class_name = _class_name , method_name = _method_name , result = untokenized_value )
773
771
return untokenized_value
@@ -882,7 +880,7 @@ def __validate_server_group_targeting_limits(self, attribute_key, attribute_valu
882
880
self ._logger .severe ('WLSDPLY-05033' , key , model_folder_path , str (type (key )),
883
881
class_name = _class_name , method_name = __method_name )
884
882
else :
885
- if '${' in key :
883
+ if variables . has_variables ( key ) :
886
884
self ._report_unsupported_variable_usage (key , model_folder_path )
887
885
888
886
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
904
902
_method_name = '_validate_single_server_group_target_limits_value'
905
903
906
904
if type (value ) is str :
907
- if '${' in str (value ):
905
+ if variables . has_variables ( str (value ) ):
908
906
self ._report_unsupported_variable_usage (str (value ), model_folder_path )
909
907
else :
910
908
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):
922
920
923
921
def _report_unsupported_variable_usage (self , tokenized_value , model_folder_path ):
924
922
_method_name = '_report_unsupported_variable_usage'
925
- tokens = validation_utils . extract_substitution_tokens (tokenized_value )
923
+ tokens = variables . get_variable_names (tokenized_value )
926
924
for token in tokens :
927
925
self ._logger .severe ('WLSDPLY-05030' , model_folder_path , token ,
928
926
class_name = _class_name , method_name = _method_name )
0 commit comments