Esempio n. 1
0
def set_up_nginx():
    buildpackutil.download_and_unpack(
        buildpackutil.get_blobstore_url(
            "/mx-buildpack/nginx-1.15.10-linux-x64-cflinuxfs2-6247377a.tgz"),
        BUILD_DIR,
        cache_dir=CACHE_DIR,
    )
Esempio n. 2
0
def compile(install_path, cache_dir):
    if not is_enabled():
        return
    # the dd-vX.Y.Z.tar.gz needs to be created manually
    #
    # see all bundled resources here:
    # curl -s https://cdn.mendix.com/mx-buildpack/experimental/dd-vX.Y.Z.tar.gz | tar tzv
    #
    # mx-agent-assembly-0.X-SNAPSHOT.jar is generated by the Mendix Runtime team
    #
    # the rest is copied from the datadog-agent debian package
    # install datadog-agent in a ubuntu-16.04 docker image
    # and extract the required python / dd-agent / jmxfetch dependencies
    #
    # lib/libpython2.7.so.1.0 is necessary so the go agent can include a cpython interpreter
    #
    # create the package with:
    # tar zcvf ../dd-vX.Y.Z.tar.gz --owner 0 --group 0 *
    # aws s3 cp ../dd-vX.Y.Z.tar.gz s3://mx-cdn/mx-buildpack/experimental/
    buildpackutil.download_and_unpack(
        buildpackutil.get_blobstore_url(
            "/mx-buildpack/experimental/dd-v0.9.0.tar.gz"),
        os.path.join(install_path, "datadog"),
        cache_dir=cache_dir,
    )
Esempio n. 3
0
def set_up_nginx():
    buildpackutil.download_and_unpack(
        buildpackutil.get_blobstore_url(
            "/mx-buildpack/nginx-1.13.3-linux-x64-53917f43.tgz"
        ),
        BUILD_DIR,
        cache_dir=CACHE_DIR,
    )
Esempio n. 4
0
def set_up_appdynamics():
    if buildpackutil.appdynamics_used():
        buildpackutil.download_and_unpack(
            buildpackutil.get_blobstore_url(
                "/mx-buildpack/appdynamics-agent-4.3.5.7.tar.gz"),
            DOT_LOCAL_LOCATION,
            CACHE_DIR,
        )
def compile(install_path, cache_dir):
    if not is_enabled():
        return
    #
    # Add Telegraf to the container which can forward metrics to a custom
    # AppMetrics target
    buildpackutil.download_and_unpack(
        buildpackutil.get_blobstore_url(
            '/mx-buildpack/experimental/dd-v0.8.0.tar.gz', ),
        os.path.join(install_path, 'datadog'),
        cache_dir=cache_dir,
    )

    buildpackutil.download_and_unpack(buildpackutil.get_blobstore_url(
        '/mx-buildpack/telegraf-1.7.1_linux_amd64.tar.gz'),
                                      install_path,
                                      cache_dir=cache_dir)
Esempio n. 6
0
def set_up_m2ee_client(vcap_data):
    m2ee = M2EE(yamlfiles=['.local/m2ee.yaml'], load_default_files=False, config={
        'm2ee': {
            # this is named admin_pass, but it's the verification http header
            # to communicate with the internal management port of the runtime
            'admin_pass': get_m2ee_password(),
        }
    })
    version = m2ee.config.get_runtime_version()

    mendix_runtimes_path = '/usr/local/share/mendix-runtimes.git'
    mendix_runtime_version_path = os.path.join(os.getcwd(), 'runtimes', str(version))
    if os.path.isdir(mendix_runtimes_path) and not os.path.isdir(mendix_runtime_version_path):
        buildpackutil.mkdir_p(mendix_runtime_version_path)
        env = dict(os.environ)
        env['GIT_WORK_TREE'] = mendix_runtime_version_path

        # checkout the runtime version
        process = subprocess.Popen(['git', 'checkout', str(version), '-f'],
                                   cwd=mendix_runtimes_path, env=env,
                                   stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        process.communicate()
        if process.returncode != 0:
            logger.info('Mendix {} is not available in the rootfs'.format(version))
            logger.info('Fallback (1): trying to fetch Mendix {} using git'.format(version))
            process = subprocess.Popen(['git', 'fetch', 'origin', 'refs/tags/{0}:refs/tags/{0}'.format(str(version)),
                                        '&&', 'git', 'checkout', str(version), '-f'],
                                       cwd=mendix_runtimes_path, env=env, stdout=subprocess.PIPE,
                                       stderr=subprocess.PIPE)
            process.communicate()
            if process.returncode != 0:
                logger.info('Unable to fetch Mendix {} using git'.format(version))
                url = buildpackutil.get_blobstore_url('/runtime/mendix-%s.tar.gz' % str(version))
                logger.info('Fallback (2): downloading Mendix {} from {}'.format(version, url))
                buildpackutil.download_and_unpack(url, os.path.join(os.getcwd(), 'runtimes'))

        m2ee.reload_config()
    set_runtime_config(
        m2ee.config._model_metadata,
        m2ee.config._conf['mxruntime'],
        vcap_data,
        m2ee,
    )
    java_version = buildpackutil.get_java_version(
        m2ee.config.get_runtime_version()
    )
    set_jvm_memory(
        m2ee.config._conf['m2ee'],
        vcap_data,
        java_version,
    )
    set_jetty_config(m2ee)
    activate_new_relic(m2ee, vcap_data['application_name'])
    activate_appdynamics(m2ee, vcap_data['application_name'])
    set_application_name(m2ee, vcap_data['application_name'])
    telegraf.update_config(m2ee, vcap_data['application_name'])
    datadog.update_config(m2ee, vcap_data['application_name'])
    return m2ee
Esempio n. 7
0
def compile(install_path, cache_dir):
    if not is_enabled():
        return
    #
    # Add Telegraf to the container which can forward metrics to a custom
    # AppMetrics target
    datadog.download(install_path, cache_dir)

    buildpackutil.download_and_unpack(
        buildpackutil.get_blobstore_url(
            "/mx-buildpack/telegraf-1.7.1_linux_amd64.tar.gz"),
        install_path,
        cache_dir=cache_dir,
    )
Esempio n. 8
0
def set_up_m2ee_client(vcap_data):
    m2ee = M2EE(yamlfiles=['.local/m2ee.yaml'], load_default_files=False)
    version = m2ee.config.get_runtime_version()

    mendix_runtimes_path = '/usr/local/share/mendix-runtimes.git'
    mendix_runtime_version_path = os.path.join(os.getcwd(), 'runtimes', str(version))
    if os.path.isdir(mendix_runtimes_path) and not os.path.isdir(mendix_runtime_version_path):
        buildpackutil.mkdir_p(mendix_runtime_version_path)
        env = dict(os.environ)
        env['GIT_WORK_TREE'] = mendix_runtime_version_path

        # checkout the runtime version
        process = subprocess.Popen(['git', 'checkout', str(version), '-f'], cwd=mendix_runtimes_path, env=env,
                                   stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        process.communicate()
        if process.returncode != 0:
            # do a 'git fetch --tags' to refresh the bare repo, then retry to checkout the runtime version
            logger.info('mendix runtime version {mx_version} is missing in this rootfs'.format(mx_version=version))
            process = subprocess.Popen(['git', 'fetch', '--tags', '&&', 'git', 'checkout', str(version), '-f'],
                                       cwd=mendix_runtimes_path, env=env, stdout=subprocess.PIPE,
                                       stderr=subprocess.PIPE)
            process.communicate()
            if process.returncode != 0:
                # download the mendix runtime version from our blobstore
                logger.info('unable to use rootfs for mendix runtime version {mx_version}'.format(mx_version=version))
                url = buildpackutil.get_blobstore_url('/runtime/mendix-%s.tar.gz' % str(version))
                buildpackutil.download_and_unpack(url, os.path.join(os.getcwd(), 'runtimes'))

        m2ee.reload_config()
    set_runtime_config(
        m2ee.config._model_metadata,
        m2ee.config._conf['mxruntime'],
        vcap_data,
        m2ee,
    )
    set_heap_size(m2ee.config._conf['m2ee']['javaopts'])
    activate_new_relic(m2ee, vcap_data['application_name'])
    activate_appdynamics(m2ee, vcap_data['application_name'])
    set_application_name(m2ee, vcap_data['application_name'])
    java_version = buildpackutil.get_java_version(
        m2ee.config.get_runtime_version()
    )
    java_opts = m2ee.config._conf['m2ee']['javaopts']
    if java_version.startswith('7'):
        java_opts.append('-XX:MaxPermSize=128M')
    elif java_version.startswith('8'):
        java_opts.append('-XX:MaxMetaspaceSize=128M')
    return m2ee
Esempio n. 9
0
def compile(install_path, cache_dir):
    if not is_enabled():
        return
    #
    # Add Telegraf to the container which can forward metrics to a custom
    # AppMetrics target
    buildpackutil.download_and_unpack(
        buildpackutil.get_blobstore_url(
            "/mx-buildpack/experimental/dd-v0.8.0.tar.gz"),
        os.path.join(install_path, "datadog"),
        cache_dir=cache_dir,
    )

    buildpackutil.download_and_unpack(
        "https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly_linux_amd64.tar.gz",
        install_path,
        cache_dir=cache_dir,
    )
Esempio n. 10
0
def set_up_m2ee_client(vcap_data):
    m2ee = M2EE(yamlfiles=['.local/m2ee.yaml'], load_default_files=False)
    version = m2ee.config.get_runtime_version()

    mendix_runtimes_path = '/usr/local/share/mendix-runtimes.git'
    mendix_runtime_version_path = os.path.join(os.getcwd(), 'runtimes', str(version))
    if os.path.isdir(mendix_runtimes_path) and not os.path.isdir(mendix_runtime_version_path):
        buildpackutil.mkdir_p(mendix_runtime_version_path)
        env = dict(os.environ)
        env['GIT_WORK_TREE'] = mendix_runtime_version_path

        # checkout the runtime version
        process = subprocess.Popen(['git', 'checkout', str(version), '-f'], cwd=mendix_runtimes_path, env=env,
                                   stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        process.communicate()
        if process.returncode != 0:
            # do a 'git fetch --tags' to refresh the bare repo, then retry to checkout the runtime version
            logger.info('mendix runtime version {mx_version} is missing in this rootfs'.format(mx_version=version))
            process = subprocess.Popen(['git', 'fetch', '--tags', '&&', 'git', 'checkout', str(version), '-f'],
                                       cwd=mendix_runtimes_path, env=env, stdout=subprocess.PIPE,
                                       stderr=subprocess.PIPE)
            process.communicate()
            if process.returncode != 0:
                # download the mendix runtime version from our blobstore
                logger.info('unable to use rootfs for mendix runtime version {mx_version}'.format(mx_version=version))
                url = buildpackutil.get_blobstore_url('/runtime/mendix-%s.tar.gz' % str(version))
                buildpackutil.download_and_unpack(url, os.path.join(os.getcwd(), 'runtimes'))

        m2ee.reload_config()
    set_runtime_config(
        m2ee.config._model_metadata,
        m2ee.config._conf['mxruntime'],
        vcap_data,
        m2ee,
    )
    set_heap_size(m2ee.config._conf['m2ee']['javaopts'])
    activate_new_relic(m2ee, vcap_data['application_name'])
    activate_appdynamics(m2ee, vcap_data['application_name'])
    set_application_name(m2ee, vcap_data['application_name'])

    return m2ee
Esempio n. 11
0
def download_mendix_version():
    logging.debug("downloading mendix version")

    git_repo_found = os.path.isdir("/usr/local/share/mendix-runtimes.git")

    if git_repo_found and not os.environ.get("FORCED_MXRUNTIME_URL"):
        logging.debug("rootfs with mendix runtime detected, skipping download")
        return

    url = os.environ.get("FORCED_MXRUNTIME_URL")
    if url is not None:
        cache_dir = "/tmp/downloads"
    else:
        cache_dir = CACHE_DIR
        url = buildpackutil.get_blobstore_url("/runtime/mendix-%s.tar.gz" %
                                              str(get_runtime_version()))
    logging.debug("rootfs without mendix runtimes detected, "
                  "downloading and unpacking mendix runtime now")
    buildpackutil.download_and_unpack(url,
                                      os.path.join(BUILD_DIR, "runtimes"),
                                      cache_dir=cache_dir)
Esempio n. 12
0
def set_up_m2ee_client(vcap_data):
    m2ee = M2EE(
        yamlfiles=[".local/m2ee.yaml"],
        load_default_files=False,
        config={
            "m2ee": {
                # this is named admin_pass, but it's the verification http header
                # to communicate with the internal management port of the runtime
                "admin_pass": get_m2ee_password()
            }
        },
    )
    version = m2ee.config.get_runtime_version()

    mendix_runtimes_path = "/usr/local/share/mendix-runtimes.git"
    mendix_runtime_version_path = os.path.join(
        os.getcwd(), "runtimes", str(version)
    )
    if os.path.isdir(mendix_runtimes_path) and not os.path.isdir(
        mendix_runtime_version_path
    ):
        buildpackutil.mkdir_p(mendix_runtime_version_path)
        env = dict(os.environ)
        env["GIT_WORK_TREE"] = mendix_runtime_version_path

        # checkout the runtime version
        process = subprocess.Popen(
            ["git", "checkout", str(version), "-f"],
            cwd=mendix_runtimes_path,
            env=env,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
        process.communicate()
        if process.returncode != 0:
            logger.info(
                "Mendix {} is not available in the rootfs".format(version)
            )
            logger.info(
                "Fallback (1): trying to fetch Mendix {} using git".format(
                    version
                )
            )
            process = subprocess.Popen(
                [
                    "git",
                    "fetch",
                    "origin",
                    "refs/tags/{0}:refs/tags/{0}".format(str(version)),
                    "&&",
                    "git",
                    "checkout",
                    str(version),
                    "-f",
                ],
                cwd=mendix_runtimes_path,
                env=env,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE,
            )
            process.communicate()
            if process.returncode != 0:
                logger.info(
                    "Unable to fetch Mendix {} using git".format(version)
                )
                url = buildpackutil.get_blobstore_url(
                    "/runtime/mendix-%s.tar.gz" % str(version)
                )
                logger.info(
                    "Fallback (2): downloading Mendix {} from {}".format(
                        version, url
                    )
                )
                buildpackutil.download_and_unpack(
                    url, os.path.join(os.getcwd(), "runtimes")
                )

        m2ee.reload_config()
    set_runtime_config(
        m2ee.config._model_metadata,
        m2ee.config._conf["mxruntime"],
        vcap_data,
        m2ee,
    )
    java_version = buildpackutil.get_java_version(
        m2ee.config.get_runtime_version()
    )
    set_jvm_memory(m2ee.config._conf["m2ee"], vcap_data, java_version)
    set_jvm_locale(m2ee.config._conf["m2ee"], java_version)
    set_jetty_config(m2ee)
    activate_new_relic(m2ee, vcap_data["application_name"])
    activate_appdynamics(m2ee, vcap_data["application_name"])
    set_application_name(m2ee, vcap_data["application_name"])
    telegraf.update_config(m2ee, vcap_data["application_name"])
    datadog.update_config(m2ee, vcap_data["application_name"])
    return m2ee