blob: 90b58c3e06372be257b2660090a7d9ea1ef1af1f [file] [log] [blame]
Sapan Bhatia26d40bc2014-05-12 15:28:02 -04001from core.models import Slice, SliceDeployments, User
2from 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()
14 for slice_deployment in SliceDeployments.objects.filter(slice=slice):
15 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()