Tony Mack | e4be32f | 2014-03-11 20:45:25 -0400 | [diff] [blame] | 1 | import os |
| 2 | import base64 |
| 3 | from django.db.models import F, Q |
| 4 | from planetstack.config import Config |
| 5 | from observer.openstacksyncstep import OpenStackSyncStep |
| 6 | from core.models.site import * |
| 7 | |
| 8 | class SyncSiteDeployments(OpenStackSyncStep): |
| 9 | requested_interval=0 |
Sapan Bhatia | 663626e | 2014-07-23 09:50:33 -0400 | [diff] [blame] | 10 | provides=[SiteDeployments, Site] |
Tony Mack | e4be32f | 2014-03-11 20:45:25 -0400 | [diff] [blame] | 11 | |
| 12 | def sync_record(self, site_deployment): |
| 13 | if not site_deployment.tenant_id: |
| 14 | driver = self.driver.admin_driver(deployment=site_deployment.deployment.name) |
| 15 | tenant = driver.create_tenant(tenant_name=site_deployment.site.login_base, |
| 16 | description=site_deployment.site.name, |
| 17 | enabled=site_deployment.site.enabled) |
| 18 | site_deployment.tenant_id = tenant.id |
| 19 | site_deployment.save() |
| 20 | elif site_deployment.site.id and site_deployment.tenant_id: |
Tony Mack | a16cfb2 | 2014-06-19 22:00:22 -0400 | [diff] [blame] | 21 | driver = self.driver.admin_driver(deployment=site_deployment.deployment.name) |
Tony Mack | e4be32f | 2014-03-11 20:45:25 -0400 | [diff] [blame] | 22 | driver.update_tenant(site_deployment.tenant_id, |
| 23 | description=site_deployment.site.name, |
| 24 | enabled=site_deployment.site.enabled) |
| 25 | |
Sapan Bhatia | 663626e | 2014-07-23 09:50:33 -0400 | [diff] [blame] | 26 | def delete_record(self, site_deployment): |
| 27 | if site_deployment.tenant_id: |
| 28 | driver = self.driver.admin_driver(deployment=site_deployment.deployment.name) |
| 29 | driver.delete_tenant(site_deployment.tenant_id) |