Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgr/influx: Add InfluxDB SSL Option #19374

Merged
merged 1 commit into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/mgr/influx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions src/pybind/mgr/influx/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -139,6 +141,9 @@ def set_config_option(self, option, value):
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):
Expand All @@ -155,6 +160,11 @@ def init_module_config(self):
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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you cast from String to Bool here, but how does that work when somebody changes the configuration on runtime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not recognized this dynamic option. I will fix this.
Do we want verify_ssl to be true by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


def send_to_influx(self):
if not self.config['hostname']:
Expand All @@ -169,7 +179,9 @@ def send_to_influx(self):
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
Expand Down