def remove_membership_task(image_version, group): celery_logger.debug("remove_membership_task task started at %s." % timezone.now()) try: remove_membership(image_version, group) celery_logger.debug("remove_membership_task task finished at %s." % timezone.now()) except Exception as exc: celery_logger.exception(exc) remove_membership_task.retry(exc=exc)
def _clean_memberships(db_machines, acct_driver=None): """ For each db_machine, check the # of shared access. If the # is >128, this application was made in error and should be 'cleaned' so it can be re-built in the next run of 'monitor_machines' """ for db_machine in db_machines: members_qs = db_machine.members.all() group_key = 'group__name' if members_qs.count() < 128: members_qs = db_machine.application_version.membership.all() if members_qs.count() < 128: members_qs = db_machine.application.applicationmembership_set.all() group_key = 'group_ptr__name' if members_qs.count() < 128: continue for member in members_qs.order_by(group_key): image_version = db_machine.application_version remove_membership(image_version, member.group, acct_driver)
def perform_destroy(self, instance): remove_membership(instance.image_version, instance.group) instance.delete()