Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

Read service-wide configuration values via API

avatar

Hi,

 I am wondering if it is possible to get Service-Wide configurations via read_config method of the RoleConfigGroupsResourceApi class.

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

 

The read_roles method of RolesResourceAPI returns theses roles:

 

CD-HDFS-eHtEMKVf-DATANODE-BASE
CD-HDFS-eHtEMKVf-SECONDARYNAMENODE-BASE
CD-HDFS-eHtEMKVf-HTTPFS-BASE
CD-HDFS-eHtEMKVf-DATANODE-BASE
CD-HDFS-eHtEMKVf-DATANODE-BASE
CD-HDFS-eHtEMKVf-NAMENODE-BASE

 

 But when I query all these roles, I cannot find the Service-Wide property of Advanced configuration for core-site.xml

 

Reading configuration for CD-HDFS-eHtEMKVf-DATANODE-BASE
{'items': [{'default': None,
            'description': 'For advanced use only, key-value pairs (one on '
                           "each line) to be inserted into a role's "
                           'environment. Applies to configurations of this '
                           'role except client configuration.',
            'display_name': 'DataNode Environment Advanced Configuration '
                            'Snippet (Safety Valve)',
            'name': 'DATANODE_role_env_safety_valve',
            'related_name': '',
            'required': False,
            'sensitive': False,
            'validation_message': None,
            'validation_state': 'OK',
            'validation_warnings_suppressed': False,
            'value': None},
           {'default': '{"critical":"never","warning":"1000000.0"}',
            'description': 'The health test thresholds of the number of blocks '
                           'on a DataNode',
            'display_name': 'DataNode Block Count Thresholds',
            'name': 'datanode_block_count_thresholds',
            'related_name': '',
            'required': False,
            'sensitive': False,
            'validation_message': None,
            'validation_state': 'OK',
            'validation_warnings_suppressed': None,
            'value': None},
           {'default': None,

 

 

Maybe I should search in other classes? Please advise,

Thanks

1 ACCEPTED SOLUTION

avatar

The solution is quite simple, was not aware that the service-wide configurations are not in roles but in services. So the solution is to use a ServicesResourceApi endpoint and read_service_config method.

Something like this:

 

    def get_service_config(self, service_name):
        """Returns the configuration of the service"""
        services_instance = cm_client.ServicesResourceApi(self.api)
        view = 'summary'
        try:
            api_response = services_instance.read_service_config(
                self.cluster_name, service_name, view=view)
            return api_response.to_dict()
        except ApiException as exception:
            print(f"Exception when calling ServicesResourceApi->read_service_config: {exception}\n")

View solution in original post

1 REPLY 1

avatar

The solution is quite simple, was not aware that the service-wide configurations are not in roles but in services. So the solution is to use a ServicesResourceApi endpoint and read_service_config method.

Something like this:

 

    def get_service_config(self, service_name):
        """Returns the configuration of the service"""
        services_instance = cm_client.ServicesResourceApi(self.api)
        view = 'summary'
        try:
            api_response = services_instance.read_service_config(
                self.cluster_name, service_name, view=view)
            return api_response.to_dict()
        except ApiException as exception:
            print(f"Exception when calling ServicesResourceApi->read_service_config: {exception}\n")