Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How can we put the host in Maintenance mode through REST api?

Highlighted

How can we put the host in Maintenance mode through REST api?

Expert Contributor
 
6 REPLIES 6

Re: How can we put the host in Maintenance mode through REST api?

Ram, please check step 3 in:

https://cwiki.apache.org/confluence/display/AMBARI/Using+APIs+to+delete+a+service+or+all+host+compon...

This has to be done component wise for the given host.

Re: How can we put the host in Maintenance mode through REST api?

Expert Contributor

So, there is no REST api to put the host in maintenance mode. It has to be done component by component on host right? Can you please check this thread and let me know the process? https://community.hortonworks.com/questions/21761/how-can-we-do-os-updates-in-the-real-time-prod-clu...

Re: How can we put the host in Maintenance mode through REST api?

New Contributor

@Ram D

http://c6401.ambari.apache.org:8080/api/v1/clusters/c1/hosts -X PUT -d

{"RequestInfo":{"context":"Turn On Maintenance Mode for host","query":"Hosts/host_name.in(c6401.ambari.apache.org)"},"Body":{"Hosts":{"maintenance_state":"ON"}}}

You can get this query and data from the Developer Tools (Network) in Chrome when you are on the hosts page. Click on the Host Actions menu and click Turn On Maintenance Mode.

Re: How can we put the host in Maintenance mode through REST api?

Rising Star

@Ram D See below, username and password are admin user id and password for Ambari. Below example is for Yarn.

curl -k -u <username>:<password> -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Turn on Maintenance for YARN"},"Body":{"ServiceInfo":{"maintenance_state":"ON"}}}'http://<AMBARISERVERFQDN>:8080/api/v1/clusters/<CLUSTERNAME>/services/YARN

curl -k -u <username>:<password> -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Turn off Maintenance for YARN"},"Body":{"ServiceInfo":{"maintenance_state":"OFF"}}}'http://<AMBARISERVERFQDN>:8080/api/v1/clusters/<CLUSTERNAME>/services/YARN

Re: How can we put the host in Maintenance mode through REST api?

New Contributor

What is the curl command to put one node to a maintenance mode ? I can put multiple.

curl -u user -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context:"Turn Off Maintenance Mode for host","query":"Hosts/host_name.in(host1,host2)"},"Body":{"Hosts":{"maintenance_state":"OFF"}}}' http://ambari_host:8080/api/v1/clusters/comcastdrcluster/hosts

Is there an open library where i can see what curl commands we can do?

Regards

Meena Rajani

Re: How can we put the host in Maintenance mode through REST api?

New Contributor

Both of these worked

curl -u user -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Turn Off Maintenance Mode for host","query":"Hosts/host_name.in(host1,host2)"},"Body":{"Hosts":{"maintenance_state":"OFF"}}}' http://ambari_host:8080/api/v1/clusters/clustername/hosts



curl -u user -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Turn Off Maintenance Mode for host","query":"Hosts/host_name.in(host1)"},"Body":{"Hosts":{"maintenance_state":"OFF"}}}' http://ambari_host:8080/api/v1/clusters/clustername/hosts
Don't have an account?
Coming from Hortonworks? Activate your account here