blob: 90b58c3e06372be257b2660090a7d9ea1ef1af1f [file] [log] [blame]
Tony Mackbdb188a2014-04-01 20:24:47 -04001from core.models import Slice, SliceDeployments, User
Tony Mack387a73f2013-09-18 07:59:14 -04002from observer.deleter import Deleter
Tony Mack79e78c82014-04-12 10:26:15 -04003from observer.deleters.slice_deployment_deleter import SliceDeploymentDeleter
4from util.logger import Logger, logging
5
6logger = Logger(level=logging.INFO)
Sapan Bhatiadbaf1932013-09-03 11:28:52 -04007
Tony Mack387a73f2013-09-18 07:59:14 -04008class SliceDeleter(Deleter):
Tony Mackf77f1402014-04-02 07:06:53 -04009 model='Slice'
Sapan Bhatiadbaf1932013-09-03 11:28:52 -040010
Tony Mackf77f1402014-04-02 07:06:53 -040011 def call(self, pk):
12 slice = Slice.objects.get(pk=pk)
Tony Mack79e78c82014-04-12 10:26:15 -040013 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)
Tony Mack387a73f2013-09-18 07:59:14 -040019 slice.delete()