[sysadmin-bin] Additional option to sync the foundation LDAP group with mailusers so that export-mails.py will be a



commit 6ac6b9ab7ed5307fb729d246da0d8cb6480f4a29
Author: Andrea Veri <av gnome org>
Date:   Sun Sep 28 00:26:46 2014 +0200

    Additional option to sync the foundation LDAP group with mailusers so that export-mails.py will be able 
to create aliases automatically when someone joins the foundation group

 membership/foundation-operations.py |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/membership/foundation-operations.py b/membership/foundation-operations.py
index e2ad9c5..e59a5c7 100755
--- a/membership/foundation-operations.py
+++ b/membership/foundation-operations.py
@@ -21,10 +21,14 @@ parser.add_option("--automatic-subscriptions",
                   action="store_true", default=False,
                   help="Automatically subscribes new Foundation members to the foundation-announce "
                        "mailing list. To be executed on smtp.gnome.org")
+parser.add_option("--sync-foundation-with-mailusers",
+                  action="store_true", default=False,
+                  help="Make sure foundation LDAP group members are synced to the mailusers group "
+                       "which is then exported through the export-mail.py script"
 
 (options, args) = parser.parse_args()
 
-LDAP_GROUP_BASE='cn=groups,cn=accounts,dc=gnome,dc=org'
+LDAP_GROUP_BASE='cn=groups,cn=compat,dc=gnome,dc=org'
 LDAP_USER_BASE='cn=users,cn=accounts,dc=gnome,dc=org'
 
 TODAY = strftime("%Y-%m-%d", gmtime())
@@ -63,7 +67,7 @@ def _parse_members_from_group(group):
 
     return members
 
-def _get_foundation_members():
+def  _get_foundation_members():
     foundationmembers = _parse_members_from_group('foundation')
 
     return foundationmembers
@@ -96,6 +100,18 @@ def _get_foundation_fields_from_ldap():
         else:
            pass
 
+def sync_user_to_ldap_mailusers(member):
+        add_members = [(ldap.MOD_ADD, 'member', 'uid=%s,cn=users,cn=accounts,dc=sweetrevenge,dc=it' % 
(member))]
+        l.modify_s('cn=mailusers,cn=groups,cn=accounts,dc=sweetrevenge,dc=it', add_members)
+
+def _sync_foundation_with_mailusers():
+    foundationmembers = _get_foundation_members()
+    mailusers = _parse_members_from_group('mailusers')
+
+    for member in foundationmembers:
+        if member not in mailusers:
+            sync_user_to_ldap_mailusers(member)
+
 def send_form_letters(form_letter, email, name):
     try:
         msg = MIMEText(form_letter)
@@ -242,5 +258,8 @@ def main():
     if options.automatic_subscriptions:
         subscribe_new_members()
 
+    if options.sync_foundation_with_mailusers:
+        _sync_foundation_with_mailusers()
+
 if __name__ == "__main__":
     main()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]