Tony Mack | 387a73f | 2013-09-18 07:59:14 -0400 | [diff] [blame] | 1 | from core.models import Network |
| 2 | from deleter import Deleter |
| 3 | |
| 4 | class NetworkDeleter(Deleter): |
| 5 | model='Network' |
| 6 | |
| 7 | def call(self, pk): |
| 8 | network = Network.objects.get(pk=pk) |
| 9 | if (network.router_id) and (network.subnet_id): |
| 10 | self.driver.delete_router_interface(network.router_id, network.subnet_id) |
| 11 | if network.subnet_id: |
| 12 | self.driver.delete_subnet(network.subnet_id) |
| 13 | if network.router_id: |
| 14 | self.driver.delete_router(network.router_id) |
| 15 | if network.network_id: |
| 16 | self.driver.delete_network(network.network_id) |
| 17 | network.delete() |