def trove_dashboard_git_clone(config_yaml):
    """ Clone from git repository specified in the config.yaml.
        Assuming here the trove dashboard is not supplied in a
        normal distro package, meaning the only install option is
        to specify the git url in the config.yaml.  (No default
        location is specified here either in the code.)
    """
    config = _git_yaml_load(config_yaml)

    git_repository = None
    for c in config['repositories']:
        if c['name'] == TROVE_DASHBOARD:
            git_repository = c['repository']
            git_branch = c['branch']

    if git_repository is None:
        error_out('Missing repository in config.yaml')

    juju_log('Git repository: {} branch: {}'.format(git_repository,
                                                    git_branch))

    depth = '1'
    parent_dir = GIT_CLONE_PARENT_DIR
    clone_dir = install_remote(git_repository,
                               dest=parent_dir,
                               branch=git_branch,
                               depth=depth)
    juju_log('Cloned into directory: {}'.format(clone_dir))

    return clone_dir
Example #2
0
def import_key(keyid):
    cmd = "apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 " \
          "--recv-keys %s" % keyid
    try:
        subprocess.check_call(cmd.split(' '))
    except subprocess.CalledProcessError:
        error_out("Error importing repo key %s" % keyid)
Example #3
0
 def test_error_out(self, mocked_exit, juju_log):
     '''Test erroring out'''
     openstack.error_out('Everything broke.')
     _log = 'FATAL ERROR: Everything broke.'
     juju_log.assert_called_with(_log, level='ERROR')
     mocked_exit.assert_called_with(1)
Example #4
0
def configure_installation_source(rel):
    '''Configure apt installation source.'''
    rel_list = rel.replace(', ', '\n').replace(',', '\n').split('\n')
    if os.path.exists('/etc/apt/sources.list.d/n1k_deb.list'):
        os.remove('/etc/apt/sources.list.d/n1k_deb.list')
    for rel in rel_list:
        if rel == 'distro':
            return
        elif rel[:4] == "ppa:":
            src = rel
            subprocess.check_call(["add-apt-repository", "-y", src])
        elif rel[:3] == "deb":
            l = len(rel.split('|'))
            if l == 2:
                src, key = rel.split('|')
                juju_log("Importing PPA key from keyserver for %s" % src)
                import_key(key)
            elif l == 1:
                src = rel
            with open('/etc/apt/sources.list.d/n1k_deb.list', 'ab+') as f:
                f.write("%s \n" % (src))
        elif rel[:6] == 'cloud:':
            ubuntu_rel = lsb_release()['DISTRIB_CODENAME']
            rel = rel.split(':')[1]
            u_rel = rel.split('-')[0]
            ca_rel = rel.split('-')[1]

            if u_rel != ubuntu_rel:
                e = 'Cannot install from Cloud Archive pocket %s on this Ubuntu '\
                    'version (%s)' % (ca_rel, ubuntu_rel)
                error_out(e)

            if 'staging' in ca_rel:
                # staging is just a regular PPA.
                os_rel = ca_rel.split('/')[0]
                ppa = 'ppa:ubuntu-cloud-archive/%s-staging' % os_rel
                cmd = 'add-apt-repository -y %s' % ppa
                subprocess.check_call(cmd.split(' '))
                return
            # map charm config options to actual archive pockets.
            pockets = {'folsom': 'precise-updates/folsom',
                       'folsom/updates': 'precise-updates/folsom',
                       'folsom/proposed': 'precise-proposed/folsom',
                       'grizzly': 'precise-updates/grizzly',
                       'grizzly/updates': 'precise-updates/grizzly',
                       'grizzly/proposed': 'precise-proposed/grizzly',
                       'havana': 'precise-updates/havana',
                       'havana/updates': 'precise-updates/havana',
                       'havana/proposed': 'precise-proposed/havana', }

            try:
                pocket = pockets[ca_rel]
            except KeyError:
                e = 'Invalid Cloud Archive release specified: %s' % rel
                error_out(e)

            src = "deb %s %s main" % (CLOUD_ARCHIVE_URL, pocket)
            apt_install('ubuntu-cloud-keyring', fatal=True)

            with open('/etc/apt/sources.list.d/cloud-archive.list', 'ab+') as f:
                f.write("%s \n" % (src))
        else:
            error_out("Invalid openstack-release specified: %s" % rel)