def main(args):
    """
    The python entry point for deployApps.

    :param args:
    :return:
    """
    _method_name = 'main'

    __logger.entering(args[0],
                      class_name=_class_name,
                      method_name=_method_name)
    for index, arg in enumerate(args):
        __logger.finer('sys.argv[{0}] = {1}',
                       str(index),
                       str(arg),
                       class_name=_class_name,
                       method_name=_method_name)

    __wlst_helper.silence()

    try:
        model_context = __process_args(args)
    except CLAException, ex:
        exit_code = ex.getExitCode()
        if exit_code != CommandLineArgUtil.HELP_EXIT_CODE:
            __logger.severe('WLSDPLY-20008',
                            _program_name,
                            ex.getLocalizedMessage(),
                            error=ex,
                            class_name=_class_name,
                            method_name=_method_name)
        __clean_up_temp_files()
        tool_exit.end(None, exit_code)
def load_model(program_name, model_context, aliases, filter_type, wlst_mode):
    """
    Load the model based on the arguments in the model context.
    Apply the variable substitution, if specified, and validate the model.
    Apply any model filters of the specified type that are configured, and re-validate if necessary
    The tool will exit if exceptions are encountered.
    :param program_name: the program name, for logging
    :param model_context: the model context
    :param aliases: the alias configuration
    :param filter_type: the type of any filters to be applied
    :param wlst_mode: offline or online
    :return: the resulting model dictionary
    """
    _method_name = 'load_model'

    variable_map = {}
    try:
        if model_context.get_variable_file():
            # callers of this method allow multiple variable files
            variable_map = variables.load_variables(
                model_context.get_variable_file(), allow_multiple_files=True)
    except VariableException, ex:
        __logger.severe('WLSDPLY-20004',
                        program_name,
                        ex.getLocalizedMessage(),
                        error=ex,
                        class_name=_class_name,
                        method_name=_method_name)
        clean_up_temp_files()
        tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
Пример #3
0
def main(args):
    """
    The main entry point for the validateModel tool.

    :param args:
    :return:
    """
    _method_name = 'main'

    __logger.entering(args[0], class_name=_class_name, method_name=_method_name)
    for index, arg in enumerate(args):
        __logger.finer('sys.argv[{0}] = {1}', str(index), arg, class_name=_class_name, method_name=_method_name)

    exit_code = CommandLineArgUtil.PROG_OK_EXIT_CODE

    try:
        model_context = __process_args(args)
    except CLAException, ex:
        exit_code = ex.getExitCode()
        if exit_code != CommandLineArgUtil.HELP_EXIT_CODE:
            __logger.severe('WLSDPLY-20008', _program_name, ex.getLocalizedMessage(), error=ex,
                            class_name=_class_name, method_name=_method_name)
        cla_helper.clean_up_temp_files()
        # create a minimal model for summary logging
        model_context = model_context_helper.create_exit_context(_program_name)
        tool_exit.end(model_context, exit_code)
def validate_model(program_name, model_dictionary, model_context, aliases,
                   wlst_mode):
    """
    Validate the model dictionary based on the specified model context and aliases.
    The tool will exit if exceptions are encountered, or the validation returns a STOP code.
    :param program_name: the program name, for logging
    :param model_dictionary: the model dictionary
    :param model_context: the model context
    :param aliases: the aliases
    :param wlst_mode: offline or online
    :return:
    """
    _method_name = 'validate_model'

    try:
        validator = Validator(model_context, aliases, wlst_mode=wlst_mode)

        # no need to pass the variable file for processing, substitution has already been performed
        return_code = validator.validate_in_tool_mode(
            model_dictionary,
            variables_file_name=None,
            archive_file_name=model_context.get_archive_file_name())
    except ValidateException, ex:
        __logger.severe('WLSDPLY-20000',
                        program_name,
                        ex.getLocalizedMessage(),
                        error=ex,
                        class_name=_class_name,
                        method_name=_method_name)
        clean_up_temp_files()
        tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
Пример #5
0
def __process_model_args(argument_map):
    """
    Determine if the model file was passed separately or requires extraction from the archive.
    :param argument_map: the arguments map
    :raises CLAException: if the arguments were not valid or an error occurred extracting the model from the archive
    """
    _method_name = '__process_model_args'

    cla_helper.validate_optional_archive(_program_name, argument_map)

    try:
        cla_helper.validate_model_present(_program_name, argument_map)
    except CLAException, ce:
        # in lax validation mode, if no model is found, log at INFO and exit
        method = dictionary_utils.get_element(
            argument_map, CommandLineArgUtil.VALIDATION_METHOD)
        if method == CommandLineArgUtil.LAX_VALIDATION_METHOD:
            __logger.info('WLSDPLY-20032',
                          _program_name,
                          class_name=_class_name,
                          method_name=_method_name)
            model_context = model_context_helper.create_exit_context(
                _program_name)
            tool_exit.end(model_context, CommandLineArgUtil.PROG_OK_EXIT_CODE)
        raise ce
Пример #6
0
def validateRCUArgsAndModel(model_context, model, alias_helper):
    has_atpdbinfo = 0
    domain_info = model[model_constants.DOMAIN_INFO]
    if domain_info is not None:
        if model_constants.RCU_DB_INFO in domain_info:
            rcu_db_info = RcuDbInfo(alias_helper,
                                    domain_info[model_constants.RCU_DB_INFO])
            has_tns_admin = rcu_db_info.has_tns_admin()
            has_regular_db = rcu_db_info.is_regular_db()
            has_atpdbinfo = rcu_db_info.has_atpdbinfo()

            if model_context.get_archive_file_name() and not has_regular_db:
                System.setProperty('oracle.jdbc.fanEnabled', 'false')

                # 1. If it does not have the oracle.net.tns_admin specified, then extract to domain/atpwallet
                # 2. If it is plain old regular oracle db, do nothing
                # 3. If it deos not have tns_admin in the model, then the wallet must be in the archive
                if not has_tns_admin:
                    # extract the wallet first
                    archive_file = WLSDeployArchive(
                        model_context.get_archive_file_name())
                    atp_wallet_zipentry = None
                    if archive_file:
                        atp_wallet_zipentry = archive_file.getATPWallet()
                    if atp_wallet_zipentry and model[
                            model_constants.TOPOLOGY]['Name']:
                        extract_path = atp_helper.extract_walletzip(
                            model, model_context, archive_file,
                            atp_wallet_zipentry)
                        # update the model to add the tns_admin
                        model[model_constants.DOMAIN_INFO][
                            model_constants.RCU_DB_INFO][
                                model_constants.
                                DRIVER_PARAMS_NET_TNS_ADMIN] = extract_path
                    else:
                        __logger.severe('WLSDPLY-12411',
                                        error=None,
                                        class_name=_class_name,
                                        method_name="validateRCUArgsAndModel")
                        __clean_up_temp_files()
                        tool_exit.end(model_context,
                                      CommandLineArgUtil.PROG_ERROR_EXIT_CODE)

        else:
            if model_context.get_domain_typedef().required_rcu():
                if not model_context.get_rcu_database(
                ) or not model_context.get_rcu_prefix():
                    __logger.severe('WLSDPLY-12408',
                                    model_context.get_domain_type(),
                                    CommandLineArgUtil.RCU_DB_SWITCH,
                                    CommandLineArgUtil.RCU_PREFIX_SWITCH)
                    __clean_up_temp_files()
                    tool_exit.end(model_context,
                                  CommandLineArgUtil.PROG_ERROR_EXIT_CODE)

    return has_atpdbinfo
Пример #7
0
def __log_and_exit(model_context, exit_code, class_name, method_name):
    """
    Helper method to log the exiting message and call sys.exit()
    :param exit_code: the exit code to use
    :param class_name: the class name to pass  to the logger
    :param method_name: the method name to pass to the logger
    """
    __logger.exiting(result=exit_code, class_name=class_name, method_name=method_name)

    tool_exit.end(model_context, exit_code)
Пример #8
0
def validate_model(model_dictionary, model_context, aliases):
    _method_name = 'validate_model'

    try:
        validator = Validator(model_context, aliases, wlst_mode=__wlst_mode)

        # no need to pass the variable file for processing, substitution has already been performed
        return_code = validator.validate_in_tool_mode(model_dictionary, variables_file_name=None,
                                                      archive_file_name=model_context.get_archive_file_name())
    except ValidateException, ex:
        __logger.severe('WLSDPLY-20000', _program_name, ex.getLocalizedMessage(), error=ex,
                        class_name=_class_name, method_name=_method_name)
        __clean_up_temp_files()
        tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
Пример #9
0
def validate_rcu_args_and_model(model_context, model, archive_helper, aliases):
    _method_name = 'validate_rcu_args_and_model'

    has_atpdbinfo = 0
    domain_info = model[model_constants.DOMAIN_INFO]
    if domain_info is not None:
        if model_constants.RCU_DB_INFO in domain_info:
            rcu_db_info = RcuDbInfo(model_context, aliases,
                                    domain_info[model_constants.RCU_DB_INFO])
            has_tns_admin = rcu_db_info.has_tns_admin()
            has_regular_db = rcu_db_info.is_regular_db()
            has_atpdbinfo = rcu_db_info.has_atpdbinfo()

            if archive_helper and not has_regular_db:
                System.setProperty('oracle.jdbc.fanEnabled', 'false')

                # 1. If it does not have the oracle.net.tns_admin specified, then extract to domain/atpwallet
                # 2. If it is plain old regular oracle db, do nothing
                # 3. If it deos not have tns_admin in the model, then the wallet must be in the archive
                if not has_tns_admin:
                    wallet_path = archive_helper.extract_atp_wallet()
                    if wallet_path:
                        # update the model to add the tns_admin
                        model[model_constants.DOMAIN_INFO][
                            model_constants.RCU_DB_INFO][
                                model_constants.
                                DRIVER_PARAMS_NET_TNS_ADMIN] = wallet_path
                    else:
                        __logger.severe('WLSDPLY-12411',
                                        error=None,
                                        class_name=_class_name,
                                        method_name=_method_name)
                        cla_helper.clean_up_temp_files()
                        tool_exit.end(model_context,
                                      CommandLineArgUtil.PROG_ERROR_EXIT_CODE)

        else:
            if model_context.get_domain_typedef().required_rcu():
                if not model_context.get_rcu_database(
                ) or not model_context.get_rcu_prefix():
                    __logger.severe('WLSDPLY-12408',
                                    model_context.get_domain_type(),
                                    CommandLineArgUtil.RCU_DB_SWITCH,
                                    CommandLineArgUtil.RCU_PREFIX_SWITCH)
                    cla_helper.clean_up_temp_files()
                    tool_exit.end(model_context,
                                  CommandLineArgUtil.PROG_ERROR_EXIT_CODE)

    return has_atpdbinfo
Пример #10
0
def main():
    """
    The main entry point for the discoverDomain tool.
    :param args: the command-line arguments
    """
    _method_name = 'main'

    __logger.entering(class_name=_class_name, method_name=_method_name)
    for index, arg in enumerate(sys.argv):
        __logger.finer('sys.argv[{0}] = {1}',
                       str(index),
                       str(arg),
                       class_name=_class_name,
                       method_name=_method_name)

    # create a minimal model for summary logging
    model_context = model_context_helper.create_exit_context(_program_name)
    _outputdir = None

    try:
        model_context = __process_args(sys.argv, __logger)
        _outputdir = model_context.get_kubernetes_output_dir()
        model1 = model_context.get_model_file()
        # for f in [ model1 ]:
        #     if not os.path.exists(f):
        #         raise CLAException("Model %s does not exists" % f)
        #     if os.path.isdir(f):
        #         raise CLAException("Model %s is a directory" % f)

        obj = PrepareModel(model1, model_context, __logger, _outputdir)
        rc = obj.walk()
        tool_exit.end(model_context, rc)

    except CLAException, ex:
        exit_code = 2
        if exit_code != CommandLineArgUtil.HELP_EXIT_CODE:
            __logger.severe('WLSDPLY-20008',
                            _program_name,
                            ex.getLocalizedMessage(),
                            error=ex,
                            class_name=_class_name,
                            method_name=_method_name)
        cla_helper.clean_up_temp_files()
        tool_exit.end(model_context, exit_code)
Пример #11
0
        __logger.severe('WLSDPLY-20000',
                        _program_name,
                        ex.getLocalizedMessage(),
                        error=ex,
                        class_name=_class_name,
                        method_name=_method_name)
        cla_helper.clean_up_temp_files()
        tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)

    if return_code == Validator.ReturnCode.STOP:
        __logger.severe('WLSDPLY-20001',
                        _program_name,
                        class_name=_class_name,
                        method_name=_method_name)
        cla_helper.clean_up_temp_files()
        tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)


def main(args):
    """
    The python entry point for deployApps.

    :param args:
    :return:
    """
    _method_name = 'main'

    __logger.entering(args[0],
                      class_name=_class_name,
                      method_name=_method_name)
    for index, arg in enumerate(args):
Пример #12
0
            if model_file_name is not None:
                __perform_model_file_validation(model_file_name, model_context)

                summary_handler = SummaryHandler.findInstance()
                if summary_handler is not None:
                    summary_level = summary_handler.getMaximumMessageLevel()
                    if summary_level == Level.SEVERE:
                        exit_code = CommandLineArgUtil.PROG_ERROR_EXIT_CODE
                    elif summary_level == Level.WARNING:
                        exit_code = CommandLineArgUtil.PROG_WARNING_EXIT_CODE

        except ValidateException, ve:
            __logger.severe('WLSDPLY-20000',
                            _program_name,
                            ve.getLocalizedMessage(),
                            error=ve,
                            class_name=_class_name,
                            method_name=_method_name)
            cla_helper.clean_up_temp_files()
            sys.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE)

        cla_helper.clean_up_temp_files()

        tool_exit.end(model_context, exit_code)
    return


if __name__ == "main":
    WebLogicDeployToolingVersion.logVersionInfo(_program_name)
    main(sys.argv)
Пример #13
0
    except CLAException, ex:
        exit_code = 2
        if exit_code != CommandLineArgUtil.HELP_EXIT_CODE:
            __logger.severe('WLSDPLY-20008',
                            _program_name,
                            ex.getLocalizedMessage(),
                            error=ex,
                            class_name=_class_name,
                            method_name=_method_name)
        cla_helper.clean_up_temp_files()
        tool_exit.end(model_context, exit_code)
    except CompareException, ce:
        cla_helper.clean_up_temp_files()
        __logger.severe('WLSDPLY-05801', ce.getLocalizedMessage())
        tool_exit.end(model_context, 2)
    except PyWLSTException, pe:
        cla_helper.clean_up_temp_files()
        __logger.severe('WLSDPLY-05801', pe.getLocalizedMessage())
        tool_exit.end(model_context, 2)
    except:
        exc_type, exc_obj, exc_tb = sys.exc_info()
        eeString = traceback.format_exception(exc_type, exc_obj, exc_tb)
        cla_helper.clean_up_temp_files()
        __logger.severe('WLSDPLY-05801', eeString)
        tool_exit.end(model_context, 2)


def format_message(key, *args):
    """
    Get message using the bundle.