Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 1 | import os |
| 2 | import base64 |
Tony Mack | ae7f30c | 2013-09-25 12:46:50 -0400 | [diff] [blame] | 3 | from django.db.models import F, Q |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 4 | from planetstack.config import Config |
Sapan Bhatia | 04c94ad | 2013-09-02 18:00:28 -0400 | [diff] [blame] | 5 | from observer.openstacksyncstep import OpenStackSyncStep |
Tony Mack | b469d24 | 2015-01-03 19:37:39 -0500 | [diff] [blame] | 6 | from core.models.site import Site, SiteDeployments, SiteDeployments |
Tony Mack | 528d422 | 2014-12-05 17:13:08 -0500 | [diff] [blame] | 7 | from observer.steps.sync_controller_site_deployments import * |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 8 | |
| 9 | class SyncSites(OpenStackSyncStep): |
Tony Mack | dacfb98 | 2013-09-24 21:57:16 -0400 | [diff] [blame] | 10 | provides=[Site] |
| 11 | requested_interval=0 |
Tony Mack | 66646d5 | 2013-09-24 21:47:12 -0400 | [diff] [blame] | 12 | |
Tony Mack | dacfb98 | 2013-09-24 21:57:16 -0400 | [diff] [blame] | 13 | def sync_record(self, site): |
Tony Mack | e4be32f | 2014-03-11 20:45:25 -0400 | [diff] [blame] | 14 | site.save() |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 15 | |
Sapan Bhatia | 18c64cf | 2014-07-23 09:05:38 -0400 | [diff] [blame] | 16 | def delete_record(self, site): |
Tony Mack | 528d422 | 2014-12-05 17:13:08 -0500 | [diff] [blame] | 17 | # delete associated controllers site deployments |
Tony Mack | 528d422 | 2014-12-05 17:13:08 -0500 | [diff] [blame] | 18 | site_deployments = SiteDeployments.objects.filter(site=site) |
Tony Mack | b469d24 | 2015-01-03 19:37:39 -0500 | [diff] [blame] | 19 | site_deploy_deleter = SyncControllerSiteDeployments().delete_record |
Tony Mack | 528d422 | 2014-12-05 17:13:08 -0500 | [diff] [blame] | 20 | for site_deployment in site_deployments: |
Tony Mack | b469d24 | 2015-01-03 19:37:39 -0500 | [diff] [blame] | 21 | site_deployment_deleter(site_deployment) |
| 22 | |
Tony Mack | 528d422 | 2014-12-05 17:13:08 -0500 | [diff] [blame] | 23 | |
| 24 | |
| 25 | |