Renamed UserDeployment back to UserDeployments
diff --git a/planetstack/core/migrations/0001_initial.py b/planetstack/core/migrations/0001_initial.py
index 3ce8e6e..80d9c9a 100644
--- a/planetstack/core/migrations/0001_initial.py
+++ b/planetstack/core/migrations/0001_initial.py
@@ -948,7 +948,7 @@
bases=(models.Model,),
),
migrations.CreateModel(
- name='UserDeployments',
+ name='UserDeploymentss',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', models.DateTimeField(default=django.utils.timezone.now, auto_now_add=True)),
diff --git a/planetstack/core/models/__init__.py b/planetstack/core/models/__init__.py
index b539bb8..2070e16 100644
--- a/planetstack/core/models/__init__.py
+++ b/planetstack/core/models/__init__.py
@@ -12,7 +12,7 @@
from .site import DeploymentLinkManager,DeploymentLinkDeletionManager
from .slice import Slice, SliceDeployments
from .site import SitePrivilege, SiteDeployments
-from .userdeployments import UserDeployment
+from .userdeployments import UserDeployments
from .image import Image, ImageDeployments
from .node import Node
from .serviceresource import ServiceResource
diff --git a/planetstack/core/models/userdeployments.py b/planetstack/core/models/userdeployments.py
index d0337ba..d8051bf 100644
--- a/planetstack/core/models/userdeployments.py
+++ b/planetstack/core/models/userdeployments.py
@@ -6,7 +6,7 @@
from core.models import PlCoreBase,Site,User,Deployment
from core.models import Deployment,DeploymentLinkManager,DeploymentLinkDeletionManager
-class UserDeployment(PlCoreBase):
+class UserDeployments(PlCoreBase):
objects = DeploymentLinkManager()
deleted_objects = DeploymentLinkDeletionManager()
@@ -19,7 +19,7 @@
@staticmethod
def select_by_user(user):
if user.is_admin:
- qs = UserDeployment.objects.all()
+ qs = UserDeployments.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 3f93060..3930eb0 100644
--- a/planetstack/ec2_observer/deleters/user_deleter.py
+++ b/planetstack/ec2_observer/deleters/user_deleter.py
@@ -1,13 +1,13 @@
-from core.models import User, UserDeployment
+from core.models import User, UserDeployments
from observer.deleter import Deleter
-from observer.deleters.user_deployment_deleter import UserDeploymentDeleter
+from observer.deleters.user_deployment_deleter import UserDeploymentsDeleter
class UserDeleter(Deleter):
model='User'
def call(self, pk):
user = User.objects.get(pk=pk)
- user_deployment_deleter = UserDeploymentDeleter()
- for user_deployment in UserDeployment.objects.filter(user=user):
+ user_deployment_deleter = UserDeploymentsDeleter()
+ for user_deployment in UserDeployments.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 6d3825c..4bc7619 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, UserDeployment
+from core.models import User, UserDeployments
from observer.deleter import Deleter
-class UserDeploymentDeleter(Deleter):
- model='UserDeployment'
+class UserDeploymentsDeleter(Deleter):
+ model='UserDeployments'
def call(self, pk):
- user_deployment = UserDeployment.objects.get(pk=pk)
+ user_deployment = UserDeployments.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 c14f72b..1503431 100644
--- a/planetstack/genapi.py
+++ b/planetstack/genapi.py
@@ -176,9 +176,9 @@
url(r'plstackapi/slicedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDeploymentsDetail.as_view(), name ='slicedeployment-detail'),
# url(r'plstackapi/slicedeployments/!new/$', SliceDeploymentsNew.as_view(), name ='slicedeployment-new'),
- url(r'plstackapi/userdeployments/$', UserDeploymentList.as_view(), name='userdeployment-list'),
- url(r'plstackapi/userdeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDeploymentDetail.as_view(), name ='userdeployment-detail'),
-# url(r'plstackapi/userdeployments/!new/$', UserDeploymentNew.as_view(), name ='userdeployment-new'),
+ url(r'plstackapi/userdeployments/$', UserDeploymentsList.as_view(), name='userdeployment-list'),
+ url(r'plstackapi/userdeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDeploymentsDetail.as_view(), name ='userdeployment-detail'),
+# url(r'plstackapi/userdeployments/!new/$', UserDeploymentsNew.as_view(), name ='userdeployment-new'),
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'),
@@ -1026,18 +1026,18 @@
-class UserDeploymentSerializer(serializers.HyperlinkedModelSerializer):
+class UserDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
id = serializers.Field()
class Meta:
- model = UserDeployment
+ model = UserDeployments
fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
-class UserDeploymentIdSerializer(serializers.ModelSerializer):
+class UserDeploymentsIdSerializer(serializers.ModelSerializer):
id = serializers.Field()
class Meta:
- model = UserDeployment
+ model = UserDeployments
fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
@@ -1306,7 +1306,7 @@
SliceDeployments: SliceDeploymentsSerializer,
- UserDeployment: UserDeploymentSerializer,
+ UserDeployments: UserDeploymentsSerializer,
Account: AccountSerializer,
@@ -4378,10 +4378,10 @@
-class UserDeploymentList(generics.ListCreateAPIView):
- queryset = UserDeployment.objects.select_related().all()
- serializer_class = UserDeploymentSerializer
- id_serializer_class = UserDeploymentIdSerializer
+class UserDeploymentsList(generics.ListCreateAPIView):
+ queryset = UserDeployments.objects.select_related().all()
+ serializer_class = UserDeploymentsSerializer
+ id_serializer_class = UserDeploymentsIdSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
@@ -4393,7 +4393,7 @@
return self.serializer_class
def get_queryset(self):
- return UserDeployment.select_by_user(self.request.user)
+ return UserDeployments.select_by_user(self.request.user)
def create(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.DATA, files=request.FILES)
@@ -4402,21 +4402,21 @@
obj = serializer.object
obj.caller = request.user
if obj.can_update(request.user):
- return super(UserDeploymentList, self).create(request, *args, **kwargs)
+ return super(UserDeploymentsList, self).create(request, *args, **kwargs)
else:
raise Exception("failed obj.can_update")
- ret = super(UserDeploymentList, self).create(request, *args, **kwargs)
+ ret = super(UserDeploymentsList, self).create(request, *args, **kwargs)
if (ret.status_code%100 != 200):
raise Exception(ret.data)
return ret
-class UserDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
- queryset = UserDeployment.objects.select_related().all()
- serializer_class = UserDeploymentSerializer
- id_serializer_class = UserDeploymentIdSerializer
+class UserDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
+ queryset = UserDeployments.objects.select_related().all()
+ serializer_class = UserDeploymentsSerializer
+ id_serializer_class = UserDeploymentsIdSerializer
def get_serializer_class(self):
no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
@@ -4426,7 +4426,7 @@
return self.serializer_class
def get_queryset(self):
- return UserDeployment.select_by_user(self.request.user)
+ return UserDeployments.select_by_user(self.request.user)
# update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
@@ -4437,9 +4437,9 @@
filled with defaults. I solved it another way, so this code may soon be
abandoned.
-class UserDeploymentNew(GenericAPIView):
- serializer_class = UserDeploymentSerializer
- id_serializer_class = UserDeploymentIdSerializer
+class UserDeploymentsNew(GenericAPIView):
+ serializer_class = UserDeploymentsSerializer
+ id_serializer_class = UserDeploymentsIdSerializer
def get(self, request, *args, **kwargs):
return self.makenew(request, *args, **kwargs)
@@ -4452,7 +4452,7 @@
return self.serializer_class
def makenew(self, request, *args, **kwargs):
- obj = UserDeployment()
+ obj = UserDeployments()
serializer = self.get_serializer(obj)
return Response(serializer.data)
"""
diff --git a/planetstack/model_policies/model_policy_User.py b/planetstack/model_policies/model_policy_User.py
index 7af6ff3..6118a7b 100644
--- a/planetstack/model_policies/model_policy_User.py
+++ b/planetstack/model_policies/model_policy_User.py
@@ -1,7 +1,7 @@
from core.models import *
def handle(user):
- from core.models import Deployment,SiteDeployments,UserDeployment
+ from core.models import Deployment,SiteDeployments,UserDeployments
from collections import defaultdict
deployments = Deployment.objects.all()
site_deployments = SiteDeployments.objects.all()
@@ -10,7 +10,7 @@
site_deploy_lookup[site_deployment.site].append(site_deployment.deployment)
user_deploy_lookup = defaultdict(list)
- for user_deployment in UserDeployment.objects.all():
+ for user_deployment in UserDeployments.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 = UserDeployment(user=user, deployment=expected_deployment)
+ ud = UserDeployments(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 d1a1fed..d07b279 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, UserDeployment, SitePrivilege, SiteDeployments
+from core.models import User, UserDeployments, SitePrivilege, SiteDeployments
class SyncSitePrivileges(OpenStackSyncStep):
requested_interval=0
@@ -20,7 +20,7 @@
# sync site privileges at all site deployments
site_deployments = SiteDeployments.objects.filter(site=site_priv.site)
for site_deployment in site_deployments:
- user_deployments = UserDeployment.objects.filter(deployment=site_deployment.deployment)
+ 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)
diff --git a/planetstack/openstack_observer/steps/sync_slice_deployments.py b/planetstack/openstack_observer/steps/sync_slice_deployments.py
index 9e79164..97196d6 100644
--- a/planetstack/openstack_observer/steps/sync_slice_deployments.py
+++ b/planetstack/openstack_observer/steps/sync_slice_deployments.py
@@ -7,7 +7,7 @@
from observer.openstacksyncstep import OpenStackSyncStep
from core.models.site import Deployment, SiteDeployments
from core.models.slice import Slice, SliceDeployments
-from core.models.userdeployments import UserDeployment
+from core.models.userdeployments import UserDeployments
from util.logger import Logger, logging
from observer.ansible import *
@@ -48,7 +48,7 @@
logger.info("deployment %r has no admin_user, skipping" % slice_deployment.deployment)
return
- deployment_users = UserDeployment.objects.filter(user=slice_deployment.slice.creator,
+ deployment_users = UserDeployments.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 88a182e..b1cd223 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 UserDeployment
+from core.models.userdeployments import UserDeployments
from util.logger import Logger, logging
logger = Logger(level=logging.INFO)
@@ -26,7 +26,7 @@
for slice_deployment in slice_deployments:
if not slice_deployment.tenant_id:
continue
- user_deployments = UserDeployment.objects.filter(deployment=slice_deployment.deployment,
+ user_deployments = UserDeployments.objects.filter(deployment=slice_deployment.deployment,
user=slice_memb.user)
if user_deployments:
kuser_id = user_deployments[0].kuser_id
diff --git a/planetstack/openstack_observer/steps/sync_user_deployments.py b/planetstack/openstack_observer/steps/sync_user_deployments.py
index 54f6130..2e8256f 100644
--- a/planetstack/openstack_observer/steps/sync_user_deployments.py
+++ b/planetstack/openstack_observer/steps/sync_user_deployments.py
@@ -7,23 +7,23 @@
from observer.openstacksyncstep import OpenStackSyncStep
from core.models.site import SiteDeployments, Deployment
from core.models.user import User
-from core.models.userdeployments import UserDeployment
+from core.models.userdeployments import UserDeployments
from util.logger import Logger, logging
from observer.ansible import *
logger = Logger(level=logging.INFO)
-class SyncUserDeployment(OpenStackSyncStep):
- provides=[UserDeployment, User]
+class SyncUserDeployments(OpenStackSyncStep):
+ provides=[UserDeployments, User]
requested_interval=0
def fetch_pending(self, deleted):
if (deleted):
- return UserDeployment.deleted_objects.all()
+ return UserDeployments.deleted_objects.all()
else:
- return UserDeployment.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
+ return UserDeployments.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 242b8be..a22c213 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 UserDeployment
-from observer.steps.sync_user_deployments import SyncUserDeployment
+from core.models.userdeployments import UserDeployments
+from observer.steps.sync_user_deployments import SyncUserDeployments
class SyncUsers(OpenStackSyncStep):
provides=[User]
requested_interval=0
def sync_record(self, user):
- for user_deployment in UserDeployment.objects.filter(user=user):
+ for user_deployment in UserDeployments.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 = SyncUserDeployment().delete_record
- for user_deployment in UserDeployment.objects.filter(user=user):
+ user_deployment_deleter = SyncUserDeployments().delete_record
+ for user_deployment in UserDeployments.objects.filter(user=user):
user_deployment_deleter(user_deployment)