Renamed UserDeployments->UserDeployment
diff --git a/planetstack/core/models/site.py b/planetstack/core/models/site.py
index 9ef48c2..f562b92 100644
--- a/planetstack/core/models/site.py
+++ b/planetstack/core/models/site.py
@@ -255,12 +255,12 @@
             qs = DeploymentPrivilege.objects.filter(id__in=dpriv_ids)
         return qs 
 
-class SiteDeployments(PlCoreBase):
+class SiteDeployment(PlCoreBase):
     objects = DeploymentLinkManager()
     deleted_objects = DeploymentLinkDeletionManager()
 
-    site = models.ForeignKey(Site)
-    deployment = models.ForeignKey(Deployment)
+    site = models.ForeignKey(Site,related_name='sitedeployments')
+    deployment = models.ForeignKey(Deployment,related_name='sitedeployments')
     tenant_id = models.CharField(null=True, blank=True, max_length=200, help_text="Keystone tenant id")    
 
     #class Meta:
diff --git a/planetstack/core/models/userdeployments.py b/planetstack/core/models/userdeployments.py
index 5685668..6cc2643 100644
--- a/planetstack/core/models/userdeployments.py
+++ b/planetstack/core/models/userdeployments.py
@@ -19,7 +19,7 @@
     @staticmethod
     def select_by_user(user):
         if user.is_admin:
-            qs = UserDeployments.objects.all()
+            qs = UserDeployment.objects.all()
         else:
             users = Users.select_by_user(user)
             qs = Usereployments.objects.filter(user__in=slices)
diff --git a/planetstack/ec2_observer/deleters/user_deleter.py b/planetstack/ec2_observer/deleters/user_deleter.py
index 3573f8d..ab5651e 100644
--- a/planetstack/ec2_observer/deleters/user_deleter.py
+++ b/planetstack/ec2_observer/deleters/user_deleter.py
@@ -8,6 +8,6 @@
     def call(self, pk):
         user = User.objects.get(pk=pk)
         user_deployment_deleter = UserDeploymentDeleter()
-        for user_deployment in UserDeployments.objects.filter(user=user):
+        for user_deployment in UserDeployment.objects.filter(user=user):
             user_deployment_deleter(user_deployment.id)
         user.delete()
diff --git a/planetstack/ec2_observer/deleters/user_deployment_deleter.py b/planetstack/ec2_observer/deleters/user_deployment_deleter.py
index 49d349b..6d3825c 100644
--- a/planetstack/ec2_observer/deleters/user_deployment_deleter.py
+++ b/planetstack/ec2_observer/deleters/user_deployment_deleter.py
@@ -1,11 +1,11 @@
-from core.models import User, UserDeployments
+from core.models import User, UserDeployment
 from observer.deleter import Deleter
 
 class UserDeploymentDeleter(Deleter):
     model='UserDeployment'
 
     def call(self, pk):
-        user_deployment = UserDeployments.objects.get(pk=pk)
+        user_deployment = UserDeployment.objects.get(pk=pk)
         if user_deployment.user.kuser_id:
             driver = self.driver.admin_driver(deployment=user_deployment.deployment.name)
             driver.delete_user(user_deployment.user.kuser_id)
diff --git a/planetstack/genapi.py b/planetstack/genapi.py
index 51da3e9..dcc35a1 100644
--- a/planetstack/genapi.py
+++ b/planetstack/genapi.py
@@ -138,8 +138,8 @@
         url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
         url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
     
-        url(r'plstackapi/user_deployments/$', UserDeploymentsList.as_view(), name='userdeployments-list'),
-        url(r'plstackapi/user_deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDeploymentsDetail.as_view(), name ='userdeployments-detail'),
+        url(r'plstackapi/user_deployments/$', UserDeploymentList.as_view(), name='userdeployments-list'),
+        url(r'plstackapi/user_deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDeploymentDetail.as_view(), name ='userdeployments-detail'),
     
         url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'),
         url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
@@ -976,18 +976,18 @@
 
 
 
-class UserDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
+class UserDeploymentSerializer(serializers.HyperlinkedModelSerializer):
     id = serializers.Field()
     
     class Meta:
-        model = UserDeployments
+        model = UserDeployment
         fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
 
-class UserDeploymentsIdSerializer(serializers.ModelSerializer):
+class UserDeploymentIdSerializer(serializers.ModelSerializer):
     id = serializers.Field()
     
     class Meta:
-        model = UserDeployments
+        model = UserDeployment
         fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
 
 
@@ -3292,10 +3292,10 @@
 
 
 
-class UserDeploymentsList(generics.ListCreateAPIView):
-    queryset = UserDeployments.objects.select_related().all()
-    serializer_class = UserDeploymentsSerializer
-    id_serializer_class = UserDeploymentsIdSerializer
+class UserDeploymentList(generics.ListCreateAPIView):
+    queryset = UserDeployment.objects.select_related().all()
+    serializer_class = UserDeploymentSerializer
+    id_serializer_class = UserDeploymentIdSerializer
     filter_backends = (filters.DjangoFilterBackend,)
     filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
 
@@ -3307,27 +3307,27 @@
             return self.serializer_class
 
     def get_queryset(self):
-        return UserDeployments.select_by_user(self.request.user)
+        return UserDeployment.select_by_user(self.request.user)
 
     def create(self, request, *args, **kwargs):
-        obj = UserDeployments(**request.DATA)
+        obj = UserDeployment(**request.DATA)
         obj.caller = request.user
         if obj.can_update(request.user):
-            return super(UserDeploymentsList, self).create(request, *args, **kwargs)
+            return super(UserDeploymentList, self).create(request, *args, **kwargs)
         else:
             raise Exception("failed obj.can_update")
 
-        ret = super(UserDeploymentsList, self).create(request, *args, **kwargs)
+        ret = super(UserDeploymentList, self).create(request, *args, **kwargs)
         if (ret.status_code%100 != 200):
             raise Exception(ret.data)
 
         return ret
 
 
-class UserDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
-    queryset = UserDeployments.objects.select_related().all()
-    serializer_class = UserDeploymentsSerializer
-    id_serializer_class = UserDeploymentsIdSerializer
+class UserDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
+    queryset = UserDeployment.objects.select_related().all()
+    serializer_class = UserDeploymentSerializer
+    id_serializer_class = UserDeploymentIdSerializer
 
     def get_serializer_class(self):
         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
@@ -3337,7 +3337,7 @@
             return self.serializer_class
     
     def get_queryset(self):
-        return UserDeployments.select_by_user(self.request.user)
+        return UserDeployment.select_by_user(self.request.user)
 
     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
 
diff --git a/planetstack/model_policies/model_policy_User.py b/planetstack/model_policies/model_policy_User.py
index 6118a7b..cc8bbe6 100644
--- a/planetstack/model_policies/model_policy_User.py
+++ b/planetstack/model_policies/model_policy_User.py
@@ -1,16 +1,16 @@
 from core.models import *
 
 def handle(user):
-	from core.models import Deployment,SiteDeployments,UserDeployments
+	from core.models import Deployment,SiteDeployment,UserDeployment
 	from collections import defaultdict
 	deployments = Deployment.objects.all()
-	site_deployments = SiteDeployments.objects.all()
+	site_deployments = SiteDeployment.objects.all()
 	site_deploy_lookup = defaultdict(list)
 	for site_deployment in site_deployments:
 		site_deploy_lookup[site_deployment.site].append(site_deployment.deployment)
 
 	user_deploy_lookup = defaultdict(list)
-	for user_deployment in UserDeployments.objects.all():
+	for user_deployment in UserDeployment.objects.all():
 		user_deploy_lookup[user_deployment.user].append(user_deployment.deployment)
    
 	all_deployments = Deployment.objects.filter() 
@@ -27,6 +27,6 @@
 		if not user in user_deploy_lookup or \
 		  expected_deployment not in user_deploy_lookup[user]: 
 			# add new record
-			ud = UserDeployments(user=user, deployment=expected_deployment)
+			ud = UserDeployment(user=user, deployment=expected_deployment)
 			ud.save()    
 
diff --git a/planetstack/openstack_observer/steps/sync_site_privileges.py b/planetstack/openstack_observer/steps/sync_site_privileges.py
index db2c012..78da7b2 100644
--- a/planetstack/openstack_observer/steps/sync_site_privileges.py
+++ b/planetstack/openstack_observer/steps/sync_site_privileges.py
@@ -18,9 +18,9 @@
 
     def sync_record(self, site_priv):
         # sync site privileges at all site deployments
-        site_deployments = SiteDeployments.objects.filter(site=site_priv.site)
+        site_deployments = SiteDeployment.objects.filter(site=site_priv.site)
         for site_deployment in site_deployments:
-            user_deployments = UserDeployments.objects.filter(deployment=site_deployment.deployment)
+            user_deployments = UserDeployment.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)
diff --git a/planetstack/openstack_observer/steps/sync_slice_deployments.py b/planetstack/openstack_observer/steps/sync_slice_deployments.py
index d7282c6..2bc2082 100644
--- a/planetstack/openstack_observer/steps/sync_slice_deployments.py
+++ b/planetstack/openstack_observer/steps/sync_slice_deployments.py
@@ -48,7 +48,7 @@
             logger.info("deployment %r has no admin_user, skipping" % slice_deployment.deployment)
             return
 
-	deployment_users = UserDeployments.objects.filter(user=slice_deployment.slice.creator,
+	deployment_users = UserDeployment.objects.filter(user=slice_deployment.slice.creator,
                                                              deployment=slice_deployment.deployment)            
     	if not deployment_users:
 	    logger.info("slice createor %s has not accout at deployment %s" % (slice_deployment.slice.creator, slice_deployment.deployment.name))
diff --git a/planetstack/openstack_observer/steps/sync_slice_memberships.py b/planetstack/openstack_observer/steps/sync_slice_memberships.py
index 9b7b40b..f51a96b 100644
--- a/planetstack/openstack_observer/steps/sync_slice_memberships.py
+++ b/planetstack/openstack_observer/steps/sync_slice_memberships.py
@@ -4,7 +4,7 @@
 from planetstack.config import Config
 from observer.openstacksyncstep import OpenStackSyncStep
 from core.models.slice import *
-from core.models.userdeployments import UserDeployments
+from core.models.userdeployments import UserDeployment
 from util.logger import Logger, logging
 
 logger = Logger(level=logging.INFO)
diff --git a/planetstack/openstack_observer/steps/sync_slices.py b/planetstack/openstack_observer/steps/sync_slices.py
index 1b89ecd..6d6ca46 100644
--- a/planetstack/openstack_observer/steps/sync_slices.py
+++ b/planetstack/openstack_observer/steps/sync_slices.py
@@ -4,7 +4,7 @@
 from django.db.models import F, Q
 from planetstack.config import Config
 from observer.openstacksyncstep import OpenStackSyncStep
-from core.models.slice import Slice, SliceDeployments
+from core.models.slice import Slice, SliceDeployment
 from util.logger import Logger, logging
 from observer.steps.sync_slice_deployments import *
 
diff --git a/planetstack/openstack_observer/steps/sync_user_deployments.py b/planetstack/openstack_observer/steps/sync_user_deployments.py
index 6a87cbf..69faa9f 100644
--- a/planetstack/openstack_observer/steps/sync_user_deployments.py
+++ b/planetstack/openstack_observer/steps/sync_user_deployments.py
@@ -5,25 +5,25 @@
 from django.db.models import F, Q
 from planetstack.config import Config
 from observer.openstacksyncstep import OpenStackSyncStep
-from core.models.site import SiteDeployments, Deployment
+from core.models.site import SiteDeployment, Deployment
 from core.models.user import User
-from core.models.userdeployments import UserDeployments
+from core.models.userdeployments import UserDeployment
 from util.logger import Logger, logging
 
 from observer.ansible import *
 
 logger = Logger(level=logging.INFO)
 
-class SyncUserDeployments(OpenStackSyncStep):
-    provides=[UserDeployments, User]
+class SyncUserDeployment(OpenStackSyncStep):
+    provides=[UserDeployment, User]
     requested_interval=0
 
     def fetch_pending(self, deleted):
 
         if (deleted):
-            return UserDeployments.deleted_objects.all()
+            return UserDeployment.deleted_objects.all()
         else:
-            return UserDeployments.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None)) 
+            return UserDeployment.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None)) 
 
     def sync_record(self, user_deployment):
         logger.info("sync'ing user %s at deployment %s" % (user_deployment.user, user_deployment.deployment.name))
diff --git a/planetstack/openstack_observer/steps/sync_users.py b/planetstack/openstack_observer/steps/sync_users.py
index a22c213..242b8be 100644
--- a/planetstack/openstack_observer/steps/sync_users.py
+++ b/planetstack/openstack_observer/steps/sync_users.py
@@ -5,20 +5,20 @@
 from planetstack.config import Config
 from observer.openstacksyncstep import OpenStackSyncStep
 from core.models.user import User
-from core.models.userdeployments import  UserDeployments
-from observer.steps.sync_user_deployments import SyncUserDeployments
+from core.models.userdeployments import  UserDeployment
+from observer.steps.sync_user_deployments import SyncUserDeployment
 
 class SyncUsers(OpenStackSyncStep):
     provides=[User]
     requested_interval=0
 
     def sync_record(self, user):
-        for user_deployment in UserDeployments.objects.filter(user=user):
+        for user_deployment in UserDeployment.objects.filter(user=user):
             # bump the 'updated' field so user account are updated across 
             # deployments.
             user_deployment.save()
 
     def delete_record(self, user):
-        user_deployment_deleter = SyncUserDeployments().delete_record
-        for user_deployment in UserDeployments.objects.filter(user=user):
+        user_deployment_deleter = SyncUserDeployment().delete_record
+        for user_deployment in UserDeployment.objects.filter(user=user):
             user_deployment_deleter(user_deployment)