blob: a8a00f6772d3a1f91cc788506dc12890f52973d2 [file] [log] [blame]
Tony Macke4be32f2014-03-11 20:45:25 -04001import os
2import base64
3from django.db.models import F, Q
4from planetstack.config import Config
5from observer.openstacksyncstep import OpenStackSyncStep
6from core.models.site import *
7
8class SyncSiteDeployments(OpenStackSyncStep):
9 requested_interval=0
Sapan Bhatia663626e2014-07-23 09:50:33 -040010 provides=[SiteDeployments, Site]
Tony Macke4be32f2014-03-11 20:45:25 -040011
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 Macka16cfb22014-06-19 22:00:22 -040021 driver = self.driver.admin_driver(deployment=site_deployment.deployment.name)
Tony Macke4be32f2014-03-11 20:45:25 -040022 driver.update_tenant(site_deployment.tenant_id,
23 description=site_deployment.site.name,
24 enabled=site_deployment.site.enabled)
25
Sapan Bhatia663626e2014-07-23 09:50:33 -040026 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)