ambari-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sumit Mohanty <smoha...@hortonworks.com>
Subject Re: Access Ambari API through Service Install Script
Date Wed, 26 Nov 2014 01:12:43 GMT
There is another way to find out.

The command-*.json file created while invoking the INSTALL command will
have a property bag by the name of "clusterHostInfo". That has list of
hosts for various component types.

For example, one can get the list of rs_hosts using

  rs_hosts = default('/clusterHostInfo/hbase_rs_hosts', [])

In your case, you can look for
'/clusterHostInfo/<slave_component_name>_hosts'


Sample of the relevant section from a command-*.json

...
   "clusterHostInfo": {
        "ganglia_monitor_hosts": [
            "c6403.ambari.apache.org"
        ],
        "all_hosts": [
            "c6403.ambari.apache.org"
        ],
        "namenode_host": [
            "c6403.ambari.apache.org"
        ],
        "ambari_server_host": [
            "c6403.ambari.apache.org"
        ],
        "zookeeper_hosts": [
            "c6403.ambari.apache.org"
        ],
...

On Tue, Nov 25, 2014 at 4:46 PM, Yusaku Sako <yusaku@hortonworks.com> wrote:

> Can someone help?
>
> Yusaku
>
> On Sat, Nov 22, 2014 at 4:48 PM, Brian de la Motte <
> bdelamotte@zdatainc.com> wrote:
>
>> Hi everyone,
>>
>> I'm trying to integrate a custom service into Ambari. The problem is the
>> service's master during installation needs to know about the hosts that are
>> to be the service's slaves. The only way I was able to find that info was
>> by using the API.
>>
>> Is it a good idea to have the master's install script call the API to get
>> that info or is there an easier way? I think it would work but the script
>> would need to know the username and password for Ambari's API call.
>>
>> Is there a way to get the service's slave's hosts without the API or for
>> a Python script to get the admin username and password from a config in
>> order to call the API?
>>
>> The call I would possibly use is something like this:
>>
>> curl  --user admin:admin
>> http://127.0.0.1:8080/api/v1/clusters/abc/services/CUST_SERVICE/components/CUST_SERVICE_SLAVE?fields=host_components/HostRoles/host_name
>>
>>
>> I could parse out the hostnames from this but how do I make this call
>> without knowing what username and password to use.
>>
>> Any ideas or alternative methods?
>>
>> Thank you!
>>
>> Brian
>>
>
>
> CONFIDENTIALITY NOTICE
> NOTICE: This message is intended for the use of the individual or entity
> to which it is addressed and may contain information that is confidential,
> privileged and exempt from disclosure under applicable law. If the reader
> of this message is not the intended recipient, you are hereby notified that
> any printing, copying, dissemination, distribution, disclosure or
> forwarding of this communication is strictly prohibited. If you have
> received this communication in error, please contact the sender immediately
> and delete it from your system. Thank You.

-- 
CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to 
which it is addressed and may contain information that is confidential, 
privileged and exempt from disclosure under applicable law. If the reader 
of this message is not the intended recipient, you are hereby notified that 
any printing, copying, dissemination, distribution, disclosure or 
forwarding of this communication is strictly prohibited. If you have 
received this communication in error, please contact the sender immediately 
and delete it from your system. Thank You.

Mime
View raw message