Created on
02-24-2020
06:43 AM
- last edited on
02-24-2020
08:22 AM
by
ask_bill_brooks
Hello
Anybody knows how can i turn on/off maintenance mode for host via API ?
Created 02-24-2020 12:01 PM
In order to turn ON maintenance mode for Host "abcd.example.com"
# curl -iLvk -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Turn On Maintenance Mode for host","query":"Hosts/host_name.in(abcd.example.com)"},"Body":{"Hosts":{"maintenance_state":"ON"}}}' ttp://ambariserver.example.com:8080/api/v1/clusters/DemoCluster/hosts
In order to turn OFF maintenance mode for Host "abcd.example.com"
# curl -iLvk -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Turn On Maintenance Mode for host","query":"Hosts/host_name.in(abcd.example.com)"},"Body":{"Hosts":{"maintenance_state":"OFF"}}}' ttp://ambariserver.example.com:8080/api/v1/clusters/DemoCluster/hosts
.
Please change the Cluster Name "DemoCluster" and hostnames of ambari server and intended host , credentials in the above above example API calls.
Created 03-02-2020 02:30 AM
Created 03-02-2020 03:04 AM
Most the API calls will remain same/similar in Ambari 2.7 and previous releases.
Ambari 2.7 has a cool new feature where it is integrated with Swagger and you can try and explore all the REST APIs.
Steps to use Swagger
For more information on this please refer to : https://community.cloudera.com/t5/Community-Articles/How-To-Use-Swagger-with-Ambari-Explore-Ambari-R...
If your question is answered then, Please make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.