|
|
@ -24,20 +24,23 @@ logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
@task(autoretry_for=(Exception,), default_retry_delay=60 * 60)
|
|
|
|
@task(autoretry_for=(Exception,), default_retry_delay=60 * 60)
|
|
|
|
def push_all_users():
|
|
|
|
def push_all_users():
|
|
|
|
|
|
|
|
count = 0
|
|
|
|
for u in User.objects.all():
|
|
|
|
for u in User.objects.all():
|
|
|
|
# skip 'empty' accounts
|
|
|
|
# skip 'empty' accounts
|
|
|
|
if u.vpnuser.expiration is None:
|
|
|
|
if u.vpnuser.expiration is None:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
logger.debug("pushing user %r", u)
|
|
|
|
logger.debug("pushing user #%d %r", user.id, user)
|
|
|
|
|
|
|
|
|
|
|
|
django_lcore.sync_user(u.vpnuser, fail_silently=False)
|
|
|
|
django_lcore.sync_user(u.vpnuser, fail_silently=False)
|
|
|
|
|
|
|
|
count += 1
|
|
|
|
|
|
|
|
logger.info("pushed %d users", count)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@task(autoretry_for=(Exception,), max_retries=10, retry_backoff=True)
|
|
|
|
@task(autoretry_for=(Exception,), max_retries=10, retry_backoff=True)
|
|
|
|
def push_user(user_id):
|
|
|
|
def push_user(user_id):
|
|
|
|
user = User.objects.get(id=user_id)
|
|
|
|
user = User.objects.get(id=user_id)
|
|
|
|
logger.debug("pushing user %r", user)
|
|
|
|
logger.info("pushing user #%d %r", user.id, user)
|
|
|
|
django_lcore.sync_user(user.vpnuser, fail_silently=False)
|
|
|
|
django_lcore.sync_user(user.vpnuser, fail_silently=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -66,7 +69,6 @@ def notify_vpn_auth_fails():
|
|
|
|
NOTIFY_EVERY = timedelta(days=180) # users notified recently should be ignored
|
|
|
|
NOTIFY_EVERY = timedelta(days=180) # users notified recently should be ignored
|
|
|
|
|
|
|
|
|
|
|
|
def find_fails_for_user(u):
|
|
|
|
def find_fails_for_user(u):
|
|
|
|
return True
|
|
|
|
|
|
|
|
""" returns true if there are 'many' recent fails """
|
|
|
|
""" returns true if there are 'many' recent fails """
|
|
|
|
path = api.info["current_instance"] + "/users/" + u.username + "/auth-events/"
|
|
|
|
path = api.info["current_instance"] + "/users/" + u.username + "/auth-events/"
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|