Using the Cloudera Manager API to Set Advanced Configuration Snippets (Safety Valves)
You can use the Cloudera Manager API to set service configuration properties.
-
Find the name of the configuration property.
- Go to the Cloudera Manager Configuration Property Reference and navigate to the page for the Cloudera Runtime version and service you want to configure.
- Search through the page for the Advanced Configuration Snippet property.
- Copy the value of the API Name.
- Determine whether the Advanced Configuration Snippet property
is defined using name/value pairs or XML:
-
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:
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 tocurl -X PUT -u username:password "Cloudera_Manager_server_name:Cloudera_Manager_server_port/api/v51/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 } ]}"
test=2
:
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:curl -X PUT -u admin:admin "http://myCMserver.com:7180/api/v51/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 } ]}"
foo1=bar1
, then to add an additional name/value pair, you must set the value like this:
This command sets the Advanced Configuration Snippet to the following:\"value\": \"foo1=bar1 foo2=bar2\"
foo1=bar1 foo2=bar2
- Snippet is defined using
XML:
For example:curl -X PUT -u username:password "Cloudera_Manager_server_name:Cloudera_Manager_server_port/api/v51/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 } ]}"
This call sets the Advanced Configuration Snippet to the following:curl -X PUT -u admin:admin "http://myCMserver.com:7180/api/v51/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 } ]}"
<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.
- Snippet is defined using name/value
pairs: