예제 #1
0
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc')
    configs = [
        {'src': src_etc,
         'dest': '/etc/neutron'},
        {'src': os.path.join(src_etc, 'neutron/plugins'),
         'dest': '/etc/neutron/plugins'},
        {'src': os.path.join(src_etc, 'neutron/rootwrap.d'),
         'dest': '/etc/neutron/rootwrap.d'},
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/neutron-rootwrap'),
         'link': '/usr/local/bin/neutron-rootwrap'},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/neutron_sudoers', '/etc/sudoers.d/neutron_sudoers', {},
           perms=0o440)

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    neutron_ovs_agent_context = {
        'service_description': 'Neutron OpenvSwitch Plugin Agent',
        'charm_name': 'neutron-openvswitch',
        'process_name': 'neutron-openvswitch-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-openvswitch-agent'),
        'cleanup_process_name': 'neutron-ovs-cleanup',
        'plugin_config': '/etc/neutron/plugins/ml2/ml2_conf.ini',
        'log_file': '/var/log/neutron/openvswitch-agent.log',
    }

    neutron_ovs_cleanup_context = {
        'service_description': 'Neutron OpenvSwitch Cleanup',
        'charm_name': 'neutron-openvswitch',
        'process_name': 'neutron-ovs-cleanup',
        'executable_name': os.path.join(bin_dir, 'neutron-ovs-cleanup'),
        'log_file': '/var/log/neutron/ovs-cleanup.log',
    }

    # NOTE(coreycb): Needs systemd support
    render('git/upstart/neutron-plugin-openvswitch-agent.upstart',
           '/etc/init/neutron-plugin-openvswitch-agent.conf',
           neutron_ovs_agent_context, perms=0o644)
    render('git/upstart/neutron-ovs-cleanup.upstart',
           '/etc/init/neutron-ovs-cleanup.conf',
           neutron_ovs_cleanup_context, perms=0o644)

    service_restart('neutron-plugin-openvswitch-agent')
예제 #2
0
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc')
    configs = [
        {'src': src_etc,
         'dest': '/etc/neutron'},
        {'src': os.path.join(src_etc, 'neutron/plugins'),
         'dest': '/etc/neutron/plugins'},
        {'src': os.path.join(src_etc, 'neutron/rootwrap.d'),
         'dest': '/etc/neutron/rootwrap.d'},
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/neutron-rootwrap'),
         'link': '/usr/local/bin/neutron-rootwrap'},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/neutron_sudoers', '/etc/sudoers.d/neutron_sudoers', {},
           perms=0o440)

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    neutron_ovs_agent_context = {
        'service_description': 'Neutron OpenvSwitch Plugin Agent',
        'charm_name': 'neutron-openvswitch',
        'process_name': 'neutron-openvswitch-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-openvswitch-agent'),
        'cleanup_process_name': 'neutron-ovs-cleanup',
        'plugin_config': '/etc/neutron/plugins/ml2/ml2_conf.ini',
        'log_file': '/var/log/neutron/openvswitch-agent.log',
    }

    neutron_ovs_cleanup_context = {
        'service_description': 'Neutron OpenvSwitch Cleanup',
        'charm_name': 'neutron-openvswitch',
        'process_name': 'neutron-ovs-cleanup',
        'executable_name': os.path.join(bin_dir, 'neutron-ovs-cleanup'),
        'log_file': '/var/log/neutron/ovs-cleanup.log',
    }

    # NOTE(coreycb): Needs systemd support
    render('git/upstart/neutron-plugin-openvswitch-agent.upstart',
           '/etc/init/neutron-plugin-openvswitch-agent.conf',
           neutron_ovs_agent_context, perms=0o644)
    render('git/upstart/neutron-ovs-cleanup.upstart',
           '/etc/init/neutron-ovs-cleanup.conf',
           neutron_ovs_cleanup_context, perms=0o644)

    service_restart('neutron-plugin-openvswitch-agent')
예제 #3
0
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        pip_install('mysql-python', proxy=http_proxy,
                    venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install('mysql-python',
                    venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc')
    configs = [
        {'src': src_etc,
         'dest': '/etc/neutron'},
        {'src': os.path.join(src_etc, 'neutron/plugins'),
         'dest': '/etc/neutron/plugins'},
        {'src': os.path.join(src_etc, 'neutron/rootwrap.d'),
         'dest': '/etc/neutron/rootwrap.d'},
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/neutron-rootwrap'),
         'link': '/usr/local/bin/neutron-rootwrap'},
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/neutron-db-manage'),
         'link': '/usr/local/bin/neutron-db-manage'},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/neutron_sudoers', '/etc/sudoers.d/neutron_sudoers', {},
           perms=0o440)

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    neutron_api_context = {
        'service_description': 'Neutron API server',
        'charm_name': 'neutron-api',
        'process_name': 'neutron-server',
        'executable_name': os.path.join(bin_dir, 'neutron-server'),
    }

    # NOTE(coreycb): Needs systemd support
    render('git/upstart/neutron-server.upstart',
           '/etc/init/neutron-server.conf',
           neutron_api_context, perms=0o644)

    if not is_unit_paused_set():
        service_restart('neutron-server')
예제 #4
0
def git_post_install_late(projects_yaml):
    """Perform horizon post-install setup."""
    render('git/dashboard.conf',
           '/etc/apache2/conf-available/openstack-dashboard.conf',
           {'virtualenv': git_pip_venv_dir(projects_yaml)},
           owner='root', group='root', perms=0o644)

    python = os.path.join(git_pip_venv_dir(projects_yaml), 'bin/python')
    subprocess.check_call([python, '/usr/share/openstack-dashboard/manage.py',
                           'collectstatic', '--noinput'])
    subprocess.check_call([python, '/usr/share/openstack-dashboard/manage.py',
                           'compress', '--force'])
def plugin_relation_joined(rel_id=None):
    if git_install_requested():
        bin_path = git_pip_venv_dir(config('openstack-origin-git'))
    else:
        bin_path = '/usr/bin'
    relation_set(release=os_release("openstack-dashboard"),
                 relation_id=rel_id,
                 bin_path=bin_path,
                 openstack_dir=INSTALL_DIR)
def plugin_relation_joined(rel_id=None):
    if git_install_requested():
        bin_path = git_pip_venv_dir(config('openstack-origin-git'))
    else:
        bin_path = '/usr/bin'
    relation_set(release=os_release("openstack-dashboard"),
                 relation_id=rel_id,
                 bin_path=bin_path,
                 openstack_dir=INSTALL_DIR)
예제 #7
0
def git_post_install(projects_yaml):
    """Perform glance post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        pip_install('mysql-python', proxy=http_proxy,
                    venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install('mysql-python',
                    venv=git_pip_venv_dir(projects_yaml))

    for cs in CONSOLE_SCRIPTS:
        src = os.path.join(git_pip_venv_dir(projects_yaml),
                           'bin/%s' % cs)
        link = '/usr/local/bin/%s' % cs
        if os.path.lexists(link):
            os.remove(link)
        os.symlink(src, link)

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    astara_orchestrator_context = {
        'service_description': 'Astara Network Service Function Orchestrator',
        'service_name': 'Astara',
        # NOTE(adam_g): need to run as root until oslo.rootwrap integration
        # is added:
        # https://blueprints.launchpad.net/astara/+spec/astara-rootwrap
        'user_name': 'root',
        'start_dir': '/var/lib/astara',
        'process_name': 'astara-orchestrator',
        'executable_name': os.path.join(bin_dir, 'astara-orchestrator'),
        'config_files': ['/etc/astara/orchestrator.ini'],
        'log_file': '/var/log/astara/astara-orchestrator.log',
    }

    # NOTE(coreycb): Needs systemd support
    templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
    templates_dir = os.path.join(charm_dir(), templates_dir)
    render('git.upstart', '/etc/init/astara-orchestrator.conf',
           astara_orchestrator_context, perms=0o644,
           templates_dir=templates_dir)
예제 #8
0
def git_post_install_late(projects_yaml):
    """Perform horizon post-install setup."""
    projects_yaml = git_default_repos(projects_yaml)

    subprocess.check_call(['a2enconf', 'openstack-dashboard'])

    if not is_unit_paused_set():
        service_restart('apache2')

    python = os.path.join(git_pip_venv_dir(projects_yaml), 'bin/python')
    subprocess.check_call([python, '/usr/share/openstack-dashboard/manage.py',
                           'collectstatic', '--noinput'])
    subprocess.check_call([python, '/usr/share/openstack-dashboard/manage.py',
                           'compress', '--force'])
    def __call__(self):
        ''' Provide all configuration for Horizon '''
        projects_yaml = git_default_repos(config('openstack-origin-git'))
        ctxt = {
            'compress_offline':
            bool_from_string(config('offline-compression')),
            'debug':
            bool_from_string(config('debug')),
            'customization_module':
            config('customization-module'),
            'default_role':
            config('default-role'),
            "webroot":
            config('webroot') or '/',
            "ubuntu_theme":
            bool_from_string(config('ubuntu-theme')),
            "default_theme":
            config('default-theme'),
            "secret":
            config('secret') or pwgen(),
            'support_profile':
            config('profile') if config('profile') in ['cisco'] else None,
            "neutron_network_dvr":
            config("neutron-network-dvr"),
            "neutron_network_l3ha":
            config("neutron-network-l3ha"),
            "neutron_network_lb":
            config("neutron-network-lb"),
            "neutron_network_firewall":
            config("neutron-network-firewall"),
            "neutron_network_vpn":
            config("neutron-network-vpn"),
            "cinder_backup":
            config("cinder-backup"),
            "password_retrieve":
            config("password-retrieve"),
            'virtualenv':
            git_pip_venv_dir(projects_yaml)
            if config('openstack-origin-git') else None,
            'default_domain':
            config('default_domain')
            if config('default_domain') else 'default',
            'multi_domin':
            False if config('default_domain') else True
        }

        return ctxt
예제 #10
0
def api_extensions_path():
    """Return need the full path to the installation of neutron API extensions
    This is dependent on how the library was installed (git vs pkg)
    """
    if git_install_requested():
        venv_dir = git_pip_venv_dir(config('openstack-origin-git'))
        py = os.path.join(venv_dir, 'bin', 'python')
    else:
        py = subprocess.check_output(['which', 'python']).strip()

    cmd = [
        py, '-c', 'from akanda import neutron; print neutron.__file__;'
    ]
    module_path = subprocess.check_output(cmd)
    ext_path = os.path.join(os.path.dirname(module_path), 'extensions')

    if not os.path.isdir(ext_path):
        m = ('Could not locate astara-neutron API extensions directory @ %s' %
             ext_path)
        juju_log(m, 'ERROR')
        raise Exception(m)

    return ext_path
    def __call__(self):
        ''' Provide all configuration for Horizon '''
        projects_yaml = git_default_repos(config('openstack-origin-git'))
        ctxt = {
            'compress_offline': config('offline-compression') in ['yes', True],
            'debug': config('debug') in ['yes', True],
            'default_role': config('default-role'),
            "webroot": config('webroot'),
            "ubuntu_theme": config('ubuntu-theme') in ['yes', True],
            "default_theme": config('default-theme'),
            "secret": config('secret') or pwgen(),
            'support_profile': config('profile')
            if config('profile') in ['cisco'] else None,
            "neutron_network_dvr": config("neutron-network-dvr"),
            "neutron_network_l3ha": config("neutron-network-l3ha"),
            "neutron_network_lb": config("neutron-network-lb"),
            "neutron_network_firewall": config("neutron-network-firewall"),
            "neutron_network_vpn": config("neutron-network-vpn"),
            "cinder_backup": config("cinder-backup"),
            'virtualenv': git_pip_venv_dir(projects_yaml)
            if config('openstack-origin-git') else None,
        }

        return ctxt
예제 #12
0
def git_post_install(projects_yaml):
    """Perform cinder post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    base_packages = ['mysql-python']
    for pkg in base_packages:
        if http_proxy:
            pip_install(pkg, proxy=http_proxy,
                        venv=git_pip_venv_dir(projects_yaml))
        else:
            pip_install(pkg,
                        venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'cinder'), 'etc/cinder')
    configs = {
        'src': src_etc,
        'dest': '/etc/cinder',
    }

    if os.path.exists(configs['dest']):
        shutil.rmtree(configs['dest'])
    shutil.copytree(configs['src'], configs['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/cinder-manage'),
         'link': '/usr/local/bin/cinder-manage'},
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/cinder-rootwrap'),
         'link': '/usr/local/bin/cinder-rootwrap'},
        # NOTE(coreycb): This is ugly but couldn't find pypi package that
        #                installs rbd.py and rados.py.
        {'src': '/usr/lib/python2.7/dist-packages/rbd.py',
         'link': os.path.join(git_pip_venv_dir(projects_yaml),
                              'lib/python2.7/site-packages/rbd.py')},
        {'src': '/usr/lib/python2.7/dist-packages/rados.py',
         'link': os.path.join(git_pip_venv_dir(projects_yaml),
                              'lib/python2.7/site-packages/rados.py')},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('cinder.conf', '/etc/cinder/cinder.conf', {}, owner='cinder',
           group='cinder', perms=0o644)
    render('git/cinder_tgt.conf', '/etc/tgt/conf.d', {}, owner='cinder',
           group='cinder', perms=0o644)
    render('git/logging.conf', '/etc/cinder/logging.conf', {}, owner='cinder',
           group='cinder', perms=0o644)
    render('git/cinder_sudoers', '/etc/sudoers.d/cinder_sudoers', {},
           owner='root', group='root', perms=0o440)

    os.chmod('/etc/sudoers.d', 0o750)

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    cinder_api_context = {
        'service_description': 'Cinder API server',
        'service_name': 'Cinder',
        'user_name': 'cinder',
        'start_dir': '/var/lib/cinder',
        'process_name': 'cinder-api',
        'executable_name': os.path.join(bin_dir, 'cinder-api'),
        'config_files': ['/etc/cinder/cinder.conf'],
        'log_file': '/var/log/cinder/cinder-api.log',
    }

    cinder_backup_context = {
        'service_description': 'Cinder backup server',
        'service_name': 'Cinder',
        'user_name': 'cinder',
        'start_dir': '/var/lib/cinder',
        'process_name': 'cinder-backup',
        'executable_name': os.path.join(bin_dir, 'cinder-backup'),
        'config_files': ['/etc/cinder/cinder.conf'],
        'log_file': '/var/log/cinder/cinder-backup.log',
    }

    cinder_scheduler_context = {
        'service_description': 'Cinder scheduler server',
        'service_name': 'Cinder',
        'user_name': 'cinder',
        'start_dir': '/var/lib/cinder',
        'process_name': 'cinder-scheduler',
        'executable_name': os.path.join(bin_dir, 'cinder-scheduler'),
        'config_files': ['/etc/cinder/cinder.conf'],
        'log_file': '/var/log/cinder/cinder-scheduler.log',
    }

    cinder_volume_context = {
        'service_description': 'Cinder volume server',
        'service_name': 'Cinder',
        'user_name': 'cinder',
        'start_dir': '/var/lib/cinder',
        'process_name': 'cinder-volume',
        'executable_name': os.path.join(bin_dir, 'cinder-volume'),
        'config_files': ['/etc/cinder/cinder.conf'],
        'log_file': '/var/log/cinder/cinder-volume.log',
    }

    # NOTE(coreycb): Needs systemd support
    templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
    templates_dir = os.path.join(charm_dir(), templates_dir)
    render('git.upstart', '/etc/init/cinder-api.conf',
           cinder_api_context, perms=0o644, templates_dir=templates_dir)
    render('git.upstart', '/etc/init/cinder-backup.conf',
           cinder_backup_context, perms=0o644, templates_dir=templates_dir)
    render('git.upstart', '/etc/init/cinder-scheduler.conf',
           cinder_scheduler_context, perms=0o644, templates_dir=templates_dir)
    render('git.upstart', '/etc/init/cinder-volume.conf',
           cinder_volume_context, perms=0o644, templates_dir=templates_dir)

    service_restart('tgtd')

    [service_restart(s) for s in services()]
예제 #13
0
def git_post_install(projects_yaml):
    """Perform cinder post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    base_packages = ['mysql-python', 'python-cephlibs']
    for pkg in base_packages:
        if http_proxy:
            pip_install(pkg,
                        proxy=http_proxy,
                        venv=git_pip_venv_dir(projects_yaml))
        else:
            pip_install(pkg, venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'cinder'), 'etc/cinder')
    configs = {
        'src': src_etc,
        'dest': '/etc/cinder',
    }

    if os.path.exists(configs['dest']):
        shutil.rmtree(configs['dest'])
    shutil.copytree(configs['src'], configs['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {
            'src':
            os.path.join(git_pip_venv_dir(projects_yaml), 'bin/cinder-manage'),
            'link':
            '/usr/local/bin/cinder-manage'
        },
        {
            'src':
            os.path.join(git_pip_venv_dir(projects_yaml),
                         'bin/cinder-rootwrap'),
            'link':
            '/usr/local/bin/cinder-rootwrap'
        },
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/cinder_tgt.conf',
           '/etc/tgt/conf.d', {},
           owner='cinder',
           group='cinder',
           perms=0o644)
    render('git/logging.conf',
           '/etc/cinder/logging.conf', {},
           owner='cinder',
           group='cinder',
           perms=0o644)
    render('git/cinder_sudoers',
           '/etc/sudoers.d/cinder_sudoers', {},
           owner='root',
           group='root',
           perms=0o440)

    os.chmod('/etc/sudoers.d', 0o750)

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    # Use systemd init units/scripts from ubuntu wily onward
    if lsb_release()['DISTRIB_RELEASE'] >= '15.10':
        templates_dir = os.path.join(charm_dir(), 'templates/git')
        daemons = [
            'cinder-api', 'cinder-backup', 'cinder-scheduler', 'cinder-volume'
        ]
        for daemon in daemons:
            cinder_context = {
                'daemon_path': os.path.join(bin_dir, daemon),
            }
            template_file = 'git/{}.init.in.template'.format(daemon)
            init_in_file = '{}.init.in'.format(daemon)
            render(template_file,
                   os.path.join(templates_dir, init_in_file),
                   cinder_context,
                   perms=0o644)
        git_generate_systemd_init_files(templates_dir)
    else:
        cinder_api_context = {
            'service_description': 'Cinder API server',
            'service_name': 'Cinder',
            'user_name': 'cinder',
            'start_dir': '/var/lib/cinder',
            'process_name': 'cinder-api',
            'executable_name': os.path.join(bin_dir, 'cinder-api'),
            'config_files': ['/etc/cinder/cinder.conf'],
            'log_file': '/var/log/cinder/cinder-api.log',
        }

        cinder_backup_context = {
            'service_description': 'Cinder backup server',
            'service_name': 'Cinder',
            'user_name': 'cinder',
            'start_dir': '/var/lib/cinder',
            'process_name': 'cinder-backup',
            'executable_name': os.path.join(bin_dir, 'cinder-backup'),
            'config_files': ['/etc/cinder/cinder.conf'],
            'log_file': '/var/log/cinder/cinder-backup.log',
        }

        cinder_scheduler_context = {
            'service_description': 'Cinder scheduler server',
            'service_name': 'Cinder',
            'user_name': 'cinder',
            'start_dir': '/var/lib/cinder',
            'process_name': 'cinder-scheduler',
            'executable_name': os.path.join(bin_dir, 'cinder-scheduler'),
            'config_files': ['/etc/cinder/cinder.conf'],
            'log_file': '/var/log/cinder/cinder-scheduler.log',
        }

        cinder_volume_context = {
            'service_description': 'Cinder volume server',
            'service_name': 'Cinder',
            'user_name': 'cinder',
            'start_dir': '/var/lib/cinder',
            'process_name': 'cinder-volume',
            'executable_name': os.path.join(bin_dir, 'cinder-volume'),
            'config_files': ['/etc/cinder/cinder.conf'],
            'log_file': '/var/log/cinder/cinder-volume.log',
        }

        templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
        templates_dir = os.path.join(charm_dir(), templates_dir)
        render('git.upstart',
               '/etc/init/cinder-api.conf',
               cinder_api_context,
               perms=0o644,
               templates_dir=templates_dir)
        render('git.upstart',
               '/etc/init/cinder-backup.conf',
               cinder_backup_context,
               perms=0o644,
               templates_dir=templates_dir)
        render('git.upstart',
               '/etc/init/cinder-scheduler.conf',
               cinder_scheduler_context,
               perms=0o644,
               templates_dir=templates_dir)
        render('git.upstart',
               '/etc/init/cinder-volume.conf',
               cinder_volume_context,
               perms=0o644,
               templates_dir=templates_dir)

    if not is_unit_paused_set():
        service_restart('tgtd')

        [service_restart(s) for s in services()]
예제 #14
0
def git_post_install(projects_yaml):
    """Perform glance post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        for pkg in ['mysql-python', 'python-cephlibs']:
            pip_install(pkg, proxy=http_proxy,
                        venv=git_pip_venv_dir(projects_yaml))
    else:
        for pkg in ['mysql-python', 'python-cephlibs']:
            pip_install(pkg, venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'glance'), 'etc')
    configs = {
        'src': src_etc,
        'dest': GLANCE_CONF_DIR,
    }

    if os.path.exists(configs['dest']):
        shutil.rmtree(configs['dest'])
    shutil.copytree(configs['src'], configs['dest'])

    symlinks = [
        # NOTE(coreycb): Need to find better solution than bin symlinks.
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/glance-manage'),
         'link': '/usr/local/bin/glance-manage'},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    # Use systemd init units/scripts from ubuntu wily onward
    if lsb_release()['DISTRIB_RELEASE'] >= '15.10':
        templates_dir = os.path.join(charm_dir(), TEMPLATES, 'git')
        daemons = ['glance-api', 'glance-glare', 'glance-registry']
        for daemon in daemons:
            glance_context = {
                'daemon_path': os.path.join(bin_dir, daemon),
            }
            template_file = 'git/{}.init.in.template'.format(daemon)
            init_in_file = '{}.init.in'.format(daemon)
            render(template_file, os.path.join(templates_dir, init_in_file),
                   glance_context, perms=0o644)
        git_generate_systemd_init_files(templates_dir)
    else:
        glance_api_context = {
            'service_description': 'Glance API server',
            'service_name': 'Glance',
            'user_name': 'glance',
            'start_dir': '/var/lib/glance',
            'process_name': 'glance-api',
            'executable_name': os.path.join(bin_dir, 'glance-api'),
            'config_files': [GLANCE_API_CONF],
            'log_file': '/var/log/glance/api.log',
        }

        glance_registry_context = {
            'service_description': 'Glance registry server',
            'service_name': 'Glance',
            'user_name': 'glance',
            'start_dir': '/var/lib/glance',
            'process_name': 'glance-registry',
            'executable_name': os.path.join(bin_dir, 'glance-registry'),
            'config_files': [GLANCE_REGISTRY_CONF],
            'log_file': '/var/log/glance/registry.log',
        }

        templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
        templates_dir = os.path.join(charm_dir(), templates_dir)
        render('git.upstart', '/etc/init/glance-api.conf',
               glance_api_context, perms=0o644,
               templates_dir=templates_dir)
        render('git.upstart', '/etc/init/glance-registry.conf',
               glance_registry_context, perms=0o644,
               templates_dir=templates_dir)

    # Don't restart services if the unit is supposed to be paused.
    if not is_unit_paused_set():
        service_restart('glance-api')
        service_restart('glance-registry')
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        pip_install('mysql-python', proxy=http_proxy,
                    venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install('mysql-python',
                    venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc')
    configs = [
        {'src': src_etc,
         'dest': '/etc/neutron'},
        {'src': os.path.join(src_etc, 'neutron/plugins'),
         'dest': '/etc/neutron/plugins'},
        {'src': os.path.join(src_etc, 'neutron/rootwrap.d'),
         'dest': '/etc/neutron/rootwrap.d'},
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/neutron-rootwrap'),
         'link': '/usr/local/bin/neutron-rootwrap'},
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/neutron-db-manage'),
         'link': '/usr/local/bin/neutron-db-manage'},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/neutron_sudoers', '/etc/sudoers.d/neutron_sudoers', {},
           perms=0o440)

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    # Use systemd init units/scripts from ubuntu wily onward
    if lsb_release()['DISTRIB_RELEASE'] >= '15.10':
        templates_dir = os.path.join(charm_dir(), 'templates/git')
        daemon = 'neutron-server'
        neutron_api_context = {
            'daemon_path': os.path.join(bin_dir, daemon),
        }
        template_file = 'git/{}.init.in.template'.format(daemon)
        init_in_file = '{}.init.in'.format(daemon)
        render(template_file, os.path.join(templates_dir, init_in_file),
               neutron_api_context, perms=0o644)
        git_generate_systemd_init_files(templates_dir)
    else:
        neutron_api_context = {
            'service_description': 'Neutron API server',
            'charm_name': 'neutron-api',
            'process_name': 'neutron-server',
            'executable_name': os.path.join(bin_dir, 'neutron-server'),
        }

        render('git/upstart/neutron-server.upstart',
               '/etc/init/neutron-server.conf',
               neutron_api_context, perms=0o644)

    if not is_unit_paused_set():
        service_restart('neutron-server')
예제 #16
0
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        pip_install('mysql-python',
                    proxy=http_proxy,
                    venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install('mysql-python', venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc')
    configs = [
        {
            'src': src_etc,
            'dest': '/etc/neutron'
        },
        {
            'src': os.path.join(src_etc, 'neutron/plugins'),
            'dest': '/etc/neutron/plugins'
        },
        {
            'src': os.path.join(src_etc, 'neutron/rootwrap.d'),
            'dest': '/etc/neutron/rootwrap.d'
        },
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {
            'src':
            os.path.join(git_pip_venv_dir(projects_yaml),
                         'bin/neutron-rootwrap'),
            'link':
            '/usr/local/bin/neutron-rootwrap'
        },
        {
            'src':
            os.path.join(git_pip_venv_dir(projects_yaml),
                         'bin/neutron-db-manage'),
            'link':
            '/usr/local/bin/neutron-db-manage'
        },
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/neutron_sudoers',
           '/etc/sudoers.d/neutron_sudoers', {},
           perms=0o440)

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    neutron_api_context = {
        'service_description': 'Neutron API server',
        'charm_name': 'neutron-api',
        'process_name': 'neutron-server',
        'executable_name': os.path.join(bin_dir, 'neutron-server'),
    }

    # NOTE(coreycb): Needs systemd support
    render('git/upstart/neutron-server.upstart',
           '/etc/init/neutron-server.conf',
           neutron_api_context,
           perms=0o644)

    service_restart('neutron-server')
예제 #17
0
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        pip_install('mysql-python',
                    proxy=http_proxy,
                    venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install('mysql-python', venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'nova'), 'etc/nova')
    configs = [
        {
            'src': src_etc,
            'dest': '/etc/nova'
        },
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {
            'src': os.path.join(git_pip_venv_dir(projects_yaml),
                                'bin/nova-manage'),
            'link': '/usr/local/bin/nova-manage'
        },
        {
            'src':
            os.path.join(git_pip_venv_dir(projects_yaml), 'bin/nova-rootwrap'),
            'link':
            '/usr/local/bin/nova-rootwrap'
        },
        {
            'src':
            os.path.join(git_pip_venv_dir(projects_yaml),
                         'bin/neutron-db-manage'),
            'link':
            '/usr/local/bin/neutron-db-manage'
        },
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers', {}, perms=0o440)

    nova_cc = 'nova-cloud-controller'
    nova_user = '******'
    start_dir = '/var/lib/nova'
    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    nova_conf = '/etc/nova/nova.conf'
    nova_ec2_api_context = {
        'service_description': 'Nova EC2 API server',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-api-ec2',
        'executable_name': os.path.join(bin_dir, 'nova-api-ec2'),
        'config_files': [nova_conf],
    }
    nova_api_os_compute_context = {
        'service_description': 'Nova OpenStack Compute API server',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-api-os-compute',
        'executable_name': os.path.join(bin_dir, 'nova-api-os-compute'),
        'config_files': [nova_conf],
    }
    nova_cells_context = {
        'service_description': 'Nova cells',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-cells',
        'executable_name': os.path.join(bin_dir, 'nova-cells'),
        'config_files': [nova_conf],
    }
    nova_cert_context = {
        'service_description': 'Nova cert',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-cert',
        'executable_name': os.path.join(bin_dir, 'nova-cert'),
        'config_files': [nova_conf],
    }
    nova_conductor_context = {
        'service_description': 'Nova conductor',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-conductor',
        'executable_name': os.path.join(bin_dir, 'nova-conductor'),
        'config_files': [nova_conf],
    }
    nova_consoleauth_context = {
        'service_description': 'Nova console auth',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-consoleauth',
        'executable_name': os.path.join(bin_dir, 'nova-consoleauth'),
        'config_files': [nova_conf],
    }
    nova_console_context = {
        'service_description': 'Nova console',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-console',
        'executable_name': os.path.join(bin_dir, 'nova-console'),
        'config_files': [nova_conf],
    }
    nova_novncproxy_context = {
        'service_description': 'Nova NoVNC proxy',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-novncproxy',
        'executable_name': os.path.join(bin_dir, 'nova-novncproxy'),
        'config_files': [nova_conf],
    }
    nova_objectstore_context = {
        'service_description': 'Nova object store',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-objectstore',
        'executable_name': os.path.join(bin_dir, 'nova-objectstore'),
        'config_files': [nova_conf],
    }
    nova_scheduler_context = {
        'service_description': 'Nova scheduler',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-scheduler',
        'executable_name': os.path.join(bin_dir, 'nova-scheduler'),
        'config_files': [nova_conf],
    }
    nova_serialproxy_context = {
        'service_description': 'Nova serial proxy',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-serialproxy',
        'executable_name': os.path.join(bin_dir, 'nova-serialproxy'),
        'config_files': [nova_conf],
    }
    nova_spiceproxy_context = {
        'service_description': 'Nova spice proxy',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-spicehtml5proxy',
        'executable_name': os.path.join(bin_dir, 'nova-spicehtml5proxy'),
        'config_files': [nova_conf],
    }
    nova_xvpvncproxy_context = {
        'service_description': 'Nova XVPVNC proxy',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-xvpvncproxy',
        'executable_name': os.path.join(bin_dir, 'nova-xvpvncproxy'),
        'config_files': [nova_conf],
    }

    # NOTE(coreycb): Needs systemd support
    templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
    templates_dir = os.path.join(charm_dir(), templates_dir)
    os_rel = os_release('nova-common')
    render('git.upstart',
           '/etc/init/nova-api-ec2.conf',
           nova_ec2_api_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/nova-api-os-compute.conf',
           nova_api_os_compute_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/nova-cells.conf',
           nova_cells_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/nova-cert.conf',
           nova_cert_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/nova-conductor.conf',
           nova_conductor_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/nova-consoleauth.conf',
           nova_consoleauth_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/nova-console.conf',
           nova_console_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/nova-novncproxy.conf',
           nova_novncproxy_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/nova-objectstore.conf',
           nova_objectstore_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/nova-scheduler.conf',
           nova_scheduler_context,
           perms=0o644,
           templates_dir=templates_dir)
    if os_rel >= 'juno':
        render('git.upstart',
               '/etc/init/nova-serialproxy.conf',
               nova_serialproxy_context,
               perms=0o644,
               templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/nova-spiceproxy.conf',
           nova_spiceproxy_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/nova-xvpvncproxy.conf',
           nova_xvpvncproxy_context,
           perms=0o644,
           templates_dir=templates_dir)

    apt_update()
    apt_install(LATE_GIT_PACKAGES, fatal=True)
def git_post_install(projects_yaml):
    """Perform glance post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        for pkg in ['mysql-python', 'python-cephlibs']:
            pip_install(pkg,
                        proxy=http_proxy,
                        venv=git_pip_venv_dir(projects_yaml))
    else:
        for pkg in ['mysql-python', 'python-cephlibs']:
            pip_install(pkg, venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'glance'), 'etc')
    configs = {
        'src': src_etc,
        'dest': GLANCE_CONF_DIR,
    }

    if os.path.exists(configs['dest']):
        shutil.rmtree(configs['dest'])
    shutil.copytree(configs['src'], configs['dest'])

    symlinks = [
        # NOTE(coreycb): Need to find better solution than bin symlinks.
        {
            'src':
            os.path.join(git_pip_venv_dir(projects_yaml), 'bin/glance-manage'),
            'link':
            '/usr/local/bin/glance-manage'
        },
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    # Use systemd init units/scripts from ubuntu wily onward
    if lsb_release()['DISTRIB_RELEASE'] >= '15.10':
        templates_dir = os.path.join(charm_dir(), TEMPLATES, 'git')
        daemons = ['glance-api', 'glance-glare', 'glance-registry']
        for daemon in daemons:
            glance_context = {
                'daemon_path': os.path.join(bin_dir, daemon),
            }
            template_file = 'git/{}.init.in.template'.format(daemon)
            init_in_file = '{}.init.in'.format(daemon)
            render(template_file,
                   os.path.join(templates_dir, init_in_file),
                   glance_context,
                   perms=0o644)
        git_generate_systemd_init_files(templates_dir)
    else:
        glance_api_context = {
            'service_description': 'Glance API server',
            'service_name': 'Glance',
            'user_name': 'glance',
            'start_dir': '/var/lib/glance',
            'process_name': 'glance-api',
            'executable_name': os.path.join(bin_dir, 'glance-api'),
            'config_files': [GLANCE_API_CONF],
            'log_file': '/var/log/glance/api.log',
        }

        glance_registry_context = {
            'service_description': 'Glance registry server',
            'service_name': 'Glance',
            'user_name': 'glance',
            'start_dir': '/var/lib/glance',
            'process_name': 'glance-registry',
            'executable_name': os.path.join(bin_dir, 'glance-registry'),
            'config_files': [GLANCE_REGISTRY_CONF],
            'log_file': '/var/log/glance/registry.log',
        }

        templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
        templates_dir = os.path.join(charm_dir(), templates_dir)
        render('git.upstart',
               '/etc/init/glance-api.conf',
               glance_api_context,
               perms=0o644,
               templates_dir=templates_dir)
        render('git.upstart',
               '/etc/init/glance-registry.conf',
               glance_registry_context,
               perms=0o644,
               templates_dir=templates_dir)

    # Don't restart services if the unit is supposed to be paused.
    if not is_unit_paused_set():
        service_restart('glance-api')
        service_restart('glance-registry')
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc')
    configs = [
        {'src': src_etc,
         'dest': '/etc/neutron'},
        {'src': os.path.join(src_etc, 'neutron/plugins'),
         'dest': '/etc/neutron/plugins'},
        {'src': os.path.join(src_etc, 'neutron/rootwrap.d'),
         'dest': '/etc/neutron/rootwrap.d'},
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/neutron-rootwrap'),
         'link': '/usr/local/bin/neutron-rootwrap'},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/neutron_sudoers', '/etc/sudoers.d/neutron_sudoers', {},
           perms=0o440)

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    # Use systemd init units/scripts from ubuntu wily onward
    if lsb_release()['DISTRIB_RELEASE'] >= '15.10':
        templates_dir = os.path.join(charm_dir(), 'templates/git')
        daemons = ['neutron-openvswitch-agent', 'neutron-ovs-cleanup']
        for daemon in daemons:
            neutron_ovs_context = {
                'daemon_path': os.path.join(bin_dir, daemon),
            }
            filename = daemon
            if daemon == 'neutron-openvswitch-agent':
                if os_release('neutron-common') < 'mitaka':
                    filename = 'neutron-plugin-openvswitch-agent'
            template_file = 'git/{}.init.in.template'.format(filename)
            init_in_file = '{}.init.in'.format(filename)
            render(template_file, os.path.join(templates_dir, init_in_file),
                   neutron_ovs_context, perms=0o644)
        git_generate_systemd_init_files(templates_dir)

        for daemon in daemons:
            filename = daemon
            if daemon == 'neutron-openvswitch-agent':
                if os_release('neutron-common') < 'mitaka':
                    filename = 'neutron-plugin-openvswitch-agent'
            service('enable', filename)
    else:
        neutron_ovs_agent_context = {
            'service_description': 'Neutron OpenvSwitch Plugin Agent',
            'charm_name': 'neutron-openvswitch',
            'process_name': 'neutron-openvswitch-agent',
            'executable_name': os.path.join(bin_dir,
                                            'neutron-openvswitch-agent'),
            'cleanup_process_name': 'neutron-ovs-cleanup',
            'plugin_config': '/etc/neutron/plugins/ml2/ml2_conf.ini',
            'log_file': '/var/log/neutron/openvswitch-agent.log',
        }

        neutron_ovs_cleanup_context = {
            'service_description': 'Neutron OpenvSwitch Cleanup',
            'charm_name': 'neutron-openvswitch',
            'process_name': 'neutron-ovs-cleanup',
            'executable_name': os.path.join(bin_dir, 'neutron-ovs-cleanup'),
            'log_file': '/var/log/neutron/ovs-cleanup.log',
        }

        if os_release('neutron-common') < 'mitaka':
            render('git/upstart/neutron-plugin-openvswitch-agent.upstart',
                   '/etc/init/neutron-plugin-openvswitch-agent.conf',
                   neutron_ovs_agent_context, perms=0o644)
        else:
            render('git/upstart/neutron-plugin-openvswitch-agent.upstart',
                   '/etc/init/neutron-openvswitch-agent.conf',
                   neutron_ovs_agent_context, perms=0o644)
        render('git/upstart/neutron-ovs-cleanup.upstart',
               '/etc/init/neutron-ovs-cleanup.conf',
               neutron_ovs_cleanup_context, perms=0o644)

    if not is_unit_paused_set():
        service_restart('neutron-plugin-openvswitch-agent')
예제 #20
0
def git_post_install(projects_yaml):
    """Perform glance post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        pip_install('mysql-python', proxy=http_proxy,
                    venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install('mysql-python',
                    venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'glance'), 'etc')
    configs = {
        'src': src_etc,
        'dest': '/etc/glance',
    }

    if os.path.exists(configs['dest']):
        shutil.rmtree(configs['dest'])
    shutil.copytree(configs['src'], configs['dest'])

    symlinks = [
        # NOTE(coreycb): Need to find better solution than bin symlinks.
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/glance-manage'),
         'link': '/usr/local/bin/glance-manage'},
        # NOTE(coreycb): This is ugly but couldn't find pypi package that
        #                installs rbd.py and rados.py.
        {'src': '/usr/lib/python2.7/dist-packages/rbd.py',
         'link': os.path.join(git_pip_venv_dir(projects_yaml),
                              'lib/python2.7/site-packages/rbd.py')},
        {'src': '/usr/lib/python2.7/dist-packages/rados.py',
         'link': os.path.join(git_pip_venv_dir(projects_yaml),
                              'lib/python2.7/site-packages/rados.py')},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    glance_api_context = {
        'service_description': 'Glance API server',
        'service_name': 'Glance',
        'user_name': 'glance',
        'start_dir': '/var/lib/glance',
        'process_name': 'glance-api',
        'executable_name': os.path.join(bin_dir, 'glance-api'),
        'config_files': ['/etc/glance/glance-api.conf'],
        'log_file': '/var/log/glance/api.log',
    }

    glance_registry_context = {
        'service_description': 'Glance registry server',
        'service_name': 'Glance',
        'user_name': 'glance',
        'start_dir': '/var/lib/glance',
        'process_name': 'glance-registry',
        'executable_name': os.path.join(bin_dir, 'glance-registry'),
        'config_files': ['/etc/glance/glance-registry.conf'],
        'log_file': '/var/log/glance/registry.log',
    }

    # NOTE(coreycb): Needs systemd support
    templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
    templates_dir = os.path.join(charm_dir(), templates_dir)
    render('git.upstart', '/etc/init/glance-api.conf',
           glance_api_context, perms=0o644, templates_dir=templates_dir)
    render('git.upstart', '/etc/init/glance-registry.conf',
           glance_registry_context, perms=0o644, templates_dir=templates_dir)

    service_restart('glance-api')
    service_restart('glance-registry')
예제 #21
0
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc')
    configs = [
        {
            'src': src_etc,
            'dest': '/etc/neutron'
        },
        {
            'src': os.path.join(src_etc, 'neutron/plugins'),
            'dest': '/etc/neutron/plugins'
        },
        {
            'src': os.path.join(src_etc, 'neutron/rootwrap.d'),
            'dest': '/etc/neutron/rootwrap.d'
        },
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {
            'src':
            os.path.join(git_pip_venv_dir(projects_yaml),
                         'bin/neutron-rootwrap'),
            'link':
            '/usr/local/bin/neutron-rootwrap'
        },
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/neutron_sudoers',
           '/etc/sudoers.d/neutron_sudoers', {},
           perms=0o440)

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    cmp_os_release = CompareOpenStackReleases(os_release('neutron-common'))
    # Use systemd init units/scripts from ubuntu wily onward
    _release = lsb_release()['DISTRIB_CODENAME']
    if CompareHostReleases(_release) >= 'wily':
        templates_dir = os.path.join(charm_dir(), 'templates/git')
        daemons = ['neutron-openvswitch-agent', 'neutron-ovs-cleanup']
        for daemon in daemons:
            neutron_ovs_context = {
                'daemon_path': os.path.join(bin_dir, daemon),
            }
            filename = daemon
            if daemon == 'neutron-openvswitch-agent':
                if cmp_os_release < 'mitaka':
                    filename = 'neutron-plugin-openvswitch-agent'
            template_file = 'git/{}.init.in.template'.format(filename)
            init_in_file = '{}.init.in'.format(filename)
            render(template_file,
                   os.path.join(templates_dir, init_in_file),
                   neutron_ovs_context,
                   perms=0o644)
        git_generate_systemd_init_files(templates_dir)

        for daemon in daemons:
            filename = daemon
            if daemon == 'neutron-openvswitch-agent':
                if cmp_os_release < 'mitaka':
                    filename = 'neutron-plugin-openvswitch-agent'
            service('enable', filename)
    else:
        neutron_ovs_agent_context = {
            'service_description': 'Neutron OpenvSwitch Plugin Agent',
            'charm_name': 'neutron-openvswitch',
            'process_name': 'neutron-openvswitch-agent',
            'executable_name': os.path.join(bin_dir,
                                            'neutron-openvswitch-agent'),
            'cleanup_process_name': 'neutron-ovs-cleanup',
            'plugin_config': '/etc/neutron/plugins/ml2/ml2_conf.ini',
            'log_file': '/var/log/neutron/openvswitch-agent.log',
        }

        neutron_ovs_cleanup_context = {
            'service_description': 'Neutron OpenvSwitch Cleanup',
            'charm_name': 'neutron-openvswitch',
            'process_name': 'neutron-ovs-cleanup',
            'executable_name': os.path.join(bin_dir, 'neutron-ovs-cleanup'),
            'log_file': '/var/log/neutron/ovs-cleanup.log',
        }

        if cmp_os_release < 'mitaka':
            render('git/upstart/neutron-plugin-openvswitch-agent.upstart',
                   '/etc/init/neutron-plugin-openvswitch-agent.conf',
                   neutron_ovs_agent_context,
                   perms=0o644)
        else:
            render('git/upstart/neutron-plugin-openvswitch-agent.upstart',
                   '/etc/init/neutron-openvswitch-agent.conf',
                   neutron_ovs_agent_context,
                   perms=0o644)
        render('git/upstart/neutron-ovs-cleanup.upstart',
               '/etc/init/neutron-ovs-cleanup.conf',
               neutron_ovs_cleanup_context,
               perms=0o644)

    if not is_unit_paused_set():
        service_restart('neutron-plugin-openvswitch-agent')
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        pip_install('mysql-python', proxy=http_proxy,
                    venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install('mysql-python',
                    venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'nova'), 'etc/nova')
    configs = [
        {'src': src_etc,
         'dest': '/etc/nova'},
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/nova-manage'),
         'link': '/usr/local/bin/nova-manage'},
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/nova-rootwrap'),
         'link': '/usr/local/bin/nova-rootwrap'},
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/neutron-db-manage'),
         'link': '/usr/local/bin/neutron-db-manage'},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers', {}, perms=0o440)

    nova_cc = 'nova-cloud-controller'
    nova_user = '******'
    start_dir = '/var/lib/nova'
    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    nova_conf = '/etc/nova/nova.conf'
    nova_ec2_api_context = {
        'service_description': 'Nova EC2 API server',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-api-ec2',
        'executable_name': os.path.join(bin_dir, 'nova-api-ec2'),
        'config_files': [nova_conf],
    }
    nova_api_os_compute_context = {
        'service_description': 'Nova OpenStack Compute API server',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-api-os-compute',
        'executable_name': os.path.join(bin_dir, 'nova-api-os-compute'),
        'config_files': [nova_conf],
    }
    nova_cells_context = {
        'service_description': 'Nova cells',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-cells',
        'executable_name': os.path.join(bin_dir, 'nova-cells'),
        'config_files': [nova_conf],
    }
    nova_cert_context = {
        'service_description': 'Nova cert',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-cert',
        'executable_name': os.path.join(bin_dir, 'nova-cert'),
        'config_files': [nova_conf],
    }
    nova_conductor_context = {
        'service_description': 'Nova conductor',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-conductor',
        'executable_name': os.path.join(bin_dir, 'nova-conductor'),
        'config_files': [nova_conf],
    }
    nova_consoleauth_context = {
        'service_description': 'Nova console auth',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-consoleauth',
        'executable_name': os.path.join(bin_dir, 'nova-consoleauth'),
        'config_files': [nova_conf],
    }
    nova_console_context = {
        'service_description': 'Nova console',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-console',
        'executable_name': os.path.join(bin_dir, 'nova-console'),
        'config_files': [nova_conf],
    }
    nova_novncproxy_context = {
        'service_description': 'Nova NoVNC proxy',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-novncproxy',
        'executable_name': os.path.join(bin_dir, 'nova-novncproxy'),
        'config_files': [nova_conf],
    }
    nova_objectstore_context = {
        'service_description': 'Nova object store',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-objectstore',
        'executable_name': os.path.join(bin_dir, 'nova-objectstore'),
        'config_files': [nova_conf],
    }
    nova_scheduler_context = {
        'service_description': 'Nova scheduler',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-scheduler',
        'executable_name': os.path.join(bin_dir, 'nova-scheduler'),
        'config_files': [nova_conf],
    }
    nova_serialproxy_context = {
        'service_description': 'Nova serial proxy',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-serialproxy',
        'executable_name': os.path.join(bin_dir, 'nova-serialproxy'),
        'config_files': [nova_conf],
    }
    nova_spiceproxy_context = {
        'service_description': 'Nova spice proxy',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-spicehtml5proxy',
        'executable_name': os.path.join(bin_dir, 'nova-spicehtml5proxy'),
        'config_files': [nova_conf],
    }
    nova_xvpvncproxy_context = {
        'service_description': 'Nova XVPVNC proxy',
        'service_name': nova_cc,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-xvpvncproxy',
        'executable_name': os.path.join(bin_dir, 'nova-xvpvncproxy'),
        'config_files': [nova_conf],
    }

    # NOTE(coreycb): Needs systemd support
    templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
    templates_dir = os.path.join(charm_dir(), templates_dir)
    os_rel = os_release('nova-common')
    render('git.upstart', '/etc/init/nova-api-ec2.conf',
           nova_ec2_api_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart', '/etc/init/nova-api-os-compute.conf',
           nova_api_os_compute_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart', '/etc/init/nova-cells.conf',
           nova_cells_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart', '/etc/init/nova-cert.conf',
           nova_cert_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart', '/etc/init/nova-conductor.conf',
           nova_conductor_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart', '/etc/init/nova-consoleauth.conf',
           nova_consoleauth_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart', '/etc/init/nova-console.conf',
           nova_console_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart', '/etc/init/nova-novncproxy.conf',
           nova_novncproxy_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart', '/etc/init/nova-objectstore.conf',
           nova_objectstore_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart', '/etc/init/nova-scheduler.conf',
           nova_scheduler_context, perms=0o644,
           templates_dir=templates_dir)
    if os_rel >= 'juno':
        render('git.upstart', '/etc/init/nova-serialproxy.conf',
               nova_serialproxy_context, perms=0o644,
               templates_dir=templates_dir)
    render('git.upstart', '/etc/init/nova-spiceproxy.conf',
           nova_spiceproxy_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart', '/etc/init/nova-xvpvncproxy.conf',
           nova_xvpvncproxy_context, perms=0o644,
           templates_dir=templates_dir)

    apt_update()
    apt_install(LATE_GIT_PACKAGES, fatal=True)
예제 #23
0
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        pip_install('libvirt-python',
                    proxy=http_proxy,
                    venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install('libvirt-python', venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'nova'), 'etc/nova')
    configs = [
        {
            'src': src_etc,
            'dest': '/etc/nova'
        },
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {
            'src':
            os.path.join(git_pip_venv_dir(projects_yaml), 'bin/nova-rootwrap'),
            'link':
            '/usr/local/bin/nova-rootwrap'
        },
        {
            'src':
            os.path.join(git_pip_venv_dir(projects_yaml),
                         'bin/privsep-helper'),
            'link':
            '/usr/local/bin/privsep-helper'
        },
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    virt_type = VIRT_TYPES[config('virt-type')][0]
    nova_compute_conf = 'git/{}.conf'.format(virt_type)
    render(nova_compute_conf, '/etc/nova/nova-compute.conf', {}, perms=0o644)
    render('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers', {}, perms=0o440)

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    # Use systemd init units/scripts from ubuntu wily onward
    if lsb_release()['DISTRIB_RELEASE'] >= '15.10':
        templates_dir = os.path.join(charm_dir(), 'templates/git')
        daemons = [
            'nova-api', 'nova-api-metadata', 'nova-compute', 'nova-network'
        ]
        for daemon in daemons:
            nova_compute_context = {
                'daemon_path': os.path.join(bin_dir, daemon),
            }
            template_file = 'git/{}.init.in.template'.format(daemon)
            init_in_file = '{}.init.in'.format(daemon)
            render(template_file,
                   os.path.join(templates_dir, init_in_file),
                   nova_compute_context,
                   perms=0o644)
        git_generate_systemd_init_files(templates_dir)
    else:
        service_name = 'nova-compute'
        nova_user = '******'
        start_dir = '/var/lib/nova'
        nova_conf = '/etc/nova/nova.conf'
        nova_api_context = {
            'service_description': 'Nova API server',
            'service_name': service_name,
            'user_name': nova_user,
            'start_dir': start_dir,
            'process_name': 'nova-api',
            'executable_name': os.path.join(bin_dir, 'nova-api'),
            'config_files': [nova_conf],
        }
        nova_api_metadata_context = {
            'service_description': 'Nova Metadata API server',
            'service_name': service_name,
            'user_name': nova_user,
            'start_dir': start_dir,
            'process_name': 'nova-api-metadata',
            'executable_name': os.path.join(bin_dir, 'nova-api-metadata'),
            'config_files': [nova_conf],
        }
        nova_compute_context = {
            'service_description': 'Nova compute worker',
            'service_name': service_name,
            'user_name': nova_user,
            'process_name': 'nova-compute',
            'executable_name': os.path.join(bin_dir, 'nova-compute'),
            'config_files': [nova_conf, '/etc/nova/nova-compute.conf'],
        }
        nova_network_context = {
            'service_description': 'Nova network worker',
            'service_name': service_name,
            'user_name': nova_user,
            'start_dir': start_dir,
            'process_name': 'nova-network',
            'executable_name': os.path.join(bin_dir, 'nova-network'),
            'config_files': [nova_conf],
        }
        templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
        templates_dir = os.path.join(charm_dir(), templates_dir)
        render('git.upstart',
               '/etc/init/nova-api-metadata.conf',
               nova_api_metadata_context,
               perms=0o644,
               templates_dir=templates_dir)
        render('git.upstart',
               '/etc/init/nova-api.conf',
               nova_api_context,
               perms=0o644,
               templates_dir=templates_dir)
        render('git/upstart/nova-compute.upstart',
               '/etc/init/nova-compute.conf',
               nova_compute_context,
               perms=0o644)
        render('git.upstart',
               '/etc/init/nova-network.conf',
               nova_network_context,
               perms=0o644,
               templates_dir=templates_dir)

    apt_update()
    apt_install(LATE_GIT_PACKAGES, fatal=True)
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        pip_install('libvirt-python', proxy=http_proxy,
                    venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install('libvirt-python',
                    venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'nova'), 'etc/nova')
    configs = [
        {'src': src_etc,
         'dest': '/etc/nova'},
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/nova-rootwrap'),
         'link': '/usr/local/bin/nova-rootwrap'},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    virt_type = VIRT_TYPES[config('virt-type')][0]
    nova_compute_conf = 'git/{}.conf'.format(virt_type)
    render(nova_compute_conf, '/etc/nova/nova-compute.conf', {}, perms=0o644)
    render('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers', {}, perms=0o440)

    service_name = 'nova-compute'
    nova_user = '******'
    start_dir = '/var/lib/nova'
    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    nova_conf = '/etc/nova/nova.conf'
    nova_api_metadata_context = {
        'service_description': 'Nova Metadata API server',
        'service_name': service_name,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-api-metadata',
        'executable_name': os.path.join(bin_dir, 'nova-api-metadata'),
        'config_files': [nova_conf],
    }
    nova_api_context = {
        'service_description': 'Nova API server',
        'service_name': service_name,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-api',
        'executable_name': os.path.join(bin_dir, 'nova-api'),
        'config_files': [nova_conf],
    }
    # Use systemd init units/scripts from ubuntu wily onwar
    if init_is_systemd():
        activate_path = os.path.join(git_pip_venv_dir(projects_yaml), 'bin',
                                     'activate')
        nova_compute_context = {
            'daemon_path': os.path.join(bin_dir, 'nova-compute'),
            'activate_path': activate_path,
        }
        templates_dir = os.path.join(charm_dir(), 'templates/git')
        render('git/nova-compute.system.in.template',
               '/lib/systemd/system/nova-compute.service',
               nova_compute_context, perms=0o644)
    else:
        nova_compute_context = {
            'service_description': 'Nova compute worker',
            'service_name': service_name,
            'user_name': nova_user,
            'process_name': 'nova-compute',
            'executable_name': os.path.join(bin_dir, 'nova-compute'),
            'config_files': [nova_conf, '/etc/nova/nova-compute.conf'],
        }
        render('git/upstart/nova-compute.upstart',
               '/etc/init/nova-compute.conf',
               nova_compute_context, perms=0o644)

    nova_network_context = {
        'service_description': 'Nova network worker',
        'service_name': service_name,
        'user_name': nova_user,
        'start_dir': start_dir,
        'process_name': 'nova-network',
        'executable_name': os.path.join(bin_dir, 'nova-network'),
        'config_files': [nova_conf],
    }

    # NOTE(coreycb): Needs systemd support
    templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
    templates_dir = os.path.join(charm_dir(), templates_dir)
    render('git.upstart', '/etc/init/nova-api-metadata.conf',
           nova_api_metadata_context, perms=0o644, templates_dir=templates_dir)
    render('git.upstart', '/etc/init/nova-api.conf',
           nova_api_context, perms=0o644, templates_dir=templates_dir)
    render('git.upstart', '/etc/init/nova-network.conf',
           nova_network_context, perms=0o644, templates_dir=templates_dir)

    apt_update()
    apt_install(LATE_GIT_PACKAGES, fatal=True)
예제 #25
0
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc')
    configs = [
        {'src': src_etc,
         'dest': '/etc/neutron'},
        {'src': os.path.join(src_etc, 'neutron/plugins'),
         'dest': '/etc/neutron/plugins'},
        {'src': os.path.join(src_etc, 'neutron/rootwrap.d'),
         'dest': '/etc/neutron/rootwrap.d'},
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/neutron-rootwrap'),
         'link': '/usr/local/bin/neutron-rootwrap'},
        {'src': '/usr/local/bin/neutron-rootwrap',
         'link': '/usr/bin/neutron-rootwrap'},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/neutron_sudoers',
           '/etc/sudoers.d/neutron_sudoers', {}, perms=0o440)
    render('git/cron.d/neutron-dhcp-agent-netns-cleanup',
           '/etc/cron.d/neutron-dhcp-agent-netns-cleanup', {}, perms=0o755)
    render('git/cron.d/neutron-l3-agent-netns-cleanup',
           '/etc/cron.d/neutron-l3-agent-netns-cleanup', {}, perms=0o755)
    render('git/cron.d/neutron-lbaas-agent-netns-cleanup',
           '/etc/cron.d/neutron-lbaas-agent-netns-cleanup', {}, perms=0o755)

    service_name = 'quantum-gateway'
    user_name = 'neutron'
    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    neutron_api_context = {
        'service_description': 'Neutron API server',
        'service_name': service_name,
        'process_name': 'neutron-server',
        'executable_name': os.path.join(bin_dir, 'neutron-server'),
    }
    neutron_dhcp_agent_context = {
        'service_description': 'Neutron DHCP Agent',
        'service_name': service_name,
        'process_name': 'neutron-dhcp-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-dhcp-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/dhcp_agent.ini'],
        'log_file': '/var/log/neutron/dhcp-agent.log',
    }
    neutron_l3_agent_context = {
        'service_description': 'Neutron L3 Agent',
        'service_name': service_name,
        'process_name': 'neutron-l3-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-l3-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/l3_agent.ini',
                         '/etc/neutron/fwaas_driver.ini'],
        'log_file': '/var/log/neutron/l3-agent.log',
    }
    neutron_lbaas_agent_context = {
        'service_description': 'Neutron LBaaS Agent',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-lbaas-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-lbaas-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/lbaas_agent.ini'],
        'log_file': '/var/log/neutron/lbaas-agent.log',
    }
    neutron_metadata_agent_context = {
        'service_description': 'Neutron Metadata Agent',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-metadata-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-metadata-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/metadata_agent.ini'],
        'log_file': '/var/log/neutron/metadata-agent.log',
    }
    neutron_metering_agent_context = {
        'service_description': 'Neutron Metering Agent',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-metering-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-metering-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/metering_agent.ini'],
        'log_file': '/var/log/neutron/metering-agent.log',
    }
    neutron_ovs_cleanup_context = {
        'service_description': 'Neutron OVS cleanup',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-ovs-cleanup',
        'executable_name': os.path.join(bin_dir, 'neutron-ovs-cleanup'),
        'config_file': '/etc/neutron/neutron.conf',
        'log_file': '/var/log/neutron/ovs-cleanup.log',
    }
    neutron_plugin_bigswitch_context = {
        'service_description': 'Neutron BigSwitch Plugin Agent',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-restproxy-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-restproxy-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/plugins/bigswitch/restproxy.ini'],
        'log_file': '/var/log/neutron/bigswitch-agent.log',
    }
    neutron_plugin_ibm_context = {
        'service_description': 'Neutron IBM SDN Plugin Agent',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-ibm-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-ibm-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/plugins/ibm/sdnve_neutron_plugin.ini'],
        'log_file': '/var/log/neutron/ibm-agent.log',
    }
    neutron_plugin_linuxbridge_context = {
        'service_description': 'Neutron Linux Bridge Plugin Agent',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-linuxbridge-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-linuxbridge-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/plugins/ml2/ml2_conf.ini'],
        'log_file': '/var/log/neutron/linuxbridge-agent.log',
    }
    neutron_plugin_mlnx_context = {
        'service_description': 'Neutron MLNX Plugin Agent',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-mlnx-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-mlnx-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/plugins/mlnx/mlnx_conf.ini'],
        'log_file': '/var/log/neutron/mlnx-agent.log',
    }
    neutron_plugin_nec_context = {
        'service_description': 'Neutron NEC Plugin Agent',
        'service_name': service_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-nec-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-nec-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/plugins/nec/nec.ini'],
        'log_file': '/var/log/neutron/nec-agent.log',
    }
    neutron_plugin_oneconvergence_context = {
        'service_description': 'Neutron One Convergence Plugin Agent',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-nvsd-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-nvsd-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/plugins/oneconvergence/nvsdplugin.ini'],
        'log_file': '/var/log/neutron/nvsd-agent.log',
    }
    neutron_plugin_openflow_context = {
        'service_description': 'Neutron OpenFlow Plugin Agent',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-ofagent-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-ofagent-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/plugins/ml2/ml2_conf_ofa.ini'],
        'log_file': '/var/log/neutron/openflow-agent.log',
    }
    neutron_plugin_openvswitch_context = {
        'service_description': 'Neutron OpenvSwitch Plugin Agent',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-openvswitch-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-openvswitch-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/plugins/ml2/ml2_conf.ini'],
        'log_file': '/var/log/neutron/openvswitch-agent.log',
    }
    neutron_plugin_ryu_context = {
        'service_description': 'Neutron RYU Plugin Agent',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-ryu-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-ryu-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/plugins/ryu/ryu.ini'],
        'log_file': '/var/log/neutron/ryu-agent.log',
    }
    neutron_plugin_sriov_context = {
        'service_description': 'Neutron SRIOV SDN Plugin Agent',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-sriov-nic-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-sriov-nic-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/plugins/ml2/ml2_conf_sriov'],
        'log_file': '/var/log/neutron/sriov-agent.log',
    }
    neutron_vpn_agent_context = {
        'service_description': 'Neutron VPN Agent',
        'service_name': service_name,
        'process_name': 'neutron-vpn-agent',
        'executable_name': os.path.join(bin_dir, 'neutron-vpn-agent'),
        'config_files': ['/etc/neutron/neutron.conf',
                         '/etc/neutron/vpn_agent.ini',
                         '/etc/neutron/l3_agent.ini',
                         '/etc/neutron/fwaas_driver.ini'],
        'log_file': '/var/log/neutron/vpn_agent.log',
    }

    # NOTE(coreycb): Needs systemd support
    templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
    templates_dir = os.path.join(charm_dir(), templates_dir)
    render('git/upstart/neutron-agent.upstart',
           '/etc/init/neutron-dhcp-agent.conf',
           neutron_dhcp_agent_context, perms=0o644)
    render('git/upstart/neutron-agent.upstart',
           '/etc/init/neutron-l3-agent.conf',
           neutron_l3_agent_context, perms=0o644)
    render('git.upstart',
           '/etc/init/neutron-lbaas-agent.conf',
           neutron_lbaas_agent_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-metadata-agent.conf',
           neutron_metadata_agent_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-metering-agent.conf',
           neutron_metering_agent_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-ovs-cleanup.conf',
           neutron_ovs_cleanup_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-bigswitch-agent.conf',
           neutron_plugin_bigswitch_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-ibm-agent.conf',
           neutron_plugin_ibm_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-linuxbridge-agent.conf',
           neutron_plugin_linuxbridge_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-mlnx-agent.conf',
           neutron_plugin_mlnx_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-nec-agent.conf',
           neutron_plugin_nec_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-oneconvergence-agent.conf',
           neutron_plugin_oneconvergence_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-openflow-agent.conf',
           neutron_plugin_openflow_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-openvswitch-agent.conf',
           neutron_plugin_openvswitch_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-ryu-agent.conf',
           neutron_plugin_ryu_context, perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-sriov-agent.conf',
           neutron_plugin_sriov_context, perms=0o644,
           templates_dir=templates_dir)
    render('git/upstart/neutron-server.upstart',
           '/etc/init/neutron-server.conf',
           neutron_api_context, perms=0o644)
    render('git/upstart/neutron-agent.upstart',
           '/etc/init/neutron-vpn-agent.conf',
           neutron_vpn_agent_context, perms=0o644)
예제 #26
0
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    src_etc = os.path.join(git_src_dir(projects_yaml, "neutron"), "etc")
    configs = [
        {"src": src_etc, "dest": "/etc/neutron"},
        {"src": os.path.join(src_etc, "neutron/plugins"), "dest": "/etc/neutron/plugins"},
        {"src": os.path.join(src_etc, "neutron/rootwrap.d"), "dest": "/etc/neutron/rootwrap.d"},
    ]

    for c in configs:
        if os.path.exists(c["dest"]):
            shutil.rmtree(c["dest"])
        shutil.copytree(c["src"], c["dest"])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {
            "src": os.path.join(git_pip_venv_dir(projects_yaml), "bin/neutron-rootwrap"),
            "link": "/usr/local/bin/neutron-rootwrap",
        },
        {"src": "/usr/local/bin/neutron-rootwrap", "link": "/usr/bin/neutron-rootwrap"},
    ]

    for s in symlinks:
        if os.path.lexists(s["link"]):
            os.remove(s["link"])
        os.symlink(s["src"], s["link"])

    render("git/neutron_sudoers", "/etc/sudoers.d/neutron_sudoers", {}, perms=0o440)
    render(
        "git/cron.d/neutron-dhcp-agent-netns-cleanup", "/etc/cron.d/neutron-dhcp-agent-netns-cleanup", {}, perms=0o755
    )
    render("git/cron.d/neutron-l3-agent-netns-cleanup", "/etc/cron.d/neutron-l3-agent-netns-cleanup", {}, perms=0o755)
    render(
        "git/cron.d/neutron-lbaas-agent-netns-cleanup", "/etc/cron.d/neutron-lbaas-agent-netns-cleanup", {}, perms=0o755
    )

    service_name = "quantum-gateway"
    user_name = "neutron"
    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), "bin")
    neutron_api_context = {
        "service_description": "Neutron API server",
        "service_name": service_name,
        "process_name": "neutron-server",
        "executable_name": os.path.join(bin_dir, "neutron-server"),
    }
    neutron_dhcp_agent_context = {
        "service_description": "Neutron DHCP Agent",
        "service_name": service_name,
        "process_name": "neutron-dhcp-agent",
        "executable_name": os.path.join(bin_dir, "neutron-dhcp-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/dhcp_agent.ini"],
        "log_file": "/var/log/neutron/dhcp-agent.log",
    }
    neutron_l3_agent_context = {
        "service_description": "Neutron L3 Agent",
        "service_name": service_name,
        "process_name": "neutron-l3-agent",
        "executable_name": os.path.join(bin_dir, "neutron-l3-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/l3_agent.ini", "/etc/neutron/fwaas_driver.ini"],
        "log_file": "/var/log/neutron/l3-agent.log",
    }
    neutron_lbaas_agent_context = {
        "service_description": "Neutron LBaaS Agent",
        "service_name": service_name,
        "user_name": user_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-lbaas-agent",
        "executable_name": os.path.join(bin_dir, "neutron-lbaas-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/lbaas_agent.ini"],
        "log_file": "/var/log/neutron/lbaas-agent.log",
    }
    neutron_metadata_agent_context = {
        "service_description": "Neutron Metadata Agent",
        "service_name": service_name,
        "user_name": user_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-metadata-agent",
        "executable_name": os.path.join(bin_dir, "neutron-metadata-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/metadata_agent.ini"],
        "log_file": "/var/log/neutron/metadata-agent.log",
    }
    neutron_metering_agent_context = {
        "service_description": "Neutron Metering Agent",
        "service_name": service_name,
        "user_name": user_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-metering-agent",
        "executable_name": os.path.join(bin_dir, "neutron-metering-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/metering_agent.ini"],
        "log_file": "/var/log/neutron/metering-agent.log",
    }
    neutron_ovs_cleanup_context = {
        "service_description": "Neutron OVS cleanup",
        "service_name": service_name,
        "user_name": user_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-ovs-cleanup",
        "executable_name": os.path.join(bin_dir, "neutron-ovs-cleanup"),
        "config_file": "/etc/neutron/neutron.conf",
        "log_file": "/var/log/neutron/ovs-cleanup.log",
    }
    neutron_plugin_bigswitch_context = {
        "service_description": "Neutron BigSwitch Plugin Agent",
        "service_name": service_name,
        "user_name": user_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-restproxy-agent",
        "executable_name": os.path.join(bin_dir, "neutron-restproxy-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/plugins/bigswitch/restproxy.ini"],
        "log_file": "/var/log/neutron/bigswitch-agent.log",
    }
    neutron_plugin_ibm_context = {
        "service_description": "Neutron IBM SDN Plugin Agent",
        "service_name": service_name,
        "user_name": user_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-ibm-agent",
        "executable_name": os.path.join(bin_dir, "neutron-ibm-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/plugins/ibm/sdnve_neutron_plugin.ini"],
        "log_file": "/var/log/neutron/ibm-agent.log",
    }
    neutron_plugin_linuxbridge_context = {
        "service_description": "Neutron Linux Bridge Plugin Agent",
        "service_name": service_name,
        "user_name": user_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-linuxbridge-agent",
        "executable_name": os.path.join(bin_dir, "neutron-linuxbridge-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/plugins/ml2/ml2_conf.ini"],
        "log_file": "/var/log/neutron/linuxbridge-agent.log",
    }
    neutron_plugin_mlnx_context = {
        "service_description": "Neutron MLNX Plugin Agent",
        "service_name": service_name,
        "user_name": user_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-mlnx-agent",
        "executable_name": os.path.join(bin_dir, "neutron-mlnx-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/plugins/mlnx/mlnx_conf.ini"],
        "log_file": "/var/log/neutron/mlnx-agent.log",
    }
    neutron_plugin_nec_context = {
        "service_description": "Neutron NEC Plugin Agent",
        "service_name": service_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-nec-agent",
        "executable_name": os.path.join(bin_dir, "neutron-nec-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/plugins/nec/nec.ini"],
        "log_file": "/var/log/neutron/nec-agent.log",
    }
    neutron_plugin_oneconvergence_context = {
        "service_description": "Neutron One Convergence Plugin Agent",
        "service_name": service_name,
        "user_name": user_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-nvsd-agent",
        "executable_name": os.path.join(bin_dir, "neutron-nvsd-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/plugins/oneconvergence/nvsdplugin.ini"],
        "log_file": "/var/log/neutron/nvsd-agent.log",
    }
    neutron_plugin_openflow_context = {
        "service_description": "Neutron OpenFlow Plugin Agent",
        "service_name": service_name,
        "user_name": user_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-ofagent-agent",
        "executable_name": os.path.join(bin_dir, "neutron-ofagent-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/plugins/ml2/ml2_conf_ofa.ini"],
        "log_file": "/var/log/neutron/openflow-agent.log",
    }
    neutron_plugin_openvswitch_context = {
        "service_description": "Neutron OpenvSwitch Plugin Agent",
        "service_name": service_name,
        "user_name": user_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-openvswitch-agent",
        "executable_name": os.path.join(bin_dir, "neutron-openvswitch-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/plugins/ml2/ml2_conf.ini"],
        "log_file": "/var/log/neutron/openvswitch-agent.log",
    }
    neutron_plugin_ryu_context = {
        "service_description": "Neutron RYU Plugin Agent",
        "service_name": service_name,
        "user_name": user_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-ryu-agent",
        "executable_name": os.path.join(bin_dir, "neutron-ryu-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/plugins/ryu/ryu.ini"],
        "log_file": "/var/log/neutron/ryu-agent.log",
    }
    neutron_plugin_sriov_context = {
        "service_description": "Neutron SRIOV SDN Plugin Agent",
        "service_name": service_name,
        "user_name": user_name,
        "start_dir": "/var/lib/neutron",
        "process_name": "neutron-sriov-nic-agent",
        "executable_name": os.path.join(bin_dir, "neutron-sriov-nic-agent"),
        "config_files": ["/etc/neutron/neutron.conf", "/etc/neutron/plugins/ml2/ml2_conf_sriov"],
        "log_file": "/var/log/neutron/sriov-agent.log",
    }
    neutron_vpn_agent_context = {
        "service_description": "Neutron VPN Agent",
        "service_name": service_name,
        "process_name": "neutron-vpn-agent",
        "executable_name": os.path.join(bin_dir, "neutron-vpn-agent"),
        "config_files": [
            "/etc/neutron/neutron.conf",
            "/etc/neutron/vpn_agent.ini",
            "/etc/neutron/l3_agent.ini",
            "/etc/neutron/fwaas_driver.ini",
        ],
        "log_file": "/var/log/neutron/vpn_agent.log",
    }

    # NOTE(coreycb): Needs systemd support
    templates_dir = "hooks/charmhelpers/contrib/openstack/templates"
    templates_dir = os.path.join(charm_dir(), templates_dir)
    render(
        "git/upstart/neutron-agent.upstart",
        "/etc/init/neutron-dhcp-agent.conf",
        neutron_dhcp_agent_context,
        perms=0o644,
    )
    render(
        "git/upstart/neutron-agent.upstart", "/etc/init/neutron-l3-agent.conf", neutron_l3_agent_context, perms=0o644
    )
    render(
        "git.upstart",
        "/etc/init/neutron-lbaas-agent.conf",
        neutron_lbaas_agent_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render(
        "git.upstart",
        "/etc/init/neutron-metadata-agent.conf",
        neutron_metadata_agent_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render(
        "git.upstart",
        "/etc/init/neutron-metering-agent.conf",
        neutron_metering_agent_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render(
        "git.upstart",
        "/etc/init/neutron-ovs-cleanup.conf",
        neutron_ovs_cleanup_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render(
        "git.upstart",
        "/etc/init/neutron-plugin-bigswitch-agent.conf",
        neutron_plugin_bigswitch_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render(
        "git.upstart",
        "/etc/init/neutron-plugin-ibm-agent.conf",
        neutron_plugin_ibm_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render(
        "git.upstart",
        "/etc/init/neutron-plugin-linuxbridge-agent.conf",
        neutron_plugin_linuxbridge_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render(
        "git.upstart",
        "/etc/init/neutron-plugin-mlnx-agent.conf",
        neutron_plugin_mlnx_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render(
        "git.upstart",
        "/etc/init/neutron-plugin-nec-agent.conf",
        neutron_plugin_nec_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render(
        "git.upstart",
        "/etc/init/neutron-plugin-oneconvergence-agent.conf",
        neutron_plugin_oneconvergence_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render(
        "git.upstart",
        "/etc/init/neutron-plugin-openflow-agent.conf",
        neutron_plugin_openflow_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render(
        "git.upstart",
        "/etc/init/neutron-plugin-openvswitch-agent.conf",
        neutron_plugin_openvswitch_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render(
        "git.upstart",
        "/etc/init/neutron-plugin-ryu-agent.conf",
        neutron_plugin_ryu_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render(
        "git.upstart",
        "/etc/init/neutron-plugin-sriov-agent.conf",
        neutron_plugin_sriov_context,
        perms=0o644,
        templates_dir=templates_dir,
    )
    render("git/upstart/neutron-server.upstart", "/etc/init/neutron-server.conf", neutron_api_context, perms=0o644)
    render(
        "git/upstart/neutron-agent.upstart", "/etc/init/neutron-vpn-agent.conf", neutron_vpn_agent_context, perms=0o644
    )
예제 #27
0
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc')
    configs = [
        {
            'src': src_etc,
            'dest': '/etc/neutron'
        },
        {
            'src': os.path.join(src_etc, 'neutron/plugins'),
            'dest': '/etc/neutron/plugins'
        },
        {
            'src': os.path.join(src_etc, 'neutron/rootwrap.d'),
            'dest': '/etc/neutron/rootwrap.d'
        },
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {
            'src':
            os.path.join(git_pip_venv_dir(projects_yaml),
                         'bin/neutron-rootwrap'),
            'link':
            '/usr/local/bin/neutron-rootwrap'
        },
        {
            'src': '/usr/local/bin/neutron-rootwrap',
            'link': '/usr/bin/neutron-rootwrap'
        },
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/neutron_sudoers',
           '/etc/sudoers.d/neutron_sudoers', {},
           perms=0o440)
    render('git/cron.d/neutron-dhcp-agent-netns-cleanup',
           '/etc/cron.d/neutron-dhcp-agent-netns-cleanup', {},
           perms=0o755)
    render('git/cron.d/neutron-l3-agent-netns-cleanup',
           '/etc/cron.d/neutron-l3-agent-netns-cleanup', {},
           perms=0o755)
    render('git/cron.d/neutron-lbaas-agent-netns-cleanup',
           '/etc/cron.d/neutron-lbaas-agent-netns-cleanup', {},
           perms=0o755)

    service_name = 'quantum-gateway'
    user_name = 'neutron'
    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    neutron_api_context = {
        'service_description': 'Neutron API server',
        'service_name': service_name,
        'process_name': 'neutron-server',
        'executable_name': os.path.join(bin_dir, 'neutron-server'),
    }
    neutron_dhcp_agent_context = {
        'service_description':
        'Neutron DHCP Agent',
        'service_name':
        service_name,
        'process_name':
        'neutron-dhcp-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-dhcp-agent'),
        'config_files':
        ['/etc/neutron/neutron.conf', '/etc/neutron/dhcp_agent.ini'],
        'log_file':
        '/var/log/neutron/dhcp-agent.log',
    }
    neutron_l3_agent_context = {
        'service_description':
        'Neutron L3 Agent',
        'service_name':
        service_name,
        'process_name':
        'neutron-l3-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-l3-agent'),
        'config_files': [
            '/etc/neutron/neutron.conf', '/etc/neutron/l3_agent.ini',
            '/etc/neutron/fwaas_driver.ini'
        ],
        'log_file':
        '/var/log/neutron/l3-agent.log',
    }
    neutron_lbaas_agent_context = {
        'service_description':
        'Neutron LBaaS Agent',
        'service_name':
        service_name,
        'user_name':
        user_name,
        'start_dir':
        '/var/lib/neutron',
        'process_name':
        'neutron-lbaas-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-lbaas-agent'),
        'config_files':
        ['/etc/neutron/neutron.conf', '/etc/neutron/lbaas_agent.ini'],
        'log_file':
        '/var/log/neutron/lbaas-agent.log',
    }
    neutron_metadata_agent_context = {
        'service_description':
        'Neutron Metadata Agent',
        'service_name':
        service_name,
        'user_name':
        user_name,
        'start_dir':
        '/var/lib/neutron',
        'process_name':
        'neutron-metadata-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-metadata-agent'),
        'config_files':
        ['/etc/neutron/neutron.conf', '/etc/neutron/metadata_agent.ini'],
        'log_file':
        '/var/log/neutron/metadata-agent.log',
    }
    neutron_metering_agent_context = {
        'service_description':
        'Neutron Metering Agent',
        'service_name':
        service_name,
        'user_name':
        user_name,
        'start_dir':
        '/var/lib/neutron',
        'process_name':
        'neutron-metering-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-metering-agent'),
        'config_files':
        ['/etc/neutron/neutron.conf', '/etc/neutron/metering_agent.ini'],
        'log_file':
        '/var/log/neutron/metering-agent.log',
    }
    neutron_ovs_cleanup_context = {
        'service_description': 'Neutron OVS cleanup',
        'service_name': service_name,
        'user_name': user_name,
        'start_dir': '/var/lib/neutron',
        'process_name': 'neutron-ovs-cleanup',
        'executable_name': os.path.join(bin_dir, 'neutron-ovs-cleanup'),
        'config_file': '/etc/neutron/neutron.conf',
        'log_file': '/var/log/neutron/ovs-cleanup.log',
    }
    neutron_plugin_bigswitch_context = {
        'service_description':
        'Neutron BigSwitch Plugin Agent',
        'service_name':
        service_name,
        'user_name':
        user_name,
        'start_dir':
        '/var/lib/neutron',
        'process_name':
        'neutron-restproxy-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-restproxy-agent'),
        'config_files': [
            '/etc/neutron/neutron.conf',
            '/etc/neutron/plugins/bigswitch/restproxy.ini'
        ],
        'log_file':
        '/var/log/neutron/bigswitch-agent.log',
    }
    neutron_plugin_ibm_context = {
        'service_description':
        'Neutron IBM SDN Plugin Agent',
        'service_name':
        service_name,
        'user_name':
        user_name,
        'start_dir':
        '/var/lib/neutron',
        'process_name':
        'neutron-ibm-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-ibm-agent'),
        'config_files': [
            '/etc/neutron/neutron.conf',
            '/etc/neutron/plugins/ibm/sdnve_neutron_plugin.ini'
        ],
        'log_file':
        '/var/log/neutron/ibm-agent.log',
    }
    neutron_plugin_linuxbridge_context = {
        'service_description':
        'Neutron Linux Bridge Plugin Agent',
        'service_name':
        service_name,
        'user_name':
        user_name,
        'start_dir':
        '/var/lib/neutron',
        'process_name':
        'neutron-linuxbridge-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-linuxbridge-agent'),
        'config_files':
        ['/etc/neutron/neutron.conf', '/etc/neutron/plugins/ml2/ml2_conf.ini'],
        'log_file':
        '/var/log/neutron/linuxbridge-agent.log',
    }
    neutron_plugin_mlnx_context = {
        'service_description':
        'Neutron MLNX Plugin Agent',
        'service_name':
        service_name,
        'user_name':
        user_name,
        'start_dir':
        '/var/lib/neutron',
        'process_name':
        'neutron-mlnx-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-mlnx-agent'),
        'config_files': [
            '/etc/neutron/neutron.conf',
            '/etc/neutron/plugins/mlnx/mlnx_conf.ini'
        ],
        'log_file':
        '/var/log/neutron/mlnx-agent.log',
    }
    neutron_plugin_nec_context = {
        'service_description':
        'Neutron NEC Plugin Agent',
        'service_name':
        service_name,
        'start_dir':
        '/var/lib/neutron',
        'process_name':
        'neutron-nec-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-nec-agent'),
        'config_files':
        ['/etc/neutron/neutron.conf', '/etc/neutron/plugins/nec/nec.ini'],
        'log_file':
        '/var/log/neutron/nec-agent.log',
    }
    neutron_plugin_oneconvergence_context = {
        'service_description':
        'Neutron One Convergence Plugin Agent',
        'service_name':
        service_name,
        'user_name':
        user_name,
        'start_dir':
        '/var/lib/neutron',
        'process_name':
        'neutron-nvsd-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-nvsd-agent'),
        'config_files': [
            '/etc/neutron/neutron.conf',
            '/etc/neutron/plugins/oneconvergence/nvsdplugin.ini'
        ],
        'log_file':
        '/var/log/neutron/nvsd-agent.log',
    }
    neutron_plugin_openflow_context = {
        'service_description':
        'Neutron OpenFlow Plugin Agent',
        'service_name':
        service_name,
        'user_name':
        user_name,
        'start_dir':
        '/var/lib/neutron',
        'process_name':
        'neutron-ofagent-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-ofagent-agent'),
        'config_files': [
            '/etc/neutron/neutron.conf',
            '/etc/neutron/plugins/ml2/ml2_conf_ofa.ini'
        ],
        'log_file':
        '/var/log/neutron/openflow-agent.log',
    }
    neutron_plugin_openvswitch_context = {
        'service_description':
        'Neutron OpenvSwitch Plugin Agent',
        'service_name':
        service_name,
        'user_name':
        user_name,
        'start_dir':
        '/var/lib/neutron',
        'process_name':
        'neutron-openvswitch-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-openvswitch-agent'),
        'config_files':
        ['/etc/neutron/neutron.conf', '/etc/neutron/plugins/ml2/ml2_conf.ini'],
        'log_file':
        '/var/log/neutron/openvswitch-agent.log',
    }
    neutron_plugin_ryu_context = {
        'service_description':
        'Neutron RYU Plugin Agent',
        'service_name':
        service_name,
        'user_name':
        user_name,
        'start_dir':
        '/var/lib/neutron',
        'process_name':
        'neutron-ryu-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-ryu-agent'),
        'config_files':
        ['/etc/neutron/neutron.conf', '/etc/neutron/plugins/ryu/ryu.ini'],
        'log_file':
        '/var/log/neutron/ryu-agent.log',
    }
    neutron_plugin_sriov_context = {
        'service_description':
        'Neutron SRIOV SDN Plugin Agent',
        'service_name':
        service_name,
        'user_name':
        user_name,
        'start_dir':
        '/var/lib/neutron',
        'process_name':
        'neutron-sriov-nic-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-sriov-nic-agent'),
        'config_files': [
            '/etc/neutron/neutron.conf',
            '/etc/neutron/plugins/ml2/ml2_conf_sriov'
        ],
        'log_file':
        '/var/log/neutron/sriov-agent.log',
    }
    neutron_vpn_agent_context = {
        'service_description':
        'Neutron VPN Agent',
        'service_name':
        service_name,
        'process_name':
        'neutron-vpn-agent',
        'executable_name':
        os.path.join(bin_dir, 'neutron-vpn-agent'),
        'config_files': [
            '/etc/neutron/neutron.conf', '/etc/neutron/vpn_agent.ini',
            '/etc/neutron/l3_agent.ini', '/etc/neutron/fwaas_driver.ini'
        ],
        'log_file':
        '/var/log/neutron/vpn_agent.log',
    }

    # NOTE(coreycb): Needs systemd support
    templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
    templates_dir = os.path.join(charm_dir(), templates_dir)
    render('git/upstart/neutron-agent.upstart',
           '/etc/init/neutron-dhcp-agent.conf',
           neutron_dhcp_agent_context,
           perms=0o644)
    render('git/upstart/neutron-agent.upstart',
           '/etc/init/neutron-l3-agent.conf',
           neutron_l3_agent_context,
           perms=0o644)
    render('git.upstart',
           '/etc/init/neutron-lbaas-agent.conf',
           neutron_lbaas_agent_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-metadata-agent.conf',
           neutron_metadata_agent_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-metering-agent.conf',
           neutron_metering_agent_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-ovs-cleanup.conf',
           neutron_ovs_cleanup_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-bigswitch-agent.conf',
           neutron_plugin_bigswitch_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-ibm-agent.conf',
           neutron_plugin_ibm_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-linuxbridge-agent.conf',
           neutron_plugin_linuxbridge_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-mlnx-agent.conf',
           neutron_plugin_mlnx_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-nec-agent.conf',
           neutron_plugin_nec_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-oneconvergence-agent.conf',
           neutron_plugin_oneconvergence_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-openflow-agent.conf',
           neutron_plugin_openflow_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-openvswitch-agent.conf',
           neutron_plugin_openvswitch_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-ryu-agent.conf',
           neutron_plugin_ryu_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/neutron-plugin-sriov-agent.conf',
           neutron_plugin_sriov_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git/upstart/neutron-server.upstart',
           '/etc/init/neutron-server.conf',
           neutron_api_context,
           perms=0o644)
    render('git/upstart/neutron-agent.upstart',
           '/etc/init/neutron-vpn-agent.conf',
           neutron_vpn_agent_context,
           perms=0o644)
def git_post_install(projects_yaml):
    """Perform post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        pip_install('mysql-python', proxy=http_proxy,
                    venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install('mysql-python',
                    venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc')
    configs = [
        {'src': src_etc,
         'dest': '/etc/neutron'},
        {'src': os.path.join(src_etc, 'neutron/plugins'),
         'dest': '/etc/neutron/plugins'},
        {'src': os.path.join(src_etc, 'neutron/rootwrap.d'),
         'dest': '/etc/neutron/rootwrap.d'},
    ]

    for c in configs:
        if os.path.exists(c['dest']):
            shutil.rmtree(c['dest'])
        shutil.copytree(c['src'], c['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/neutron-rootwrap'),
         'link': '/usr/local/bin/neutron-rootwrap'},
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/neutron-db-manage'),
         'link': '/usr/local/bin/neutron-db-manage'},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/neutron_sudoers', '/etc/sudoers.d/neutron_sudoers', {},
           perms=0o440)

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    # Use systemd init units/scripts from ubuntu wily onward
    if lsb_release()['DISTRIB_RELEASE'] >= '15.10':
        templates_dir = os.path.join(charm_dir(), 'templates/git')
        daemon = 'neutron-server'
        neutron_api_context = {
            'daemon_path': os.path.join(bin_dir, daemon),
        }
        template_file = 'git/{}.init.in.template'.format(daemon)
        init_in_file = '{}.init.in'.format(daemon)
        render(template_file, os.path.join(templates_dir, init_in_file),
               neutron_api_context, perms=0o644)
        git_generate_systemd_init_files(templates_dir)
    else:
        neutron_api_context = {
            'service_description': 'Neutron API server',
            'charm_name': 'neutron-api',
            'process_name': 'neutron-server',
            'executable_name': os.path.join(bin_dir, 'neutron-server'),
        }

        render('git/upstart/neutron-server.upstart',
               '/etc/init/neutron-server.conf',
               neutron_api_context, perms=0o644)

    if not is_unit_paused_set():
        service_restart('neutron-server')
예제 #29
0
def git_post_install(projects_yaml):
    """Perform cinder post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    base_packages = ['mysql-python', 'python-cephlibs']
    for pkg in base_packages:
        if http_proxy:
            pip_install(pkg, proxy=http_proxy,
                        venv=git_pip_venv_dir(projects_yaml))
        else:
            pip_install(pkg,
                        venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'cinder'), 'etc/cinder')
    configs = {
        'src': src_etc,
        'dest': '/etc/cinder',
    }

    if os.path.exists(configs['dest']):
        shutil.rmtree(configs['dest'])
    shutil.copytree(configs['src'], configs['dest'])

    # NOTE(coreycb): Need to find better solution than bin symlinks.
    symlinks = [
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/cinder-manage'),
         'link': '/usr/local/bin/cinder-manage'},
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
                             'bin/cinder-rootwrap'),
         'link': '/usr/local/bin/cinder-rootwrap'},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/cinder_tgt.conf', '/etc/tgt/conf.d', {}, owner='cinder',
           group='cinder', perms=0o644)
    render('git/logging.conf', '/etc/cinder/logging.conf', {}, owner='cinder',
           group='cinder', perms=0o644)
    render('git/cinder_sudoers', '/etc/sudoers.d/cinder_sudoers', {},
           owner='root', group='root', perms=0o440)

    os.chmod('/etc/sudoers.d', 0o750)

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    # Use systemd init units/scripts from ubuntu wily onward
    if lsb_release()['DISTRIB_RELEASE'] >= '15.10':
        templates_dir = os.path.join(charm_dir(), 'templates/git')
        daemons = ['cinder-api', 'cinder-backup', 'cinder-scheduler',
                   'cinder-volume']
        for daemon in daemons:
            cinder_context = {
                'daemon_path': os.path.join(bin_dir, daemon),
            }
            template_file = 'git/{}.init.in.template'.format(daemon)
            init_in_file = '{}.init.in'.format(daemon)
            render(template_file, os.path.join(templates_dir, init_in_file),
                   cinder_context, perms=0o644)
        git_generate_systemd_init_files(templates_dir)
    else:
        cinder_api_context = {
            'service_description': 'Cinder API server',
            'service_name': 'Cinder',
            'user_name': 'cinder',
            'start_dir': '/var/lib/cinder',
            'process_name': 'cinder-api',
            'executable_name': os.path.join(bin_dir, 'cinder-api'),
            'config_files': ['/etc/cinder/cinder.conf'],
            'log_file': '/var/log/cinder/cinder-api.log',
        }

        cinder_backup_context = {
            'service_description': 'Cinder backup server',
            'service_name': 'Cinder',
            'user_name': 'cinder',
            'start_dir': '/var/lib/cinder',
            'process_name': 'cinder-backup',
            'executable_name': os.path.join(bin_dir, 'cinder-backup'),
            'config_files': ['/etc/cinder/cinder.conf'],
            'log_file': '/var/log/cinder/cinder-backup.log',
        }

        cinder_scheduler_context = {
            'service_description': 'Cinder scheduler server',
            'service_name': 'Cinder',
            'user_name': 'cinder',
            'start_dir': '/var/lib/cinder',
            'process_name': 'cinder-scheduler',
            'executable_name': os.path.join(bin_dir, 'cinder-scheduler'),
            'config_files': ['/etc/cinder/cinder.conf'],
            'log_file': '/var/log/cinder/cinder-scheduler.log',
        }

        cinder_volume_context = {
            'service_description': 'Cinder volume server',
            'service_name': 'Cinder',
            'user_name': 'cinder',
            'start_dir': '/var/lib/cinder',
            'process_name': 'cinder-volume',
            'executable_name': os.path.join(bin_dir, 'cinder-volume'),
            'config_files': ['/etc/cinder/cinder.conf'],
            'log_file': '/var/log/cinder/cinder-volume.log',
        }

        templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
        templates_dir = os.path.join(charm_dir(), templates_dir)
        render('git.upstart', '/etc/init/cinder-api.conf',
               cinder_api_context, perms=0o644,
               templates_dir=templates_dir)
        render('git.upstart', '/etc/init/cinder-backup.conf',
               cinder_backup_context, perms=0o644,
               templates_dir=templates_dir)
        render('git.upstart', '/etc/init/cinder-scheduler.conf',
               cinder_scheduler_context, perms=0o644,
               templates_dir=templates_dir)
        render('git.upstart', '/etc/init/cinder-volume.conf',
               cinder_volume_context, perms=0o644,
               templates_dir=templates_dir)

    if not is_unit_paused_set():
        service_restart('tgtd')

        [service_restart(s) for s in services()]
def git_post_install(projects_yaml):
    """Perform horizon post-install setup."""
    src_dir = git_src_dir(projects_yaml, 'horizon')
    copy_files = {
        'manage': {
            'src': os.path.join(src_dir, 'manage.py'),
            'dest': '/usr/share/openstack-dashboard/manage.py',
        },
        'settings': {
            'src': os.path.join(src_dir, 'openstack_dashboard/settings.py'),
            'dest': '/usr/share/openstack-dashboard/settings.py',
        },
        'local_settings_example': {
            'src': os.path.join(src_dir, 'openstack_dashboard/local',
                                'local_settings.py.example'),
            'dest': '/etc/openstack-dashboard/local_settings.py',
        },
    }

    for name, files in copy_files.iteritems():
        if os.path.exists(files['dest']):
            os.remove(files['dest'])
        shutil.copyfile(files['src'], files['dest'])

    copy_trees = {
        'openstack_dashboard': {
            'src': os.path.join(src_dir, 'openstack_dashboard'),
            'dest': '/usr/share/openstack-dashboard/openstack_dashboard',
        },
    }

    for name, dirs in copy_trees.iteritems():
        if os.path.exists(dirs['dest']):
            shutil.rmtree(dirs['dest'])
        shutil.copytree(dirs['src'], dirs['dest'])

    share_dir = '/usr/share/openstack-dashboard/openstack_dashboard'
    symlinks = [
        {'src': '/usr/share/openstack-dashboard/openstack_dashboard/static',
         'link': '/usr/share/openstack-dashboard/static'},
        {'src': '/usr/bin/lessc',
         'link': '/usr/share/openstack-dashboard/bin/less/lessc'},
        {'src': '/etc/openstack-dashboard/local_settings.py',
         'link': os.path.join(share_dir, 'local/local_settings.py')},
        {'src': os.path.join(git_pip_venv_dir(projects_yaml),
         'local/lib/python2.7/site-packages/horizon/static/horizon/'),
         'link': os.path.join(share_dir, 'static/horizon')},
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    render('git/dashboard.conf',
           '/etc/apache2/conf-available/openstack-dashboard.conf',
           {'virtualenv': git_pip_venv_dir(projects_yaml)},
           owner='root', group='root', perms=0o644)

    os.chmod('/var/lib/openstack-dashboard', 0o750)
    os.chmod('/usr/share/openstack-dashboard/manage.py', 0o755),

    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        pip_install('python-memcached', proxy=http_proxy,
                    venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install('python-memcached',
                    venv=git_pip_venv_dir(projects_yaml))
    python = os.path.join(git_pip_venv_dir(projects_yaml), 'bin/python')
    subprocess.check_call([python, '/usr/share/openstack-dashboard/manage.py',
                           'collectstatic', '--noinput'])
    subprocess.check_call([python, '/usr/share/openstack-dashboard/manage.py',
                           'compress', '--force'])

    uid = pwd.getpwnam('horizon').pw_uid
    gid = grp.getgrnam('horizon').gr_gid
    os.chown('/etc/openstack-dashboard', uid, gid)
    os.chown('/usr/share/openstack-dashboard/openstack_dashboard/static',
             uid, gid)
    os.chown('/var/lib/openstack-dashboard', uid, gid)

    static_dir = '/usr/share/openstack-dashboard/openstack_dashboard/static'
    for root, dirs, files in os.walk(static_dir):
        for d in dirs:
            os.lchown(os.path.join(root, d), uid, gid)
        for f in files:
            os.lchown(os.path.join(root, f), uid, gid)

    subprocess.check_call(['a2enconf', 'openstack-dashboard'])

    if not is_unit_paused_set():
        service_restart('apache2')
예제 #31
0
def git_post_install(projects_yaml):
    """Perform glance post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        pip_install('mysql-python',
                    proxy=http_proxy,
                    venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install('mysql-python', venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, 'glance'), 'etc')
    configs = {
        'src': src_etc,
        'dest': '/etc/glance',
    }

    if os.path.exists(configs['dest']):
        shutil.rmtree(configs['dest'])
    shutil.copytree(configs['src'], configs['dest'])

    symlinks = [
        # NOTE(coreycb): Need to find better solution than bin symlinks.
        {
            'src':
            os.path.join(git_pip_venv_dir(projects_yaml), 'bin/glance-manage'),
            'link':
            '/usr/local/bin/glance-manage'
        },
        # NOTE(coreycb): This is ugly but couldn't find pypi package that
        #                installs rbd.py and rados.py.
        {
            'src':
            '/usr/lib/python2.7/dist-packages/rbd.py',
            'link':
            os.path.join(git_pip_venv_dir(projects_yaml),
                         'lib/python2.7/site-packages/rbd.py')
        },
        {
            'src':
            '/usr/lib/python2.7/dist-packages/rados.py',
            'link':
            os.path.join(git_pip_venv_dir(projects_yaml),
                         'lib/python2.7/site-packages/rados.py')
        },
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
    glance_api_context = {
        'service_description': 'Glance API server',
        'service_name': 'Glance',
        'user_name': 'glance',
        'start_dir': '/var/lib/glance',
        'process_name': 'glance-api',
        'executable_name': os.path.join(bin_dir, 'glance-api'),
        'config_files': ['/etc/glance/glance-api.conf'],
        'log_file': '/var/log/glance/api.log',
    }

    glance_registry_context = {
        'service_description': 'Glance registry server',
        'service_name': 'Glance',
        'user_name': 'glance',
        'start_dir': '/var/lib/glance',
        'process_name': 'glance-registry',
        'executable_name': os.path.join(bin_dir, 'glance-registry'),
        'config_files': ['/etc/glance/glance-registry.conf'],
        'log_file': '/var/log/glance/registry.log',
    }

    # NOTE(coreycb): Needs systemd support
    templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
    templates_dir = os.path.join(charm_dir(), templates_dir)
    render('git.upstart',
           '/etc/init/glance-api.conf',
           glance_api_context,
           perms=0o644,
           templates_dir=templates_dir)
    render('git.upstart',
           '/etc/init/glance-registry.conf',
           glance_registry_context,
           perms=0o644,
           templates_dir=templates_dir)

    service_restart('glance-api')
    service_restart('glance-registry')
def git_post_install(projects_yaml):
    """Perform horizon post-install setup."""
    projects_yaml = git_default_repos(projects_yaml)

    src_dir = git_src_dir(projects_yaml, 'horizon')
    copy_files = {
        'manage': {
            'src': os.path.join(src_dir, 'manage.py'),
            'dest': '/usr/share/openstack-dashboard/manage.py',
        },
        'settings': {
            'src': os.path.join(src_dir, 'openstack_dashboard/settings.py'),
            'dest': '/usr/share/openstack-dashboard/settings.py',
        },
        'local_settings_example': {
            'src':
            os.path.join(src_dir, 'openstack_dashboard/local',
                         'local_settings.py.example'),
            'dest':
            '/etc/openstack-dashboard/local_settings.py',
        },
    }

    for name, files in copy_files.iteritems():
        if os.path.exists(files['dest']):
            os.remove(files['dest'])
        shutil.copyfile(files['src'], files['dest'])

    copy_trees = {
        'openstack_dashboard': {
            'src': os.path.join(src_dir, 'openstack_dashboard'),
            'dest': '/usr/share/openstack-dashboard/openstack_dashboard',
        },
    }

    for name, dirs in copy_trees.iteritems():
        if os.path.exists(dirs['dest']):
            shutil.rmtree(dirs['dest'])
        shutil.copytree(dirs['src'], dirs['dest'])

    share_dir = '/usr/share/openstack-dashboard/openstack_dashboard'
    symlinks = [
        {
            'src': '/usr/share/openstack-dashboard/openstack_dashboard/static',
            'link': '/usr/share/openstack-dashboard/static'
        },
        {
            'src': '/usr/bin/lessc',
            'link': '/usr/share/openstack-dashboard/bin/less/lessc'
        },
        {
            'src': '/etc/openstack-dashboard/local_settings.py',
            'link': os.path.join(share_dir, 'local/local_settings.py')
        },
        {
            'src':
            os.path.join(
                git_pip_venv_dir(projects_yaml),
                'local/lib/python2.7/site-packages/horizon/static/horizon/'),
            'link':
            os.path.join(share_dir, 'static/horizon')
        },
    ]

    for s in symlinks:
        if os.path.lexists(s['link']):
            os.remove(s['link'])
        os.symlink(s['src'], s['link'])

    os.chmod('/var/lib/openstack-dashboard', 0o750)
    os.chmod('/usr/share/openstack-dashboard/manage.py', 0o755),

    http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
    if http_proxy:
        pip_install('python-memcached',
                    proxy=http_proxy,
                    venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install('python-memcached', venv=git_pip_venv_dir(projects_yaml))
    python = os.path.join(git_pip_venv_dir(projects_yaml), 'bin/python')
    subprocess.check_call([
        python, '/usr/share/openstack-dashboard/manage.py', 'collectstatic',
        '--noinput'
    ])
    subprocess.check_call([
        python, '/usr/share/openstack-dashboard/manage.py', 'compress',
        '--force'
    ])

    uid = pwd.getpwnam('horizon').pw_uid
    gid = grp.getgrnam('horizon').gr_gid
    os.chown('/etc/openstack-dashboard', uid, gid)
    os.chown('/usr/share/openstack-dashboard/openstack_dashboard/static', uid,
             gid)
    os.chown('/var/lib/openstack-dashboard', uid, gid)

    static_dir = '/usr/share/openstack-dashboard/openstack_dashboard/static'
    for root, dirs, files in os.walk(static_dir):
        for d in dirs:
            os.lchown(os.path.join(root, d), uid, gid)
        for f in files:
            os.lchown(os.path.join(root, f), uid, gid)

    if not is_unit_paused_set():
        service_restart('apache2')
예제 #33
0
def git_post_install(projects_yaml):
    """Perform glance post-install setup."""
    http_proxy = git_yaml_value(projects_yaml, "http_proxy")
    if http_proxy:
        pip_install("mysql-python", proxy=http_proxy, venv=git_pip_venv_dir(projects_yaml))
    else:
        pip_install("mysql-python", venv=git_pip_venv_dir(projects_yaml))

    src_etc = os.path.join(git_src_dir(projects_yaml, "glance"), "etc")
    configs = {"src": src_etc, "dest": "/etc/glance"}

    if os.path.exists(configs["dest"]):
        shutil.rmtree(configs["dest"])
    shutil.copytree(configs["src"], configs["dest"])

    symlinks = [
        # NOTE(coreycb): Need to find better solution than bin symlinks.
        {
            "src": os.path.join(git_pip_venv_dir(projects_yaml), "bin/glance-manage"),
            "link": "/usr/local/bin/glance-manage",
        },
        # NOTE(coreycb): This is ugly but couldn't find pypi package that
        #                installs rbd.py and rados.py.
        {
            "src": "/usr/lib/python2.7/dist-packages/rbd.py",
            "link": os.path.join(git_pip_venv_dir(projects_yaml), "lib/python2.7/site-packages/rbd.py"),
        },
        {
            "src": "/usr/lib/python2.7/dist-packages/rados.py",
            "link": os.path.join(git_pip_venv_dir(projects_yaml), "lib/python2.7/site-packages/rados.py"),
        },
    ]

    for s in symlinks:
        if os.path.lexists(s["link"]):
            os.remove(s["link"])
        os.symlink(s["src"], s["link"])

    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), "bin")
    glance_api_context = {
        "service_description": "Glance API server",
        "service_name": "Glance",
        "user_name": "glance",
        "start_dir": "/var/lib/glance",
        "process_name": "glance-api",
        "executable_name": os.path.join(bin_dir, "glance-api"),
        "config_files": ["/etc/glance/glance-api.conf"],
        "log_file": "/var/log/glance/api.log",
    }

    glance_registry_context = {
        "service_description": "Glance registry server",
        "service_name": "Glance",
        "user_name": "glance",
        "start_dir": "/var/lib/glance",
        "process_name": "glance-registry",
        "executable_name": os.path.join(bin_dir, "glance-registry"),
        "config_files": ["/etc/glance/glance-registry.conf"],
        "log_file": "/var/log/glance/registry.log",
    }

    # NOTE(coreycb): Needs systemd support
    templates_dir = "hooks/charmhelpers/contrib/openstack/templates"
    templates_dir = os.path.join(charm_dir(), templates_dir)
    render("git.upstart", "/etc/init/glance-api.conf", glance_api_context, perms=0o644, templates_dir=templates_dir)
    render(
        "git.upstart",
        "/etc/init/glance-registry.conf",
        glance_registry_context,
        perms=0o644,
        templates_dir=templates_dir,
    )

    service_restart("glance-api")
    service_restart("glance-registry")