refactor
diff --git a/planetstack/openstack_observer/steps/sync_site_privileges.py b/planetstack/openstack_observer/steps/sync_site_privileges.py
index 2378b88..9dcd07e 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, ControllerUsers, SitePrivilege, ControllerSites
+from core.models import User, ControllerUsers, SitePrivilege, ControllerSiteDeployments
class SyncSitePrivileges(OpenStackSyncStep):
requested_interval=0
@@ -18,12 +18,13 @@
def sync_record(self, site_priv):
# 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)
+ ctrl_site_deployments = ControllerSiteDeployments.objects.filter(site_deployment__site=site_priv.site)
+ for ctrl_site_deployment in ctrl_site_deployments:
+ controller_users = ControllerUsers.objects.filter(controller=ctrl_site_deployment.controller,
+ user=site_priv.user)
if controller_users:
kuser_id = controller_users[0].kuser_id
- driver = self.driver.admin_driver(controller=controller_site.controller)
+ driver = self.driver.admin_driver(controller=ctrl_site_deployment.controller)
driver.add_user_role(kuser_id,
- controller_site.tenant_id,
+ ctrl_site_deployment.controller.tenant_id,
site_priv.role.role)