コード例 #1
0
ファイル: tyr.py プロジェクト: CanalTP/fabric_navitia
def upgrade_tyr_packages():
    packages = [
        'logrotate',
        'git',
        ]
    if env.distrib == 'ubuntu14.04':
        packages += ['libpython2.7-dev']
    elif env.distrib == 'debian7':
        packages += ['python2.7-dev']
    elif env.distrib == 'debian8':
        packages += ['python2.7-dev', 'g++']
    require.deb.packages(packages, update=True)
    package_filter_list = ['navitia-tyr*deb',
                           'navitia-common*deb']
    _install_packages(package_filter_list)
    if not python.is_pip_installed():
        python.install_pip()

    #we want the version of the system for these packages
    run('''sed -e "/protobuf/d" -e "/psycopg2/d"  /usr/share/tyr/requirements.txt > /tmp/tyr_requirements.txt''')
    run('git config --global url."https://".insteadOf git://')
    require.python.install_requirements('/tmp/tyr_requirements.txt', use_sudo=True, exists_action='w')
    if env.use_systemd:
        _upload_template('tyr/systemd_tyr_worker.jinja', env.service_name('tyr_worker'),
                         user='******', mode='644', context={'env': env})
    else:
        _upload_template('tyr/tyr_worker.jinja', env.service_name('tyr_worker'),
                         user='******', mode='755', context={'env': env})
    restart_tyr_worker()
    update_init(host='tyr')
コード例 #2
0
ファイル: kraken.py プロジェクト: CanalTP/fabric_navitia
def update_eng_instance_conf(instance, host=None):
    instance = get_real_instance(instance)
    hosts = [host] if host else instance.kraken_engines
    for host in hosts:
        with settings(host_string=host):
            require.files.directory(os.path.join(instance.kraken_basedir, instance.name),
                                    owner=env.KRAKEN_USER, group=env.KRAKEN_USER, use_sudo=True)
            _upload_template("kraken/kraken.ini.jinja", "%s/%s/kraken.ini" %
                             (env.kraken_basedir, instance.name),
                             context={
                                 'env': env,
                                 'instance': instance,
                             }
            )

            if env.use_systemd:
                _upload_template("kraken/systemd_kraken.jinja",
                                 "{}".format(env.service_name('kraken_{}'.format(instance.name))),
                                 context={'env': env,
                                          'instance': instance.name,
                                          'kraken_base_conf': env.kraken_basedir,
                                 },
                                 mode='644'
                )
            else:
                _upload_template("kraken/kraken.initscript.jinja",
                                 "{}".format(env.service_name('kraken_{}'.format(instance.name))),
                                 context={'env': env,
                                          'instance': instance.name,
                                          'kraken_base_conf': env.kraken_basedir,
                                 },
                                 mode='755'
                )
            # TODO check this, make it consistent with env.use_systemd
            update_init(host='eng')
コード例 #3
0
def upgrade_tyr_packages():
    packages = [
        'logrotate',
        'git',
        ]
    if env.distrib == 'ubuntu14.04':
        packages += ['libpython2.7-dev']
    elif env.distrib == 'debian7':
        packages += ['python2.7-dev']
    elif env.distrib == 'debian8':
        packages += ['python2.7-dev', 'g++']
    require.deb.packages(packages, update=True)
    package_filter_list = ['navitia-tyr*deb',
                           'navitia-common*deb']
    _install_packages(package_filter_list)
    if not python.is_pip_installed():
        python.install_pip()

    #we want the version of the system for these packages
    run('''sed -e "/protobuf/d" -e "/psycopg2/d"  /usr/share/tyr/requirements.txt > /tmp/tyr_requirements.txt''')
    run('git config --global url."https://".insteadOf git://')
    require.python.install_requirements('/tmp/tyr_requirements.txt', use_sudo=True, exists_action='w')
    if env.use_systemd:
        _upload_template('tyr/systemd_tyr_worker.jinja', env.service_name('tyr_worker'),
                         user='******', mode='644', context={'env': env})
    else:
        _upload_template('tyr/tyr_worker.jinja', env.service_name('tyr_worker'),
                         user='******', mode='755', context={'env': env})
    restart_tyr_worker()
    update_init(host='tyr')
コード例 #4
0
def update_tyr_confs():
    execute_flat(update_tyr_config_file)
    for instance in env.instances.values():
        execute_flat(update_tyr_instance_conf, instance)
    execute(update_cities_conf)
    execute(restart_tyr_worker)
    update_init(host='tyr')
コード例 #5
0
def update_eng_instance_conf(instance, host=None):
    instance = get_real_instance(instance)
    hosts = [host] if host else instance.kraken_engines
    for host in hosts:
        with settings(host_string=host):
            require.files.directory(os.path.join(instance.kraken_basedir, instance.name),
                                    owner=env.KRAKEN_USER, group=env.KRAKEN_USER, use_sudo=True)
            _upload_template("kraken/kraken.ini.jinja", "%s/%s/kraken.ini" %
                             (env.kraken_basedir, instance.name),
                             context={
                                 'env': env,
                                 'instance': instance,
                             }
            )

            if env.use_systemd:
                _upload_template("kraken/systemd_kraken.jinja",
                                 "{}".format(env.service_name('kraken_{}'.format(instance.name))),
                                 context={'env': env,
                                          'instance': instance.name,
                                          'kraken_base_conf': env.kraken_basedir,
                                 },
                                 mode='644'
                )
            else:
                _upload_template("kraken/kraken.initscript.jinja",
                                 "{}".format(env.service_name('kraken_{}'.format(instance.name))),
                                 context={'env': env,
                                          'instance': instance.name,
                                          'kraken_base_conf': env.kraken_basedir,
                                 },
                                 mode='755'
                )
            # TODO check this, make it consistent with env.use_systemd
            update_init(host='eng')
コード例 #6
0
ファイル: kraken.py プロジェクト: niko64fx/fabric_navitia
def update_eng_instance_conf(instance):
    instance = get_real_instance(instance)
    for host in instance.kraken_engines:
        with settings(host_string=host):
            _upload_template("kraken/kraken.ini.jinja", "%s/%s/kraken.ini" %
                             (env.kraken_basedir, instance.name),
                             context={
                                 'env': env,
                                 'instance': instance,
                             }
            )

            if env.use_systemd:
                _upload_template("kraken/systemd_kraken.jinja",
                                 "{}".format(env.service_name('kraken_{}'.format(instance.name))),
                                 context={'env': env,
                                          'instance': instance.name,
                                          'kraken_base_conf': env.kraken_basedir,
                                 },
                                 mode='644'
                )
            else:
                _upload_template("kraken/kraken.initscript.jinja",
                                 "{}".format(env.service_name('kraken_{}'.format(instance.name))),
                                 context={'env': env,
                                          'instance': instance.name,
                                          'kraken_base_conf': env.kraken_basedir,
                                 },
                                 mode='755'
                )
            # TODO check this, make it consistent with env.use_systemd
            update_init(host='eng')
コード例 #7
0
ファイル: tyr.py プロジェクト: CanalTP/fabric_navitia
def setup_tyr_master():
    require_directory(env.ed_basedir, owner='www-data', group='www-data', use_sudo=True)
    if env.use_systemd:
        _upload_template('tyr/systemd_tyr_beat.jinja', env.service_name('tyr_beat'),
                         user='******', mode='644', context={'env': env})
    else:
        _upload_template('tyr/tyr_beat.jinja',env.service_name('tyr_beat'),
                         user='******', mode='755', context={'env': env})
    update_init(host='tyr')
コード例 #8
0
def setup_tyr_master():
    require_directory(env.ed_basedir, owner='www-data', group='www-data', use_sudo=True)
    if env.use_systemd:
        _upload_template('tyr/systemd_tyr_beat.jinja', env.service_name('tyr_beat'),
                         user='******', mode='644', context={'env': env})
    else:
        _upload_template('tyr/tyr_beat.jinja',env.service_name('tyr_beat'),
                         user='******', mode='755', context={'env': env})
    update_init(host='tyr')
コード例 #9
0
ファイル: tyr.py プロジェクト: CanalTP/fabric_navitia
def setup_tyr():
    require.users.user('www-data')

    require_directories([env.tyr_base_instances_dir,
                               env.tyr_basedir,
                               ],
                              owner=env.TYR_USER,
                              group=env.TYR_USER,
                              mode='755',
                              use_sudo=True)

    require_directory(env.tyr_base_logdir,
                              owner=env.TYR_USER,
                              group=env.TYR_USER,
                              mode='777',
                              use_sudo=True)

    require_directory(env.tyr_base_destination_dir,
                              is_on_nfs4=False,
                              owner=env.TYR_USER,
                              group=env.TYR_USER,
                              mode='755',
                              use_sudo=True)

    require.files.file(env.tyr_base_logfile,
                              owner=env.TYR_USER,
                              group=env.TYR_USER,
                              mode='766',
                              use_sudo=True)

    require.files.file(env.tyr_logfile_pattern,
                              owner=env.TYR_USER,
                              group=env.TYR_USER,
                              mode='766',
                              use_sudo=True)

    update_tyr_confs()

    if env.use_systemd:
        _upload_template('tyr/systemd_tyr_worker.jinja', env.service_name('tyr_worker'),
                         user='******', mode='644', context={'env': env})
    else:
        _upload_template('tyr/tyr_worker.jinja', env.service_name('tyr_worker'),
                         user='******', mode='755', context={'env': env})
    update_init(host='tyr')

    if not files.is_dir(env.tyr_migration_dir):
        idempotent_symlink('/usr/share/tyr/migrations/', env.tyr_migration_dir, use_sudo=True)
        sudo("chown www-data:www-data {}".format(env.tyr_migration_dir))

    # we create a symlink for tyr manage_py
    tyr_symlink = os.path.join(env.tyr_basedir, 'manage.py')
    if not files.is_file(tyr_symlink):
        idempotent_symlink('/usr/bin/manage_tyr.py', tyr_symlink, use_sudo=True)
コード例 #10
0
def setup_tyr():
    require.users.user('www-data')

    require_directories([env.tyr_base_instances_dir,
                               env.tyr_basedir,
                               ],
                              owner=env.TYR_USER,
                              group=env.TYR_USER,
                              mode='755',
                              use_sudo=True)

    require_directory(env.tyr_base_logdir,
                              owner=env.TYR_USER,
                              group=env.TYR_USER,
                              mode='777',
                              use_sudo=True)

    require_directory(env.tyr_base_destination_dir,
                              is_on_nfs4=False,
                              owner=env.TYR_USER,
                              group=env.TYR_USER,
                              mode='755',
                              use_sudo=True)

    require.files.file(env.tyr_base_logfile,
                              owner=env.TYR_USER,
                              group=env.TYR_USER,
                              mode='766',
                              use_sudo=True)

    require.files.file(env.tyr_logfile_pattern,
                              owner=env.TYR_USER,
                              group=env.TYR_USER,
                              mode='766',
                              use_sudo=True)

    update_tyr_confs()

    if env.use_systemd:
        _upload_template('tyr/systemd_tyr_worker.jinja', env.service_name('tyr_worker'),
                         user='******', mode='644', context={'env': env})
    else:
        _upload_template('tyr/tyr_worker.jinja', env.service_name('tyr_worker'),
                         user='******', mode='755', context={'env': env})
    update_init(host='tyr')

    if not files.is_dir(env.tyr_migration_dir):
        idempotent_symlink('/usr/share/tyr/migrations/', env.tyr_migration_dir, use_sudo=True)
        sudo("chown www-data:www-data {}".format(env.tyr_migration_dir))

    # we create a symlink for tyr manage_py
    tyr_symlink = os.path.join(env.tyr_basedir, 'manage.py')
    if not files.is_file(tyr_symlink):
        idempotent_symlink('/usr/bin/manage_tyr.py', tyr_symlink, use_sudo=True)
コード例 #11
0
def update_eng_instance_conf(instance):
    instance = get_real_instance(instance)
    for host in instance.kraken_engines:
        with settings(host_string=host):
            _upload_template("kraken/kraken.ini.jinja",
                             "%s/%s/kraken.ini" %
                             (env.kraken_basedir, instance.name),
                             context={
                                 'env': env,
                                 'instance': instance,
                             })

            if env.use_systemd:
                _upload_template("kraken/systemd_kraken.jinja",
                                 "{}".format(
                                     env.service_name('kraken_{}'.format(
                                         instance.name))),
                                 context={
                                     'env': env,
                                     'instance': instance.name,
                                     'kraken_base_conf': env.kraken_basedir,
                                 },
                                 mode='644')
            else:
                _upload_template("kraken/kraken.initscript.jinja",
                                 "{}".format(
                                     env.service_name('kraken_{}'.format(
                                         instance.name))),
                                 context={
                                     'env': env,
                                     'instance': instance.name,
                                     'kraken_base_conf': env.kraken_basedir,
                                 },
                                 mode='755')
            # TODO check this, make it consistent with env.use_systemd
            update_init(host='eng')