- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How can I setting the rack ID in Ambari API?
- Labels:
-
Apache Ambari
Created 12-02-2015 02:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have to build a large cluster, for which I’ll need to set rack ID many times. I know two methods in Ambari Web for setting the Rack ID. http://docs.hortonworks.com/HDPDocuments/Ambari-2.1.2.0/bk_Ambari_Users_Guide/content/ch03s11.html
So I want to know if I can write a script which sets the rack ID in Ambari API
Ambari: 2.1.2.1 Hadoop: HDP2.3.0
Created 12-02-2015 03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The hosts table in the database has a field called rack_info that supports up to 255 chars. It can be edited from the UI in the Host page for a single host.
In order to edit it using the API, you can make a single request to edit it for x number of hosts. E.g.,
curl -u $username:$password -X PUT -H 'X-Requested-By:admin' http://$server:8080/api/v1/clusters/$clustername/hosts -d '{"RequestInfo":{"context":"Set Rack","query":"Hosts/host_name.in($FQDN_1,$FQDN_2,$FQDN_3)"},"Body":{"Hosts":{"rack_info":"/my_new_rack_value"}}}'
Actual call,
curl -u admin:admin -X PUT -H 'X-Requested-By:admin' http://c6401.ambari.apache.org:8080/api/v1/clusters/c1/hosts -d '{"RequestInfo":{"context":"Set Rack","query":"Hosts/host_name.in(c6401.ambari.apache.org,c6402.ambari.apache.org,c6403.ambari.apache.org)"},"Body":{"Hosts":{"rack_info":"/my_new_rack_value"}}}'
Created 12-02-2015 02:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please see this
With the latest Ambari UI code you should see an option to set the rack info for each host. You can also set the rack info property through the API ...
PUT api/v1/clusters/c1/hosts/[host_name] { "Hosts" : { "rack_info" : "/rack-01" }
}
Created 12-02-2015 03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The hosts table in the database has a field called rack_info that supports up to 255 chars. It can be edited from the UI in the Host page for a single host.
In order to edit it using the API, you can make a single request to edit it for x number of hosts. E.g.,
curl -u $username:$password -X PUT -H 'X-Requested-By:admin' http://$server:8080/api/v1/clusters/$clustername/hosts -d '{"RequestInfo":{"context":"Set Rack","query":"Hosts/host_name.in($FQDN_1,$FQDN_2,$FQDN_3)"},"Body":{"Hosts":{"rack_info":"/my_new_rack_value"}}}'
Actual call,
curl -u admin:admin -X PUT -H 'X-Requested-By:admin' http://c6401.ambari.apache.org:8080/api/v1/clusters/c1/hosts -d '{"RequestInfo":{"context":"Set Rack","query":"Hosts/host_name.in(c6401.ambari.apache.org,c6402.ambari.apache.org,c6403.ambari.apache.org)"},"Body":{"Hosts":{"rack_info":"/my_new_rack_value"}}}'
Created 12-16-2015 01:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It worked! Thank you.
