<?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 Ambari API to restart all the services with stale configurations ? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115331#M26129</link>
    <description>&lt;P&gt;Is there any single curl command to restart all the services with stale configurations using Ambari API ?&lt;/P&gt;</description>
    <pubDate>Tue, 26 Apr 2016 00:35:42 GMT</pubDate>
    <dc:creator>KuldeepK</dc:creator>
    <dc:date>2016-04-26T00:35:42Z</dc:date>
    <item>
      <title>Ambari API to restart all the services with stale configurations ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115331#M26129</link>
      <description>&lt;P&gt;Is there any single curl command to restart all the services with stale configurations using Ambari API ?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 00:35:42 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115331#M26129</guid>
      <dc:creator>KuldeepK</dc:creator>
      <dc:date>2016-04-26T00:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari API to restart all the services with stale configurations ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115332#M26130</link>
      <description>&lt;P&gt;Unfortunately this is not a part of the release branch. The patch is committed to trunk and scheduled for 2.4.0.&lt;/P&gt;&lt;P&gt;&lt;A href="https://issues.apache.org/jira/browse/AMBARI-14394" target="_blank"&gt;https://issues.apache.org/jira/browse/AMBARI-14394&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 01:17:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115332#M26130</guid>
      <dc:creator>sidwagle</dc:creator>
      <dc:date>2016-04-26T01:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari API to restart all the services with stale configurations ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115333#M26131</link>
      <description>&lt;P&gt;Thanks &lt;A rel="user" href="https://community.cloudera.com/users/399/swagle.html" nodeid="399"&gt;@swagle&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 02:48:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115333#M26131</guid>
      <dc:creator>KuldeepK</dc:creator>
      <dc:date>2016-04-26T02:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari API to restart all the services with stale configurations ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115334#M26132</link>
      <description>&lt;P&gt;Okay till we get single command, I have created below script which can be useful for others who has same question &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;[root@sandbox test12334]# cat ambari.props
CLUSTER_NAME=Sandbox
AMBARI_ADMIN_USER=admin
AMBARI_ADMIN_PASSWORD=admin
AMBARI_HOST=sandbox.hortonworks.com&lt;/PRE&gt;&lt;PRE&gt;[root@sandbox test12334]# cat restart_services.sh
#!/bin/bash
#Author - Kuldeep Kulkarni (http://crazyadmins.com)
#############
LOC=`pwd`
PROP=ambari.props
source $LOC/$PROP
#############
start_stale_services()
{
echo "curl -u $AMBARI_ADMIN_USER:$AMBARI_ADMIN_PASSWORD http://$AMBARI_HOST:8080/api/v1/clusters/Sandbox/host_components?HostRoles/stale_configs=true&amp;amp;fields=HostRoles/service_name,HostRoles/host_name&amp;amp;minimal_response=false"&amp;gt; /tmp/curl_ambari.sh
sh /tmp/curl_ambari.sh 1 &amp;gt; /tmp/stale_services_json 2&amp;gt;/dev/null
sleep 1
grep host_components /tmp/stale_services_json|grep -v stale|rev|cut -d'"' -f2|rev &amp;gt; /tmp/list_of_components
for URL in `cat /tmp/list_of_components`
do
curl -u $AMBARI_ADMIN_USER:$AMBARI_ADMIN_PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{"HostRoles": {"state": "INSTALLED"}}' "$URL"
sleep 0.5
curl -u $AMBARI_ADMIN_USER:$AMBARI_ADMIN_PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{"HostRoles": {"state": "STARTED"}}' "$URL"
done
}
start_stale_services&lt;/PRE&gt;&lt;P&gt;Note - to run this script, you should have ambari.props and script at the same location.&lt;/P&gt;&lt;P&gt;I tried below curl call to stop all/start all but it did not clear the stale service restart alerts hence I had to come up with above workaround.&lt;/P&gt;&lt;PRE&gt;curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Stop HDFS via REST"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}' &lt;A href="http://AMBARI_SERVER_HOST:8080/api/v1/clusters/CLUSTER_NAME/services" target="_blank"&gt;http://AMBARI_SERVER_HOST:8080/api/v1/clusters/CLUSTER_NAME/services&lt;/A&gt;&lt;/PRE&gt;&lt;PRE&gt;curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Stop HDFS via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}' &lt;A href="http://AMBARI_SERVER_HOST:8080/api/v1/clusters/CLUSTER_NAME/services" target="_blank"&gt;http://AMBARI_SERVER_HOST:8080/api/v1/clusters/CLUSTER_NAME/services&lt;/A&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Apr 2016 02:54:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115334#M26132</guid>
      <dc:creator>KuldeepK</dc:creator>
      <dc:date>2016-04-26T02:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari API to restart all the services with stale configurations ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115335#M26133</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/399/swagle.html" nodeid="399"&gt;@swagle&lt;/A&gt; ^^&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 02:55:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115335#M26133</guid>
      <dc:creator>KuldeepK</dc:creator>
      <dc:date>2016-04-26T02:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari API to restart all the services with stale configurations ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115336#M26134</link>
      <description>&lt;P&gt;The Start All/Stop All works just the same although there is a slight delay in updating the state which would mean stae alert not cleared immediately. I believe we send config tags from the agent only after a certain number if heartbeats.&lt;/P&gt;&lt;P&gt;However, what you have in the scrip is exactly what the UI does, so that should work just fine. (+1)&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 02:58:26 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115336#M26134</guid>
      <dc:creator>sidwagle</dc:creator>
      <dc:date>2016-04-26T02:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari API to restart all the services with stale configurations ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115337#M26135</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/399/swagle.html" nodeid="399"&gt;@swagle&lt;/A&gt; Thank you. I will check with start all/stop all again.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 03:11:10 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-API-to-restart-all-the-services-with-stale/m-p/115337#M26135</guid>
      <dc:creator>KuldeepK</dc:creator>
      <dc:date>2016-04-26T03:11:10Z</dc:date>
    </item>
  </channel>
</rss>

