Needed to handle case where no protocol was specified in configuration. So added in an if clause to check if the protocol was present

This commit is contained in:
Deepak Kaul 2020-07-06 21:54:36 +00:00
parent f162020eae
commit 3d5490b6c4

View File

@ -44,7 +44,7 @@ class Export(GlancesExport):
self.user = None self.user = None
self.password = None self.password = None
self.queue = None self.queue = None
self.protocol = 'amqp' self.protocol = None
# Optionals configuration keys # Optionals configuration keys
# N/A # N/A
@ -68,6 +68,14 @@ class Export(GlancesExport):
"""Init the connection to the rabbitmq server.""" """Init the connection to the rabbitmq server."""
if not self.export_enable: if not self.export_enable:
return None return None
# Needed for when protocol is not specified and when protocol is upper case
# only amqp and amqps supported
if self.protocol is not None and (self.protocol.lower() == 'amqps'):
self.protocol = 'amqps'
else:
self.protocol = 'amqp'
try: try:
parameters = pika.URLParameters( parameters = pika.URLParameters(
self.protocol + self.protocol +