InfluxDB_database: Make the path argument conditional on the InfluxDB version (#1126) (#1236)

Co-authored-by: Mathias Ettinger <mathias.ettinger@viveris.f>
(cherry picked from commit ce0f327875)

Co-authored-by: Mathias Ettinger <mathias@mettinger.fr>
This commit is contained in:
patchback[bot] 2020-11-06 13:48:18 +01:00 committed by GitHub
parent f1ca1ccd89
commit 24f973a9d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 4 deletions

View file

@ -9,6 +9,7 @@ __metaclass__ = type
import traceback
from ansible.module_utils.basic import missing_required_lib
from distutils.version import LooseVersion
REQUESTS_IMP_ERR = None
try:
@ -69,7 +70,6 @@ class InfluxDb():
args = dict(
host=self.hostname,
port=self.port,
path=self.path,
username=self.username,
password=self.password,
database=self.database_name,
@ -80,9 +80,13 @@ class InfluxDb():
udp_port=self.params['udp_port'],
proxies=self.params['proxies'],
)
influxdb_api_version = tuple(influxdb_version.split("."))
if influxdb_api_version >= ('4', '1', '0'):
influxdb_api_version = LooseVersion(influxdb_version)
if influxdb_api_version >= LooseVersion('4.1.0'):
# retries option is added in version 4.1.0
args.update(retries=self.params['retries'])
if influxdb_api_version >= LooseVersion('5.1.0'):
# path argument is added in version 5.1.0
args.update(path=self.path)
return InfluxDBClient(**args)