Member since
06-29-2021
3
Posts
0
Kudos Received
0
Solutions
07-06-2021
03:58 AM
sending basic examples of getting the expiration date via API for single host: import cm_client from cm_client.rest import ApiException from pprint import pprint # Configure HTTP basic authorization: basic cm_client.configuration.username = '<USERNAME>' cm_client.configuration.password = '<PASSWORD>' # Create an instance of the API class api_host = 'http://<Cloudera host>' port = '7180' api_version = 'v41' # Construct base URL for API api_url = api_host + ':' + port + '/api/' + api_version api_client = cm_client.ApiClient(api_url) cluster_api_instance = cm_client.ClouderaManagerResourceApi(api_client) try: # Retrieve information about the Cloudera Manager license. api_response = cluster_api_instance.read_license() pprint(api_response.expiration) except ApiException as e: print("Exception when calling ClouderaManagerResourceApi->read_license: %s\n" % e) for several hosts: import cm_client from cm_client.rest import ApiException from pprint import pprint import datetime # Configure HTTP basic authorization: basic cm_client.configuration.username = '<USERNAME>' cm_client.configuration.password = '<PASSWORD>' hosts_list= {"<host 1>" , "<host 2>" , "<host 3>", ....} # Create an instance of the API class for cdh_host in hosts_list: api_host = 'http://' + cdh_host port = '7180' api_version = 'v41' # Construct base URL for API api_url = api_host + ':' + port + '/api/' + api_version api_client = cm_client.ApiClient(api_url) cluster_api_instance = cm_client.ClouderaManagerResourceApi(api_client) print cdh_host + ":" try: # Retrieve information about the Cloudera Manager license. api_response = cluster_api_instance.read_license() expiration_date = api_response.expiration[0:10] print(expiration_date) print "##############" except ApiException as e: print("Exception when calling ClouderaManagerResourceApi->read_license: %s\n" % e)
... View more