You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

We can also get the information of a specific cluster

  1. Show a specific cluster in Ambari
    mycluster = client.get_cluster('cluster1')
    print mycluster
    print mycluster.to_json_dict()
    print"\n"

    mycluster is a ClusterModel object which has many useful methods.

  2. Show all hosts in the cluster
    clusters_hosts = mycluster.get_all_hosts()
    print clusters_hosts.to_json_dict()
    print clusters_hosts
    print"\n"
  3. Show a specific host in the cluster
    host1 = mycluster.get_host('host1')
    print host1
    print host1.clusterRef.cluster_name
    print host1.to_json_dict()
    print"\n"
  4. Show all components of a host
    host1_comp = host1.get_host_components()
    print host1_comp
    print host1_comp.to_json_dict()
    print"\n"
  5. Show a specific service of a cluster
    nn = host1.get_host_component("NAMENODE")
    print nn
    print nn.to_json_dict()
    print nn.clusterRef.cluster_name
    print"\n"
  6. Show all services in the cluster
    serviceList = mycluster.get_all_services()
    print serviceList
    print serviceList.to_json_dict()
    print"\n"
  7. Show a specific service of a cluster
    ganglia = mycluster.get_service("GANGLIA")
    print  ganglia
    print ganglia.to_json_dict()
    print"\n"
  8. Show all components of a service
    ganglia_comps = ganglia.get_service_components()
    print ganglia_comps
    print ganglia_comps.to_json_dict()
    print"\n"
  9. Show a specific component of a service
    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"
  10. Stop a service
    ganglia.stop()
  11. Satrt a service
    ganglia.start()
  • No labels