Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 1 | from core.models import Slice, SliceDeployments, User |
| 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() |
| 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() |