blob: 17619c58b8f6400728b5be231ff4e69ed0b89ee2 [file] [log] [blame]
Tony Mackbdb188a2014-04-01 20:24:47 -04001from core.models import Site, SiteDeployments
Tony Macke4be32f2014-03-11 20:45:25 -04002from observer.deleter import Deleter
Tony Mack387a73f2013-09-18 07:59:14 -04003
4class SiteDeleter(Deleter):
5 model='Site'
6
7 def call(self, pk):
8 site = Site.objects.get(pk=pk)
Tony Mackbdb188a2014-04-01 20:24:47 -04009 site_deployments = SiteDeployments.objects.filter(site=site)
10 for site_deployment in site_deployments:
11 if site_deployment.tenant_id:
Tony Mackf77f1402014-04-02 07:06:53 -040012 driver = self.driver.admin_driver(deployment=site_deployment.deployment.name)
Tony Mackbdb188a2014-04-01 20:24:47 -040013 driver.delete_tenant(site_deployment.tenant_id)
14 site_deployment.delete()
Tony Mack387a73f2013-09-18 07:59:14 -040015 site.delete()