Created 07-20-2017 06:56 AM
Hi Friends,
Getting the following exception:
cm_api.api_client.ApiException: HTTP Error 401: basic auth failed (error 401)
CM is on the same host where I am executing the python script. Seems a very basic error. Passing admin CM credentials. Seeking pointers to
- which port is it using?
- do I have to enable CM REST API?
- anyothers?
Complete stack trace.
[rizwmian@w0575oslshcea01 cluster_diff]$ python --version
Python 2.6.6
[rizwmian@w0575oslshcea01 cluster_diff]$ cdh.py
Traceback (most recent call last):
File "./cdh.py", line 67, in <module>
main()
File "./cdh.py", line 62, in main
cluster = find_cluster(api, None)
File "./cdh.py", line 12, in find_cluster
all_clusters = api.get_all_clusters()
File "/usr/lib/python2.6/site-packages/cm_api/api_client.py", line 128, in get_all_clusters
return clusters.get_all_clusters(self, view)
File "/usr/lib/python2.6/site-packages/cm_api/endpoints/clusters.py", line 66, in get_all_clusters
params=view and dict(view=view) or None)
File "/usr/lib/python2.6/site-packages/cm_api/endpoints/types.py", line 139, in call
ret = method(path, params=params)
File "/usr/lib/python2.6/site-packages/cm_api/resource.py", line 110, in get
return self.invoke("GET", relpath, params)
File "/usr/lib/python2.6/site-packages/cm_api/resource.py", line 73, in invoke
headers=headers)
File "/usr/lib/python2.6/site-packages/cm_api/http_client.py", line 174, in execute
raise self._exc_class(ex)
cm_api.api_client.ApiException: HTTP Error 401: basic auth failed (error 401)
cm_api.api_client.ApiException: HTTP Error 401: basic auth failed (error 401)
Created on 07-20-2017 08:26 AM - edited 07-20-2017 08:26 AM
Figured out. Need both:
- username/password to connect to cm api
- user launching script to have valid kerberos ticket (surprising find)
Thanks everyone. 🙂
Created on 07-20-2017 08:26 AM - edited 07-20-2017 08:26 AM
Figured out. Need both:
- username/password to connect to cm api
- user launching script to have valid kerberos ticket (surprising find)
Thanks everyone. 🙂
Created 10-16-2017 08:40 AM
Hello,
i am also facing the same issue . can you please elaborate what exactly you did.
Thank you.
-avi
Created 10-16-2017 02:19 PM
In order to use the API, you must provide authenticate to CM. See the example here:
https://cloudera.github.io/cm_api/docs/python-client/
# Get a handle to the API client from cm_api.api_client import ApiResource cm_host = "cm-host" api = ApiResource(cm_host, username="admin", password="admin") # Get a list of all clusters cdh4 = None for c in api.get_all_clusters(): print c.name if c.version == "CDH4": cdh4 = c
Created 10-16-2017 11:46 PM
Thanks ,
i figured out the issue.
i was passing the credentials but as it was a new service id , i had not added it with our hadoop group.
so the credential also couldnot be logged in to cloudera manager (which i hadnt checked earlier ,as it was working fine while logging into the server )