blob: 6796d7affd4d7823f57107aee0acd47705c0c326 [file] [log] [blame]
Tony Mack387a73f2013-09-18 07:59:14 -04001from core.models import Slice
2from observer.deleter import Deleter
Sapan Bhatiadbaf1932013-09-03 11:28:52 -04003
Tony Mack387a73f2013-09-18 07:59:14 -04004class SliceDeleter(Deleter):
Sapan Bhatiadbaf1932013-09-03 11:28:52 -04005 model='Slice'
6
7 def call(self, pk):
Tony Mack387a73f2013-09-18 07:59:14 -04008 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()