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 cluster + what is the right syntax in order to upload json file

Solved Go to solution
Highlighted

ambari cluster + what is the right syntax in order to upload json file

hi all

we have ambari cluster Version 2.5.0.3 , while all clients machines are Linux redhat

first I generated the json file to my Linux machine as the following: ( on ambari server machine )

curl -H "X-Requested-By: ambari" -X GET -u admin:admin http://130.14.6.28:8080/api/v1/clusters/HDP01\?format\=blueprint > blueprint.json

then I update the blueprint.json file with some changes about the parameters and their values

finally my target is to upload the new blueprint.json to ambari cluster in order to take affect !

path=/root

curl -H "X-Requested-By: ambari" --data @ -X POST -u admin:admin http://130.14.6.28:8080/api/v1/blueprints/HDP01 -d @$path/blueprint.json

but I get the following errors ( seems because wrong syntax )

Warning: Couldn't read data from file "", this makes an empty POST. { "status" : 400, "message" : "Invalid Request: Malformed Request Body. An exception occurred parsing the request body: Unexpected character ('&' (code 38)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: java.io.StringReader@4a3484a6; line: 1, column: 3]"

please advice what is wrong in my syntax ? and what is the right syntax in order to upload the new update blueprint.json file

Michael-Bronson
1 ACCEPTED SOLUTION

Accepted Solutions

Re: ambari cluster + what is the right syntax in order to upload json file

Mentor

@uri ben-ari @Jay SenSharma

This thread have been going on endlessly, and with duplicates.. I provided you the curl step mentioned above. If an answer provided solved the initial issue please do raise another thread. As jay stated you should mark the appropriate answer as "ACCEPTED" otherwise members will not attend to your questions in the future ,personally I have posted about 4 answers to your same thread .....

13 REPLIES 13

Re: ambari cluster + what is the right syntax in order to upload json file

Super Mentor

@uri ben-ari

You should not use the > redirect operator to move the JSON response to a file ... Instead use the Curl "-o /PATH/TO/file.json") to do the same . Please try

Example:

# curl  -u admin:admin -H "X-Requested-By: ambari" -X GET http://130.14.6.28:8080/api/v1/clusters/HDP01?format=blueprint -o /tmp/HDP01_blueprint.json

.

Still if you find any issue with the JSON data then please attach the edited JSON so that we can check the JSON characters are fine or not?

Re: ambari cluster + what is the right syntax in order to upload json file

ok thx , what about the second part - curl -H "X-Requested-By: ambari" --data @ -X POST -u admin:admin http://130.14.6.28:8080/api/v1/blueprints/HDP01 -d @$path/blueprint.json

Michael-Bronson

Re: ambari cluster + what is the right syntax in order to upload json file

the json data is ok , the problem is about my syntax ( with curl .... )

Michael-Bronson

Re: ambari cluster + what is the right syntax in order to upload json file

Super Mentor

@uri ben-ari

Yes, in the POST you have twice "--data" and "-d" both are not needed together. So please try:

# curl -u admin:admin -H "X-Requested-By: ambari" -d @$path/blueprint.json -X POST  http://130.14.6.28:8080/api/v1/blueprints/HDP01

.

OR

# curl -u admin:admin -H "X-Requested-By: ambari" -X POST  http://130.14.6.28:8080/api/v1/blueprints/HDP01 -d @$path/blueprint.json 

Here the "$path/blueprint.json" needs to be replaced with the actual path like -d@/tmp/blueprint.json

.

Re: ambari cluster + what is the right syntax in order to upload json file

thx for your answer , now I get - { "status" : 409, "message" : "Attempted to create a Blueprint which already exists, blueprint_name=HDP01" }

Michael-Bronson

Re: ambari cluster + what is the right syntax in order to upload json file

Super Mentor

@uri ben-ari

Please change the blueprint name to something else inside your blueprint.json file.

If you want to see the rpeviously registered blueorint names then you can use the following kind of API:

curl  -u admin:admin -H "X-Requested-By: ambari" -X GET http://130.14.6.28:8080/api/v1/blueprints

.

Blueprint name should be unique.

Else you can delete the Old blueprints from your ambari server using the name>

curl  -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://130.14.6.28:8080/api/v1/blueprints/HDP01

.

Re: ambari cluster + what is the right syntax in order to upload json file

ok I removed the old json file and after I create the new one I get this - { "status" : 400, "message" : "Cluster Topology validation failed. Invalid service component count: [Schema_Registry(actual=3, required=5), MassFlowManager(actual=1, required=5), MassRepo(actual=1, required=5), Airflow(actual=1, required=5)]. To disable topology validation and create the blueprint, add the following to the end of the url: '?validate_topology=false'"

Michael-Bronson

Re: ambari cluster + what is the right syntax in order to upload json file

Super Mentor
@uri ben-ari

It means either you are using some services like Nifi/Oozie and few configurations are missing like "Schema_Registry", "MassFlowManager" ... etc. So the blueprint registration is failing.

The other option will be to add the "?validate_topology=false" parametere in the URL to tell ambari to not validate the blueprint so that later you can update it.

# curl -u admin:admin -H "X-Requested-By: ambari" -X POST  http://130.14.6.28:8080/api/v1/blueprints/HDP01?validate_topology=false -d @$path/blueprint.json 

Re: ambari cluster + what is the right syntax in order to upload json file

ok now its work but little problem , before I upload the blueprint .json file I change the value - yarn.scheduler.minimum-allocation-mb" , and after I upload the json file and I access to ambari GUI I see the previos value - why ? , second I also restart the ambari-server but still have the old value

Michael-Bronson