def __perform_model_file_validation(model_file_name, model_context): """ :param model_file_name: :param model_context: :return: :raises ValidationException: """ _method_name = '__perform_model_file_validation' __logger.entering(model_file_name, class_name=_class_name, method_name=_method_name) try: model_validator = Validator(model_context, logger=__logger) variable_map = model_validator.load_variables(model_context.get_variable_file()) model_dictionary = cla_helper.merge_model_files(model_file_name, variable_map) if cla_helper.check_persist_model(): persist_model_dict = copy.deepcopy(model_dictionary) variables.substitute(persist_model_dict, variable_map, model_context) cla_helper.persist_model(model_context, persist_model_dict) model_validator.validate_in_standalone_mode(model_dictionary, variable_map, model_context.get_archive_file_name()) except (TranslateException, VariableException), te: __logger.severe('WLSDPLY-20009', _program_name, model_file_name, te.getLocalizedMessage(), error=te, class_name=_class_name, method_name=_method_name) ex = exception_helper.create_validate_exception(te.getLocalizedMessage(), error=te) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex
def compare(self): """ Do the actual compare of the models. :return: whether the difference is safe for online dynamic update """ _method_name = "compare" # arguments have been verified and same extensions model_file_name = None # validate models first try: if FileUtils.isYamlFile(JFile(os.path.splitext(self.current_dict_file)[1].lower())): model_file_name = self.current_dict_file FileToPython(model_file_name, True).parse() model_file_name = self.past_dict_file FileToPython(model_file_name, True).parse() self.model_context.set_validation_method('lax') aliases = Aliases(model_context=self.model_context, wlst_mode=WlstModes.OFFLINE, exception_type=ExceptionType.COMPARE) validator = Validator(self.model_context, aliases, wlst_mode=WlstModes.OFFLINE) variable_map = validator.load_variables(self.model_context.get_variable_file()) model_file_name = self.current_dict_file model_dictionary = cla_helper.merge_model_files(model_file_name, variable_map) variables.substitute(model_dictionary, variable_map, self.model_context) # Run this utility in stand-alone mode instead of tool mode, # which has stricter checks for the tools. # An archive is not used with the compare models and if the model # references a file in an archive, the compareModel will fail if # running in the stricter tool mode (even with lax). # arg_map = dict() arg_map[CommandLineArgUtil.MODEL_FILE_SWITCH] = model_file_name model_context_copy = self.model_context.copy(arg_map) val_copy = Validator(model_context_copy, aliases, wlst_mode=WlstModes.OFFLINE) # any variables should have been substituted at this point validate_variables = {} return_code = val_copy.validate_in_standalone_mode(model_dictionary, validate_variables, archive_file_name=None) if return_code == Validator.ReturnCode.STOP: _logger.severe('WLSDPLY-05705', model_file_name) return VALIDATION_FAIL current_dict = model_dictionary model_file_name = self.past_dict_file model_dictionary = cla_helper.merge_model_files(model_file_name, variable_map) variables.substitute(model_dictionary, variable_map, self.model_context) arg_map[CommandLineArgUtil.MODEL_FILE_SWITCH] = model_file_name model_context_copy = self.model_context.copy(arg_map) val_copy = Validator(model_context_copy, aliases, wlst_mode=WlstModes.OFFLINE) return_code = val_copy.validate_in_standalone_mode(model_dictionary, validate_variables, archive_file_name=None) if return_code == Validator.ReturnCode.STOP: _logger.severe('WLSDPLY-05705', model_file_name) return VALIDATION_FAIL past_dict = model_dictionary except ValidateException, te: _logger.severe('WLSDPLY-20009', _program_name, model_file_name, te.getLocalizedMessage(), error=te, class_name=_class_name, method_name=_method_name) ex = exception_helper.create_compare_exception(te.getLocalizedMessage(), error=te) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) return VALIDATION_FAIL
def compare(self): """ Do the actual compare of the models. :return: whether the difference is safe for online dynamic update """ _method_name = "compare" # arguments have been verified and same extensions model_file_name = None # validate models first try: if os.path.splitext(self.current_dict_file)[1].lower() == ".yaml": model_file_name = self.current_dict_file FileToPython(model_file_name, True).parse() model_file_name = self.past_dict_file FileToPython(model_file_name, True).parse() aliases = Aliases(model_context=self.model_context, wlst_mode=WlstModes.OFFLINE) validator = Validator(self.model_context, aliases, wlst_mode=WlstModes.OFFLINE) variable_map = validator.load_variables( self.model_context.get_variable_file()) model_file_name = self.current_dict_file model_dictionary = cla_helper.merge_model_files( model_file_name, variable_map) variables.substitute(model_dictionary, variable_map, self.model_context) return_code = validator.validate_in_tool_mode( model_dictionary, variables_file_name=None, archive_file_name=None) if return_code == Validator.ReturnCode.STOP: __logger.severe('WLSDPLY-05705', model_file_name) return VALIDATION_FAIL current_dict = model_dictionary model_file_name = self.past_dict_file model_dictionary = cla_helper.merge_model_files( model_file_name, variable_map) variables.substitute(model_dictionary, variable_map, self.model_context) return_code = validator.validate_in_tool_mode( model_dictionary, variables_file_name=None, archive_file_name=None) if return_code == Validator.ReturnCode.STOP: __logger.severe('WLSDPLY-05705', model_file_name) return VALIDATION_FAIL past_dict = model_dictionary except ValidateException, te: __logger.severe('WLSDPLY-20009', _program_name, model_file_name, te.getLocalizedMessage(), error=te, class_name=_class_name, method_name=_method_name) ex = exception_helper.create_compare_exception( te.getLocalizedMessage(), error=te) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) return VALIDATION_FAIL