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.

AMBARI + how to set value in json REST API

Solved Go to solution
Highlighted

AMBARI + how to set value in json REST API

 

the following API example , will stop the kafka service in ambari

export service=kafka

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo":{"context":"_PARSE_.STOP.$service","operation_level":{"level":"SERVICE","cluster_name":"$CLUSTER_NAME","service_name":"$service"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://$HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/$service 

the problem is about the syntax - _PARSE_.STOP.$service

and we see that actually service value - kafka not set in - PARSE.STOP.$service

so ambri saw the name as - PARSE.STOP.$service and not PARSE.STOP.kafka

any idea how we can set the value kafka inside the json syntax?

Michael-Bronson
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: AMBARI + how to set value in json REST API

Super Mentor

@mike_bronson7 

Thank you for sharing the screenshot .. it is very clean now.

Please replace the following:

"$CLUSTER_NAME" with "'"$CLUSTER_NAME"'"
"$service" with "'"$service"'"
"_PARSE_.STOP.$service" with "'"_PARSE_.STOP.$service"'"

 

In general, Replace any value which has    $ABCD with a single quote and then quote mark as  '"$ABCD"'

 

So the over all change will be "$ABCD" ----> "'"$ABCD"'"


Stop Kafka Service:

# curl -iLv -u "admin:admin" -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo":{"context":"'"_PARSE_.STOP.$service"'","operation_level":{"level":"SERVICE","cluster_name":"'"$CLUSTER_NAME"'","service_name":"'"$service"'"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://$HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/$service

 

Start Kafka Service

# curl -iLv -u "admin:admin" -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo":{"context":"'"_PARSE_.START.$service"'","operation_level":{"level":"SERVICE","cluster_name":"'"$CLUSTER_NAME"'","service_name":"'"$service"'"}},"Body":{"ServiceInfo":{"state":"STARTED"}}}' http://$HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/$service




 

 

View solution in original post

5 REPLIES 5
Highlighted

Re: AMBARI + how to set value in json REST API

Super Mentor

@mike_bronson7 

I think the only change you will need to make is the "KAFKA" service in Uppercase because "kafka" in lowercase will not exist as a service.

Following is the example which i tested in my cluster and it works pretty fine.

# export service=kafka    (INCORRECT)

# export service=KAFKA

# curl -iLv -u "admin:admin" -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo":{"context":"_PARSE_.STOP.$service","operation_level":{"level":"SERVICE","cluster_name":"$CLUSTER_NAME","service_name":"$service"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://$HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/$service

 

In order to start KAFKA service.

# curl -iLv -u "admin:admin" -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo":{"context":"_PARSE_.START.$service","operation_level":{"level":"SERVICE","cluster_name":"$CLUSTER_NAME","service_name":"$service"}},"Body":{"ServiceInfo":{"state":"STARTED"}}}' http://$HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/$service

 

.

 

Highlighted

Re: AMBARI + how to set value in json REST API

Dear Jay

 

yes I put KAFKA and not kafka , ( just I wrote by mistake in the post kafka instead KAFKA

but with the same problem

 

Michael-Bronson
Highlighted

Re: AMBARI + how to set value in json REST API

also this is what we get from "ops" in ambari

 

you can see that ambari identify this as "$service" and not as KAFKA

 

Capture.PNG

Michael-Bronson
Highlighted

Re: AMBARI + how to set value in json REST API

Super Mentor

@mike_bronson7 

Thank you for sharing the screenshot .. it is very clean now.

Please replace the following:

"$CLUSTER_NAME" with "'"$CLUSTER_NAME"'"
"$service" with "'"$service"'"
"_PARSE_.STOP.$service" with "'"_PARSE_.STOP.$service"'"

 

In general, Replace any value which has    $ABCD with a single quote and then quote mark as  '"$ABCD"'

 

So the over all change will be "$ABCD" ----> "'"$ABCD"'"


Stop Kafka Service:

# curl -iLv -u "admin:admin" -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo":{"context":"'"_PARSE_.STOP.$service"'","operation_level":{"level":"SERVICE","cluster_name":"'"$CLUSTER_NAME"'","service_name":"'"$service"'"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://$HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/$service

 

Start Kafka Service

# curl -iLv -u "admin:admin" -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo":{"context":"'"_PARSE_.START.$service"'","operation_level":{"level":"SERVICE","cluster_name":"'"$CLUSTER_NAME"'","service_name":"'"$service"'"}},"Body":{"ServiceInfo":{"state":"STARTED"}}}' http://$HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/$service




 

 

View solution in original post

Re: AMBARI + how to set value in json REST API

Dear Jay

 

what to say - you are the best , 

well done 

 

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