add new deleters, update existing deleters
diff --git a/planetstack/observer/deleters/network_deleter.py b/planetstack/observer/deleters/network_deleter.py
index 880b91c..0d21fda 100644
--- a/planetstack/observer/deleters/network_deleter.py
+++ b/planetstack/observer/deleters/network_deleter.py
@@ -1,17 +1,19 @@
-from core.models import Network
+from core.models import Network, NetworkDeployments
from observer.deleter import Deleter
+from observer.deleters.network_deployment_deleter import NetworkDeploymentDeleter
+from util.logger import Logger, logging
+
+logger = Logger(level=logging.INFO)
class NetworkDeleter(Deleter):
model='Network'
def call(self, pk):
network = Network.objects.get(pk=pk)
- if (network.router_id) and (network.subnet_id):
- self.driver.delete_router_interface(network.router_id, network.subnet_id)
- if network.subnet_id:
- self.driver.delete_subnet(network.subnet_id)
- if network.router_id:
- self.driver.delete_router(network.router_id)
- if network.network_id:
- self.driver.delete_network(network.network_id)
+ network_deployment_deleter = NetworkDeploymentDeleter()
+ for network_deployment in NetworkDeployments.objects.filter(network=network):
+ try:
+ network_deployment_deleter(network_deployment.id)
+ except:
+ logger.log_exc("Failed to delte network deployment %s" % network_deployment)
network.delete()