コード例 #1
0
def install_keystone():
    saved_path = os.getcwd()
    os.chdir('{}'.format(CHARM_LIB_DIR + "oracle_keystone"))
    pip_install('.')
    os.chdir(saved_path)
    with open("/etc/apache2/apache2.conf", "a") as apache_conf:
        apache_conf.write("ServerName {}".format(unit_get('private-address')))
コード例 #2
0
ファイル: utils.py プロジェクト: zetas/ceilometer-charm-mysql
def _git_clone_and_install_single(repo, branch, parent_dir, update_requirements):
    """
    Clone and install a single git repository.
    """
    dest_dir = os.path.join(parent_dir, os.path.basename(repo))

    if not os.path.exists(parent_dir):
        juju_log('Directory already exists at {}. '
                 'No need to create directory.'.format(parent_dir))
        os.mkdir(parent_dir)

    if not os.path.exists(dest_dir):
        juju_log('Cloning git repo: {}, branch: {}'.format(repo, branch))
        repo_dir = install_remote(repo, dest=parent_dir, branch=branch)
    else:
        repo_dir = dest_dir

    if update_requirements:
        if not requirements_dir:
            error_out('requirements repo must be cloned before '
                      'updating from global requirements.')
        _git_update_requirements(repo_dir, requirements_dir)

    juju_log('Installing git repo from dir: {}'.format(repo_dir))
    pip_install(repo_dir)

    return repo_dir
コード例 #3
0
def install_nrpe_deps():
    NAGIOSCHECK = {
        'path': '/tmp/nagioscheck',
        'url': 'https://github.com/MartinHell/pynagioscheck.git'
    }
    NAGIOS_PLUGIN = {
        'path': '/tmp/nagiosplugin',
        'url': 'https://github.com/Boolman/nagios-plugin-elasticsearch.git'
    }
    try:
        from git import Repo
    except:
        python.pip_install("gitpython")
        from git import Repo

    try:
        Repo.clone_from(NAGIOSCHECK['url'], NAGIOSCHECK['path'])
        Repo.clone_from(NAGIOS_PLUGIN['url'], NAGIOS_PLUGIN['path'])
        sp.Popen(["python", "setup.py", "install"],
                 cwd=NAGIOSCHECK['path'],
                 stdout=sp.PIPE,
                 stderr=sp.STDOUT).communicate()
        sp.Popen(["python", "setup.py", "install"],
                 cwd=NAGIOS_PLUGIN['path'],
                 stdout=sp.PIPE,
                 stderr=sp.STDOUT).communicate()
    except:
        return False
コード例 #4
0
 def test_pip_install_multiple(self):
     """
     Check if pip_install works correctly with multiple packages
     """
     packages.pip_install(["mock", "nose"])
     self.pip_execute.assert_called_with(["install",
                                          "mock", "nose"])
コード例 #5
0
def install_cherrypy_helloworld():
    """Install the cherrypy helloworld service."""
    # Install dependencies for our helloworld service
    for pkg in ['CherryPy', 'jinja2']:
        pip_install(pkg)

    # When we first run, generate the systemd service file
    with open('{}/templates/helloworld.service.j2'.format(charm_dir())) as f:
        t = Template(f.read())

        # Render the new configuration
        rendered = t.render(
            charm_dir=charm_dir(),
        )

        status_set('maintenance', 'Creating helloworld service...')
        service_file = "/etc/systemd/system/{}.service".format(charm_name())
        with open(service_file, "w") as svc:
            svc.write(rendered)

        # Render the initial configuration
        render_config()

        status_set('maintenance', 'Starting helloworld service...')
        service_start(charm_name())

        # Make sure the port is open
        update_http_port()

        status_set('active', 'Ready!')

    set_flag('cherrypy-helloworld.installed')
コード例 #6
0
ファイル: utils.py プロジェクト: wuwenbin2/onos-controller
def _git_clone_and_install_single(repo, branch, update_requirements=False):
    """Clone and install a single git repository."""
    dest_parent_dir = "/mnt/openstack-git/"
    dest_dir = os.path.join(dest_parent_dir, os.path.basename(repo))

    if not os.path.exists(dest_parent_dir):
        juju_log('Host dir not mounted at {}. '
                 'Creating directory there instead.'.format(dest_parent_dir))
        os.mkdir(dest_parent_dir)

    if not os.path.exists(dest_dir):
        juju_log('Cloning git repo: {}, branch: {}'.format(repo, branch))
        repo_dir = install_remote(repo, dest=dest_parent_dir, branch=branch)
    else:
        repo_dir = dest_dir

    if update_requirements:
        if not requirements_dir:
            error_out('requirements repo must be cloned before '
                      'updating from global requirements.')
        _git_update_requirements(repo_dir, requirements_dir)

    juju_log('Installing git repo from dir: {}'.format(repo_dir))
    pip_install(repo_dir)

    return repo_dir
コード例 #7
0
ファイル: present.py プロジェクト: jamesbeedy/layer-present
def install_presentation():

    """ Install presentation
    """

    opts = layer.options('git-deploy')

    # Clone repo
    hookenv.status_set('maintenance', 
                       'Installing and building the presentation.')

    # Build and install
    with chdir(opts.get('target')):
        with open('requirements.txt', 'r') as f:
            for i in list(map(lambda b: b.strip('\n'), f.readlines())):
                pip_install(i)

        sphinx_build_cmd = 'sphinx-build -b html source %s' % opts.get('target')
        subprocess.call(sphinx_build_cmd.split(), shell=False)
    present_chown_cmd = 'chown -R www-data:www-data %s' % opts.get('target')
    subprocess.call(present_chown_cmd.split(), shell=False)   
    
    # Configure nginx vhost
    configure_site('present', 'present.vhost', app_path=opts.get('target'))

    # Open presentation front-end port
    hookenv.open_port(config['port'])

    # Set status
    hookenv.status_set('active', 
                       'Presentation is active on port %s' % config['port'])
    # Set state
    set_state('presentation.available')
コード例 #8
0
def _git_clone_and_install_single(repo, branch, parent_dir,
                                  update_requirements):
    """
    Clone and install a single git repository.
    """
    dest_dir = os.path.join(parent_dir, os.path.basename(repo))

    if not os.path.exists(parent_dir):
        juju_log('Directory already exists at {}. '
                 'No need to create directory.'.format(parent_dir))
        os.mkdir(parent_dir)

    if not os.path.exists(dest_dir):
        juju_log('Cloning git repo: {}, branch: {}'.format(repo, branch))
        repo_dir = install_remote(repo, dest=parent_dir, branch=branch)
    else:
        repo_dir = dest_dir

    if update_requirements:
        if not requirements_dir:
            error_out('requirements repo must be cloned before '
                      'updating from global requirements.')
        _git_update_requirements(repo_dir, requirements_dir)

    juju_log('Installing git repo from dir: {}'.format(repo_dir))
    pip_install(repo_dir)

    return repo_dir
コード例 #9
0
ファイル: present.py プロジェクト: jamesbeedy/layer-present
def install_presentation():
    """ Install presentation
    """

    opts = layer.options('git-deploy')

    # Clone repo
    hookenv.status_set('maintenance',
                       'Installing and building the presentation.')

    # Build and install
    with chdir(opts.get('target')):
        with open('requirements.txt', 'r') as f:
            for i in list(map(lambda b: b.strip('\n'), f.readlines())):
                pip_install(i)

        sphinx_build_cmd = 'sphinx-build -b html source %s' % opts.get(
            'target')
        subprocess.call(sphinx_build_cmd.split(), shell=False)
    present_chown_cmd = 'chown -R www-data:www-data %s' % opts.get('target')
    subprocess.call(present_chown_cmd.split(), shell=False)

    # Configure nginx vhost
    configure_site('present', 'present.vhost', app_path=opts.get('target'))

    # Open presentation front-end port
    hookenv.open_port(config['port'])

    # Set status
    hookenv.status_set('active',
                       'Presentation is active on port %s' % config['port'])
    # Set state
    set_state('presentation.available')
コード例 #10
0
def install_keystone():
    saved_path = os.getcwd()
    os.chdir('{}'.format(CHARM_LIB_DIR + "oracle_keystone"))
    pip_install('.')
    os.chdir(saved_path)
    with open("/etc/apache2/apache2.conf", "a") as apache_conf:
        apache_conf.write("ServerName {}".format(unit_get('private-address')))
コード例 #11
0
ファイル: utils.py プロジェクト: javacruft/charm-ceph-mon
def _git_clone_and_install_single(repo, branch, depth, parent_dir, http_proxy,
                                  update_requirements):
    """
    Clone and install a single git repository.
    """
    if not os.path.exists(parent_dir):
        juju_log('Directory already exists at {}. '
                 'No need to create directory.'.format(parent_dir))
        os.mkdir(parent_dir)

    juju_log('Cloning git repo: {}, branch: {}'.format(repo, branch))
    repo_dir = install_remote(repo, dest=parent_dir, branch=branch, depth=depth)

    venv = os.path.join(parent_dir, 'venv')

    if update_requirements:
        if not requirements_dir:
            error_out('requirements repo must be cloned before '
                      'updating from global requirements.')
        _git_update_requirements(venv, repo_dir, requirements_dir)

    juju_log('Installing git repo from dir: {}'.format(repo_dir))
    if http_proxy:
        pip_install(repo_dir, proxy=http_proxy, venv=venv)
    else:
        pip_install(repo_dir, venv=venv)

    return repo_dir
コード例 #12
0
 def test_pip_install_upgrade(self):
     """
     Check if pip_install works correctly with a single package
     """
     packages.pip_install("mock", upgrade=True)
     self.pip_execute.assert_called_with(["install",
                                          "--upgrade",
                                          "mock"])
コード例 #13
0
ファイル: sentry.py プロジェクト: joedborg/sentry-charm
def install_sentry():
    conf = hookenv.config()
    version = conf.get('version', '8.13.0')
    apt_install(['libffi-dev', 'libssl-dev', 'libpq-dev', 'libjpeg-dev'])
    pip_install(['cffi', 'cryptography', 'sentry==%s' % version])
    copy_service_files()

    set_state('sentry.installed')
コード例 #14
0
ファイル: test_packages.py プロジェクト: thedac/charm-helpers
 def test_pip_install_venv(self, join, check_call):
     """
     Check if pip_install works correctly with multiple packages
     """
     join.return_value = 'joined-path'
     packages.pip_install(["mock", "nose"], venv=True)
     check_call.assert_called_with(
         ["joined-path", "install", "mock", "nose"])
コード例 #15
0
def do_pip_installs(plugin_yaml, clone_dir):
    """ Run pip install for the source code downloaded from the git
        clone.
    """
    for plugin in _git_yaml_load(plugin_yaml):
        plugin_dir = os.path.join(clone_dir, plugin)
        juju_log('pip install from: {}'.format(plugin_dir))
        pip_install(plugin_dir)
コード例 #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)

    if not is_unit_paused_set():
        service_restart('neutron-server')
コード例 #17
0
def config_changed():
    # If neutron is ready to be queried then check for incompatability between
    # existing neutron objects and charm settings
    codename = get_os_codename_install_source(config('openstack-origin'))
    if codename >= 'kilo':
        branch = "stable/%s" % codename
        pip_install("git+https://github.com/openstack/networking-hyperv.git@%s" % branch)

    if neutron_ready():
        if l3ha_router_present() and not get_l3ha():
            e = ('Cannot disable Router HA while ha enabled routers exist.'
                 ' Please remove any ha routers')
            status_set('blocked', e)
            raise Exception(e)
        if dvr_router_present() and not get_dvr():
            e = ('Cannot disable dvr while dvr enabled routers exist. Please'
                 ' remove any distributed routers')
            log(e, level=ERROR)
            status_set('blocked', e)
            raise Exception(e)
    if config('prefer-ipv6'):
        status_set('maintenance', 'configuring ipv6')
        setup_ipv6()
        sync_db_with_multi_ipv6_addresses(config('database'),
                                          config('database-user'))

    global CONFIGS
    if git_install_requested():
        if config_value_changed('openstack-origin-git'):
            status_set('maintenance', 'Running Git install')
            git_install(config('openstack-origin-git'))
    elif not config('action-managed-upgrade'):
        if openstack_upgrade_available('neutron-common'):
            status_set('maintenance', 'Running openstack upgrade')
            do_openstack_upgrade(CONFIGS)

    additional_install_locations(
        config('neutron-plugin'),
        config('openstack-origin')
    )
    status_set('maintenance', 'Installing apt packages')
    apt_install(filter_installed_packages(
                determine_packages(config('openstack-origin'))),
                fatal=True)
    configure_https()
    update_nrpe_config()
    CONFIGS.write_all()
    for r_id in relation_ids('neutron-api'):
        neutron_api_relation_joined(rid=r_id)
    for r_id in relation_ids('neutron-plugin-api'):
        neutron_plugin_api_relation_joined(rid=r_id)
    for r_id in relation_ids('amqp'):
        amqp_joined(relation_id=r_id)
    for r_id in relation_ids('identity-service'):
        identity_joined(rid=r_id)
    for rid in relation_ids('zeromq-configuration'):
        zeromq_configuration_relation_joined(rid)
    [cluster_joined(rid) for rid in relation_ids('cluster')]
コード例 #18
0
def install_dependencies():
    deps = hookenv.config()['pip3-dependencies'].split()
    if deps:
        pip_install(deps)
    set_state('dependencies.installed')
    # This might run before jupyter is started for the first time. In that case,
    # don't restart jupyter.
    if host.service_running('jupyter-notebook'):
        restart_notebook()
コード例 #19
0
def install_dependencies():
    deps = hookenv.config()['pip3-dependencies'].split()
    if deps:
        pip_install(deps)
    set_state('dependencies.installed')
    # This might run before jupyter is started for the first time. In that case,
    # don't restart jupyter.
    if host.service_running('jupyter-notebook'):
        restart_notebook()
コード例 #20
0
    def install(self):
        """In addition to other commands, install our arista package.

        TODO: add an http proxy?
        TODO: add version
        TODO: stick the pip package in the wheelhouse instead
        """
        pip_install(NETWORKING_ARISTA_PACKAGE)
        super().install()
コード例 #21
0
def install_networking_arista():
    if config('arista-version') is None:
        package_version = ARISTA_VERSION
    else:
        package_version = config('arista-version')
    package_name = 'networking-arista==%s' % package_version
    if config('pip-proxy') != "None":
        pip_install(package_name, fatal=True, proxy=config('pip-proxy'))
    else:
        pip_install(package_name, fatal=True)
コード例 #22
0
ファイル: flask.py プロジェクト: IBCNServices/tengu-charms
def install():
	if not os.path.exists("/home/ubuntu/flask-config"):
		touch('/home/ubuntu/flask-config')
	for pkg in ['Flask', 'gunicorn', 'nginx']:
		pip_install(pkg)
	set_state('flask.installed')
	if config["nginx"]:
		set_state('nginx.install')
	else:	
		set_state('nginx.stop')
コード例 #23
0
def install():
    if not os.path.exists("/home/ubuntu/flask-config"):
        touch('/home/ubuntu/flask-config')
    for pkg in ['Flask', 'gunicorn', 'nginx']:
        pip_install(pkg)
    set_state('flask.installed')
    if config["nginx"]:
        set_state('nginx.install')
    else:
        set_state('nginx.stop')
コード例 #24
0
ファイル: flask.py プロジェクト: tengu-team/layer-flask
def install():
    if not os.path.exists("/home/ubuntu/flask"):
        os.mkdir('/home/ubuntu/flask')
        shutil.chown('/home/ubuntu/flask', user='******', group='ubuntu')
        touch('/home/ubuntu/flask/flask-config')
    for pkg in ['Flask', 'gunicorn', 'nginx']:
        pip_install(pkg)
    set_state('flask.installed')
    if config["nginx"]:
        set_state('nginx.install')
    else:
        set_state('nginx.stop')
コード例 #25
0
def install_whelp():
    '''
    Reactive hook to install whelp
    '''
    hookenv.status_set('maintenance', 'Installing whelp')

    whelp = Whelp()

    whelp_tar = hookenv.resource_get('webapp')

    hookenv.status_set('maintenance', 'installing webapp')

    # Extract tar resource
    tar = tarfile.open(whelp_tar)
    tar.extractall(WHELP_HOME)

    # Install pip3 reqs
    with chdir('/srv/whelp/whelp'):
        with open('requirements.txt', 'r') as f:
            for i in list(map(lambda b: b.strip('\n'), f.readlines())):
                pip_install(i)

    # Set permissions
    chownr(WHELP_HOME, 'www-data', 'www-data')

    # Get state files for whelp to run
    whelp.get_whelp_bucket_files()

    # Configure NGINX
    configure_site('whelp',
                   'whelp.vhost',
                   port=config['port'],
                   whelp_port=config['whelp-port'])

    # Start Supervisor
    subprocess.call('supervisord -c /etc/supervisor/supervisord.conf'.split(),
                    shell=False)

    # Render whelp supervisor.conf
    whelp.render_whelp_supervisor_conf()

    # Open port 80
    hookenv.open_port(config['port'])

    # Set status to active
    hookenv.status_set('active', 'Whelp is active on port %s' % config['port'])

    # Set whelp.available state
    set_state('whelp.installed')
コード例 #26
0
ファイル: mychain.py プロジェクト: zhougit86/demo_charm
def install():
    """Set the installed state.

    This is the entry point.
    """

    # install everything needed to construct the environment
    pip_install('time')

    # this assertion should fail!
    assert config['app-name'] == 'chained states'

    # do sth
    config = hookenv.config()
    config['playbook'] = 'give me a name'
コード例 #27
0
def install2():
    """
    Install a custom version of ansible for our charm.
    Because of the hack required to install python with xenial
    our install script is called install2, need to call the ansible playbook
    using the install tag.
    """
    status_set(status_maintenance, msg_install_prereqs)
    apt_install(required_aps)

    status_set(status_maintenance, msg_install_ansible)
    pip_install(required_pip_packages, fatal=True)

    status_set(status_maintenance, msg_install_service)
    apply_playbook(playbook, tags=['install'])
コード例 #28
0
def install():
    apt_update(fatal=True)
    pkgs = determine_packages()
    apt_install(pkgs, fatal=True)
    pkgs = determine_pip_packages()
    pip_install(pkgs, fatal=True, upgrade=True)
    download_cplane_packages()
    install_cplane_packages()
    prepare_env()
    install_neutron()
    if config('db-on-host') is False:
        install_oracle_client()
        configure_oracle_client()
    os.system("pip install python-openstackclient")
    copy_neutron_files()
    install_cplane_neutron()
コード例 #29
0
def install_layer_mongo_database(mongodb):
    pip_install('pymongo')
    db_name = service_name()
    conf = config()
    import pymongo
    log('Creating database {}'.format(db_name))
    uri = mongodb.connection_string()
    conn = pymongo.MongoClient(uri)
    tengu_db = conn[db_name]
    tengu_db[conf['collection']].insert_one(
    {'tengu_db': 'created {}'.format(datetime.datetime.now())}
    )
    unitd.set('db_name', db_name)
    unitd.set('uri', uri)
    status_set('active', 'Database {} succesfully created'.format(db_name))
    set_state('layer-mongo-database.installed')
コード例 #30
0
def install():
    apt_update(fatal=True)
    pkgs = determine_packages()
    apt_install(pkgs, fatal=True)
    pkgs = determine_pip_packages()
    pip_install(pkgs, fatal=True, upgrade=True)
    download_cplane_packages()
    install_cplane_packages()
    prepare_env()
    install_keystone()
    cmd = 'pip install -r requirement.txt'
    os.system(cmd)
    if config('db-on-host') is False:
        install_oracle_client()
        configure_oracle_client()
    os.system("pip install python-openstackclient")
    restart_service()
コード例 #31
0
def install_plugin(ip, ver):
    """Install Horizon plugin and workloadmgrclient packages
    from TVAULT_IPADDRESS provided by the user
    """

    pkg = "http://" + ip + \
          ":8081/packages/python-workloadmgrclient-" + ver + \
          ".tar.gz"

    try:
        pip_install(pkg, venv="/usr", options="--no-deps")
        log("TrilioVault WorkloadMgrClient package installation passed")
    except Exception as e:
        # workloadmgrclient package install failed
        log("TrilioVault WorkloadMgrClient package installation failed")
        log("With exception --{}".format(e))
        return False

    pkg = "http://" + ip + \
          ":8081/packages/tvault-horizon-plugin-" + ver + \
          ".tar.gz"

    try:
        pip_install(pkg, venv="/usr", options="--no-deps")
        log("TrilioVault Horizon Plugin package installation passed")
    except Exception as e:
        # Horixon Plugin package install failed
        log("TrilioVault Horizon Plugin package installation failed")
        log("With exception --{}".format(e))
        return False

    # Copy TrilioVault files
    copy_files()

    # Start the application
    status_set('maintenance', 'Starting...')

    try:
        service_restart("apache2")
    except Exception as e:
        # apache2 restart failed
        log("Apache2 restart failed with exception --{}".format(e))
        return False

    return True
コード例 #32
0
def install():
    """Set the installed state.

    This is the entry point.
    """

    # install everything needed to construct the environment
    pip_install('time')

    # this assertion should fail!
    assert config['app-name'] == 'x1'

    # test: subprocess
    log("install-----------------")
    args = [x.strip() for x in "sudo apt update".split()]
    p = subprocess.Popen(args, shell=True)

    # do sth
    config = hookenv.config()
    config['playbook'] = 'give me a name'
コード例 #33
0
def install_networking_plumgrid():
    '''
    Installs networking-plumgrid package
    '''
    if not config('enable-deb-networking-install'):
        release = os_release('neutron-common', base='kilo')
        if config('networking-plumgrid-version') is None:
            package_version = NETWORKING_PLUMGRID_VERSION[release]
        else:
            package_version = config('networking-plumgrid-version')
        package_name = 'networking-plumgrid==%s' % package_version
        if config('pip-proxy') != "None":
            pip_install(package_name, fatal=True, proxy=config('pip-proxy'))
        else:
            pip_install(package_name, fatal=True)
        if is_leader() and package_version != '2015.1.1.1':
            migrate_neutron_db()
    else:
        apt_install('networking-plumgrid', options=['--force-yes'], fatal=True)
        if is_leader():
            migrate_neutron_db()
コード例 #34
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)
コード例 #35
0
ファイル: test_packages.py プロジェクト: thedac/charm-helpers
    def test_pip_install(self):
        """
        Check if pip_install works correctly with a single package
        """
        packages.pip_install("mock")
        self.pip_execute.assert_called_with(["install", "mock"])
        packages.pip_install("mock", proxy="proxy_addr:8080")

        self.pip_execute.assert_called_with(
            ["install", "--proxy=proxy_addr:8080", "mock"])
        packages.pip_install("mock", log="output.log", proxy="proxy_addr:8080")

        self.pip_execute.assert_called_with(
            ["install", "--log=output.log", "--proxy=proxy_addr:8080", "mock"])
コード例 #36
0
ファイル: errbot.py プロジェクト: 1stvamp/juju-errbot
def install_errbot():
    hookenv.status_set('maintenance', 'Installing packages')
    codename = lsb_release()['DISTRIB_CODENAME']
    if codename == 'trusty':
        venv_pkg = 'python3.4-venv'
    elif codename == 'xenial':
        venv_pkg = 'python3.5-venv'
    else:
        venv_pkg = 'python3-venv'
    apt_packages = [
        'python3',
        'python3-pip',
        'libssl-dev',
        'libffi-dev',
        'python3-dev',
        'git',
        venv_pkg,
    ]
    fetch.apt_install(fetch.filter_installed_packages(apt_packages))

    # Make sure we have a python3 virtualenv to install into
    with ensure_user_and_perms(PATHS):
        if not path.exists(PIP_PATH):
            hookenv.log('Creating python3 venv')
            check_call(['/usr/bin/python3', '-m', 'venv', VENV_PATH])
            pip_install('six', venv=VENV_PATH, upgrade=True)
            # Kill system six wheel copied into venv, as it's too old
            wheels_path = path.join(path.join(VENV_PATH, 'lib'),
                                    'python-wheels')
            hookenv.log('Removing six-1.5 wheel from venv')
            six_paths = glob(path.join(wheels_path, 'six-1.5*'))
            for p in six_paths:
                check_call(['rm', '-f', path.join(wheels_path, p)])

    version = hookenv.config('version')
    if not version:
        hookenv.log('version not set, skipping install of errbot',
                    level='WARNING')
        return

    current_version = ''
    if path.exists(ERRBOT_PATH):
        pip_show = check_output([PIP_PATH, 'show', 'errbot'])
        current_version_match = search('Version: (.*)',
                                       pip_show.decode('ascii'))
        if current_version_match.groups():
            current_version = current_version_match.groups()[0]

    if version != current_version:
        hookenv.status_set('maintenance',
                           'Installing configured version of errbot and'
                           ' dependencies')
        pip_pkgs = [
            'errbot=={}'.format(version),
        ]
        backend = hookenv.config('backend').lower()

        pip_pkg_map = {
            'irc': 'irc',
            'hipchat': 'hypchat',
            'slack': 'slackclient',
            'telegram': 'python-telegram-bot',
        }
        if backend in pip_pkg_map:
            pip_pkgs.append(pip_pkg_map[backend])

        if backend in ('xmpp', 'hipchat'):
            check_call(['/usr/bin/python3', '-m', 'venv',
                        '--system-site-packages', VENV_PATH])
            xmpp_pkgs = [
                'python3-dns',
                'python3-sleekxmpp',
                'python3-pyasn1',
                'python3-pyasn1-modules',
            ]
            fetch.apt_install(fetch.filter_installed_packages(xmpp_pkgs))

        pip_install(get_wheels_store() + pip_pkgs, venv=VENV_PATH)
    set_state('errbot.installed')
コード例 #37
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')
コード例 #38
0
def install_jupyter_notebook():
    hookenv.log("Install Jupyter-notebook")
    pip_install('pip', upgrade=True)
    pip_install('jupyter')
    set_state('jupyter-notebook.installed')
コード例 #39
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')
コード例 #40
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)
コード例 #41
0
ファイル: utils.py プロジェクト: javacruft/charm-ceph-mon
def git_clone_and_install(projects_yaml, core_project):
    """
    Clone/install all specified OpenStack repositories.

    The expected format of projects_yaml is:

        repositories:
          - {name: keystone,
             repository: 'git://git.openstack.org/openstack/keystone.git',
             branch: 'stable/icehouse'}
          - {name: requirements,
             repository: 'git://git.openstack.org/openstack/requirements.git',
             branch: 'stable/icehouse'}

        directory: /mnt/openstack-git
        http_proxy: squid-proxy-url
        https_proxy: squid-proxy-url

    The directory, http_proxy, and https_proxy keys are optional.

    """
    global requirements_dir
    parent_dir = '/mnt/openstack-git'
    http_proxy = None

    projects = _git_yaml_load(projects_yaml)
    _git_validate_projects_yaml(projects, core_project)

    old_environ = dict(os.environ)

    if 'http_proxy' in projects.keys():
        http_proxy = projects['http_proxy']
        os.environ['http_proxy'] = projects['http_proxy']
    if 'https_proxy' in projects.keys():
        os.environ['https_proxy'] = projects['https_proxy']

    if 'directory' in projects.keys():
        parent_dir = projects['directory']

    pip_create_virtualenv(os.path.join(parent_dir, 'venv'))

    # Upgrade setuptools and pip from default virtualenv versions. The default
    # versions in trusty break master OpenStack branch deployments.
    for p in ['pip', 'setuptools']:
        pip_install(p, upgrade=True, proxy=http_proxy,
                    venv=os.path.join(parent_dir, 'venv'))

    for p in projects['repositories']:
        repo = p['repository']
        branch = p['branch']
        depth = '1'
        if 'depth' in p.keys():
            depth = p['depth']
        if p['name'] == 'requirements':
            repo_dir = _git_clone_and_install_single(repo, branch, depth,
                                                     parent_dir, http_proxy,
                                                     update_requirements=False)
            requirements_dir = repo_dir
        else:
            repo_dir = _git_clone_and_install_single(repo, branch, depth,
                                                     parent_dir, http_proxy,
                                                     update_requirements=True)

    os.environ = old_environ
コード例 #42
0
def install_neutron():
    saved_path = os.getcwd()
    os.chdir('{}'.format(CHARM_LIB_DIR + "oracle_neutron"))
    pip_install('.')
    os.chdir(saved_path)
コード例 #43
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')
コード例 #44
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()]
コード例 #45
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")
コード例 #46
0
def upgrade_charm():
    hookenv.log("Upgrading Notebook Charm")
    pip_install('jupyter', upgrade=True)
コード例 #47
0
def install_apache_toree(spark): #pylint: disable=W0613
    hookenv.log("Installing apache toree")
    pip_install('toree')
    #run_as('root', 'jupyter', 'toree', 'install', '--interpreters=PySpark,Scala,SparkR,SQL')
    set_state('apache-toree.installed')
コード例 #48
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')
コード例 #49
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()]
コード例 #50
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')
コード例 #51
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)