removing volume on deleting user
This commit is contained in:
parent
098564e333
commit
238247a5d5
@ -27,3 +27,11 @@ class DockerManager:
|
||||
container = self.client.containers.get(container_id)
|
||||
container.stop()
|
||||
container.remove()
|
||||
|
||||
def remove_volume(self, volume_id):
|
||||
|
||||
volume = self.client.volumes.get(volume_id)
|
||||
|
||||
if volume is not None:
|
||||
volume.remove(force=True)
|
||||
|
||||
|
@ -75,3 +75,15 @@ def close_session(sender, instance, **kwargs):
|
||||
except Session.DoesNotExist:
|
||||
pass
|
||||
NGINXConfigurator.refresh_config(get_sessions_data())
|
||||
|
||||
|
||||
@receiver(pre_delete, sender=Profile)
|
||||
def clean_up_volume(sender, instance, **kwargs):
|
||||
try:
|
||||
volume_id = instance.volume
|
||||
|
||||
docker_manager = DockerManager()
|
||||
docker_manager.remove_volume(volume_id)
|
||||
|
||||
except :
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user