refactor
diff --git a/planetstack/openstack_observer/steps/sync_sites.py b/planetstack/openstack_observer/steps/sync_sites.py
index 530301a..e18e2f8 100644
--- a/planetstack/openstack_observer/steps/sync_sites.py
+++ b/planetstack/openstack_observer/steps/sync_sites.py
@@ -3,8 +3,8 @@
from django.db.models import F, Q
from planetstack.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
-from core.models.site import Site
-from observer.steps.sync_controller_sites import *
+from core.models.site import Site, SiteDeployments, ControllerSiteDeployments
+from observer.steps.sync_controller_site_deployments import *
class SyncSites(OpenStackSyncStep):
provides=[Site]
@@ -14,7 +14,16 @@
site.save()
def delete_record(self, site):
- controller_sites = ControllerSites.objects.filter(site=site)
- controller_site_deleter = SyncControllerSites().delete_record
- for controller_site in controller_sites:
- controller_site_deleter(controller_site)
+ # delete associated controllers site deployments
+ ctrl_site_deployments = ControllerSiteDeployments.objects.filter(site_deployment__site=site)
+ ctrl_site_deploy_deleter = SyncControllerSiteDeployments().delete_record
+ for ctrl_site_deployment in ctrl_site_deployments:
+ ctrl_site_deployment_deleter(ctrl_site_deployment)
+
+ # delete site deployments
+ site_deployments = SiteDeployments.objects.filter(site=site)
+ for site_deployment in site_deployments:
+ site_deployment.delete()
+
+
+