Пример #1
0
def setup_dependencies_and_mdsd(configurator):
    """
    Set up dependencies for mdsd, such as following:
    1) Distro-specific packages (see DistroSpecific.py)
    2) Set up omsagent (fluentd), syslog (rsyslog or syslog-ng) for mdsd
    :return: Status code and message
    """
    install_package_error = ""
    retry = 3
    while retry > 0:
        error, msg = g_dist_config.install_required_packages()
        hutil.log(msg)
        if error == 0:
            break
        else:
            retry -= 1
            hutil.log("Sleep 60 retry " + str(retry))
            install_package_error = msg
            time.sleep(60)
    if install_package_error:
        if len(install_package_error) > 1024:
            install_package_error = install_package_error[
                0:512] + install_package_error[-512:-1]
        hutil.error(install_package_error)
        return 2, install_package_error

    # Run mdsd prep commands
    g_dist_config.prepare_for_mdsd_install()

    # Set up omsagent
    omsagent_setup_exit_code, omsagent_setup_output = oms.setup_omsagent(
        configurator, RunGetOutput, hutil.log, hutil.error)
    if omsagent_setup_exit_code is not 0:
        return 3, omsagent_setup_output

    # Install lad-mdsd pkg (/usr/local/lad/bin/mdsd). Must be done after omsagent install because of dependencies
    cmd_exit_code, cmd_output = g_dist_config.install_lad_mdsd()
    if cmd_exit_code != 0:
        return 4, 'lad-mdsd pkg install failed. Exit code={0}, Output={1}'.format(
            cmd_exit_code, cmd_output)

    return 0, 'success'
def setup_dependencies_and_mdsd(configurator):
    """
    Set up dependencies for mdsd, such as following:
    1) Distro-specific packages (see DistroSpecific.py)
    2) Set up omsagent (fluentd), syslog (rsyslog or syslog-ng) for mdsd
    :return: Status code and message
    """
    install_package_error = ""
    retry = 3
    while retry > 0:
        error, msg = g_dist_config.install_required_packages()
        hutil.log(msg)
        if error == 0:
            break
        else:
            retry -= 1
            hutil.log("Sleep 60 retry " + str(retry))
            install_package_error = msg
            time.sleep(60)
    if install_package_error:
        if len(install_package_error) > 1024:
            install_package_error = install_package_error[0:512] + install_package_error[-512:-1]
        hutil.error(install_package_error)
        return 2, install_package_error

    # Run mdsd prep commands
    g_dist_config.prepare_for_mdsd_install()

    # Set up omsagent
    omsagent_setup_exit_code, omsagent_setup_output = oms.setup_omsagent(configurator, RunGetOutput,
                                                                         hutil.log, hutil.error)
    if omsagent_setup_exit_code is not 0:
        return 3, omsagent_setup_output

    # Install lad-mdsd pkg (/usr/local/lad/bin/mdsd). Must be done after omsagent install because of dependencies
    cmd_exit_code, cmd_output = g_dist_config.install_lad_mdsd()
    if cmd_exit_code != 0:
        return 4, 'lad-mdsd pkg install failed. Exit code={0}, Output={1}'.format(cmd_exit_code, cmd_output)

    return 0, 'success'