Skip to end of metadata
Go to start of metadata

WARNING: The client library is still in the works and not production ready. 

Ambari python client can be used make use of Ambari APIs.

The first step is to create the Ambari client

Create Ambari client
from ambari_client.ambari_api import  AmbariClient
headers_dict={'X-Requested-By':'mycompany'} #Ambari needs X-Requested-By header
client = AmbariClient("localhost", 8080, "admin", "admin", version=1,http_header=headers_dict)
print client.version
print client.host_url
print"\n"

Some useful methods

  1. Show all clusters in Ambari
    all_clusters = client.get_all_clusters()
    print all_clusters.to_json_dict()
    print all_clusters
  2. Show all hosts in Ambari
    all_hosts = client.get_all_hosts()
    print all_hosts
    print all_hosts.to_json_dict()
    print"\n"