Tony Mack | 387a73f | 2013-09-18 07:59:14 -0400 | [diff] [blame] | 1 | from core.models import Slice |
| 2 | from observer.deleter import Deleter |
Sapan Bhatia | dbaf193 | 2013-09-03 11:28:52 -0400 | [diff] [blame] | 3 | |
Tony Mack | 387a73f | 2013-09-18 07:59:14 -0400 | [diff] [blame] | 4 | class SliceDeleter(Deleter): |
Sapan Bhatia | dbaf193 | 2013-09-03 11:28:52 -0400 | [diff] [blame] | 5 | model='Slice' |
| 6 | |
| 7 | def call(self, pk): |
Tony Mack | 387a73f | 2013-09-18 07:59:14 -0400 | [diff] [blame] | 8 | slice = Slice.objects.get(pk=pk) |
| 9 | self.driver.delete_router_interface(slice.router_id, slice.subnet_id) |
| 10 | self.driver.delete_subnet(slice.subnet_id) |
| 11 | self.driver.delete_router(slice.router_id) |
| 12 | self.driver.delete_network(slice.network_id) |
| 13 | self.driver.delete_tenant(slice.tenant_id) |
| 14 | # delete external route |
| 15 | subnet = None |
| 16 | subnets = self.driver.shell.quantum.list_subnets()['subnets'] |
| 17 | for snet in subnets: |
| 18 | if snet['id'] == slice.subnet_id: |
| 19 | subnet = snet |
| 20 | if subnet: |
| 21 | self.driver.delete_external_route(subnet) |
| 22 | slice.delete() |