Skip to content
Snippets Groups Projects
Unverified Commit 5d402351 authored by PICHOU Kyâne's avatar PICHOU Kyâne
Browse files

Support Influx without authentication

parent 8eb327f3
No related branches found
No related tags found
1 merge request!2Vmagent
......@@ -26,8 +26,8 @@ def influxb_connect(config):
:returns: InfluxDBClient object
"""
# Check configuration file
if 'url' not in config and 'user' not in config and 'password' not in config and 'database' not in config:
print('You need to add influxdb URL, user, password and database to configuration file.')
if 'url' not in config and 'database' not in config:
print('You need to add influxdb URL and database to configuration file.')
sys.exit(1)
# Parse influx connection string
......@@ -49,15 +49,26 @@ def influxb_connect(config):
# Connect to influx db
try:
client = InfluxDBClient(
host=o.hostname,
port=port,
username=config['user'],
password=config['password'],
database=config['database'],
ssl=ssl,
verify_ssl=verify
)
if 'user' in config and 'password' in config:
# Influx authentication enabled
client = InfluxDBClient(
host=o.hostname,
port=port,
username=config['user'],
password=config['password'],
database=config['database'],
ssl=ssl,
verify_ssl=verify
)
else:
# Influx authentication disabled
client = InfluxDBClient(
host=o.hostname,
port=port,
database=config['database'],
ssl=ssl,
verify_ssl=verify
)
client.ping()
return client
except Exception as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment