def _check_java_installation_health(self): platform = self._detect_platform_dir() path_to_customized_java = os.path.join(self.path_to_app, platform, "bin", "customized.java.path") final_status = Status.OK final_details = [] if not os.path.isfile(path_to_customized_java): # check if $JAVA_HOME/bin/java satisfies the requirement of JAVA 8 if JAVA_HOME is defined java_home = os.getenv("JAVA_HOME") if java_home: logger.debug("JAVA_HOME is {}".format(java_home)) java_cmd = os.path.join(java_home, "bin", "java") else: logger.debug( "JAVA_HOME is not specified. Use default java command.") java_cmd = "java" # validating java command is_healthy, detail = validateJRE(java_cmd) if is_healthy: splunk_service = SplunkServiceFactory.create( self.sessionKey, app='splunk_app_db_connect', owner=self.userName) result = self._check_commands(splunk_service) result.append( self._check_modular_alert_java_conf(splunk_service)) # we reduce the results for status, details in result: if status != Status.OK: final_status = Status.ERROR final_details.append(details) else: final_status = Status.ERROR final_details.append(detail) else: # check the content of customized.java.path with open(path_to_customized_java, 'r') as customized_java_file: java_cmd = customized_java_file.readline().strip() is_healthy, final_details = validateJRE(java_cmd) if not is_healthy: final_status = Status.ERROR return self._create_health_check_result(final_status, final_details)
def validate_java_home(self, java_home): if os.path.isdir(java_home): java_cmd = os.path.join(java_home, "bin", "java") is_valid, reason = validateJRE(java_cmd) if is_valid: is_valid, reason = checkDependencies(java_home) if not is_valid: raise Exception(reason) else: raise Exception("JAVA_HOME path not exist")