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.

configure Service Auto Start Configuration by API

Solved Go to solution
Highlighted

configure Service Auto Start Configuration by API

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

Michael-Bronson
1 ACCEPTED SOLUTION

Accepted Solutions

Re: configure Service Auto Start Configuration by API

Explorer
@uri ben-ari

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?

View solution in original post

1 REPLY 1

Re: configure Service Auto Start Configuration by API

Explorer
@uri ben-ari

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?

View solution in original post

Don't have an account?
Coming from Hortonworks? Activate your account here