<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: CM Python API in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CM-Python-API/m-p/60404#M68595</link>
    <description>&lt;P&gt;Any thoughts or direction is appreciated&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Sep 2017 23:26:27 GMT</pubDate>
    <dc:creator>code0404</dc:creator>
    <dc:date>2017-09-27T23:26:27Z</dc:date>
    <item>
      <title>CM Python API</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CM-Python-API/m-p/60338#M68594</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Below is the code snippet&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;import datetime
import getpass&lt;/STRONG&gt;
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.
&lt;STRONG&gt;cluster = api.get_all_clusters()[0]&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Its failing with Message&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Traceback (most recent call last):
  File "scan-work-items.py", line 23, in &amp;lt;module&amp;gt;
    cluster = api.get_all_clusters()[0]
  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)
&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;cm_api.api_client.ApiException:  (error 404)

&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;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. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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 ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 12:18:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CM-Python-API/m-p/60338#M68594</guid>
      <dc:creator>code0404</dc:creator>
      <dc:date>2022-09-16T12:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: CM Python API</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CM-Python-API/m-p/60404#M68595</link>
      <description>&lt;P&gt;Any thoughts or direction is appreciated&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 23:26:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CM-Python-API/m-p/60404#M68595</guid>
      <dc:creator>code0404</dc:creator>
      <dc:date>2017-09-27T23:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: CM Python API</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CM-Python-API/m-p/60409#M68596</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/21980"&gt;@code0404&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use the REST API to verify the maximum supported API version in your Cloudera Manager:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;http://host:port/api/version&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output will be the supported version. For example, "&lt;STRONG&gt;v14&lt;/STRONG&gt;".&lt;/P&gt;&lt;P&gt;Take that value and then use it in your ApiResource() like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;api = ApiResource(host, 7180, user, password,&lt;STRONG&gt;version=14&lt;/STRONG&gt;)&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;See the following for more information on ApiResource:&lt;/P&gt;&lt;P&gt;&lt;A href="https://cloudera.github.io/cm_api/epydoc/5.12.0/cm_api.api_client.ApiResource-class.html" target="_blank"&gt;https://cloudera.github.io/cm_api/epydoc/5.12.0/cm_api.api_client.ApiResource-class.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 04:28:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CM-Python-API/m-p/60409#M68596</guid>
      <dc:creator>bgooley</dc:creator>
      <dc:date>2017-09-28T04:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: CM Python API</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CM-Python-API/m-p/60430#M68597</link>
      <description>&lt;P&gt;Wow, Thanks... worked perfect after I plugged in the version.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 17:36:09 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CM-Python-API/m-p/60430#M68597</guid>
      <dc:creator>code0404</dc:creator>
      <dc:date>2017-09-28T17:36:09Z</dc:date>
    </item>
  </channel>
</rss>

