Exemplo n.º 1
0
 def setUp(self):
     super(ArchiveUrlFetchHandlerTest, self).setUp()
     self.valid_urls = (
         "http://example.com/foo.tar.gz",
         "http://example.com/foo.tgz",
         "http://example.com/foo.tar.bz2",
         "http://example.com/foo.tbz2",
         "http://example.com/foo.zip",
         "http://example.com/foo.zip?bar=baz&x=y#whee",
         "ftp://example.com/foo.tar.gz",
         "https://example.com/foo.tgz",
         "file://example.com/foo.tar.bz2",
         "file://example.com/foo.tar.bz2#sha512=beefdead",
     )
     self.invalid_urls = (
         "git://example.com/foo.tar.gz",
         "http://example.com/foo",
         "http://example.com/foobar=baz&x=y#tar.gz",
         "http://example.com/foobar?h=baz.zip",
         "bzr+ssh://example.com/foo.tar.gz",
         "lp:example/foo.tgz",
         "file//example.com/foo.tar.bz2",
         "garbage",
     )
     self.fh = archiveurl.ArchiveUrlFetchHandler()
Exemplo n.º 2
0
def download_go():
    """
    Kubernetes charm strives to support upstream. Part of this is installing a
    fairly recent edition of GO. This fetches the golang archive and installs
    it in /usr/local
    """
    go_url = 'https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz'
    go_sha1 = '5020af94b52b65cc9b6f11d50a67e4bae07b0aff'
    handler = archiveurl.ArchiveUrlFetchHandler()
    handler.install(go_url, '/usr/local', go_sha1, 'sha1')
Exemplo n.º 3
0
def install_web_ui(version, destination_directory='/usr/share/consul'):
    ''' Install the configured version of consul web ui. '''
    if version:
        web_ui_name = 'consul_{0}_web_ui.zip'.format(version)
        sha256sum = find_sha256sum(version, web_ui_name)
        print('Expecting {0} for {1}'.format(sha256sum, web_ui_name))
        url = '{0}/{1}/{2}'.format(URL_PREFIX, version, web_ui_name)
        print('Fetching {0}'.format(url))
        installer = archiveurl.ArchiveUrlFetchHandler()
        # Download and unzip the web ui to the share directory.
        installer.install(url,
                          dest=destination_directory,
                          checksum=sha256sum,
                          hash_type='sha256')
Exemplo n.º 4
0
def install_consul(version, destination_directory='/usr/local/bin'):
    ''' Install the configured version of consul for the architecture. '''
    if version:
        architecture = consul_arch()
        consul_file_name = 'consul_{0}_{1}.zip'.format(version, architecture)
        # Find the sha256sum for the specific file name.
        sha256sum = find_sha256sum(version, consul_file_name)
        print('Expecting {0} for {1}'.format(sha256sum, consul_file_name))
        url = '{0}/{1}/{2}'.format(URL_PREFIX, version, consul_file_name)
        print('Fetching {0}'.format(url))
        installer = archiveurl.ArchiveUrlFetchHandler()
        # Download and unzip the archive into the final destination directory.
        installer.install(url,
                          dest=destination_directory,
                          checksum=sha256sum,
                          hash_type='sha256')
        consul = Path(destination_directory + '/consul')
        # Make the consul binary executable.
        consul.chmod(0o555)
Exemplo n.º 5
0
def install():
    conf = hookenv.config()
    version = conf.get('version', '0.9.13')

    handler = archiveurl.ArchiveUrlFetchHandler()
    handler.download(INSTALL_URL % version, dest='/opt/gogs.tar.gz')

    extract_tarfile('/opt/gogs.tar.gz', destpath="/opt")

    # Create gogs user & group
    add_group("gogs")
    adduser("gogs", system_user=True)

    for dir in ('.ssh', 'repositories', 'data', 'logs'):
        os.makedirs(os.path.join("/opt/gogs", dir), mode=0o700, exist_ok=True)
        shutil.chown(os.path.join("/opt/gogs", dir), user="******", group="gogs")
    os.makedirs("/opt/gogs/custom/conf", mode=0o755, exist_ok=True)
    shutil.chown("/opt/gogs/custom/conf", user="******", group="gogs")

    render(source='upstart',
           target="/etc/init/gogs.conf",
           perms=0o644,
           context={})
    hookenv.status_set('maintenance', 'installation complete')
def create_virt_env():
    """
    Checks if latest version is installed or else imports the new virtual env
    And installs the Datamover package.
    """
    usr = DM_EXT_USR
    grp = DM_EXT_GRP
    path = TVAULT_HOME
    venv_path = TVAULT_VIRTENV_PATH
    tv_ip = config('triliovault-ip')
    dm_ver = None
    # create virtenv dir(/home/tvault) if it does not exist
    mkdir(path, owner=usr, group=grp, perms=501, force=True)

    latest_dm_ver = get_new_version('tvault-contego')
    if dm_ver == latest_dm_ver:
        log("Latest TrilioVault DataMover package is already installed,"
            " exiting")
        return True

    # Create virtual environment for DataMover
    handler = archiveurl.ArchiveUrlFetchHandler()
    try:
        # remove old venv if it exists
        shutil.rmtree(venv_path)
        venv_src = 'http://{}:8081/packages/queens_ubuntu'\
                   '/tvault-contego-virtenv.tar.gz'.format(tv_ip)
        venv_dest = path
        handler.install(venv_src, venv_dest)
        log("Virtual Environment installed successfully")
    except Exception as e:
        log("Failed to install Virtual Environment")
        status_set('blocked', 'Failed while Creating Virtual Env')
        return False

    # Get dependent libraries paths
    try:
        cmd = ['/usr/bin/python', 'files/trilio/get_pkgs.py']
        sym_link_paths = \
            subprocess.check_output(cmd).decode('utf-8').strip().split('\n')
    except Exception as e:
        log("Failed to get the dependent packages--{}".format(e))
        return False

    # Install TrilioVault Datamover package
    if not install_plugin(tv_ip, latest_dm_ver, '/usr'):
        return False

    # Create symlinks of the dependent libraries
    venv_pkg_path = '{}/lib/python2.7/site-packages/'.format(venv_path)
    shutil.rmtree('{}/cryptography'.format(venv_pkg_path))
    shutil.rmtree('{}/cffi'.format(venv_pkg_path))

    symlink(sym_link_paths[0], '{}/cryptography'.format(venv_pkg_path))
    symlink(sym_link_paths[2], '{}/cffi'.format(venv_pkg_path))

    shutil.copy(sym_link_paths[1], '{}/libvirtmod.so'.format(venv_pkg_path))
    shutil.copy(sym_link_paths[3], '{}/_cffi_backend.so'.format(venv_pkg_path))

    # change virtenv dir(/home/tvault) users to nova
    chownr(path, usr, grp)

    # Copy Trilio sudoers and filters files
    shutil.copy('files/trilio/trilio_sudoers', '/etc/sudoers.d/')
    shutil.copy('files/trilio/trilio.filters', '/etc/nova/rootwrap.d/')

    return True