def is_smm_service_installed(cls, cluster_name): url = Ambari.getWebUrl( is_hdp=False, is_enc=Ambari.is_ambari_encrypted() ) + "/api/v1/clusters/%s/services/STREAMSMSGMGR" % cluster_name retcode, retdata, retheaders = Ambari.performRESTCall(url) if retcode == 404: return False return True
def get_streamline_service_status(cls, cluster_name): service_state = None url = Ambari.getWebUrl(is_hdp=False) + "/api/v1/clusters/%s/services/STREAMLINE" % cluster_name retcode, retdata, retheaders = Ambari.performRESTCall(url) if retcode == 200: jsoncontent = util.getJSON(retdata) service_state = jsoncontent["ServiceInfo"]["state"] return service_state
def get_smm_service_status(cls, cluster_name): service_state = None url = Ambari.getWebUrl( is_hdp=False, is_enc=Ambari.is_ambari_encrypted() ) + "/api/v1/clusters/%s/services/STREAMSMSGMGR" % cluster_name retcode, retdata, retheaders = Ambari.performRESTCall(url) if retcode == 200: jsoncontent = util.getJSON(retdata) service_state = jsoncontent["ServiceInfo"]["state"] return service_state
def is_secure(cls): url = "%s/api/v1/clusters/%s" % (Ambari.getWebUrl(), Ambari.getClusterName()) retcode = None for i in range(10): retcode, retdata, retheaders = Ambari.performRESTCall(url) if retcode == 200: jsoncontent = util.getJSON(retdata) try: if jsoncontent['Clusters']['security_type'] == "KERBEROS": return True except: pass util.sleep(5) return False
def getServiceHosts(cls, host, service, component, cluster='cl1'): hosts = [] url = "%s/api/v1/clusters/%s/services/%s/components/%s" % ( cls.getweburl(host), cluster, service, component) retcode, retdata, retheaders = Ambari.performRESTCall(url) if retcode == 200: jsoncontent = util.getJSON(retdata) try: hosts = [ hc['HostRoles']['host_name'] for hc in jsoncontent['host_components'] ] except: hosts = [] return hosts
def checkKafkaStatusOnMetronHost(cls, metron_host): kafka_status = None url = Ambari.getWebUrl( is_hdp=False ) + "/api/v1/clusters/%s/hosts/%s/host_components/%s" % ( cls.get_ambari_cluster_name(), metron_host, cls.kafka_broker) retcode, retdata, _retheaders = Ambari.performRESTCall(url) if retcode == 200: jsoncontent = util.getJSON(retdata) try: kafka_status = jsoncontent['HostRoles']['state'] except Exception: logger.error('Kafka broker is not running on the Metron host') kafka_status = None return kafka_status
def getMetronRestProperty(cls, param_name): ''' Return the property value for given Metron Rest property from Ambari config using REST API :return: List ''' metron_rest_prop = None url = Ambari.getWebUrl( is_hdp=False ) + "/api/v1/clusters/%s/configurations?type=%s&tag=%s" % ( cls.get_ambari_cluster_name(), cls.metron_rest_config_type, cls.metron_config_tag) retcode, retdata, _retheaders = Ambari.performRESTCall(url) if retcode == 200: jsoncontent = util.getJSON(retdata) try: metron_rest_prop = [ hc['properties'][param_name] for hc in jsoncontent['items'] ] except Exception: logger.error('Metron rest property %s variable is not set', param_name) metron_rest_prop = None return metron_rest_prop
def getMetronHome(cls): ''' Return the path to Metron Home from Ambari config using REST API :return: String ''' metron_home = None url = Ambari.getWebUrl( is_hdp=False ) + "/api/v1/clusters/%s/configurations?type=%s&tag=%s" % ( cls.get_ambari_cluster_name(), cls.metron_config_type, cls.metron_config_tag) retcode, retdata, _retheaders = Ambari.performRESTCall(url) if retcode == 200: jsoncontent = util.getJSON(retdata) try: metron_home = [ hc['properties']['metron_home'] for hc in jsoncontent['items'] ] except Exception: logger.error('Metron Home variable is not set') metron_home = None return metron_home