<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: set Variable in ambari rest API in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/set-Variable-in-ambari-rest-API/m-p/294858#M217471</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/59349"&gt;@mike_bronson7&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can achieve it in a similar way described on the following thread:&lt;BR /&gt;&lt;A href="https://community.cloudera.com/t5/Support-Questions/AMBARI-how-to-set-value-in-json-REST-API/td-p/290385" target="_blank"&gt;https://community.cloudera.com/t5/Support-Questions/AMBARI-how-to-set-value-in-json-REST-API/td-p/290385&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;AMBARI_FQDN=newhwx1.example.com
CLUSTER_NAME=NewCluster
DATANODES=newhwx1.example.com,newhwx2.example.com,newhwx3.example.com,newhwx5.example.com


# curl -s -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop DataNodes","operation_level":{"level":"SERVICE","cluster_name":"'"$CLUSTER_NAME"'"},"query":"HostRoles/component_name=DATANODE&amp;amp;HostRoles/host_name.in('$DATANODES')&amp;amp;HostRoles/maintenance_state=OFF"},"Body":{"HostRoles":{"state":"INSTALLED"}}}' "http://$AMBARI_FQDN:8080/api/v1/clusters/$CLUSTER_NAME/host_components"&lt;/LI-CODE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Apr 2020 10:48:47 GMT</pubDate>
    <dc:creator>jsensharma</dc:creator>
    <dc:date>2020-04-27T10:48:47Z</dc:date>
    <item>
      <title>set Variable in ambari rest API</title>
      <link>https://community.cloudera.com/t5/Support-Questions/set-Variable-in-ambari-rest-API/m-p/294856#M217470</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hi all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the following ambari API will stop only the data-nodes on workers machines&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# curl -s -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop DataNodes","operation_level":{"level":"SERVICE","cluster_name":"$CLUSTER_NAME"},"query":"HostRoles/component_name=DATANODE&amp;amp;HostRoles/host_name.in(dn1.example.com,dn2.example.com,dn3.example.com)&amp;amp;HostRoles/maintenance_state=OFF"},"Body":{"HostRoles":{"state":"INSTALLED"}}}' "h ttp://$AMBARI_FQDN:8080/api/v1/clusters/$CLUSTER_NAME/host_components"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;now we want to replace the list -&amp;nbsp;n1.example.com,dn2.example.com,dn3.example.com&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;with variable - DATANODES=n1.example.com,dn2.example.com,dn3.example.com&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so $DATANODES will replce the list in the API as the following&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# curl -s -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop DataNodes","operation_level":{"level":"SERVICE","cluster_name":"$CLUSTER_NAME"},"query":"HostRoles/component_name=DATANODE&amp;amp;HostRoles/host_name.in($DATANODES)&amp;amp;HostRoles/maintenance_state=OFF"},"Body":{"HostRoles":{"state":"INSTALLED"}}}' "h ttp://$AMBARI_FQDN:8080/api/v1/clusters/$CLUSTER_NAME/host_components"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but this isn't working , any advice how to set it correctly ?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 10:04:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/set-Variable-in-ambari-rest-API/m-p/294856#M217470</guid>
      <dc:creator>mike_bronson7</dc:creator>
      <dc:date>2020-04-27T10:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: set Variable in ambari rest API</title>
      <link>https://community.cloudera.com/t5/Support-Questions/set-Variable-in-ambari-rest-API/m-p/294858#M217471</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/59349"&gt;@mike_bronson7&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can achieve it in a similar way described on the following thread:&lt;BR /&gt;&lt;A href="https://community.cloudera.com/t5/Support-Questions/AMBARI-how-to-set-value-in-json-REST-API/td-p/290385" target="_blank"&gt;https://community.cloudera.com/t5/Support-Questions/AMBARI-how-to-set-value-in-json-REST-API/td-p/290385&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;AMBARI_FQDN=newhwx1.example.com
CLUSTER_NAME=NewCluster
DATANODES=newhwx1.example.com,newhwx2.example.com,newhwx3.example.com,newhwx5.example.com


# curl -s -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop DataNodes","operation_level":{"level":"SERVICE","cluster_name":"'"$CLUSTER_NAME"'"},"query":"HostRoles/component_name=DATANODE&amp;amp;HostRoles/host_name.in('$DATANODES')&amp;amp;HostRoles/maintenance_state=OFF"},"Body":{"HostRoles":{"state":"INSTALLED"}}}' "http://$AMBARI_FQDN:8080/api/v1/clusters/$CLUSTER_NAME/host_components"&lt;/LI-CODE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 10:48:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/set-Variable-in-ambari-rest-API/m-p/294858#M217471</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2020-04-27T10:48:47Z</dc:date>
    </item>
  </channel>
</rss>

