]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Adding possibility to use another default LDAP instance
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 17 May 2023 09:35:06 +0000 (11:35 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 17 May 2023 09:35:06 +0000 (11:35 +0200)
etc/ldap.yaml.default
lib/pp_admintools/app/barracuda_sync.py
lib/pp_admintools/app/ldap.py

index f7f55a67b079282389ae3e761787b14e74916351..fc73cbcdc3b0975c11863fc8b22751245f8f365f 100644 (file)
@@ -22,6 +22,16 @@ ldap:
     readonly: false
     sync-source: 'dpx-prod'
     tier: 'dev'
+  dpx-dev-mail:
+    host: 'dev-ldap2.pixelpark.com'
+    ldaps: true
+    port: 636
+    base_dn: 'o=isp'
+    bind_dn: 'uid=mail-service,ou=Services,o=Pixelpark,o=isp'
+    # bind_pw: ******
+    is_admin: false
+    readonly: false
+    tier: 'dev'
   dpx-dev-ro:
     host: 'dev-ldap2.pixelpark.com'
     ldaps: true
@@ -42,6 +52,16 @@ ldap:
     is_admin: true
     readonly: false
     tier: 'prod'
+  dpx-prod-mail:
+    host: 'prd-ds.pixelpark.com'
+    ldaps: true
+    port: 636
+    base_dn: 'o=isp'
+    bind_dn: 'uid=mail-service,ou=Services,o=Pixelpark,o=isp'
+    # bind_pw: ******
+    is_admin: false
+    readonly: false
+    tier: 'prod'
   dpx-prod-ro:
     host: 'prd-ds.pixelpark.com'
     ldaps: true
index e56998daa038bf05ec4229fd2e49aa990ce84602..e41a97561b0d2fe25e5ff124d2f65b2b633d2967 100644 (file)
@@ -25,7 +25,7 @@ from fb_tools.xlate import format_list
 from .ldap import BaseLdapApplication
 from ..xlate import XLATOR
 
-__version__ = '0.6.1'
+__version__ = '0.6.2'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -83,7 +83,8 @@ class BarracudaSyncApp(BaseLdapApplication):
     use_default_ldap_connection = False
     use_multiple_ldap_connections = False
     show_cmdline_ldap_timeout = True
-    apply_default_ldap_instance_if_not_given = False
+    apply_default_ldap_instance_if_not_given = True
+    default_default_ldap_instance = 'dpx-prod-mail'
 
     # -------------------------------------------------------------------------
     def __init__(self, appname=None, base_dir=None):
index d42234d932653761ec1efa9cedc90baff6b51686..1898190544751cadaea25250068789a2ced7fae4 100644 (file)
@@ -54,7 +54,7 @@ from ..config.ldap import LdapConnectionInfo, LdapConfiguration
 # rom ..config.ldap import DEFAULT_PORT_LDAP, DEFAULT_PORT_LDAPS
 from ..config.ldap import DEFAULT_TIMEOUT
 
-__version__ = '0.11.3'
+__version__ = '0.11.4'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -171,6 +171,7 @@ class BaseLdapApplication(BaseDPXApplication):
     use_multiple_ldap_connections = False
     show_cmdline_ldap_timeout = True
     apply_default_ldap_instance_if_not_given = True
+    default_default_ldap_instance = 'default'
 
     # pattern_re_ldap_dn = (
     # '^([a-z][a-z0-9-]*)=(?![ #])(((?![\\="+,;<>]).)|(\\[ \\#="+,;<>])|(\\[a-f0-9][a-f0-9]))*'
@@ -403,7 +404,7 @@ class BaseLdapApplication(BaseDPXApplication):
             }
 
             help_default_inst = _(
-                "If not given, then the instance {!r} will be used.").format('default')
+                "If not given, then the instance {!r} will be used.").format(self.default_default_ldap_instance)
 
             help_single = _(
                 "The LDAP instance (LDAP cluster) from configuration, "
@@ -468,7 +469,7 @@ class BaseLdapApplication(BaseDPXApplication):
         self._init_default_connection()
 
         if self.use_default_ldap_connection:
-            self.ldap_instances = ['default']
+            self.ldap_instances = [self.default_default_ldap_instance]
             return
 
         LOG.debug(_("Checking given instances."))
@@ -493,7 +494,7 @@ class BaseLdapApplication(BaseDPXApplication):
                 if inst_cleared != '':
                     self.ldap_instances.append(inst.lower())
         else:
-            self.ldap_instances = ['default']
+            self.ldap_instances = [self.default_default_ldap_instance]
 
         self._verify_instances()
 
@@ -502,11 +503,11 @@ class BaseLdapApplication(BaseDPXApplication):
 
         instances = []
         for inst in self.cfg.ldap_connection.keys():
-            if inst != 'default':
+            if inst != self.default_default_ldap_instance:
                 instances.append(inst)
         instances.sort(key=str.lower)
-        if 'default' in self.cfg.ldap_connection:
-            instances.insert(0, 'default')
+        if self.default_default_ldap_instance in self.cfg.ldap_connection:
+            instances.insert(0, self.default_default_ldap_instance)
 
         max_key_len = 1
         max_tier_len = 1
@@ -593,9 +594,9 @@ class BaseLdapApplication(BaseDPXApplication):
             self.ldap_instances = filtered_instances
             return
 
-        if 'default' in self.cfg.ldap_connection:
+        if self.default_default_ldap_instance in self.cfg.ldap_connection:
             if self.apply_default_ldap_instance_if_not_given:
-                filtered_instances.insert(0, 'default')
+                filtered_instances.insert(0, self.default_default_ldap_instance)
 
         all_ok = True
         for given_inst in self.ldap_instances:
@@ -611,8 +612,8 @@ class BaseLdapApplication(BaseDPXApplication):
     # -------------------------------------------------------------------------
     def _init_default_connection(self):
 
-        if 'default' in self.cfg.ldap_connection:
-            default_connection = self.cfg.ldap_connection['default']
+        if self.default_default_ldap_instance in self.cfg.ldap_connection:
+            default_connection = self.cfg.ldap_connection[self.default_default_ldap_instance]
         else:
             default_connection = LdapConnectionInfo(
                 appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
@@ -622,7 +623,7 @@ class BaseLdapApplication(BaseDPXApplication):
                 base_dn=LdapConfiguration.default_base_dn,
                 bind_dn=LdapConfiguration.default_bind_dn,
                 initialized=False)
-            self.cfg.ldap_connection['default'] = default_connection
+            self.cfg.ldap_connection[self.default_default_ldap_instance] = default_connection
 
         v = getattr(self.args, 'ldap_host', None)
         if v: