Beispiel #1
0
def update_all_configurations(restart=True):
    """
    update all configuration and restart all services
    does not deploy any packages
    """
    restart = get_bool_from_cli(restart)

    execute(kraken.get_no_data_instances)
    execute(jormungandr.update_jormungandr_conf)
    execute(kraken.update_monitor_configuration)
    execute(tyr.update_tyr_confs)
    for instance in env.instances.values():
        execute(tyr.update_tyr_instance_conf, instance)
        execute(jormungandr.deploy_jormungandr_instance_conf, instance)
        execute(kraken.update_eng_instance_conf, instance)
    #once all has been updated, we restart all services (if needed)for the conf to be taken into account
    if restart:
        execute(tyr.restart_tyr_worker)
        execute(tyr.restart_tyr_beat)
        execute(jormungandr.reload_jormun_safe_all)
        execute(kraken.restart_all_krakens)

        # and we test the jormungandr
        for server in env.roledefs['ws']:
            jormungandr.test_jormungandr(get_host_addr(server))
Beispiel #2
0
def update_jormungandr_configurations(restart=True):
    """
    update all configuration and restart all services
    does not deploy any packages
    """
    restart = get_bool_from_cli(restart)

    execute(jormungandr.update_jormungandr_conf)
    for instance in env.instances.values():
        execute(jormungandr.deploy_jormungandr_instance_conf, instance)
    #once all has been updated, we restart all services (if needed)for the conf to be taken into account
    if restart:
        execute(jormungandr.reload_jormun_safe_all)

        # and we test the jormungandr
        for server in env.roledefs['ws']:
            jormungandr.check_jormungandr_with_retry(get_host_addr(server))
Beispiel #3
0
def update_instance(instance, reload_jormun=True):
    """
    param (instance) - update all configuration and restart all services
    does not deploy any packages
    """
    instance = get_real_instance(instance)
    reload_jormun = get_bool_from_cli(reload_jormun)
    print(blue('updating {}'.format(instance.name)))
    #first of all we compute the instance status, it will be helpfull later
    execute(compute_instance_status, instance)
    execute(tyr.create_tyr_instance, instance)
    execute(component.db.postgis_initdb, instance.db_name)
    execute(tyr.update_ed_db, instance.name)
    execute(jormungandr.deploy_jormungandr_instance_conf, instance)
    execute(kraken.create_eng_instance, instance)
    execute(tyr.deploy_default_synonyms, instance)
    execute(component.db.create_privileges_instance_db, instance)
    if reload_jormun:
        execute(jormungandr.reload_jormun_safe_all)
Beispiel #4
0
def update_instance(instance, reload_jormun=True):
    """
    param (instance) - update all configuration and restart all services
    does not deploy any packages
    """
    instance = get_real_instance(instance)
    reload_jormun = get_bool_from_cli(reload_jormun)
    print(blue('updating {}'.format(instance.name)))
    #first of all we compute the instance status, it will be helpfull later
    execute(compute_instance_status, instance)
    execute(tyr.create_tyr_instance, instance)
    execute(component.db.postgis_initdb, instance.db_name)
    execute(tyr.update_ed_db, instance.name)
    execute(jormungandr.deploy_jormungandr_instance_conf, instance)
    execute(kraken.create_eng_instance, instance)
    execute(tyr.deploy_default_synonyms, instance)
    execute(component.db.create_privileges_instance_db, instance)
    if reload_jormun:
        execute(jormungandr.reload_jormun_safe_all)
Beispiel #5
0
def upgrade_all(up_tyr=True,
                up_confs=True,
                upgrade_db_tyr=True,
                check_version=True,
                send_mail='no',
                manual_lb=False,
                check_dead=True,
                check_bina=True,
                skip_bina=False):
    """Upgrade all navitia packages, databases and launch rebinarisation of all instances """
    up_tyr = get_bool_from_cli(up_tyr)
    up_confs = get_bool_from_cli(up_confs)
    check_version = get_bool_from_cli(check_version)
    check_dead = get_bool_from_cli(check_dead)
    check_bina = get_bool_from_cli(check_bina)
    upgrade_db_tyr = get_bool_from_cli(upgrade_db_tyr)
    skip_bina = get_bool_from_cli(skip_bina)

    # check if all krakens are running with data
    not_loaded_instances = kraken.get_not_loaded_instances_per_host()

    # check one instance on each WS
    #TODO: Check all instance not only random one. #pylint: disable=fixme
    for server in env.roledefs['ws']:
        instance = random.choice(env.instances.values())
        execute(jormungandr.test_jormungandr,
                get_host_addr(server),
                instance=instance.name)

    if check_version:
        execute(compare_version_candidate_installed, host_name='tyr')

    if env.use_load_balancer:
        if manual_lb:
            print(
                yellow(
                    "WARNING : you are in MANUAL mode :\n"
                    "Check frequently for message asking you to switch nodes manually"
                ))
        else:
            # check credential NOW
            _adc_connection(check=True)

    execute(check_last_dataset)
    if send_mail in ('start', 'all'):
        broadcast_email('start')

    time_dict = TimeCollector()
    time_dict.register_start('total_deploy')

    if up_tyr:
        execute(update_tyr_step,
                time_dict,
                only_bina=False,
                check_bina=check_bina,
                upgrade_db_tyr=upgrade_db_tyr,
                skip_bina=skip_bina)

    if check_version:
        execute(compare_version_candidate_installed)

    if not skip_bina:
        execute(kraken.swap_all_data_nav)

    # Upgrade kraken/jormun on first hosts set
    if env.eng_hosts_1 and env.ws_hosts_1:
        env.roledefs['eng'] = env.eng_hosts_1
        env.roledefs['ws'] = env.ws_hosts_1
        if manual_lb:
            raw_input(
                yellow(
                    "Please disable ENG1,3/WS7-9 and enable ENG2,4/WS10-12"))
        else:
            execute(switch_to_first_phase, env.eng_haproxy1, env.ws_hosts_1,
                    env.ws_hosts_2)
    execute(upgrade_kraken,
            wait=env.KRAKEN_RESTART_SCHEME,
            up_confs=up_confs,
            supervision=True)
    if check_dead:
        execute(kraken.check_dead_instances, not_loaded_instances)
    execute(upgrade_jormungandr, reload=False, up_confs=up_confs)
    # need restart apache without using upgrade_jormungandr task previously
    # because that causes a problem in prod
    execute(jormungandr.reload_jormun_safe_all, safe=False)

    # check one instance on each WS
    #TODO: Check all instance not only random one.
    for server in env.roledefs['ws']:
        instance = random.choice(env.instances.values())
        execute(jormungandr.test_jormungandr,
                get_host_addr(server),
                instance=instance.name)

    if env.eng_hosts_2 and env.ws_hosts_2:
        # Upgrade kraken/jormun on remaining hosts
        env.roledefs['eng'] = env.eng_hosts_2
        env.roledefs['ws'] = env.ws_hosts_2
        if manual_lb:
            raw_input(
                yellow(
                    "Please enable ENG1,3/WS7-9 and disable ENG2,4/WS10-12"))
        else:
            execute(switch_to_second_phase, env.eng_haproxy1, env.eng_haproxy2,
                    env.ws_hosts_1, env.ws_hosts_2)
        execute(upgrade_jormungandr, reload=False, up_confs=up_confs)
        # need restart apache without using upgrade_jormungandr task previously
        # because that causes a problem in prod
        execute(jormungandr.reload_jormun_safe_all, safe=False)
        if manual_lb:
            raw_input(yellow("Please enable WS7-12"))
        else:
            execute(switch_to_third_phase, env.ws_hosts_2)
        env.roledefs['ws'] = env.ws_hosts
        execute(upgrade_kraken,
                wait=env.KRAKEN_RESTART_SCHEME,
                up_confs=up_confs)
        if check_dead:
            execute(kraken.check_dead_instances, not_loaded_instances)
        # check second hosts set
        for server in env.roledefs['ws']:
            instance = random.choice(env.instances.values())
            execute(jormungandr.test_jormungandr,
                    get_host_addr(server),
                    instance=instance.name)

        env.roledefs['eng'] = env.eng_hosts
        if not manual_lb:
            #execute(enable_nodes, env.eng_hosts)
            execute(enable_kraken_haproxy, env.eng_names)

    # start tyr_beat even if up_tyr is False
    execute(tyr.start_tyr_beat)
    time_dict.register_end('total_deploy')
    if send_mail in ('end', 'all'):
        warn_dict = jormungandr.check_kraken_jormun_after_deploy()
        status = show_dead_kraken_status(warn_dict, show=True)
        status += show_time_deploy(time_dict)
        broadcast_email('end', status)

    if env.use_load_balancer and manual_lb:
        print(yellow("Please enable ENG1-4/WS7-12"))
Beispiel #6
0
def upgrade_all(up_tyr=True, up_confs=True, check_version=True, send_mail='no',
                manual_lb=False, check_dead=True, check_bina=True):
    """Upgrade all navitia packages, databases and launch rebinarisation of all instances """
    up_tyr = get_bool_from_cli(up_tyr)
    up_confs = get_bool_from_cli(up_confs)
    check_version = get_bool_from_cli(check_version)
    check_dead = get_bool_from_cli(check_dead)
    check_bina = get_bool_from_cli(check_bina)

    if check_version:
        execute(compare_version_candidate_installed, host_name='tyr')

    if env.use_load_balancer:
        if manual_lb:
            print(yellow("WARNING : you are in MANUAL mode :\n"
                         "Check frequently for message asking you to switch nodes manually"))
        else:
            # check credential NOW
            _adc_connection(check=True)

    execute(check_last_dataset)
    if send_mail in ('start', 'all'):
        broadcast_email('start')

    time_dict = TimeCollector()
    time_dict.register_start('total_deploy')

    if up_tyr:
        execute(update_tyr_step, time_dict, only_bina=False, check_bina=check_bina)

    if check_version:
        execute(compare_version_candidate_installed)
    execute(kraken.swap_all_data_nav)

    # Upgrade kraken/jormun on first hosts set
    if not env.roledefs['eng'] and not env.roledefs['ws']:
        env.roledefs['eng'] = env.eng_hosts_1
        env.roledefs['ws'] = env.ws_hosts_1
        if manual_lb:
            raw_input(yellow("Please disable ENG1,3/WS7-9 and enable ENG2,4/WS10-12"))
        else:
            execute(switch_to_first_phase, env.eng_hosts_1, env.ws_hosts_1, env.ws_hosts_2)
    execute(upgrade_kraken, wait=env.KRAKEN_RESTART_SCHEME, up_confs=up_confs, supervision=True)
    if check_dead:
        execute(kraken.check_dead_instances)
    execute(upgrade_jormungandr, reload=False, up_confs=up_confs)

    # check first hosts set
    for server in env.roledefs['ws']:
        instance = random.choice(env.instances.values())
        execute(jormungandr.test_jormungandr, get_host_addr(server), instance=instance.name)

    if not env.roledefs['eng'] and not env.roledefs['ws']:
        # Upgrade kraken/jormun on remaining hosts
        env.roledefs['eng'] = env.eng_hosts_2
        env.roledefs['ws'] = env.ws_hosts_2
        if manual_lb:
            raw_input(yellow("Please enable ENG1,3/WS7-9 and disable ENG2,4/WS10-12"))
        else:
            execute(switch_to_second_phase, env.eng_hosts_1, env.eng_hosts_2,
                    env.ws_hosts_1,  env.ws_hosts_2)
        execute(upgrade_jormungandr, reload=False, up_confs=up_confs)
        if manual_lb:
            raw_input(yellow("Please enable WS7-12"))
        else:
            execute(switch_to_third_phase, env.ws_hosts_2)
        env.roledefs['ws'] = env.ws_hosts
        execute(upgrade_kraken, wait=env.KRAKEN_RESTART_SCHEME, up_confs=up_confs)

        # check second hosts set
        for server in env.roledefs['ws']:
            instance = random.choice(env.instances.values())
            execute(jormungandr.test_jormungandr, get_host_addr(server), instance=instance.name)

        if not manual_lb:
            execute(enable_all_nodes, env.eng_hosts, env.ws_hosts_1,  env.ws_hosts_2)
        env.roledefs['eng'] = env.eng_hosts

    # start tyr_beat even if up_tyr is False
    execute(tyr.start_tyr_beat)
    time_dict.register_end('total_deploy')
    if send_mail in ('end', 'all'):
        warn_dict = jormungandr.check_kraken_jormun_after_deploy()
        status = show_dead_kraken_status(warn_dict, show=True)
        status += show_time_deploy(time_dict)
        broadcast_email('end', status)

    if env.use_load_balancer and manual_lb:
        print(yellow("Please enable ENG1-4/WS7-12"))