Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

configure Service Auto Start Configuration by API

avatar

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

avatar
Contributor
@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

avatar
Contributor
@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?