blob: 7e9dfd4def5e8db4f21f4d3375768ae29856f686 [file] [log] [blame]
Sapan Bhatiabf7856b2014-11-19 15:09:38 -05001from core.models import Slice, SliceDeployments, User
Sapan Bhatia26d40bc2014-05-12 15:28:02 -04002from observer.deleter import Deleter
Sapan Bhatiabf7856b2014-11-19 15:09:38 -05003from observer.deleters.slice_deployment_deleter import SliceDeploymentsDeleter
Sapan Bhatia26d40bc2014-05-12 15:28:02 -04004from 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)
Sapan Bhatiabf7856b2014-11-19 15:09:38 -050013 slice_deployment_deleter = SliceDeploymentsDeleter()
14 for slice_deployment in SliceDeployments.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()