This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git


The following commit(s) were added to refs/heads/master by this push:
     new 513213e  use single URL component if found, fall back to old 
five-variable method if not.
513213e is described below

commit 513213eee00b13a415227359f96fd2553e763b50
Author: Daniel Gruno <[email protected]>
AuthorDate: Sun Mar 28 20:21:45 2021 +0200

    use single URL component if found, fall back to old five-variable method if 
not.
---
 tools/plugins/elastic.py | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/tools/plugins/elastic.py b/tools/plugins/elastic.py
index a9777ec..5b77475 100755
--- a/tools/plugins/elastic.py
+++ b/tools/plugins/elastic.py
@@ -61,14 +61,24 @@ class Elastic:
         self.db_mailinglist = self.dbname + '-mailinglist'
         self.db_version = 0
 
-        ssl = config.get('elasticsearch', 'ssl', fallback=False)
-        uri = config.get('elasticsearch', 'uri', fallback='')
-        auth = None
-        if config.has_option('elasticsearch', 'user'):
-            auth = (
-                config.get('elasticsearch', 'user'),
-                config.get('elasticsearch', 'password')
-            )
+        dburl = config.get('elasticsearch', 'dburl', fallback=None)
+        if not dburl:
+            ssl = config.get('elasticsearch', 'ssl', fallback=False)
+            uri = config.get('elasticsearch', 'uri', fallback='')
+            auth = None
+            if config.has_option('elasticsearch', 'user'):
+                auth = (
+                    config.get('elasticsearch', 'user'),
+                    config.get('elasticsearch', 'password')
+                )
+            dburl = {
+                "host": config.get('elasticsearch', 'hostname', 
fallback='localhost'),
+                "port": config.get('elasticsearch', 'port', fallback=9200),
+                "use_ssl": ssl,
+                "url_prefix": uri,
+                "auth": auth,
+                "ca_certs": certifi.where(),
+            }
 
         # Always allow this to be set; will be replaced as necessary by 
wait_for_active_shards
         self.consistency = config.get("elasticsearch", "write", 
fallback="quorum")
@@ -85,14 +95,7 @@ class Elastic:
 
         self.es = Elasticsearch(
             [
-                {
-                    "host": config.get('elasticsearch', 'hostname', 
fallback='localhost'),
-                    "port": config.get('elasticsearch', 'port', fallback=9200),
-                    "use_ssl": ssl,
-                    "url_prefix": uri,
-                    "auth": auth,
-                    "ca_certs": certifi.where(),
-                }
+                dburl
             ],
             max_retries=5,
             retry_on_timeout=True,

Reply via email to