def __init__(self, yaml_files=None, yolo_mode=False): logger.debug('Using m2ee-tools version %s' % m2ee.__version__) cmd.Cmd.__init__(self) if yaml_files: self.m2ee = M2EE(yamlfiles=yaml_files, load_default_files=False) else: self.m2ee = M2EE() self.yolo_mode = yolo_mode self.do_status(None) self.prompt_username = pwd.getpwuid(os.getuid())[0] self._default_prompt = "m2ee(%s): " % self.prompt_username self.prompt = self._default_prompt logger.info("Application Name: %s" % self.m2ee.config.get_app_name())
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
def __init__(self, yaml_files=None, yolo_mode=False): logger.debug('Using m2ee-tools version %s' % m2ee.__version__) cmd.Cmd.__init__(self) self.m2ee = M2EE(yaml_files=yaml_files) self.yolo_mode = yolo_mode self.prompt_username = pwd.getpwuid(os.getuid())[0] self._default_prompt = "m2ee(%s): " % self.prompt_username self.prompt = self._default_prompt self.nodetach = False
def get_m2ee(version): testdir = 'projects/%s' % version app_base = os.path.join(os.getcwd(), '%s/deployment' % testdir) with open('projects/m2ee.yaml.tmpl') as tmpl: with open('%s/m2ee.yaml' % testdir, 'w') as yaml: yaml.write(tmpl.read().format(app_base=app_base)) m2ee = M2EE(yamlfiles=['%s/m2ee.yaml' % testdir]) m2ee.admin_url = 'http://127.0.0.1:%d' % m2ee.config.get_admin_port() m2ee.runtime_url = 'http://127.0.0.1:%d' % m2ee.config.get_runtime_port() return m2ee
def __init__(self, yaml_files=None, yolo_mode=False): logger.debug('Using m2ee-tools version %s' % m2ee.__version__) cmd.Cmd.__init__(self) self.m2ee = M2EE(yaml_files=yaml_files) self.yolo_mode = yolo_mode self.onecmd('status') self.prompt_username = pwd.getpwuid(os.getuid())[0] self._default_prompt = "m2ee(%s): " % self.prompt_username self.prompt = self._default_prompt self.nodetach = False logger.info("Application Name: %s" % self.m2ee.config.get_app_name())
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
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