blob: 880b91ca9bba7cfc63c5064d4d75abdd7c5be2c0 [file] [log] [blame]
Tony Mack387a73f2013-09-18 07:59:14 -04001from core.models import Network
Tony Mackaa4a67b2014-04-02 07:06:00 -04002from observer.deleter import Deleter
Tony Mack387a73f2013-09-18 07:59:14 -04003
4class 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()