Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

The first step is to get the Ambari client

Code Block
languagepython
titleCreate Ambari client
firstline1
linenumberstrue
from ambari_client.ambari_api import  AmbariClient

...


client = AmbariClient("localhost", 8080, "admin", "admin", version=1)

...


print client.version

...


print client.host_url

...


print"\n"

...

Some useful methods

  1. Code Block
    languagepython
    titles

######################################

  1. High level
    ######################################
    all_clusters = client.get_all_clusters()

    
    print all_clusters.to_json_dict()

    
    print all_clusters
  2. Code Block
    languagepython
    titleShow all hosts in Amabri
    firstline1
    linenumberstrue
    all_hosts = client.get_all_hosts()

...

  1. 
    print all_hosts

...

  1. 
    print all_hosts.to_json_dict()

...

  1. 
    print"\n"

######################################

...