THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
Amabri Ambari python client can be used make use of Ambari APIs.
The first step is to get create the Ambari client
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
from ambari_client.ambari_api import AmbariClient client = AmbariClient("localhost", 8080, "admin", "admin", version=1) print client.version print client.host_url print"\n" |
...
Code Block language python title Show all clusters in Amabri firstline 1 linenumbers true all_clusters = client.get_all_clusters() print all_clusters.to_json_dict() print all_clusters
Code Block language python title Show all hosts in Amabri firstline 1 linenumbers true all_hosts = client.get_all_hosts() print all_hosts print all_hosts.to_json_dict() print"\n"
######################################
We can also get the information of a specific cluster
going into a specific clusterCode Block language python title Show a specific cluster in Amabri firstline 1 linenumbers true cluster =
######################################
cluster =client.get_cluster('test6')
print cluster
print cluster.to_json_dict()
print"\n"
Code Block language python title Show all hosts in the cluster firstline 1 linenumbers true clusters_hosts = cluster.get_all_hosts()
...
print clusters_hosts.to_json_dict()
...
print clusters_hosts
...
print"\n"
Code Block language python title Show a specific host in the cluster firstline 1 linenumbers true r01wn01_host = cluster.get_host('r01wn01')
...
print r01wn01_host
...
print r01wn01_host.clusterRef.cluster_name
...
print r01wn01_host.to_json_dict()
...
print"\n"
Code Block language python title Show all components of a host firstline 1 linenumbers true r01wn01_host_comp = r01wn01_host.get_host_components()
...
print r01wn01_host_comp
...
print r01wn01_host_comp.to_json_dict()
...
print"\n"
Code Block language python title Show a specific service of a cluster firstline 1 linenumbers true nn = r01wn01_host.get_host_component("NAMENODE")
...
print nn
...
print nn.to_json_dict()
...
print nn.clusterRef.cluster_name
...
print"\n"
Code Block language python title Show all services in the cluster firstline 1 linenumbers true serviceList = cluster.get_all_services()
...
print serviceList
...
print serviceList.to_json_dict()
...
print"\n"
Code Block language python title Show a specific service of a cluster firstline 1 linenumbers true ganglia = cluster.get_service("GANGLIA")
...
print ganglia
...
print ganglia.to_json_dict()
...
print"\n"
Code Block language python title Show all components of a service firstline 1 linenumbers true ganglia_comps = ganglia.get_service_components()
...
print ganglia_comps
...
print ganglia_comps.to_json_dict()
...
print"\n"
Code Block language python title Show a specific component of a service firstline 1 linenumbers true ganglia_comp1 = ganglia.get_service_component('GANGLIA_MONITOR')
...
print ganglia_comp1
...
print ganglia_comp1.to_json_dict()
...
print ganglia_comp1.clusterRef.cluster_name
...
print"\n"
Code Block language python title Stop a service firstline 1 linenumbers true ganglia.stop()
Code Block language python title Satrt a service firstline 1 linenumbers true ganglia.start()