add support of deleting remote identity from cli
This commit is contained in:
parent
cdd9ff55d6
commit
ab7b68a8b4
1 changed files with 16 additions and 6 deletions
|
@ -174,6 +174,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def delete(self, v):
|
def delete(self, v):
|
||||||
for n in v:
|
for n in v:
|
||||||
|
identity_id = None
|
||||||
try:
|
try:
|
||||||
apid = APIdentity.get_by_handle(n)
|
apid = APIdentity.get_by_handle(n)
|
||||||
if apid.deleted:
|
if apid.deleted:
|
||||||
|
@ -182,9 +183,21 @@ class Command(BaseCommand):
|
||||||
if apid.user:
|
if apid.user:
|
||||||
apid.user.clear()
|
apid.user.clear()
|
||||||
Takahe.request_delete_identity(apid.pk)
|
Takahe.request_delete_identity(apid.pk)
|
||||||
|
identity_id = apid.pk
|
||||||
|
except APIdentity.DoesNotExist:
|
||||||
|
s = n.split("@")
|
||||||
|
r = False
|
||||||
|
if len(s) == 2:
|
||||||
|
identity = Takahe.get_identity_by_handler(s[0], s[1])
|
||||||
|
if identity:
|
||||||
|
r = Takahe.request_delete_identity(identity.pk)
|
||||||
|
identity_id = identity.pk
|
||||||
|
if not r:
|
||||||
|
self.stdout.write(self.style.ERROR(f"identity {n} not found"))
|
||||||
|
if identity_id:
|
||||||
count_down = 10
|
count_down = 10
|
||||||
while count_down > 0:
|
while count_down > 0:
|
||||||
i = Identity.objects.filter(pk=apid.pk).first()
|
i = Identity.objects.filter(pk=identity_id).first()
|
||||||
if i and i.state != "deleted_fanned_out":
|
if i and i.state != "deleted_fanned_out":
|
||||||
self.stdout.write(f"waiting for takahe-stator...{count_down}")
|
self.stdout.write(f"waiting for takahe-stator...{count_down}")
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
@ -194,11 +207,8 @@ class Command(BaseCommand):
|
||||||
if count_down == 0:
|
if count_down == 0:
|
||||||
self.stdout.write(
|
self.stdout.write(
|
||||||
self.style.WARNING(
|
self.style.WARNING(
|
||||||
f"Identity {apid} was deleted, but some data in takahe has not been fully processed yet, make sure takahe-stator is running and wait a bit."
|
f"Identity {n} was deleted, but some data in takahe has not been fully processed yet, make sure takahe-stator is running and wait a bit."
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.stdout.write(f"Deleted identity {apid}")
|
self.stdout.write(f"Deleted identity {n}")
|
||||||
except APIdentity.DoesNotExist:
|
|
||||||
self.stdout.write(f"identity {n} not found")
|
|
||||||
continue
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue