jimbobhickville / python-ambariclient

Python client bindings for the Apache Ambari REST API
44 stars 31 forks source link

Add support for getting client config tar from service components #29

Closed dimaspivak closed 7 years ago

dimaspivak commented 7 years ago

This commit adds a get_client_config_tar() method to a new ClusterServiceComponentCollection class and modifying ambariclient.client.HttpClient to handle the specifics of a tarstream request response.

Example of code that exercises this new functionality in Python 3 is as follows:

>>> from ambariclient.client import Ambari
>>> ambari = Ambari('http://localhost:8080', username='admin', password='admin')
>>> client_config = ambari.clusters('cluster').services('HDFS').components.get_client_config_tar()
>>> client_config
<tarfile.TarFile object at 0x10e2bb8d0>
>>> client_config.getmembers()
[<TarInfo 'HDFS_CLIENT/.' at 0x10e25a9a8>, <TarInfo 'HDFS_CLIENT/hadoop-env.sh' at 0x10e25aa70>, <TarInfo 'HDFS_CLIENT/core-site.xml' at 0x10e25ab38>, <TarInfo 'HDFS_CLIENT/log4j.properties' at 0x10e25ac00>, <TarInfo 'HDFS_CLIENT/hdfs-site.xml' at 0x10e25acc8>]

I've also used the same code against Python 2.7, which works without a hitch.