Created on 06-11-2017 02:39 AM - edited 09-16-2022 04:44 AM
Hi Guys,
I have been struggling to get the a list of the host on which cloudera daemon is installed,
I tried using the rest API, but I did not found any path to getting the list of nodes with impala daemon on.
Does someone know how to get it ?
King Regards,
Rotem
Created 06-16-2017 08:42 AM
Then you will need to parse the REST result of the /hosts?view=full [0] endpoint which gives you map of host-to-roleRef "The list of roles assigned to this host."
$ curl -u admin:admin -X GET "http://cm-server:7180/api/v12/hosts?view=full"
[0] https://cloudera.github.io/cm_api/apidocs/v16/ns0_apiHost.html
Created on 06-11-2017 05:13 PM - edited 06-11-2017 05:14 PM
Since you did not specify which approach, I had a python console open and below seems to return what may be looking for.
from cm_api.api_client import ApiResource api = ApiResource(server_host="cloudera-manager.host.com",version=12) cluster = api.get_cluster("___REPLACE_ME_WITH_CLUSTER_NAME__") for host in api.get_all_hosts(view='full'):
# List (rolename,servicename,hostname) from all host where service name = impala
print [(x.roleName,x.serviceName,host.hostname) for x in host.roleRefs if "impala" in str(x.serviceName).lower()]
Created on 06-16-2017 08:28 AM - edited 06-16-2017 08:31 AM
Thanks for your answer.
I am trying to write a shell script using HTTP REST API.
something like "curl -u 'admin:admin' http://cm_host:7180/api/v1/clusters/dev01/services/hdfs2"
could you please assist with a command I need to run (Is there a way doing it without python just a shell script)
King Regards,
Rotem
Created 06-16-2017 08:42 AM
Then you will need to parse the REST result of the /hosts?view=full [0] endpoint which gives you map of host-to-roleRef "The list of roles assigned to this host."
$ curl -u admin:admin -X GET "http://cm-server:7180/api/v12/hosts?view=full"
[0] https://cloudera.github.io/cm_api/apidocs/v16/ns0_apiHost.html