Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 1 | from core.models import Network, NetworkDeployments |
| 2 | from observer.deleter import Deleter |
| 3 | from observer.deleters.network_deployment_deleter import NetworkDeploymentDeleter |
| 4 | from util.logger import Logger, logging |
| 5 | |
| 6 | logger = Logger(level=logging.INFO) |
| 7 | |
| 8 | class 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() |