def __process_archive_filename_arg(required_arg_map): """ Validate the archive file name and load the archive file object. :param required_arg_map: the required arguments map :raises CLAException: if a validation error occurs while loading the archive file object """ _method_name = '__process_archive_filename_arg' archive_file_name = required_arg_map[ CommandLineArgUtil.ARCHIVE_FILE_SWITCH] archive_dir_name = path_utils.get_parent_directory(archive_file_name) if os.path.exists(archive_dir_name) is False: ex = exception_helper.create_cla_exception('WLSDPLY-06026', archive_file_name) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex try: archive_file = WLSDeployArchive(archive_file_name) except (IllegalArgumentException, IllegalStateException), ie: ex = exception_helper.create_cla_exception('WLSDPLY-06013', _program_name, archive_file_name, ie.getLocalizedMessage(), error=ie) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex
def persist_model(model_context, model_dictionary): """ If environment variable __WLSDEPLOY_STORE_MODEL__ is set, save the specified model. If the variable's value starts with a slash, save to that file, otherwise use a default location. :param model_context: the model context :param model_dictionary: the model to be saved """ _method_name = 'persist_model' if check_persist_model(): store_value = os.environ.get(_store_environment_variable) if store_value.startswith('/') or store_value.startswith('\\'): file_path = store_value elif model_context.get_domain_home() is not None: file_path = model_context.get_domain_home() + os.sep + 'wlsdeploy' + os.sep + 'domain_model.json' else: file_dir = FileUtils.createTempDirectory('wlsdeploy') file_path = File(file_dir, 'domain_model.json').getAbsolutePath() __logger.info('WLSDPLY-01650', file_path, class_name=_class_name, method_name=_method_name) persist_dir = path_utils.get_parent_directory(file_path) if not os.path.exists(persist_dir): os.makedirs(persist_dir) model_file = FileUtils.getCanonicalFile(File(file_path)) model_translator.PythonToFile(model_dictionary).write_to_file(model_file.getAbsolutePath())