def git_install(projects_yaml):
    """Perform setup, and install git repos specified in yaml parameter."""
    if git_install_requested():
        git_pre_install()
        projects_yaml = git_default_repos(projects_yaml)
        git_clone_and_install(projects_yaml, core_project='nova')
        git_post_install(projects_yaml)
def git_install(projects_yaml):
    """Perform setup, and install git repos specified in yaml parameter."""
    if git_install_requested():
        git_pre_install()
        projects_yaml = git_default_repos(projects_yaml)
        git_clone_and_install(projects_yaml, core_project='horizon')
        git_post_install(projects_yaml)
def git_install(projects_yaml):
    """Perform setup, and install git repos specified in yaml parameter."""
    if git_install_requested():
        status_set('maintenance', 'Git install')
        git_pre_install()
        projects_yaml = git_default_repos(projects_yaml)
        git_clone_and_install(projects_yaml, core_project='nova')
        git_post_install(projects_yaml)
def git_install(projects_yaml):
    """Perform setup, and install git repos specified in yaml parameter."""
    status_set('maintenance', 'running git install')
    if git_install_requested():
        git_pre_install()
        projects_yaml = git_default_repos(projects_yaml)
        git_clone_and_install(projects_yaml, core_project='neutron')
        git_post_install(projects_yaml)
示例#5
0
def git_post_install_late(projects_yaml):
    """Perform horizon post-install setup."""
    projects_yaml = git_default_repos(projects_yaml)

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

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

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

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

        return ctxt
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')