예제 #1
0
def __process_java_home_arg(optional_arg_map):
    """
    Verify that java_home is set.  If not, set it.
    :param optional_arg_map: the optional arguments map
    :raises CLAException: if the java home argument is not valid
    """
    _method_name = '__process_java_home_arg'

    if CommandLineArgUtil.JAVA_HOME_SWITCH not in optional_arg_map:
        java_home_name = os.environ.get('JAVA_HOME')
        try:
            java_home = FileUtils.validateExistingDirectory(java_home_name)
        except IllegalArgumentException, iae:
            ex = exception_helper.create_cla_exception(
                'WLSDPLY-12400',
                _program_name,
                java_home_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
        optional_arg_map[
            CommandLineArgUtil.JAVA_HOME_SWITCH] = java_home.getAbsolutePath()
    def extract_file(self, path, location=None):
        """
        Extract the specified file from the archive into the specified directory, or into Domain Home.
        :param path: the path into the archive
        :param location: the location to which to extract the file
        :return: path to the extracted file
        :raises: BundleAwareException of the appropriate type: if an error occurs
        """
        _method_name = 'extract_file'
        self.__logger.entering(path,
                               class_name=self.__class_name,
                               method_name=_method_name)

        try:
            archive_file = self._find_archive_for_path(path, True)
            if location is None:
                result = archive_file.extractFile(path, self.__domain_home)
            else:
                extract_location = FileUtils.getCanonicalFile(File(location))
                result = archive_file.extractFile(path, extract_location, True)
        except (IllegalArgumentException, WLSDeployArchiveIOException), e:
            ex = exception_helper.create_exception(self.__exception_type,
                                                   "WLSDPLY-19303",
                                                   path,
                                                   self.__archive_files_text,
                                                   e.getLocalizedMessage(),
                                                   error=e)
            self.__logger.throwing(ex,
                                   class_name=self.__class_name,
                                   method_name=_method_name)
            raise ex
 def _load_category_file(self, category_file_path):
     category_input_stream = FileUtils.getResourceAsStream(
         category_file_path)
     self.assertNotEquals(category_input_stream, None)
     json_translator = JsonStreamTranslator(category_file_path,
                                            category_input_stream)
     return json_translator.parse()
예제 #4
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 get_domain_resource_schema(exception_type=ExceptionType.DEPLOY):
    """
    Read the WKO domain resource schema from its resource path.
    """
    _method_name = 'get_domain_resource_schema'

    template_stream = None
    try:
        template_stream = FileUtils.getResourceAsStream(
            DOMAIN_RESOURCE_SCHEMA_PATH)
        if template_stream is None:
            ex = exception_helper.create_exception(
                exception_type, 'WLSDPLY-10010', DOMAIN_RESOURCE_SCHEMA_PATH)
            _logger.throwing(ex,
                             class_name=_class_name,
                             method_name=_method_name)
            raise ex

        full_schema = JsonStreamToPython(DOMAIN_RESOURCE_SCHEMA_FILE,
                                         template_stream, True).parse()

        # remove the root element, since it has a version-specific name
        schema = full_schema[DOMAIN_RESOURCE_SCHEMA_ROOT]

    finally:
        if template_stream:
            template_stream.close()

    return schema
예제 #6
0
def __verify_actual_model_overrides_file_arg(compare_models_args_map):
    """

    :param compare_models_args_map:
    :return:
    """
    _method_name = '__verify_actual_models_overrides_file_arg'

    actual_models_overrides_file = None

    if compare_models_args_map[
            _ACTUAL_MODEL_OVERRIDES_FILE_SWITCH] is not None:
        try:
            actual_model_overrides_file = compare_models_args_map[
                _ACTUAL_MODEL_OVERRIDES_FILE_SWITCH]
            compare_models_args_map[_ACTUAL_MODEL_OVERRIDES_FILE_SWITCH] = \
                FileUtils.validateExistingFile(actual_model_overrides_file)
        except IllegalArgumentException, iae:
            ex = exception_helper.create_verification_exception(
                'WLSDPLY-20014',
                _ACTUAL_MODEL_OVERRIDES_FILE_SWITCH,
                iae.getLocalizedMessage(),
                error=iae)
            __logger.throwing(ex,
                              class_name=_class_name,
                              method_name=_method_name)
            raise ex
예제 #7
0
def __verify_expected_model_file_arg(compare_models_args_map):
    """

    :param compare_models_args_map:
    :return:
    """
    _method_name = '__verify_expected_model_file_arg'

    expected_model_file_name = None

    if _EXPECTED_MODEL_FILE_SWITCH in compare_models_args_map:
        try:
            expected_model_file_name = compare_models_args_map[
                _EXPECTED_MODEL_FILE_SWITCH]
            compare_models_args_map[_EXPECTED_MODEL_FILE_SWITCH] = \
                FileUtils.validateExistingFile(expected_model_file_name)
        except IllegalArgumentException, iae:
            ex = exception_helper.create_verification_exception(
                'WLSDPLY-20014',
                _EXPECTED_MODEL_FILE_SWITCH,
                iae.getLocalizedMessage(),
                error=iae)
            __logger.throwing(ex,
                              class_name=_class_name,
                              method_name=_method_name)
            raise ex
예제 #8
0
def __persist_model(model, model_context):
    """
    Save the model to the specified model file name or to the archive if the file name was not specified.
    :param model: the model to save
    :param model_context: the model context
    :raises DiscoverException: if an error occurs while create a temporary file for the model
                               or while adding it to the archive
    :raises TranslateException: if an error occurs while serializing the model or writing it to disk
    """
    _method_name = '__persist_model'

    __logger.entering(class_name=_class_name, method_name=_method_name)

    add_to_archive = False
    model_file_name = model_context.get_model_file()
    model_file = FileUtils.getCanonicalFile(File(model_file_name))
    if model_file_name is None:
        add_to_archive = True
    try:
        model_translator.PythonToFile(model.get_model()).write_to_file(model_file.getAbsolutePath())
    except TranslateException, ex:
        # Jython 2.2.1 does not support finally so use this like a finally block...
        if add_to_archive and not model_file.delete():
            model_file.deleteOnExit()
        raise ex
예제 #9
0
def __validate_archive_file_arg(required_arg_map):
    """
    Verify that the archive file exists.
    :param required_arg_map: the required arguments map
    :return: the archive file name
    :raises CLAException: if the archive file is not valid
    """
    _method_name = '__validate_archive_file_arg'

    archive_file_name = required_arg_map[CommandLineArgUtil.ARCHIVE_FILE_SWITCH]
    try:
        FileUtils.validateExistingFile(archive_file_name)
    except IllegalArgumentException, iae:
        ex = exception_helper.create_cla_exception('WLSDPLY-20014', _program_name, archive_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
예제 #10
0
def __process_java_home(optional_arg_map):
    _method_name = '__process_java_home'
    if CommandLineArgUtil.JAVA_HOME_SWITCH in optional_arg_map:
        java_home_name = optional_arg_map[CommandLineArgUtil.JAVA_HOME_SWITCH]
    else:
        java_home_name = os.environ.get('JAVA_HOME')

    try:
        FileUtils.validateExistingDirectory(java_home_name)
    except IllegalArgumentException, iae:
        # this value is used for java home global token in attributes.
        # If this was passed as command line, it might no longer exist.
        # The JAVA_HOME environment variable was validated by script.
        __logger.info('WLSDPLY-06027',
                      java_home_name,
                      iae.getLocalizedMessage(),
                      class_name=_class_name,
                      method_name=_method_name)
예제 #11
0
 def _validate_opss_wallet_arg(self, value):
     method_name = '_validate_opss_wallet_arg'
     try:
         opss_wallet = JFileUtils.validateDirectoryName(value)
     except JIllegalArgumentException, iae:
         ex = exception_helper.create_cla_exception('WLSDPLY-01646', value, iae.getLocalizedMessage(), error=iae)
         ex.setExitCode(self.ARG_VALIDATION_ERROR_EXIT_CODE)
         self._logger.throwing(ex, class_name=self._class_name, method_name=method_name)
         raise ex
예제 #12
0
    def _validate_variable_properties_file_arg(self, value):
        method_name = '_validate_variable_properties_file_arg'

        try:
            variables = JFileUtils.validateFileName(value)
        except JIllegalArgumentException, iae:
            ex = exception_helper.create_cla_exception('WLSDPLY-01620', value, iae.getLocalizedMessage(), error=iae)
            ex.setExitCode(self.ARG_VALIDATION_ERROR_EXIT_CODE)
            self._logger.throwing(ex, class_name=self._class_name, method_name=method_name)
            raise ex
예제 #13
0
def __process_variable_filename_arg(optional_arg_map):
    """
    If the variable filename argument is present, the required model variable injector json file must exist in
    the WLSDEPLOY lib directory.
    :param optional_arg_map: containing the variable file name
    :raises: CLAException: if this argument is present but the model variable injector json does not exist
    """
    _method_name = '__process_variable_filename_arg'

    if CommandLineArgUtil.VARIABLE_FILE_SWITCH in optional_arg_map:
        variable_injector_file_name = optional_arg_map[CommandLineArgUtil.VARIABLE_FILE_SWITCH]
        try:
            FileUtils.validateWritableFile(variable_injector_file_name)
        except IllegalArgumentException, ie:
            ex = exception_helper.create_cla_exception('WLSDPLY-06021', optional_arg_map[
                CommandLineArgUtil.VARIABLE_FILE_SWITCH], variable_injector_file_name,
                                                       ie.getLocalizedMessage(), error=ie)
            __logger.throwing(ex, class_name=_class_name, method_name=_method_name)
            raise ex
    def parse(self):
        """
        Based on the syntax of the file, parse the contents of the file into a python dictionary.
        :return: dictionary parsed from the file contents
        :raises TranslateException: if an error occurs
        """
        _method_name = 'parse'

        self.logger.entering(class_name=self._class_name, method_name=_method_name)
        # throws IllegalArgument if not a valid existing file
        model_file = JFileUtils.validateFileName(self.file_name)
        # yaml is the default. For now, if the file extension is not known, then parse the contents as yaml
        if JFileUtils.isJsonFile(model_file):
            result_dict = self._parse_json()
        else:
            result_dict = self._parse_yaml()

        # called method already logged result. don't log it again
        self.logger.exiting(class_name=self._class_name, method_name=_method_name)
        return result_dict
예제 #15
0
def __process_model_args(optional_arg_map):
    """
    Determine if the model file was passed separately or requires extraction from the archive.
    :param optional_arg_map:   the optional arguments map
    :raises CLAException: If an error occurs validating the arguments or extracting the model from the archive
    """
    _method_name = '__process_model_args'
    global __tmp_model_dir

    archive_file_name = None
    if CommandLineArgUtil.ARCHIVE_FILE_SWITCH in optional_arg_map:
        archive_file_name = optional_arg_map[CommandLineArgUtil.ARCHIVE_FILE_SWITCH]

        try:
            FileUtils.validateExistingFile(archive_file_name)
        except IllegalArgumentException, iae:
            ex = exception_helper.create_cla_exception('WLSDPLY-20014', _program_name, archive_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
예제 #16
0
def __process_model_args(optional_arg_map):
    """
    Verify that either the model_file or archive_file was provided and exists.
    Extract the model file if only the archive_file was provided.
    :param optional_arg_map: the optional arguments map
    :raises CLAException: if the arguments are invalid or an error occurs extracting the model from the archive
    """
    _method_name = '__process_model_args'
    global __tmp_model_dir

    if CommandLineArgUtil.MODEL_FILE_SWITCH in optional_arg_map:
        model_file_name = optional_arg_map[CommandLineArgUtil.MODEL_FILE_SWITCH]

        try:
            FileUtils.validateExistingFile(model_file_name)
        except IllegalArgumentException, iae:
            ex = exception_helper.create_cla_exception('WLSDPLY-20006', _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
    def _add_custom_configuration_to_archive(self, model_name, model_value,
                                             location):
        """
        Add custom configuration file to the archive. Modify the configuration file name in the model.
        :param model_name: attribute name of the custom configuration
        :param model_value: value containing the custom configuration file name
        :param location: context containing current location information
        :return: update custom configuration file name
        """
        _method_name = '_add_custom_configuration_to_archive'
        temp = LocationContext()
        temp.append_location(model_constants.COHERENCE_CLUSTER_SYSTEM_RESOURCE)
        cluster_name = location.get_name_for_token(
            self._aliases.get_name_token(temp))
        _logger.entering(cluster_name,
                         model_name,
                         model_value,
                         class_name=_class_name,
                         method_name=_method_name)
        new_name = model_value
        if model_value is not None:
            archive_file = self._model_context.get_archive_file()
            file_name_path = self._convert_path(model_value)
            config_file = None
            try:
                config_file = FileUtils.getCanonicalFile(File(file_name_path))
            except (IOException, SecurityException), se:
                _logger.warning('WLSDPLY-06314',
                                cluster_name,
                                file_name_path,
                                se.getLocalizedMessage(),
                                class_name=_class_name,
                                method_name=_method_name)
                new_name = None

            if file is not None:
                try:
                    new_name = archive_file.addCoherenceConfigFile(
                        cluster_name, config_file)
                    _logger.finer('WLSDPLY-06315',
                                  file_name_path,
                                  class_name=_class_name,
                                  method_name=_method_name)
                except (IllegalArgumentException,
                        WLSDeployArchiveIOException), wioe:
                    _logger.warning('WLSDPLY-06316',
                                    cluster_name,
                                    file_name_path,
                                    wioe.getLocalizedMessage(),
                                    class_name=_class_name,
                                    method_name=_method_name)
                    new_name = None
def validate_variable_file_exists(program_name, optional_arg_map):
    method_name = '_validate_variable_file_arg'
    if CommandLineArgUtil.VARIABLE_FILE_SWITCH in optional_arg_map:
        value = optional_arg_map[CommandLineArgUtil.VARIABLE_FILE_SWITCH]
        try:
            variable_file = FileUtils.validateExistingFile(value)
        except IllegalArgumentException, iae:
            ex = exception_helper.create_cla_exception('WLSDPLY-20031', program_name, value,
                                                       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
        optional_arg_map[CommandLineArgUtil.VARIABLE_FILE_SWITCH] = variable_file.getAbsolutePath()
def validate_optional_archive(program_name, optional_arg_map):
    """
    If the archive file was specified on the command line, verify that it exists.
    :param program_name: the name of the calling program, for logging
    :param optional_arg_map: the optional arguments from the command line
    :raises CLAException: if the archive was specified and does not exist
    """
    _method_name = 'validate_optional_archive'

    if CommandLineArgUtil.ARCHIVE_FILE_SWITCH in optional_arg_map:
        archive_file_name = optional_arg_map[CommandLineArgUtil.ARCHIVE_FILE_SWITCH]
        archive_files = cla_utils.get_archive_files(archive_file_name)

        for archive_file in archive_files:
            try:
                FileUtils.validateExistingFile(archive_file)
            except IllegalArgumentException, iae:
                ex = exception_helper.create_cla_exception('WLSDPLY-20014', program_name, archive_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
예제 #20
0
def list_non_dynamic_changes(model_context, non_dynamic_changes_string):
    """
    If output dir is present in the model context, write the restart data to the output dir as non_dynamic_changes.file.
    :param model_context: Current context with the run parameters.
    :param non_dynamic_changes_string: java.lang.String of changes that were non dynamic
    """
    _method_name = 'list_non_dynamic_changes'
    _logger.entering(class_name=_class_name, method_name=_method_name)
    output_dir = model_context.get_output_dir()
    if len(str(non_dynamic_changes_string)) > 0 and output_dir is not None:
        file_name = os.path.join(output_dir, 'non_dynamic_changes.file')
        pw = FileUtils.getPrintWriter(file_name)
        pw.println(non_dynamic_changes_string)
        pw.close()
def validate_model_present(program_name, optional_arg_map):
    """
    Determine if the model file was passed separately or requires extraction from the archive.
    If the model is in the archive, extract it to the temporary model location, and set that file as the
    MODEL_FILE_SWITCH argument.
    The MODEL_FILE_SWITCH value may be specified as multiple comma-separated models.
    The ARCHIVE_FILE_SWITCH value may be specified as multiple comma-separated archives.
    :param program_name: the name of the calling program, for logging
    :param optional_arg_map: the optional arguments from the command line
    :raises CLAException: if the specified model is not an existing file, or the model is not found in the archive,
    or the model is not found from either argument
    """
    _method_name = 'validate_model_present'
    global __tmp_model_dir

    if CommandLineArgUtil.MODEL_FILE_SWITCH in optional_arg_map:
        model_file_value = optional_arg_map[
            CommandLineArgUtil.MODEL_FILE_SWITCH]
        model_files = cla_utils.get_model_files(model_file_value)

        for model_file in model_files:
            try:
                FileUtils.validateExistingFile(model_file)
            except IllegalArgumentException, iae:
                ex = exception_helper.create_cla_exception(
                    'WLSDPLY-20006',
                    program_name,
                    model_file,
                    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
예제 #22
0
def get_file_hash(file_name):
    """
    Compute the Base64-encoded hash value for the specified file.
    :param file_name: the file name
    :return: the Base64-encoded hash value
    :raise: DeployException: if an error occurs
    """
    _method_name = 'get_file_hash'

    _logger.entering(file_name, class_name=_class_name, method_name=_method_name)
    try:
        result = FileUtils.computeHash(file_name)
    except (IOException, NoSuchAlgorithmException), e:
        ex = exception_helper.create_deploy_exception('WLSDPLY-09108', file_name, e.getLocalizedMessage(), error=e)
        _logger.throwing(ex, class_name=_class_name, method_name=_method_name)
        raise ex
예제 #23
0
    def write_to_json_file(self, file_name):
        """
        Convert the Python dictionary to JSON and write it to the specified file.
        :param file_name:  the name of the file
        :return: the java.io.File object of the JSON file
        """
        _method_name = 'writeToJsonFile'

        self._logger.entering(file_name, class_name=self._class_name, method_name=_method_name)
        try:
            json_file = JFileUtils.validateWritableFile(file_name)
        except JIllegalArgumentException, iae:
            json_ex = exception_helper.create_json_exception('WLSDPLY-18015', file_name,
                                                             iae.getLocalizedMessage(), error=iae)
            self._logger.throwing(class_name=self._class_name, method_name=_method_name, error=json_ex)
            raise json_ex
예제 #24
0
def verify_file_exists(file_name, logger):
    """

    :param file_name:
    :param logger: A PlatformLogger instance that will be used for logging
                   any exceptions that are thrown
    :return:
    """
    _method_name = 'verify_file_exists'

    try:
        j_file = FileUtils.validateExistingFile(file_name)
    except IllegalArgumentException, iae:
        ex = exception_helper.create_testing_exception(
            'WLSDPLY-09808', file_name, iae.getLocalizedMessage(), error=iae)
        logger.throwing(ex, class_name=_class_name, method_name=_method_name)
        raise ex
    def write_to_yaml_file(self, file_name):
        """
        Convert the Python dictionary to Yaml and write it to the specified file.
        :param file_name: the file name to which to write the Yaml output
        :return: The canonical java.io.File object for the Yaml File
        :raises: YamlException: if an error occurs while converting the dictionary to Yaml or writing to the file
        """
        _method_name = 'writeToYamlFile'

        self._logger.entering(file_name, class_name=self._class_name, method_name=_method_name)
        try:
            yaml_file = JFileUtils.validateWritableFile(file_name)
        except JIllegalArgumentException, iae:
            yaml_ex = exception_helper.create_yaml_exception('WLSDPLY-18009', file_name,
                                                             iae.getLocalizedMessage(), error=iae)
            self._logger.throwing(class_name=self._class_name, method_name=_method_name, error=yaml_ex)
            raise yaml_ex
예제 #26
0
def create_file_from_resource(resource_path, template_hash, output_file, exception_type):
    """
    Read the template from the resource stream, perform any substitutions,
    and write it to the output file.
    :param resource_path: the resource path of the source template
    :param template_hash: a dictionary of substitution values
    :param output_file: the file to write
    :param exception_type: the type of exception to throw if needed
    """
    _method_name = 'create_file_from_resource'

    template_stream = FileUtils.getResourceAsStream(resource_path)
    if template_stream is None:
        ex = exception_helper.create_exception(exception_type, 'WLSDPLY-01661', resource_path)
        __logger.throwing(ex, class_name=__class_name, method_name=_method_name)
        raise ex

    _create_file_from_stream(template_stream, template_hash, output_file)
    def write_to_file(self, file_name):
        """
        Write the Python dictionary to a file.
        :param file_name: the file name
        :return: the java.io.File object
        """
        _method_name = 'writeToFile'
        self.logger.entering(file_name, class_name=self._class_name, method_name=_method_name)

        model_file = JFile(file_name)
        if JFileUtils.isYamlFile(model_file):
            return_file = self._write_to_yaml_file(file_name)
        else:
            return_file = self._write_to_json_file(file_name)

        # called method already logged the return_file. don't log again
        self.logger.exiting(class_name=self._class_name, method_name=_method_name)
        return return_file
예제 #28
0
def create_file_from_file(file_path, template_hash, output_file, exception_type):
    """
    Read the template from the template file, perform any substitutions,
    and write it to the output file.
    :param file_path: the absolute file path of the source template
    :param template_hash: a dictionary of substitution values
    :param output_file: the file to write
    :param exception_type: the type of exception to throw if needed
    """
    _method_name = 'create_file_from_file'

    try:
        template_stream = FileUtils.getFileAsStream(file_path)
        if template_stream is not None:
            _create_file_from_stream(template_stream, template_hash, output_file)
    except (IOException, IllegalArgumentException), ie:
        ex = exception_helper.create_exception(exception_type, 'WLSDPLY-01666', file_path, ie)
        __logger.throwing(ex, class_name=__class_name, method_name=_method_name)
        raise ex
예제 #29
0
    def _validate_model_file_arg(self, value):
        method_name = '_validate_model_file_arg'

        result_model_files = []  # type: list
        if self._allow_multiple_models:
            model_files = get_model_files(value)
        else:
            model_files = [value]

        for model_file in model_files:
            try:
                model_file = JFileUtils.validateFileName(model_file)
                model_file = model_file.getAbsolutePath()
                result_model_files.append(model_file)
            except JIllegalArgumentException, iae:
                ex = exception_helper.create_cla_exception('WLSDPLY-01617', model_file, iae.getLocalizedMessage(),
                                                           error=iae)
                ex.setExitCode(self.ARG_VALIDATION_ERROR_EXIT_CODE)
                self._logger.throwing(ex, class_name=self._class_name, method_name=method_name)
                raise ex
예제 #30
0
    def get_user_env_scripts(self):
        """
        Look for the user overrides scripts run in setDomainEnv in the domain bin directory
        :raise: DiscoverException: an unexpected exception occurred writing a jar file to the archive file
        """
        _method_name = 'get_user_env_scripts'
        _logger.entering(class_name=_class_name, method_name=_method_name)
        archive_file = self._model_context.get_archive_file()
        domain_bin = self._convert_path('bin')
        entries = []
        if os.path.isdir(domain_bin):
            search_directory = FileUtils.fixupFileSeparatorsForJython(
                os.path.join(domain_bin, "setUserOverrides*.*"))
            _logger.finer('WLSDPLY-06425',
                          search_directory,
                          class_name=_class_name,
                          method_name=_method_name)
            file_list = glob.glob(search_directory)
            if file_list:
                _logger.finer('WLSDPLY-06423',
                              domain_bin,
                              class_name=_class_name,
                              method_name=_method_name)
                for entry in file_list:
                    try:
                        updated_name = archive_file.addDomainBinScript(
                            File(entry))
                    except WLSDeployArchiveIOException, wioe:
                        de = exception_helper.create_discover_exception(
                            'WLSDPLY-06426', entry, wioe.getLocalizedMessage())
                        _logger.throwing(class_name=_class_name,
                                         method_name=_method_name,
                                         error=de)
                        raise de

                    entries.append(updated_name)
                    _logger.finer('WLSDPLY-06424',
                                  entry,
                                  updated_name,
                                  class_name=_class_name,
                                  method_name=_method_name)