blob: 0d21fda42dc299c7a4f746535c3ab515b0243c34 [file] [log] [blame]
Sapan Bhatia26d40bc2014-05-12 15:28:02 -04001from core.models import Network, NetworkDeployments
2from observer.deleter import Deleter
3from observer.deleters.network_deployment_deleter import NetworkDeploymentDeleter
4from util.logger import Logger, logging
5
6logger = Logger(level=logging.INFO)
7
8class NetworkDeleter(Deleter):
9 model='Network'
10
11 def call(self, pk):
12 network = Network.objects.get(pk=pk)
13 network_deployment_deleter = NetworkDeploymentDeleter()
14 for network_deployment in NetworkDeployments.objects.filter(network=network):
15 try:
16 network_deployment_deleter(network_deployment.id)
17 except:
18 logger.log_exc("Failed to delte network deployment %s" % network_deployment)
19 network.delete()