blob: 1f7a0f8359004b8b74af79f7c711b0c04de5eb91 [file] [log] [blame]
Sapan Bhatia24836f12013-08-27 10:16:05 -04001import os
2import base64
3from planetstack.config import Config
Sapan Bhatia04c94ad2013-09-02 18:00:28 -04004from observer.openstacksyncstep import OpenStackSyncStep
5from core.models.site import Site
Sapan Bhatia24836f12013-08-27 10:16:05 -04006
7class SyncSites(OpenStackSyncStep):
8 provides=[Site]
Sapan Bhatia2ef36c82013-09-02 14:30:37 -04009 requested_interval=0
Sapan Bhatia24836f12013-08-27 10:16:05 -040010 def sync_record(self, site):
11 save_site = False
12 if not site.tenant_id:
13 tenant = self.driver.create_tenant(tenant_name=site.login_base,
14 description=site.name,
15 enabled=site.enabled)
16 site.tenant_id = tenant.id
17 save_site = True
18 # XXX - What's caller?
19 # self.driver.add_user_role(self.caller.kuser_id, tenant.id, 'admin')
20
21 # update the record
22 if site.id and site.tenant_id:
23 self.driver.update_tenant(site.tenant_id,
24 description=site.name,
25 enabled=site.enabled)
26
27 if (save_site):
28 site.save() #
29