Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 09-06-2017 02:48 PM
I do the following API in order to enable all services in ambari cluster to start automatically on system
first I collect all components:
list_of_all_components=` curl -H "X-Requested-By: ambari" -u admin:admin -X GET "http://localhost:8080/api/v1/clusters/HDP01/components?fields=ServiceComponentInf/component_name,ServiceComponentInfo/service_name,ServiceComponentInfo/categoy,ServiceComponentInfo/recovery_enabled,ServiceComponentInfo/total_count&minimal_response=true" | grep component_name | sed s'/"//g' | sed s'/,//g' | awk '{print $NF}' `
then I add the field separator ","
LIST=` echo $list_of_all_components | sed s'/ /,/g' `
and I defined the variable - $LIST inside the following API
curl -H "X-Requested-By: ambari" -u admin:admin -X PUT -d '{"RequestInfo":{"query":"ServiceComponentInfo/component_name.in($LIST)"},"ServiceComponentInfo":{"recovery_enabled":"true"}}' http://localhost:8080/api/v1/clusters/HDP01/components?
what is wrong with this , why API not accepted the variable - $LIST
{ "status" : 500, "message" : "org.apache.ambari.server.controller.spi.SystemException: An internal system exception occurred: Could not find service for component, componentName=$LIST, clusterName=HDP01, stackInfo=HDP-2.6"
remark - the answer - https://community.hortonworks.com/questions/135367/service-auto-start-configuration-by-api.html , is the same solution but have the real names components , what we want is to add the variable $LIST insted the real componets name
Created 09-06-2017 11:23 PM
Please try the curl command with double quotes (escaping the double quotes needed as part of curl rrequest)
curl -H "X-Requested-By: ambari" -u admin:admin -X PUT -d "{\"RequestInfo\":{\"query\":\"ServiceComponentInfo/component_name.in(${LIST})\"},\"ServiceComponentInfo\":{\"recovery_enabled\":\"true\"}}" http://localhost:8080/api/v1/clusters/HDP01/components?
Created 09-06-2017 11:23 PM
Please try the curl command with double quotes (escaping the double quotes needed as part of curl rrequest)
curl -H "X-Requested-By: ambari" -u admin:admin -X PUT -d "{\"RequestInfo\":{\"query\":\"ServiceComponentInfo/component_name.in(${LIST})\"},\"ServiceComponentInfo\":{\"recovery_enabled\":\"true\"}}" http://localhost:8080/api/v1/clusters/HDP01/components?