Controller replaces Deployment
diff --git a/planetstack/openstack_observer/steps/sync_site_privileges.py b/planetstack/openstack_observer/steps/sync_site_privileges.py
index d07b279..2378b88 100644
--- a/planetstack/openstack_observer/steps/sync_site_privileges.py
+++ b/planetstack/openstack_observer/steps/sync_site_privileges.py
@@ -3,7 +3,7 @@
from django.db.models import F, Q
from planetstack.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
-from core.models import User, UserDeployments, SitePrivilege, SiteDeployments
+from core.models import User, ControllerUsers, SitePrivilege, ControllerSites
class SyncSitePrivileges(OpenStackSyncStep):
requested_interval=0
@@ -17,13 +17,13 @@
return SitePrivilege.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
def sync_record(self, site_priv):
- # sync site privileges at all site deployments
- site_deployments = SiteDeployments.objects.filter(site=site_priv.site)
- for site_deployment in site_deployments:
- user_deployments = UserDeployments.objects.filter(deployment=site_deployment.deployment)
- if user_deployments:
- kuser_id = user_deployments[0].kuser_id
- driver = self.driver.admin_driver(deployment=site_deployment.deployment.name)
+ # sync site privileges at all site controllers
+ controller_sites = ControllerSites.objects.filter(site=site_priv.site)
+ for controller_site in controller_sites:
+ controller_users = ControllerUsers.objects.filter(controller=controller_site.controller)
+ if controller_users:
+ kuser_id = controller_users[0].kuser_id
+ driver = self.driver.admin_driver(controller=controller_site.controller)
driver.add_user_role(kuser_id,
- site_deployment.tenant_id,
+ controller_site.tenant_id,
site_priv.role.role)