blob: 72b10b22658ab1cae516faa38ae4ef3c4dbf3ffa [file] [log] [blame]
Sapan Bhatia26d40bc2014-05-12 15:28:02 -04001from core.models import Network, NetworkDeployments
2from observer.deleter import Deleter
3from openstack.driver import OpenStackDriver
4
5class NetworkDeploymentDeleter(Deleter):
6 model='NetworkDeployment'
7
8 def call(self, pk):
9 network_deployment = NetworkDeployments.objects.get(pk=pk)
10 driver = OpenStackDriver().client_driver(caller=network_deployment.network.owner.creator,
11 tenant=network_deployment.network.owner.name,
12 deployment=network_deployment.deployment.name)
13 if (network_deployment.router_id) and (network_deployment.subnet_id):
14 driver.delete_router_interface(network_deployment.router_id, network_deployment.subnet_id)
15 if network_deployment.subnet_id:
16 driver.delete_subnet(network_deployment.subnet_id)
17 if network_deployment.router_id:
18 driver.delete_router(network_deployment.router_id)
19 if network_deployment.net_id:
20 driver.delete_network(network_deployment.net_id)
21 network_deployment.delete()