blob: fa89d2c6cd716ce9bd4927d54f41766d99986bd1 [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
10 provides=[Site, SiteDeployments]
11
12 def fetch_pending(self):
13 return SiteDeployments.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
14
15 def sync_record(self, site_deployment):
16 if not site_deployment.tenant_id:
17 driver = self.driver.admin_driver(deployment=site_deployment.deployment.name)
18 tenant = driver.create_tenant(tenant_name=site_deployment.site.login_base,
19 description=site_deployment.site.name,
20 enabled=site_deployment.site.enabled)
21 site_deployment.tenant_id = tenant.id
22 site_deployment.save()
23 elif site_deployment.site.id and site_deployment.tenant_id:
Tony Macka16cfb22014-06-19 22:00:22 -040024 driver = self.driver.admin_driver(deployment=site_deployment.deployment.name)
Tony Macke4be32f2014-03-11 20:45:25 -040025 driver.update_tenant(site_deployment.tenant_id,
26 description=site_deployment.site.name,
27 enabled=site_deployment.site.enabled)
28