Using the Cloudera Manager API to Set Advanced Configuration Snippets (Safety Valves)

You can use the Cloudera Manager API to set service configuration properties.

You must have network access to the Cloudera Manager Admin Console.
  1. Find the name of the configuration property.
    1. Go to the Cloudera Manager Configuration Property Reference and navigate to the page for the Cloudera Runtime version and service you want to configure.
    2. Search through the page for the Advanced Configuration Snippet property.
    3. Copy the value of the API Name.
  2. Determine whether the Advanced Configuration Snippet property is defined using name/value pairs or XML:
    1. Log in to the Cloudera Manager Admin Console.
    2. Go to the service where you want to change the advanced configuration.
    3. Click the Configuration tab.
    4. Search for the Advanced Configuration Snippet property.
      • If the property is a text file using name/value pairs, the description includes a View as text link.
      • If the property is an XML file, the description includes a View as XML link.
  3. Log into a host with network access to the Cloudera Manager Admin Console using ssh, and run one of the following commands:
    • Snippet is defined using name/value pairs:
      curl -X PUT -u username:password "Cloudera_Manager_server_name:Cloudera_Manager_server_port/api/v49/clusters/Cluster_name/services/service_name/config" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"items\": [        {      \"name\": \"API-Name\",      \"value\": \"name=value\",      \"sensitive\": false    }  ]}"
      For example, the following command changes the value of the HDFS Replication Environment Advanced Configuration Snippet (Safety Valve) in the HDFS-1 service in Cluster 1 to test=2:
    • curl -X PUT -u admin:admin "http://myCMserver.com:7180/api/v49/clusters/Cluster%201/services/HDFS-1/config" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"items\": [        {      \"name\": \"hdfs_replication_env_safety_valve\",      \"value\": \"test=2\",      \"sensitive\": false    }  ]}"
      Important: The value you enter overwrites all the contents of the Snippet, so you must also include any existing values. For example, if only the following value is currently configured: foo1=bar1, then to add an additional name/value pair, you must set the value like this:
      \"value\": \"foo1=bar1 foo2=bar2\"
      This command sets the Advanced Configuration Snippet to the following:
      foo1=bar1
      foo2=bar2
    • Snippet is defined using XML:
      curl -X PUT -u username:password "Cloudera_Manager_server_name:Cloudera_Manager_server_port/api/v49/clusters/Cluster_name/services/service_name/config" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"items\": [        {      \"name\": \"API-Name\",      \"value\": \"XML structure\",      \"sensitive\": false    }  ]}"
      For example:
      curl -X PUT -u admin:admin "http://myCMserver.com:7180/api/v49/clusters/Cluster%201/services/HDFS-1/config" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"items\": [        {      \"name\": \"hdfs_replication_env_safety_valve\",      \"value\": \"<property><name>foo</name><value>bar</value><description>Example</description></property>\",      \"sensitive\": false    }  ]}"
      This call sets the Advanced Configuration Snippet to the following:
      <property>
        <name>foo</name>
        <value>bar</value>
        <description>Example</description>
      </property>
      
    • Important: The value you enter overwrites all the contents of the Snippet, so you must also include any previously-existing <property> elements.
The configuration value has been changed.