blob: 0d21fda42dc299c7a4f746535c3ab515b0243c34 [file] [log] [blame]
Tony Mack79e78c82014-04-12 10:26:15 -04001from core.models import Network, NetworkDeployments
Tony Mackaa4a67b2014-04-02 07:06:00 -04002from observer.deleter import Deleter
Tony Mack79e78c82014-04-12 10:26:15 -04003from observer.deleters.network_deployment_deleter import NetworkDeploymentDeleter
4from util.logger import Logger, logging
5
6logger = Logger(level=logging.INFO)
Tony Mack387a73f2013-09-18 07:59:14 -04007
8class NetworkDeleter(Deleter):
9 model='Network'
10
11 def call(self, pk):
12 network = Network.objects.get(pk=pk)
Tony Mack79e78c82014-04-12 10:26:15 -040013 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)
Tony Mack387a73f2013-09-18 07:59:14 -040019 network.delete()