]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Add InfluxDB SSL Option
authorTobias Gall <tobias.gall@mailbox.org>
Wed, 13 Dec 2017 18:14:50 +0000 (19:14 +0100)
committerWido den Hollander <wido@42on.com>
Wed, 6 Jun 2018 13:49:54 +0000 (15:49 +0200)
Add possibility to connect to InfluxDB via https.
Also adding the option for verifying the https cert.

Signed-off-by: Tobias Gall <tobias.gall@mailbox.org>
(cherry picked from commit f5efaa2f522b7cc7497db1d5a82785e7f08b7bb0)

doc/mgr/influx.rst
src/pybind/mgr/influx/module.py

index 37aa5cd63434d9c0ac73ee4625ed089c31685f1e..066c958a0e727e581bc595d13e0e3a906be5b330 100644 (file)
@@ -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 
index 4c22c609c65928a7285f68e9f06202c7021a1a00..bf4c3942489bfb8a332b2363802bb3fbc288219c 100644 (file)
@@ -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