~openstack-charmers-next/charms/wily/neutron-api/trunk

« back to all changes in this revision

Viewing changes to hooks/neutron_api_utils.py

  • Committer: James Page
  • Author(s): Corey Bryant
  • Date: 2016-07-07 09:58:51 UTC
  • Revision ID: james.page@ubuntu.com-20160707095851-l25bd1256p2r71yd
Add systemd init support for deploy from source

systemd is used instead of upstart by default since Ubuntu 15.10
(Wily).  This adds systemd init file support for nova services
that are deployed from source.

Change-Id: I45757fcd52426369b42916ad2195d2fe2f6a4c15

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from charmhelpers.contrib.openstack.utils import (
29
29
    os_release,
30
30
    get_os_codename_install_source,
31
 
    git_install_requested,
32
31
    git_clone_and_install,
33
32
    git_default_repos,
 
33
    git_generate_systemd_init_files,
 
34
    git_install_requested,
 
35
    git_pip_venv_dir,
34
36
    git_src_dir,
35
 
    git_pip_venv_dir,
36
37
    git_yaml_value,
37
38
    configure_installation_source,
38
39
    incomplete_relation_data,
110
111
    'libxml2-dev',
111
112
    'libxslt1-dev',
112
113
    'libyaml-dev',
 
114
    'openstack-pkg-tools',
113
115
    'python-dev',
114
116
    'python-neutronclient',  # required for get_neutron_client() import
115
117
    'python-pip',
655
657
           perms=0o440)
656
658
 
657
659
    bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
658
 
    neutron_api_context = {
659
 
        'service_description': 'Neutron API server',
660
 
        'charm_name': 'neutron-api',
661
 
        'process_name': 'neutron-server',
662
 
        'executable_name': os.path.join(bin_dir, 'neutron-server'),
663
 
    }
 
660
    # Use systemd init units/scripts from ubuntu wily onward
 
661
    if lsb_release()['DISTRIB_RELEASE'] >= '15.10':
 
662
        templates_dir = os.path.join(charm_dir(), 'templates/git')
 
663
        daemon = 'neutron-server'
 
664
        neutron_api_context = {
 
665
            'daemon_path': os.path.join(bin_dir, daemon),
 
666
        }
 
667
        template_file = 'git/{}.init.in.template'.format(daemon)
 
668
        init_in_file = '{}.init.in'.format(daemon)
 
669
        render(template_file, os.path.join(templates_dir, init_in_file),
 
670
               neutron_api_context, perms=0o644)
 
671
        git_generate_systemd_init_files(templates_dir)
 
672
    else:
 
673
        neutron_api_context = {
 
674
            'service_description': 'Neutron API server',
 
675
            'charm_name': 'neutron-api',
 
676
            'process_name': 'neutron-server',
 
677
            'executable_name': os.path.join(bin_dir, 'neutron-server'),
 
678
        }
664
679
 
665
 
    # NOTE(coreycb): Needs systemd support
666
 
    render('git/upstart/neutron-server.upstart',
667
 
           '/etc/init/neutron-server.conf',
668
 
           neutron_api_context, perms=0o644)
 
680
        render('git/upstart/neutron-server.upstart',
 
681
               '/etc/init/neutron-server.conf',
 
682
               neutron_api_context, perms=0o644)
669
683
 
670
684
    if not is_unit_paused_set():
671
685
        service_restart('neutron-server')