commit 19da3eb01d689c5c24424df9c1de0c5057d28a97 Author: Florian Best Date: Wed Oct 2 11:34:16 2019 +0200 Bug #50301: add remove_*_rejected.py --all diff --git a/services/univention-s4-connector/scripts/remove_s4_rejected.py b/services/univention-s4-connector/scripts/remove_s4_rejected.py index bb39bce681..d6d140531f 100755 --- a/services/univention-s4-connector/scripts/remove_s4_rejected.py +++ b/services/univention-s4-connector/scripts/remove_s4_rejected.py @@ -52,10 +52,24 @@ def remove_s4_rejected(s4_dn): cache_db.close() +def remove_all_s4_rejects(): + cache_db = sqlite3.connect('/etc/univention/connector/s4internal.sqlite') + c = cache_db.cursor() + c.execute("DELETE FROM 'S4 rejected'") + cache_db.commit() + cache_db.close() + + if __name__ == '__main__': parser = OptionParser(usage='remove_s4_rejected.py dn') + parser.add_option('--all', action='store_true') (options, args) = parser.parse_args() + if options.all: + remove_all_s4_rejects() + print('The rejected S4 objects have been removed.') + sys.exit(0) + if len(args) != 1: parser.print_help() sys.exit(2) diff --git a/services/univention-s4-connector/scripts/remove_ucs_rejected.py b/services/univention-s4-connector/scripts/remove_ucs_rejected.py index 48d11adcfe..d70616c491 100755 --- a/services/univention-s4-connector/scripts/remove_ucs_rejected.py +++ b/services/univention-s4-connector/scripts/remove_ucs_rejected.py @@ -57,10 +57,30 @@ def remove_ucs_rejected(ucs_dn): cache_db.close() +def remove_all_ucs_rejected(): + cache_db = sqlite3.connect('/etc/univention/connector/s4internal.sqlite') + c = cache_db.cursor() + c.execute("SELECT key FROM 'UCS rejected'") + filenames = c.fetchall() + for filename in filenames: + if filename: + if os.path.exists(filename[0]): + os.remove(filename[0]) + c.execute("DELETE FROM 'UCS rejected'") + cache_db.commit() + cache_db.close() + + if __name__ == '__main__': parser = OptionParser(usage='remove_ucs_rejected.py dn') + parser.add_option('--all', action='store_true') (options, args) = parser.parse_args() + if options.all: + print('The rejected UCS objects have been removed.') + remove_all_ucs_rejected() + sys.exit(0) + if len(args) != 1: parser.print_help() sys.exit(2)