You can refer to 
https://git-wip-us.apache.org/repos/asf?p=incubator-ambari.git;a=blob_plain;
f=ambari-server/src/test/resources/test_api.sh;hb=HEAD (test_api.sh) for
sample APIs. This is a test script so I will extract out some calls with
some explanation. All the sample calls assume default values.


Create a cluster:
curl -i -X POST -u admin:admin -d '{"Clusters": {"version" : "HDP­1.3.0"}}'
http://localhost:8080/api/v1/clusters/c1

Create services (the following examples define only 4 services):
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/services/HDFS
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/services/MAPREDUCE
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/services/GANGLIA
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/services/NAGIOS

Add necessary configurations. This is critical. A  good way to ensure that
necessary configuration is provided is to capture calls made through the web
UI.
curl -i -X PUT -u admin:admin -d '{"Clusters": {"desired_config": {"type":
"core-site", "tag": "version1", "properties" : { "fs.default.name" :
"localhost:8020"}}}}' http://localhost:8080/api/v1/clusters/c1
curl -i -X PUT -u admin:admin -d '{"Clusters": {"desired_config": {"type":
"global", "tag": "version1", "properties" : { "prop1" : "value1"}}}}'
http://localhost:8080/api/v1/clusters/c1
curl -i -X PUT -u admin:admin -d '{"Clusters": {"desired_config": {"type":
"mapred-site", "tag": "version1", "properties" : { "mapred.job.tracker" :
"localhost:50300", "mapreduce.history.server.embedded": "false",
"mapreduce.history.server.http.address": "localhost:51111"}}}}'
http://localhost:8080/api/v1/clusters/c1
curl -i -X PUT -u admin:admin -d '{"Clusters": {"desired_config": {"type":
"nagios-global", "tag": "version1", "properties" : { "nagios_web_login" :
"nagiosadmin", "nagios_web_password" : "password"  }}}}'
http://localhost:8080/api/v1/clusters/c1

Create the components for the services:
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/services/HDFS/components/NAMENODE
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/services/HDFS/components/SECONDARY_
NAMENODE
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/services/HDFS/components/DATANODE
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/services/HDFS/components/HDFS_CLIEN
T
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/services/MAPREDUCE/components/JOBTR
ACKER
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/services/MAPREDUCE/components/TASKT
RACKER
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/services/GANGLIA/components/GANGLIA
_SERVER
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/services/GANGLIA/components/GANGLIA
_MONITOR
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/services/NAGIOS/components/NAGIOS_S
ERVER

Add a host to the cluster (it is assumed that the host has ambari-agent
installed and is successfully registered)
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/hosts/host1

Add host components ­ a mapping between components to hosts:
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/hosts/$AGENT_HOST/host_components/N
AMENODE
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/hosts/$AGENT_HOST/host_components/S
ECONDARY_NAMENODE
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/hosts/$AGENT_HOST/host_components/J
OBTRACKER
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/hosts/$AGENT_HOST/host_components/D
ATANODE
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/hosts/$AGENT_HOST/host_components/T
ASKTRACKER
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/hosts/$AGENT_HOST/host_components/G
ANGLIA_SERVER
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/hosts/$AGENT_HOST/host_components/G
ANGLIA_MONITOR
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/hosts/$AGENT_HOST/host_components/H
DFS_CLIENT
curl -i -X POST -u admin:admin
http://localhost:8080/api/v1/clusters/c1/hosts/$AGENT_HOST/host_components/N
AGIOS_SERVER

Install the services:
curl -i -X PUT -u admin:admin  -d '{"ServiceInfo": {"state" : "INSTALLED"}}'
http://localhost:8080/api/v1/clusters/c1/services?ServiceInfo/state=INIT

Start the services:
curl -i -X PUT -u admin:admin  -d '{"ServiceInfo": {"state" : "STARTED"}}'
http://localhost:8080/api/v1/clusters/c1/services?ServiceInfo/state=INSTALLE
D


The API documentation is at:
https://github.com/apache/ambari/blob/trunk/ambari-server/docs/api/v1/index.
md.

From:  Yusaku Sako <[email protected]>
Reply-To:  <[email protected]>
Date:  Thursday, August 1, 2013 4:19 PM
To:  <[email protected]>
Subject:  Re: Ambari Cluster Install Automation

If you had built your cluster via API calls and want the Ambari Web UI to
recognize that the cluster has been installed and that management UI should
come up (rather than the Install Wizard), please make the following call
from the Ambari Server host:

curl -i -u admin:admin -X POST -d '{ "CLUSTER_CURRENT_STATUS":
"{\"clusterState\":\"CLUSTER_STARTED_5\"}" }'
http://localhost:8080/api/v1/persist
Yusaku




On Thu, Aug 1, 2013 at 7:15 AM, Sumit Mohanty <[email protected]>
wrote:
> One way to capture the API calls would be to run the wizard (e.g. Chrome,
> View, Developer, Developer Tool) and see the API calls.
> 
> Yusaku, will be able to help you out on how to get the UI past install when
> API is used to install HDP.
> 
> I will get back with regard to the list of API calls.
> 
> -Sumit  
> 
> From:  "Kwasnicki, Chris" <[email protected]>
> Reply-To:  <[email protected]>
> Date:  Thursday, August 1, 2013 6:28 AM
> To:  "[email protected]" <[email protected]>
> Subject:  RE: Ambari Cluster Install Automation
> 
> Can you please provide the list of APIs needed for a cluster build, or how one
> would capture the steps?
> I¹ve already unsuccessfully tried using the APIs to build a cluster so any
> guidance would be appreciated.
> Even when I issued commands via the APIs beforehand, first time I went into
> the Ambari UI the wizard always came up.
> Thanks
>  
> 
> Chris Kwasnicki · 07D-1400 · BNYMellon / TSG / IAE
> [email protected] <mailto:[email protected]>  · Desk:
> (201) 395-1533 <tel:%28201%29%20395-1533>  · Mobile: (201) 538-2838
> <tel:%28201%29%20538-2838>
>  
> 
> From: Sumit Mohanty [mailto:[email protected]]
> Sent: Thursday, August 01, 2013 1:21 AM
> To: [email protected]
> Subject: Re: Ambari Cluster Install Automation
>  
> 
> Ambari APIs do not support the manifest yet. Meanwhile, you can use the
> current Ambari API to perform a completely automated install. You can capture
> the API calls while you go through the wizard to see what steps are needed.
> Otherwise, I can provide you a list of API calls needed for a basic cluster
> install.
> 
>  
> 
> -Sumit
> 
>  
> 
> From: Yusaku Sako <[email protected]>
> Reply-To: <[email protected]>
> Date: Wednesday, July 31, 2013 9:42 PM
> To: <[email protected]>
> Subject: Re: Ambari Cluster Install Automation
> 
>  
> 
> Hello Gordon,
> 
>  
> 
> You may be interested in the work going on at
> https://issues.apache.org/jira/browse/AMBARI-1783 (Specification for a cluster
> blueprint consumable by Ambari).
> 
> The idea is to be able to create a specification for the cluster (aka "cluster
> blueprint") as a json file that is fed to an Ambari API endpoint to deploy a
> cluster.
> 
>  
> 
> Yusaku
> 
>  
> 
> On Wed, Jul 24, 2013 at 9:23 AM, Gordon Bonthron <[email protected]> wrote:
> 
> Hi all,
> 
>  
> 
> I've been looking into Ambari, and have successfully set up clusters using the
> web wizard.
> 
>  
> 
> Is there any way to have this setup automated however? I'd like to be able to
> just preprovide the answers to the wizard questions, but I don't believe this
> is possible.
> 
>  
> 
> Ideally something we could trigger from our Puppet server would be great.
> 
>  
> 
> Thanks in advance for any suggestions,
> 
> Gordon
> 
>  
>  
> 
> ******************************************************
> IMPORTANT: Any information contained in this communication is intended for the
> use of the named individual or entity. All information contained in this
> communication is not intended or construed as an offer, solicitation, or a
> recommendation to purchase any security. Advice, suggestions or views
> presented in this communication are not necessarily those of Pershing LLC nor
> do they warrant a complete or accurate statement.
> 
> If you are not an intended party to this communication, please notify the
> sender and delete/destroy any and all copies of this communication. Unintended
> recipients shall not review, reproduce, disseminate nor disclose any
> information contained in this communication. Pershing LLC reserves the right
> to monitor and retain all incoming and outgoing communications as permitted by
> applicable law.
> 
> Email communications may contain viruses or other defects. Pershing LLC does
> not accept liability nor does it warrant that email communications are virus
> or defect free.
> ******************************************************



Reply via email to