Example #1
0
def _configure_galaxy_options(env,
                              option_dict=None,
                              prefix="galaxy_universe_"):
    """
    Read through fabric's environment and make sure any property of
    the form galaxy_universe_XXX=YYY lands up in Galaxy's universe_wsgi.ini
    options as XXX=YYY using Galaxy configuration directory:
    """
    galaxy_conf_directory = env.get("galaxy_conf_directory", None)
    if not galaxy_conf_directory:
        return False
    # By default just read the options from env (i.e. from fabricrc), but
    # allow override so the options can come from a YAML file (such as done
    # with galaxy-vm-launcher.)
    if option_dict is None:
        option_dict = env

    option_priority = env.get("galaxy_conf_priority", "200")
    for key, value in option_dict.iteritems():
        if key.startswith(prefix):
            key = key[len(prefix):]
            conf_file_name = "%s_override_%s.ini" % (option_priority, key)
            conf_file = os.path.join(galaxy_conf_directory, conf_file_name)
            contents = "[app:main]\n%s=%s" % (key, value)
            _write_to_file(contents, conf_file, "0700")
            _chown_galaxy(env, conf_file)
Example #2
0
def _configure_galaxy_options(env, option_dict=None, prefix="galaxy_universe_"):
    """
    Read through fabric's environment and make sure any property of
    the form galaxy_universe_XXX=YYY, lands up in Galaxy's universe_wsgi.ini
    options as XXX=YYY using John Chilton's configuration directory work:

    https://bitbucket.org/galaxy/galaxy-central/pull-request/44/allow-usage-of-directory-of-configuration

    Until, the above pull request is accepted, its changeset should be pulled
    into the configured Galaxy repository.
    """
    galaxy_conf_directory = env.get("galaxy_conf_directory", False)
    if not galaxy_conf_directory:
        return False
    # By default just read the options from env (i.e. from fabricrc), but
    # allow override so the options can come from a YAML file (such as done
    # with galaxy-vm-launcher.)
    if option_dict is None:
        option_dict = env

    option_priority = env.get("galaxy_conf_priority", "200")
    for key, value in option_dict.iteritems():
        if key.startswith(prefix):
            key = key[len(prefix):]
            conf_file_name = "%s_override_%s.ini" % (option_priority, key)
            conf_file = os.path.join(galaxy_conf_directory, conf_file_name)
            contents = "[app:main]\n%s=%s" % (key, value)
            _write_to_file(contents, conf_file, 0700)
            _chown_galaxy(env, conf_file)
Example #3
0
def _configure_ec2_autorun(env, use_repo_autorun=False):
    """
    ec2autorun.py is a script that launches CloudMan on instance boot
    and is thus required on an instance. See the script itself for the
    details of what it does.

    This script also adds a cloudman service to ``/etc/init``, which
    actually runs ec2autorun.py as a system-level service at system boot.
    """
    script = "ec2autorun.py"
    remote = os.path.join(env.install_dir, "bin", script)
    if not exists(os.path.dirname(remote)):
        sudo('mkdir -p {0}'.format(os.path.dirname(remote)))
    if use_repo_autorun:
        url = os.path.join(MI_REPO_ROOT_URL, script)
        sudo("wget --output-document=%s %s" % (remote, url))
    else:
        install_file_dir = os.path.join(env.config_dir, os.pardir, "installed_files")
        put(os.path.join(install_file_dir, script), remote, mode=0777, use_sudo=True)
    # Create upstart configuration file for boot-time script
    cloudman_boot_file = 'cloudman.conf'
    remote_file = '/etc/init/%s' % cloudman_boot_file
    _write_to_file(cm_upstart % (remote, os.path.splitext(remote)[0]), remote_file, mode=0644)
    # Setup default image user data (if configured by image_user_data_path or
    # image_user_data_template_path). This specifies defaults for CloudMan when
    # used with resulting image, normal userdata supplied by user will override
    # these defaults.
    _setup_conf_file(env, os.path.join(env.install_dir, "bin", "IMAGE_USER_DATA"), "image_user_data", default_source="image_user_data")
    env.logger.info("Done configuring CloudMan's ec2_autorun")
Example #4
0
def install_nginx(env):
    """Nginx open source web server.
    http://www.nginx.org/
    """
    version = "1.2.0"
    url = "http://nginx.org/download/nginx-%s.tar.gz" % version

    install_dir = os.path.join(env.install_dir, "nginx")
    remote_conf_dir = os.path.join(install_dir, "conf")

    # Skip install if already present
    if exists(remote_conf_dir) and contains(os.path.join(remote_conf_dir, "nginx.conf"), "/cloud"):
        env.logger.debug("Nginx already installed; not installing it again.")
        return

    with _make_tmp_dir() as work_dir:
        with contextlib.nested(cd(work_dir), settings(hide('stdout'))):
            modules = _get_nginx_modules(env)
            module_flags = " ".join(["--add-module=../%s" % x for x in modules])
            run("wget %s" % url)
            run("tar xvzf %s" % os.path.split(url)[1])
            with cd("nginx-%s" % version):
                run("./configure --prefix=%s --with-ipv6 %s "
                    "--user=galaxy --group=galaxy --with-debug "
                    "--with-http_ssl_module --with-http_gzip_static_module" %
                    (install_dir, module_flags))
                sed("objs/Makefile", "-Werror", "")
                run("make")
                sudo("make install")
                sudo("cd %s; stow nginx" % env.install_dir)

    conf_file_contents = _get_nginx_conf_contents(env)
    nginx_conf_file = 'nginx.conf'
    _write_to_file(conf_file_contents, os.path.join(remote_conf_dir, nginx_conf_file), mode=0755)

    nginx_errdoc_file = 'nginx_errdoc.tar.gz'
    url = os.path.join(REPO_ROOT_URL, nginx_errdoc_file)
    remote_errdoc_dir = os.path.join(install_dir, "html")
    with cd(remote_errdoc_dir):
        sudo("wget --output-document=%s/%s %s" % (remote_errdoc_dir, nginx_errdoc_file, url))
        sudo('tar xvzf %s' % nginx_errdoc_file)

    sudo("mkdir -p %s" % env.install_dir)
    if not exists("%s/nginx" % env.install_dir):
        sudo("ln -s %s/sbin/nginx %s/nginx" % (install_dir, env.install_dir))
    # If the guessed symlinking did not work, force it now
    cloudman_default_dir = "/opt/galaxy/sbin"
    if not exists(cloudman_default_dir):
        sudo("mkdir -p %s" % cloudman_default_dir)
    if not exists(os.path.join(cloudman_default_dir, "nginx")):
        sudo("ln -s %s/sbin/nginx %s/nginx" % (install_dir, cloudman_default_dir))
    env.logger.debug("Nginx {0} installed to {1}".format(version, install_dir))
Example #5
0
def _configure_ec2_autorun(env, use_repo_autorun=False):
    """
    ec2autorun.py is a script that launches CloudMan on instance boot
    and is thus required on an instance. See the script itself for the
    details of what it does.

    This script also adds a cloudman service to ``/etc/init``, which
    actually runs ec2autorun.py as a system-level service at system boot.
    """
    script = "ec2autorun.py"
    remote = os.path.join(env.install_dir, "bin", script)
    if not exists(os.path.dirname(remote)):
        sudo('mkdir -p {0}'.format(os.path.dirname(remote)))
    if use_repo_autorun:
        # Is this used, can we eliminate use_repo_autorun?
        url = os.path.join(MI_REPO_ROOT_URL, script)
        sudo("wget --output-document=%s %s" % (remote, url))
    else:
        install_file_dir = os.path.join(env.config_dir, os.pardir,
                                        "installed_files")
        put(os.path.join(install_file_dir, script),
            remote,
            mode=0777,
            use_sudo=True)
    # Create upstart configuration file for boot-time script
    cloudman_boot_file = 'cloudman.conf'
    remote_file = '/etc/init/%s' % cloudman_boot_file
    _write_to_file(cm_upstart % (remote, os.path.splitext(remote)[0]),
                   remote_file,
                   mode=0644)
    # Setup default image user data (if configured by image_user_data_path or
    # image_user_data_template_path). This specifies defaults for CloudMan when
    # used with resulting image, normal userdata supplied by user will override
    # these defaults.
    image_user_data_path = os.path.join(env.install_dir, "bin",
                                        "IMAGE_USER_DATA")
    if "image_user_data_dict" in env:
        # Explicit YAML contents defined in env, just dump them as is.
        import yaml
        _write_to_file(yaml.dump(env.get("image_user_data_dict")),
                       image_user_data_path,
                       mode=0644)
    else:
        # Else use file or template file.
        _setup_conf_file(env,
                         image_user_data_path,
                         "image_user_data",
                         default_source="image_user_data")
    env.logger.info("Done configuring CloudMan's ec2_autorun")
Example #6
0
def _configure_ec2_autorun(env, use_repo_autorun=False):
    script = "ec2autorun.py"
    remote = os.path.join(env.install_dir, "bin", script)
    if not exists(os.path.dirname(remote)):
        sudo('mkdir -p {0}'.format(os.path.dirname(remote)))
    if use_repo_autorun:
        url = os.path.join(MI_REPO_ROOT_URL, script)
        sudo("wget --output-document=%s %s" % (remote, url))
    else:
        install_file_dir = os.path.join(env.config_dir, os.pardir, "installed_files")
        put(os.path.join(install_file_dir, script), remote, mode=0777, use_sudo=True)
    # Create upstart configuration file for boot-time script
    cloudman_boot_file = 'cloudman.conf'
    remote_file = '/etc/init/%s' % cloudman_boot_file
    _write_to_file(cm_upstart % (remote, os.path.splitext(remote)[0]), remote_file, mode=777)
    env.logger.debug("Done configuring CloudMan ec2_autorun")
Example #7
0
def _configure_ec2_autorun(env, use_repo_autorun=False):
    script = "ec2autorun.py"
    remote = os.path.join(env.install_dir, "bin", script)
    if not exists(os.path.dirname(remote)):
        sudo('mkdir -p {0}'.format(os.path.dirname(remote)))
    if use_repo_autorun:
        url = os.path.join(MI_REPO_ROOT_URL, script)
        sudo("wget --output-document=%s %s" % (remote, url))
    else:
        install_file_dir = os.path.join(env.config_dir, os.pardir, "installed_files")
        put(os.path.join(install_file_dir, script), remote, mode=0777, use_sudo=True)
    # Create upstart configuration file for boot-time script
    cloudman_boot_file = 'cloudman.conf'
    remote_file = '/etc/init/%s' % cloudman_boot_file
    _write_to_file(cm_upstart % (remote, os.path.splitext(remote)[0]), remote_file, mode=777)
    env.logger.debug("Done configuring CloudMan ec2_autorun")
Example #8
0
def _configure_ec2_autorun(env, use_repo_autorun=False):
    """
    ec2autorun.py is a script that launches CloudMan on instance boot
    and is thus required on an instance. See the script itself for the
    details of what it does.

    This script also adds a cloudman service to ``/etc/init``, which
    actually runs ec2autorun.py as a system-level service at system boot.
    """
    script = "ec2autorun.py"
    remote = os.path.join(env.install_dir, "bin", script)
    if not env.safe_exists(os.path.dirname(remote)):
        env.safe_sudo('mkdir -p {0}'.format(os.path.dirname(remote)))
    if use_repo_autorun:
        # Is this used, can we eliminate use_repo_autorun?
        url = os.path.join(MI_REPO_ROOT_URL, script)
        env.safe_sudo("wget --output-document=%s %s" % (remote, url))
    else:
        install_file_dir = os.path.join(env.config_dir, os.pardir, "installed_files")
        tmp_remote = os.path.join("/tmp", os.path.basename(remote))
        env.safe_put(os.path.join(install_file_dir, script), tmp_remote)
        env.safe_sudo("mv %s %s" % (tmp_remote, remote))
        env.safe_sudo("chmod 0777 %s" % remote)
    # Create upstart configuration file for boot-time script
    cloudman_boot_file = 'cloudman.conf'
    remote_file = '/etc/init/%s' % cloudman_boot_file
    _write_to_file(cm_upstart % (remote, os.path.splitext(remote)[0]), remote_file, mode="0644")
    # Setup default image user data (if configured by image_user_data_path or
    # image_user_data_template_path). This specifies defaults for CloudMan when
    # used with resulting image, normal userdata supplied by user will override
    # these defaults.
    image_user_data_path = os.path.join(env.install_dir, "bin", "IMAGE_USER_DATA")
    if "image_user_data_dict" in env:
        # Explicit YAML contents defined in env, just dump them as is.
        import yaml
        _write_to_file(yaml.dump(env.get("image_user_data_dict")), image_user_data_path, mode="0644")
    else:
        # Else use file or template file.
        _setup_conf_file(env, image_user_data_path, "image_user_data", default_source="image_user_data")
    env.logger.info("Done configuring CloudMan's ec2_autorun")
Example #9
0
def _configure_galaxy_options(env, option_dict=None, prefix="galaxy_universe_"):
    """
    Read through fabric's environment and make sure any property of
    the form galaxy_universe_XXX=YYY lands up in Galaxy's universe_wsgi.ini
    options as XXX=YYY using Galaxy configuration directory:
    """
    galaxy_conf_directory = env.get("galaxy_conf_directory", None)
    if not galaxy_conf_directory:
        return False
    # By default just read the options from env (i.e. from fabricrc), but
    # allow override so the options can come from a YAML file (such as done
    # with galaxy-vm-launcher.)
    if option_dict is None:
        option_dict = env

    option_priority = env.get("galaxy_conf_priority", "200")
    for key, value in option_dict.iteritems():
        if key.startswith(prefix):
            key = key[len(prefix):]
            conf_file_name = "%s_override_%s.ini" % (option_priority, key)
            conf_file = os.path.join(galaxy_conf_directory, conf_file_name)
            contents = "[app:main]\n%s=%s" % (key, value)
            _write_to_file(contents, conf_file, 0700)
            _chown_galaxy(env, conf_file)