Sapan Bhatia | 18e01e3 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 1 | from core.models import Slice, SliceDeployment, User |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 2 | from observer.deleter import Deleter |
| 3 | from observer.deleters.slice_deployment_deleter import SliceDeploymentDeleter |
| 4 | from util.logger import Logger, logging |
| 5 | |
| 6 | logger = Logger(level=logging.INFO) |
| 7 | |
| 8 | class SliceDeleter(Deleter): |
| 9 | model='Slice' |
| 10 | |
| 11 | def call(self, pk): |
| 12 | slice = Slice.objects.get(pk=pk) |
| 13 | slice_deployment_deleter = SliceDeploymentDeleter() |
Sapan Bhatia | 18e01e3 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 14 | for slice_deployment in SliceDeployment.objects.filter(slice=slice): |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 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() |