blob: e7c54e687884dfe926248b268e04afeb4ba58d42 [file] [log] [blame]
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -05001from core.models import Slice, SliceDeployment, User
Sapan Bhatia26d40bc2014-05-12 15:28:02 -04002from observer.deleter import Deleter
3from observer.deleters.slice_deployment_deleter import SliceDeploymentDeleter
4from util.logger import Logger, logging
5
6logger = Logger(level=logging.INFO)
7
8class SliceDeleter(Deleter):
9 model='Slice'
10
11 def call(self, pk):
12 slice = Slice.objects.get(pk=pk)
13 slice_deployment_deleter = SliceDeploymentDeleter()
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -050014 for slice_deployment in SliceDeployment.objects.filter(slice=slice):
Sapan Bhatia26d40bc2014-05-12 15:28:02 -040015 try:
16 slice_deployment_deleter(slice_deployment.id)
17 except:
18 logger.log_exc("Failed to delete slice_deployment %s" % slice_deployment)
19 slice.delete()