Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

does the swagger api v30 support cm6.2 and cluster 5.14?

Highlighted

does the swagger api v30 support cm6.2 and cluster 5.14?

New Contributor

I have a CM on v6.2 and Cluster on 5.14.4.  I am trying to use the swagger API V30 https://cloudera.github.io/cm_api/docs/python-client-swagger/ to manage the cluster.

 

I am trying to follow the examples listed on the web page. I am able to print the cluster.name which means my connection is correct.  However I can't get anything out when try to follow "Inspecting a service".

 

I am wondering if the API client only work with 6.x cluster, or it should work with 5.14 cluster as well.

 

thanks.

 

 

 

# comment out because my cluster is not 6.x
# if
cluster.full_version.startswith("6."): services_api_instance = cm_client.ServicesResourceApi(api_client) services = services_api_instance.read_services(cluster.name, view='FULL') for service in services.items: print service.display_name, "-", service.type if service.type == 'HDFS': hdfs = service

 

3 REPLIES 3

Re: does the swagger api v30 support cm6.2 and cluster 5.14?

Super Guru

@Kevin_Z,

 

The CDH version should not be relevant here.  If you are using CM 6.2 API, then the compatible API (v30) should be fine.

 

I recommend adding instrumention to the code to print out the value after each call to find out where it is failing.

 

Also, you might try this slightly different example form the python docs

https://archive.cloudera.com/cm6/6.2.0/generic/jar/cm_api/swagger-html-sdk-docs/python/docs/Services...

 

from __future__ import print_function
import time
import cm_client
from cm_client.rest import ApiException
from pprint import pprint

# Configure HTTP basic authorization: basic
configuration = cm_client.Configuration()
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

# create an instance of the API class
api_instance = cm_client.ServicesResourceApi(cm_client.ApiClient(configuration))
cluster_name = 'cluster_name_example' # str | 
view = 'summary' # str |  (optional) (default to summary)

try:
    # Lists all services registered in the cluster.
    api_response = api_instance.read_services(cluster_name, view=view)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling ServicesResourceApi->read_services: %s\n" % e)

You can plug your cluster name (returned by the previous example you had success with) into the "cluster_name" variable.

 

Re: does the swagger api v30 support cm6.2 and cluster 5.14?

New Contributor

Thank you bgooley for confirming it should work.  I will spend time to do more experiement and post back the results.

 

Regards,

 

Kevin_Z

Re: does the swagger api v30 support cm6.2 and cluster 5.14?

New Contributor

It's working now. probably there was a startup/shutdown when I tried previously.

 

thanks