コード例 #1
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')
コード例 #2
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)
コード例 #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('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)
コード例 #4
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)
コード例 #5
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)
コード例 #6
0
ファイル: cinder_utils.py プロジェクト: dosaboy/charm-cinder
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()]
コード例 #7
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()]
コード例 #8
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')
コード例 #9
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')
コード例 #10
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')
コード例 #11
0
ファイル: glance_utils.py プロジェクト: coreycb/charm-glance
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')
コード例 #12
0
ファイル: cinder_utils.py プロジェクト: coreycb/charm-cinder
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()]
コード例 #13
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')
    # 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')
コード例 #14
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')
コード例 #15
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)
コード例 #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')
    # 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')
コード例 #17
0
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')
コード例 #18
0
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')
コード例 #19
0
ファイル: glance_utils.py プロジェクト: cloudbase/hyper-c
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")