示例#1
0
    def extract_model(self, program_name):
        """
        Extract the model from the archive.
        :param program_name: the program name (for logging purposes)
        :return: the temporary directory and the full path to the model file
        :raises: BundleAwareException of the appropriate type: if an error occurs
        """
        _method_name = 'extract_model'

        self.__logger.entering(program_name,
                               class_name=self.__class_name,
                               method_name=_method_name)
        try:
            tmp_model_dir = FileUtils.createTempDirectory(program_name)
            tmp_model_file = self.__archive_file.extractModel(tmp_model_dir)
        except (IllegalArgumentException, IllegalStateException,
                WLSDeployArchiveIOException), archex:
            ex = exception_helper.create_cla_exception(
                'WLSDPLY-20010',
                program_name,
                self.__archive_file_name,
                archex.getLocalizedMessage(),
                error=archex)
            self.__logger.throwing(ex,
                                   class_name=self.__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())
示例#3
0
                _program_name,
                model_file_name,
                iae.getLocalizedMessage(),
                error=iae)
            ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE)
            __logger.throwing(ex,
                              class_name=_class_name,
                              method_name=_method_name)
            raise ex
    elif CommandLineArgUtil.ARCHIVE_FILE_SWITCH in optional_arg_map:
        archive_file_name = optional_arg_map[
            CommandLineArgUtil.ARCHIVE_FILE_SWITCH]

        try:
            archive_file = WLSDeployArchive(archive_file_name)
            __tmp_model_dir = FileUtils.createTempDirectory(_program_name)
            tmp_model_raw_file = archive_file.extractModel(__tmp_model_dir)
            if not tmp_model_raw_file:
                ex = exception_helper.create_cla_exception(
                    'WLSDPLY-20026', _program_name, archive_file_name,
                    CommandLineArgUtil.MODEL_FILE_SWITCH)
                ex.setExitCode(
                    CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE)
                __logger.throwing(ex,
                                  class_name=_class_name,
                                  method_name=_method_name)
                raise ex

            tmp_model_file = FileUtils.fixupFileSeparatorsForJython(
                tmp_model_raw_file.getAbsolutePath())
        except (IllegalArgumentException, IllegalStateException,