refactor
diff --git a/planetstack/openstack_observer/steps/sync_controller_users.py b/planetstack/openstack_observer/steps/sync_controller_users.py
index 63f5ca3..8723694 100644
--- a/planetstack/openstack_observer/steps/sync_controller_users.py
+++ b/planetstack/openstack_observer/steps/sync_controller_users.py
@@ -5,7 +5,7 @@
 from django.db.models import F, Q
 from planetstack.config import Config
 from observer.openstacksyncstep import OpenStackSyncStep
-from core.models.site import ControllerSites, Controller
+from core.models.site import Controller, SiteDeployments
 from core.models.user import User
 from core.models.usercontrollers import ControllerUsers
 from util.logger import Logger, logging
@@ -36,26 +36,27 @@
 	
         name = controller_user.user.email[:controller_user.user.email.find('@')]
 
-	roles = []
-	# setup user controller home site roles  
-        if controller_user.user.site:
-            site_controllers = ControllerSites.objects.filter(site=controller_user.user.site,
-                                                              controller=controller_user.controller)
-            if site_controllers:
-                # need the correct tenant id for site at the controller
-                tenant_id = site_controllers[0].tenant_id  
-		tenant_name = site_controllers[0].site.login_base
-
-		roles.append('user')
-                if controller_user.user.is_admin:
-                    roles.append('admin')
-	    else:
-		raise Exception('Internal error. Missing ControllerSites for user %s'%controller_user.user.email)
-	else:
+	roles = ['user']
+        if controller_user.user.is_admin:
+            roles.append('admin')
+        else:
+            raise Exception('Internal error. Missing controller for user %s'%controller_user.user.email)
+   
+	# setup user home site roles at controller 
+        if not controller_user.user.site:
 	    raise Exception('Siteless user %s'%controller_user.user.email)
+        else:
+            # look up tenant id for the user's site at the controller
+            ctrl_site_deployments = ControllerSiteDeployments.objects.filter(
+              site_deployment__site=controller_user.user.site,
+              controller=controller_user.controller)
 
+            if ctrl_site_deployments:
+                # need the correct tenant id for site at the controller
+                tenant_id = ctrl_site_deployments[0].tenant_id  
+		tenant_name = ctrl_site_deployment[0].site_deployment.site.login_base
 
-        user_fields = {'endpoint':controller_user.controller.auth_url,
+                user_fields = {'endpoint':controller_user.controller.auth_url,
 		       'name': controller_user.user.email,
                        'email': controller_user.user.email,
                        'password': hashlib.md5(controller_user.user.password).hexdigest()[:6],
@@ -65,20 +66,21 @@
 		       'roles':roles,
 		       'tenant':tenant_name}    
 	
-	rendered = template.render(user_fields)
-	res = run_template('sync_controller_users.yaml', user_fields)
+	        rendered = template.render(user_fields)
+	        res = run_template('sync_controller_users.yaml', user_fields)
 
-	# results is an array in which each element corresponds to an 
-	# "ok" string received per operation. If we get as many oks as
-	# the number of operations we issued, that means a grand success.
-	# Otherwise, the number of oks tell us which operation failed.
-	expected_length = len(roles) + 1
-	if (len(res)==expected_length):
-        	controller_user.save()
-	elif (len(res)):
-		raise Exception('Could not assign roles for user %s'%user_fields['name'])
-	else:
-		raise Exception('Could not create or update user %s'%user_fields['name'])
+	        # results is an array in which each element corresponds to an 
+	        # "ok" string received per operation. If we get as many oks as
+	        # the number of operations we issued, that means a grand success.
+	        # Otherwise, the number of oks tell us which operation failed.
+	        expected_length = len(roles) + 1
+	        if (len(res)==expected_length):
+                    controller_user.kuser_id = res[0]['id']
+        	    controller_user.save()
+	        elif (len(res)):
+		    raise Exception('Could not assign roles for user %s'%user_fields['name'])
+	        else:
+		    raise Exception('Could not create or update user %s'%user_fields['name'])
 
     def delete_record(self, controller_user):
         if controller_user.kuser_id: