09-26-2017 11:57 AM
I am trying to use cm python api, but it keeps failing out. Not sure, what is causing the issue. I get 404 error ! which I think represents object not found.
Below is the code snippet
import datetime import getpass import re from cm_api.api_client import ApiResource # Connection information. host = 'XXXXXXXXXXXXXXXXXXXXXXX' port = 7180 user = 'admin' password = 'admin' api = ApiResource(host, 7180, user, password) # Finds the first YARN service in the first cluster. cluster = api.get_all_clusters()
Its failing with Message
Traceback (most recent call last): File "scan-work-items.py", line 23, in <module> cluster = api.get_all_clusters() File "/usr/lib/python2.6/site-packages/cm_api/api_client.py", line 131, 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 183, in execute raise self._exc_class(ex) cm_api.api_client.ApiException: (error 404)
Is it because of running python 2.6 ? I am running this on NameNode in my lab cluster(6 Node) that is running outside the production CM cluster. I am trying to use the API to connect to production cluster to fetch some metrics, but it keeps erroring out.
Also, We have RM HA. Is there a way to find which node is my active Resource Manager ? and the URL for it ? without logging into CM ?
Solved! Go to Solution.
09-27-2017 09:28 PM
The 404 message that you describe usually occurs when you are using the latest Python API but your Cloudera Manager does not support that latest API version.
Use the REST API to verify the maximum supported API version in your Cloudera Manager:
The output will be the supported version. For example, "v14".
Take that value and then use it in your ApiResource() like this:
api = ApiResource(host, 7180, user, password,version=14)
See the following for more information on ApiResource: