def run(dry_run, gitlab_project_id=None, thread_pool_size=10, enable_deletion=False, send_mails=False): settings = queries.get_app_interface_settings() users = queries.get_users() g = init_github() results = threaded.run(get_user_company, users, thread_pool_size, github=g) users_to_delete = get_users_to_delete(results) if not dry_run and enable_deletion: mr_cli = mr_client_gateway.init(gitlab_project_id=gitlab_project_id) for user in users_to_delete: username = user['username'] paths = user['paths'] logging.info(['delete_user', username]) if not dry_run: if send_mails: send_email_notification(user, settings) elif enable_deletion: mr = CreateDeleteUser(username, paths) mr.submit(cli=mr_cli) else: msg = ('\'delete\' action is not enabled. ' 'Please run the integration manually ' 'with the \'--enable-deletion\' flag.') logging.warning(msg)
def run(dry_run, gitlab_project_id=None, thread_pool_size=10): users = init_users() user_specs = threaded.run(init_user_spec, users, thread_pool_size) users_to_delete = [(username, paths) for username, delete, paths in user_specs if delete] if not dry_run: mr_cli = mr_client_gateway.init(gitlab_project_id=gitlab_project_id, sqs_or_gitlab='gitlab') for username, paths in users_to_delete: logging.info(['delete_user', username]) if not dry_run: mr = CreateDeleteUser(username, paths) mr.submit(cli=mr_cli)
def run(dry_run, gitlab_project_id=None): users = init_users() ldap_users = ldap_client.get_users([u['username'] for u in users]) users_to_delete = [u for u in users if u['username'] not in ldap_users] if not dry_run: mr_cli = mr_client_gateway.init(gitlab_project_id=gitlab_project_id, sqs_or_gitlab='gitlab') for u in users_to_delete: username = u['username'] paths = u['paths'] logging.info(['delete_user', username]) if not dry_run: mr = CreateDeleteUser(username, paths) mr.submit(cli=mr_cli)
def run(dry_run, gitlab_project_id=None): users = init_users() with LdapClient.from_settings(queries.get_app_interface_settings()) as ldap_client: ldap_users = ldap_client.get_users([u["username"] for u in users]) users_to_delete = [u for u in users if u["username"] not in ldap_users] if not dry_run: mr_cli = mr_client_gateway.init( gitlab_project_id=gitlab_project_id, sqs_or_gitlab="gitlab" ) for u in users_to_delete: username = u["username"] paths = u["paths"] logging.info(["delete_user", username]) if not dry_run: mr = CreateDeleteUser(username, paths) mr.submit(cli=mr_cli)