blob: e18e2f89a9cb20b691327bf31d8cef3b6b36ef2a [file] [log] [blame]
Sapan Bhatia24836f12013-08-27 10:16:05 -04001import os
2import base64
Tony Mackae7f30c2013-09-25 12:46:50 -04003from django.db.models import F, Q
Sapan Bhatia24836f12013-08-27 10:16:05 -04004from planetstack.config import Config
Sapan Bhatia04c94ad2013-09-02 18:00:28 -04005from observer.openstacksyncstep import OpenStackSyncStep
Tony Mackd14d48f2014-12-05 17:13:08 -05006from core.models.site import Site, SiteDeployments, ControllerSiteDeployments
7from observer.steps.sync_controller_site_deployments import *
Sapan Bhatia24836f12013-08-27 10:16:05 -04008
9class SyncSites(OpenStackSyncStep):
Tony Mackdacfb982013-09-24 21:57:16 -040010 provides=[Site]
11 requested_interval=0
Tony Mack66646d52013-09-24 21:47:12 -040012
Tony Mackdacfb982013-09-24 21:57:16 -040013 def sync_record(self, site):
Tony Macke4be32f2014-03-11 20:45:25 -040014 site.save()
Sapan Bhatia24836f12013-08-27 10:16:05 -040015
Sapan Bhatia18c64cf2014-07-23 09:05:38 -040016 def delete_record(self, site):
Tony Mackd14d48f2014-12-05 17:13:08 -050017 # delete associated controllers site deployments
18 ctrl_site_deployments = ControllerSiteDeployments.objects.filter(site_deployment__site=site)
19 ctrl_site_deploy_deleter = SyncControllerSiteDeployments().delete_record
20 for ctrl_site_deployment in ctrl_site_deployments:
21 ctrl_site_deployment_deleter(ctrl_site_deployment)
22
23 # delete site deployments
24 site_deployments = SiteDeployments.objects.filter(site=site)
25 for site_deployment in site_deployments:
26 site_deployment.delete()
27
28
29