def setup(vcap_data): _pre_process_m2ee_yaml() _activate_license() client = m2ee_class( yamlfiles=[os.path.abspath(".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": security.get_m2ee_password() } }, ) _set_runtime_config( client, client.config._model_metadata, vcap_data, ) _set_application_name(client, vcap_data["application_name"]) _set_jetty_config(client) return client
def set_up_m2ee_client(vcap_data): client = m2ee_class( 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": security.get_m2ee_password() } }, ) version = client.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): util.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: logging.info("Mendix %s is not available in the rootfs", version) logging.info("Fallback (1): trying to fetch Mendix %s using git", 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: logging.info( "Unable to fetch Mendix {} using git".format(version)) url = util.get_blobstore_url("/runtime/mendix-%s.tar.gz" % str(version)) logging.info( "Fallback (2): downloading Mendix {} from {}".format( version, url)) util.download_and_unpack(url, os.path.join(os.getcwd(), "runtimes")) client.reload_config() runtime.set_runtime_config( client.config._model_metadata, client.config._conf["mxruntime"], vcap_data, client, ) java_version = runtime.get_java_version( client.config.get_runtime_version())["version"] java.update_config(client.config._conf["m2ee"], vcap_data, java_version) runtime.set_jetty_config(client) newrelic.update_config(client, vcap_data["application_name"]) appdynamics.update_config(client, vcap_data["application_name"]) runtime.set_application_name(client, vcap_data["application_name"]) telegraf.update_config(client, vcap_data["application_name"]) datadog.update_config(client) return client