Пример #1
0
def service_name(service):
    """
    Use an adapted service name with the path according to the OS
    """
    if env.use_systemd:
        return env.service_path() + service + '.service'
    else:
        return env.service_path() + service
Пример #2
0
def service_name(service):
    """
    Use an adapted service name with the path according to the OS
    """
    if env.use_systemd:
        return env.service_path() + service + '.service'
    else:
        return env.service_path() + service
Пример #3
0
def remove_kraken_instance(instance, purge_logs=False, apply_on='engines'):
    """
    Remove a kraken instance entirely
      * Stop the service
      * Remove startup at boot time
      * Remove initscript
      * Remove configuration and pid directory
    apply_on values:
     - engines: apply on instance.kraken_engines
     - reverse: apply on all engines except instance.kraken_engines
     - all: apply on all engines
    """
    instance = get_real_instance(instance)
    if apply_on == 'engines':
        hosts, exclude_hosts = instance.kraken_engines, ()
    elif apply_on == 'reverse':
        hosts, exclude_hosts = env.roledefs['eng'], instance.kraken_engines
    elif apply_on == 'all':
        hosts, exclude_hosts = env.roledefs['eng'], ()
    else:
        abort("Bad 'apply_on' parameter value: {}".format(apply_on))

    for host in set(hosts) - set(exclude_hosts):
        with settings(
            host_string=host,
            warn_only=True
        ):
            sudo("service kraken_{} stop && sleep 3".format(instance.name))

            if not env.use_systemd:
                run("update-rc.d -f kraken_{} remove".format(instance.name))
            sudo("rm -f {}/kraken_{}".format(env.service_path(), instance.name))
            sudo("rm -rf {}/{}/".format(env.kraken_basedir, instance.name))
            if purge_logs:
                sudo("rm -f {}/{}.log".format(env.kraken_log_basedir, instance.name))
Пример #4
0
def remove_kraken_instance(instance, purge_logs=False, apply_on='engines'):
    """
    Remove a kraken instance entirely
      * Stop the service
      * Remove startup at boot time
      * Remove initscript
      * Remove configuration and pid directory
    apply_on values:
     - engines: apply on instance.kraken_engines
     - reverse: apply on all engines except instance.kraken_engines
     - all: apply on all engines
    """
    instance = get_real_instance(instance)
    if apply_on == 'engines':
        hosts, exclude_hosts = instance.kraken_engines, ()
    elif apply_on == 'reverse':
        hosts, exclude_hosts = env.roledefs['eng'], instance.kraken_engines
    elif apply_on == 'all':
        hosts, exclude_hosts = env.roledefs['eng'], ()
    else:
        abort("Bad 'apply_on' parameter value: {}".format(apply_on))

    for host in set(hosts) - set(exclude_hosts):
        with settings(host_string=host, warn_only=True):
            print("INFO: removing kraken instance {} from {}".format(
                instance.name, get_host_addr(host)))

            service.stop('kraken_{}'.format(instance.name))
            run("sleep 3")
            # TODO test this on systemd machines
            if env.use_systemd:
                run("systemctl disable kraken_{}.service".format(
                    instance.name))
                run('systemctl daemon-reload')
                run("rm -f {}/kraken_{}.service".format(
                    env.service_path(), instance.name))
            else:
                run("rm -f {}/kraken_{}".format(env.service_path(),
                                                instance.name))
            run("rm -rf {}/{}/".format(env.kraken_basedir, instance.name))
            if purge_logs:
                run("rm -f {}/{}.log".format(env.kraken_log_basedir,
                                             instance.name))
Пример #5
0
def remove_kraken_instance(instance, purge_logs=False, apply_on='engines'):
    """
    Remove a kraken instance entirely
      * Stop the service
      * Remove startup at boot time
      * Remove initscript
      * Remove configuration and pid directory
    apply_on values:
     - engines: apply on instance.kraken_engines
     - reverse: apply on all engines except instance.kraken_engines
     - all: apply on all engines
    """
    instance = get_real_instance(instance)
    if apply_on == 'engines':
        hosts, exclude_hosts = instance.kraken_engines, ()
    elif apply_on == 'reverse':
        hosts, exclude_hosts = env.roledefs['eng'], instance.kraken_engines
    elif apply_on == 'all':
        hosts, exclude_hosts = env.roledefs['eng'], ()
    else:
        abort("Bad 'apply_on' parameter value: {}".format(apply_on))

    for host in set(hosts) - set(exclude_hosts):
        with settings(
            host_string=host,
            warn_only=True
        ):
            print("INFO: removing kraken instance {} from {}".format(instance.name, get_host_addr(host)))

            service.stop('kraken_{}'.format(instance.name))
            run("sleep 3")
            # TODO test this on systemd machines
            if env.use_systemd:
                run("systemctl disable kraken_{}.service".format(instance.name))
                run('systemctl daemon-reload')
            run("rm -f {}/kraken_{}".format(env.service_path(), instance.name))
            run("rm -rf {}/{}/".format(env.kraken_basedir, instance.name))
            if purge_logs:
                run("rm -f {}/{}.log".format(env.kraken_log_basedir, instance.name))
Пример #6
0
def remove_kraken_instance(instance, purge_logs=False, apply_on='engines'):
    """
    Remove a kraken instance entirely
      * Stop the service
      * Remove startup at boot time
      * Remove initscript
      * Remove configuration and pid directory
    apply_on values:
     - engines: apply on instance.kraken_engines
     - reverse: apply on all engines except instance.kraken_engines
     - all: apply on all engines
    """
    instance = get_real_instance(instance)
    if apply_on == 'engines':
        hosts, exclude_hosts = instance.kraken_engines, ()
    elif apply_on == 'reverse':
        hosts, exclude_hosts = env.roledefs['eng'], instance.kraken_engines
    elif apply_on == 'all':
        hosts, exclude_hosts = env.roledefs['eng'], ()
    else:
        abort("Bad 'apply_on' parameter value: {}".format(apply_on))

    for host in set(hosts) - set(exclude_hosts):
        with settings(host_string=host, warn_only=True):
            sudo("service kraken_{} stop; sleep 3".format(instance.name))

            if not env.use_systemd:
                run("update-rc.d -f kraken_{} remove".format(instance.name))
            sudo("rm --force {}/kraken_{}".format(env.service_path(),
                                                  instance.name))
            sudo("rm --recursive --force {}/{}/".format(
                env.kraken_basedir, instance.name))
            if purge_logs:
                # ex.: /var/log/kraken/navitia-bretagne.log
                sudo("rm --force {}-{}.log".format(env.kraken_log_name,
                                                   instance.name))