From: Tobias Gall Date: Wed, 13 Dec 2017 18:14:50 +0000 (+0100) Subject: Add InfluxDB SSL Option X-Git-Tag: v12.2.6~32^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=cefe81dbab636fa9bf7fd2fdfc61f274bae8056e;p=ceph.git Add InfluxDB SSL Option Add possibility to connect to InfluxDB via https. Also adding the option for verifying the https cert. Signed-off-by: Tobias Gall (cherry picked from commit f5efaa2f522b7cc7497db1d5a82785e7f08b7bb0) --- diff --git a/doc/mgr/influx.rst b/doc/mgr/influx.rst index 37aa5cd63434d..066c958a0e727 100644 --- a/doc/mgr/influx.rst +++ b/doc/mgr/influx.rst @@ -53,7 +53,8 @@ Additional optional configuration settings are: :interval: Time between reports to InfluxDB. Default 5 seconds. :database: InfluxDB database name. Default "ceph". You will need to create this database and grant write privileges to the configured username or the username must have admin privileges to create it. :port: InfluxDB server port. Default 8086 - +:ssl: Use https connection for InfluxDB server. Use "true" or "false". Default false +:verify_ssl: Verify https cert for InfluxDB server. Use "true" or "false". Default true --------- Debugging diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index 4c22c609c6592..bf4c3942489bf 100644 --- a/src/pybind/mgr/influx/module.py +++ b/src/pybind/mgr/influx/module.py @@ -44,7 +44,9 @@ class Module(MgrModule): 'database': 'ceph', 'username': None, 'password': None, - 'interval': 5 + 'interval': 5, + 'ssl': 'false', + 'verify_ssl': 'true' } def __init__(self, *args, **kwargs): @@ -139,6 +141,9 @@ class Module(MgrModule): if option == 'interval' and value < 5: raise RuntimeError('interval should be set to at least 5 seconds') + if option in ['ssl', 'verify_ssl']: + value = value.lower() == 'true' + self.config[option] = value def init_module_config(self): @@ -155,6 +160,11 @@ class Module(MgrModule): self.config['interval'] = \ int(self.get_config("interval", default=self.config_keys['interval'])) + ssl = self.get_config("ssl", default=self.config_keys['ssl']) + self.config['ssl'] = ssl.lower() == 'true' + verify_ssl = \ + self.get_config("verify_ssl", default=self.config_keys['verify_ssl']) + self.config['verify_ssl'] = verify_ssl.lower() == 'true' def send_to_influx(self): if not self.config['hostname']: @@ -169,7 +179,9 @@ class Module(MgrModule): client = InfluxDBClient(self.config['hostname'], self.config['port'], self.config['username'], self.config['password'], - self.config['database']) + self.config['database'], + self.config['ssl'], + self.config['verify_ssl']) # using influx client get_list_database requires admin privs, # instead we'll catch the not found exception and inform the user if