mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
fix create_user for new versions of influxdb
This commit is contained in:
parent
2f28c166dd
commit
5a8a645d4b
1 changed files with 12 additions and 0 deletions
|
@ -324,6 +324,18 @@ def user_create(name, passwd, database=None, user=None, password=None,
|
|||
client = _client(user=user, password=password, host=host, port=port)
|
||||
if database:
|
||||
client.switch_database(database)
|
||||
|
||||
# influxdb 0.9+
|
||||
if hasattr(client, 'create_user'):
|
||||
try:
|
||||
client.create_user(name, passwd)
|
||||
return True
|
||||
except:
|
||||
log.exception('InfluxDB client raised an exception')
|
||||
return False
|
||||
|
||||
# influxdb 0.8 and older
|
||||
if database:
|
||||
return client.add_database_user(name, passwd)
|
||||
return client.add_cluster_admin(name, passwd)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue