Python client can be used to create a cluster.
Below lines of code show how you can create a cluster from scratch.It is assumed that all nodes have the agents running and configured and as such there is no need to bootstrap the nodes.
Note |
---|
This feature is still not available in the trunk as of Sept-5-2013.And will be available soon.currently under work for 1.6.0+ |
Code Block |
---|
language | python |
---|
title | 1. get the client object |
---|
firstline | 1 |
---|
linenumbers | true |
---|
|
client = AmbariClient("localhost", 8080, "admin", "admin", version=1)
print client.version
print client.host_url
print"\n"
|
...
Note |
---|
We have not bootstrapped the nodes, It is assumed that the nodes are registered . if not we can register them with below api Code Block |
---|
| client.bootstrap_hosts(self , hosts_list , ssh_key=None) |
|
Code Block |
---|
language | python |
---|
title | 3. create services |
---|
firstline | 1 |
---|
linenumbers | true |
---|
|
services_list = ["HDFS", "MAPREDUCE", "NAGIOS", "GANGLIA"]
s2 = mycluster.create_services(services_list)
print s2 |
...
Code Block |
---|
language | python |
---|
title | 9. Start all services and run smoke test |
---|
firstline | 1 |
---|
linenumbers | true |
---|
|
s4 = mycluster.start_all_services(run_smoke_test=True)
print s4
print"\n" |
wait for some time and you can check http://localhost:8080/#/main/dashboard to see the cluster up and running