Search code examples
ibm-cloudanalytics-engine

How to retrieve the name node host name using Ambari?


The python-ambariclient library has an api for retrieving the host_components:

ambari.services(service_name).components(component_name).host_components

How can I extract the name_node for an IBM Analytics Engine cluster?

I think I need to make the call:

GET https://xxxx.bi.services.us-south.bluemix.net:9443/api/v1/clusters/AnalyticsEngine/services/HDFS/components/NAMENODE?fields=host_components

Which retrieves the following information:

{
  "href" : "https://xxxx.bi.services.us-south.bluemix.net:9443/api/v1/clusters/AnalyticsEngine/services/HDFS/components/NAMENODE?fields=host_components",
  "ServiceComponentInfo" : {
    "cluster_name" : "AnalyticsEngine",
    "component_name" : "NAMENODE",
    "service_name" : "HDFS"
  },
  "host_components" : [
    {
      "href" : "https://xxxx.bi.services.us-south.bluemix.net:9443/api/v1/clusters/AnalyticsEngine/hosts/xxxx.bi.services.us-south.bluemix.net/host_components/NAMENODE",
      "HostRoles" : {
        "cluster_name" : "AnalyticsEngine",
        "component_name" : "NAMENODE",
        "host_name" : "xxxx.bi.services.us-south.bluemix.net"
      }
    }
  ]
}

Solution

  • I have created a library to extract this information. Install with:

    pip install --quiet --upgrade git+https://github.com/snowch/ibm-analytics-engine-python@master
    

    Then run:

    from ibm_analytics_engine import AmbariOperations
    ambari_ops = AmbariOperations(vcap_filename='./vcap.json')
    ambari_ops.get_namenode_hostname()