Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 1 | import os |
| 2 | import base64 |
| 3 | from planetstack.config import Config |
| 4 | |
| 5 | class SyncSites(OpenStackSyncStep): |
| 6 | provides=[Site] |
Sapan Bhatia | 2ef36c8 | 2013-09-02 14:30:37 -0400 | [diff] [blame] | 7 | requested_interval=0 |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 8 | def sync_record(self, site): |
| 9 | save_site = False |
| 10 | if not site.tenant_id: |
| 11 | tenant = self.driver.create_tenant(tenant_name=site.login_base, |
| 12 | description=site.name, |
| 13 | enabled=site.enabled) |
| 14 | site.tenant_id = tenant.id |
| 15 | save_site = True |
| 16 | # XXX - What's caller? |
| 17 | # self.driver.add_user_role(self.caller.kuser_id, tenant.id, 'admin') |
| 18 | |
| 19 | # update the record |
| 20 | if site.id and site.tenant_id: |
| 21 | self.driver.update_tenant(site.tenant_id, |
| 22 | description=site.name, |
| 23 | enabled=site.enabled) |
| 24 | |
| 25 | if (save_site): |
| 26 | site.save() # |
| 27 | |