Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7eecff0b54
@ -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