Renamed SliceDeployment back to SliceDeployments
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index 84b2892..de766fc 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -422,8 +422,8 @@
def queryset(self, request):
return SitePrivilege.select_by_user(request.user)
-class SiteDeploymentInline(PlStackTabularInline):
- model = SiteDeployment
+class SiteDeploymentsInline(PlStackTabularInline):
+ model = SiteDeployments
extra = 0
suit_classes = 'suit-tab suit-tab-deployments'
fields = ['backend_status_icon', 'deployment','site']
@@ -435,10 +435,10 @@
if db_field.name == 'deployment':
kwargs['queryset'] = Deployment.select_by_user(request.user)
- return super(SiteDeploymentInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
+ return super(SiteDeploymentsInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
def queryset(self, request):
- return SiteDeployment.select_by_user(request.user)
+ return SiteDeployments.select_by_user(request.user)
class SlicePrivilegeInline(PlStackTabularInline):
@@ -574,7 +574,7 @@
# create/destroy the through models ourselves. There has to be
# a better way...
- self.manipulate_m2m_objs(deployment, self.cleaned_data['sites'], deployment.sitedeployments.all(), SiteDeployment, "deployment", "site")
+ self.manipulate_m2m_objs(deployment, self.cleaned_data['sites'], deployment.sitedeployments.all(), SiteDeployments, "deployment", "site")
self.manipulate_m2m_objs(deployment, self.cleaned_data['images'], deployment.imagedeployments.all(), ImageDeployment, "deployment", "image")
self.save_m2m()
@@ -661,7 +661,7 @@
list_display = ('backend_status_icon', 'name', 'login_base','site_url', 'enabled')
list_display_links = ('backend_status_icon', 'name', )
filter_horizontal = ('deployments',)
- inlines = [SliceInline,UserInline,TagInline, NodeInline, SitePrivilegeInline, SiteDeploymentInline]
+ inlines = [SliceInline,UserInline,TagInline, NodeInline, SitePrivilegeInline, SiteDeploymentsInline]
search_fields = ['name']
def queryset(self, request):
diff --git a/planetstack/core/models/__init__.py b/planetstack/core/models/__init__.py
index 821939e..09f4749 100644
--- a/planetstack/core/models/__init__.py
+++ b/planetstack/core/models/__init__.py
@@ -5,13 +5,13 @@
from .service import ServiceAttribute
from .tag import Tag
from .role import Role
-from .site import Site,Deployment, DeploymentRole, DeploymentPrivilege, SiteDeployment
+from .site import Site,Deployment, DeploymentRole, DeploymentPrivilege, SiteDeployments
from .dashboard import DashboardView
from .user import User, UserDashboardView
from .serviceclass import ServiceClass
from .site import DeploymentLinkManager,DeploymentLinkDeletionManager
from .slice import Slice, SliceDeployment
-from .site import SitePrivilege, SiteDeployment
+from .site import SitePrivilege, SiteDeployments
from .userdeployments import UserDeployment
from .image import Image, ImageDeployment
from .node import Node
diff --git a/planetstack/core/models/site.py b/planetstack/core/models/site.py
index 09eb786..2404e34 100644
--- a/planetstack/core/models/site.py
+++ b/planetstack/core/models/site.py
@@ -105,7 +105,7 @@
abbreviated_name = models.CharField(max_length=80)
#deployments = models.ManyToManyField('Deployment', blank=True, related_name='sites')
- deployments = models.ManyToManyField('Deployment', through='SiteDeployment', blank=True, help_text="Select which sites are allowed to host nodes in this deployment", related_name='sites')
+ deployments = models.ManyToManyField('Deployment', through='SiteDeployments', blank=True, help_text="Select which sites are allowed to host nodes in this deployment", related_name='sites')
tags = generic.GenericRelation(Tag)
def __unicode__(self): return u'%s' % (self.name)
@@ -255,7 +255,7 @@
qs = DeploymentPrivilege.objects.filter(id__in=dpriv_ids)
return qs
-class SiteDeployment(PlCoreBase):
+class SiteDeployments(PlCoreBase):
objects = DeploymentLinkManager()
deleted_objects = DeploymentLinkDeletionManager()
diff --git a/planetstack/ec2_observer/deleters/site_deleter.py b/planetstack/ec2_observer/deleters/site_deleter.py
index 88a4008..b8ca6a1 100644
--- a/planetstack/ec2_observer/deleters/site_deleter.py
+++ b/planetstack/ec2_observer/deleters/site_deleter.py
@@ -1,14 +1,14 @@
-from core.models import Site, SiteDeployment
+from core.models import Site, SiteDeployments
from observer.deleter import Deleter
-from observer.deleters.site_deployment_deleter import SiteDeploymentDeleter
+from observer.deleters.site_deployment_deleter import SiteDeploymentsDeleter
class SiteDeleter(Deleter):
model='Site'
def call(self, pk):
site = Site.objects.get(pk=pk)
- site_deployments = SiteDeployment.objects.filter(site=site)
- site_deployment_deleter = SiteDeploymentDeleter()
+ site_deployments = SiteDeployments.objects.filter(site=site)
+ site_deployment_deleter = SiteDeploymentsDeleter()
for site_deployment in site_deployments:
site_deployment_deleter(site_deployment.id)
site.delete()
diff --git a/planetstack/ec2_observer/deleters/site_deployment_deleter.py b/planetstack/ec2_observer/deleters/site_deployment_deleter.py
index db344cd..cc71d43 100644
--- a/planetstack/ec2_observer/deleters/site_deployment_deleter.py
+++ b/planetstack/ec2_observer/deleters/site_deployment_deleter.py
@@ -1,11 +1,11 @@
-from core.models import Site, SiteDeployment
+from core.models import Site, SiteDeployments
from observer.deleter import Deleter
-class SiteDeploymentDeleter(Deleter):
- model='SiteDeployment'
+class SiteDeploymentsDeleter(Deleter):
+ model='SiteDeployments'
def call(self, pk):
- site_deployment = SiteDeployment.objects.get(pk=pk)
+ site_deployment = SiteDeployments.objects.get(pk=pk)
if site_deployment.tenant_id:
driver = self.driver.admin_driver(deployment=site_deployment.deployment.name)
driver.delete_tenant(site_deployment.tenant_id)
diff --git a/planetstack/ec2_observer/steps/sync_nodes.py b/planetstack/ec2_observer/steps/sync_nodes.py
index 0fa8b61..9f032ed 100644
--- a/planetstack/ec2_observer/steps/sync_nodes.py
+++ b/planetstack/ec2_observer/steps/sync_nodes.py
@@ -20,7 +20,7 @@
return []
deployment = Deployment.objects.filter(Q(name="Amazon EC2"))[0]
- current_site_deployments = SiteDeployment.objects.filter(Q(deployment=deployment))
+ current_site_deployments = SiteDeployments.objects.filter(Q(deployment=deployment))
zone_ret = aws_run('ec2 describe-availability-zones')
zones = zone_ret['AvailabilityZones']
diff --git a/planetstack/ec2_observer/steps/sync_site_deployments.py b/planetstack/ec2_observer/steps/sync_site_deployments.py
index 5adccb7..7c24f68 100644
--- a/planetstack/ec2_observer/steps/sync_site_deployments.py
+++ b/planetstack/ec2_observer/steps/sync_site_deployments.py
@@ -7,9 +7,9 @@
from ec2_observer.awslib import *
import pdb
-class SyncSiteDeployment(SyncStep):
+class SyncSiteDeployments(SyncStep):
requested_interval=86400
- provides=[SiteDeployment]
+ provides=[SiteDeployments]
def fetch_pending(self, deletion):
if (deletion):
@@ -29,7 +29,7 @@
# The syncstep should catch it
# At any rate, we should not run if there are no deployments
deployment = Deployment.objects.filter(Q(name="Amazon EC2"))[0]
- current_site_deployments = SiteDeployment.objects.filter(Q(deployment=deployment))
+ current_site_deployments = SiteDeployments.objects.filter(Q(deployment=deployment))
site_dict = {}
for sd in current_site_deployments:
@@ -40,7 +40,7 @@
try:
site_record = site_dict[site]
except KeyError:
- sd = SiteDeployment(site=site,deployment=deployment,tenant_id=base64.urlsafe_b64encode(os.urandom(12)))
+ sd = SiteDeployments(site=site,deployment=deployment,tenant_id=base64.urlsafe_b64encode(os.urandom(12)))
updated_site_deployments.append(sd)
return updated_site_deployments
diff --git a/planetstack/ec2_observer/steps/sync_sites.py b/planetstack/ec2_observer/steps/sync_sites.py
index 0959c71..0c1c7cf 100644
--- a/planetstack/ec2_observer/steps/sync_sites.py
+++ b/planetstack/ec2_observer/steps/sync_sites.py
@@ -16,7 +16,7 @@
return []
deployment = Deployment.objects.filter(Q(name="Amazon EC2"))[0]
- current_site_deployments = SiteDeployment.objects.filter(Q(deployment=deployment))
+ current_site_deployments = SiteDeployments.objects.filter(Q(deployment=deployment))
zone_ret = aws_run('ec2 describe-availability-zones')
zones = zone_ret['AvailabilityZones']
diff --git a/planetstack/genapi.py b/planetstack/genapi.py
index 6fdc919..724789e 100644
--- a/planetstack/genapi.py
+++ b/planetstack/genapi.py
@@ -148,9 +148,9 @@
url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
# url(r'plstackapi/userdashboardviews/!new/$', UserDashboardViewNew.as_view(), name ='userdashboardview-new'),
- url(r'plstackapi/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployment-list'),
- url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentDetail.as_view(), name ='sitedeployment-detail'),
-# url(r'plstackapi/sitedeployments/!new/$', SiteDeploymentNew.as_view(), name ='sitedeployment-new'),
+ url(r'plstackapi/sitedeployments/$', SiteDeploymentsList.as_view(), name='sitedeployment-list'),
+ url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentsDetail.as_view(), name ='sitedeployment-detail'),
+# url(r'plstackapi/sitedeployments/!new/$', SiteDeploymentsNew.as_view(), name ='sitedeployment-new'),
url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
@@ -875,18 +875,18 @@
-class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer):
+class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
id = serializers.Field()
class Meta:
- model = SiteDeployment
+ model = SiteDeployments
fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
-class SiteDeploymentIdSerializer(serializers.ModelSerializer):
+class SiteDeploymentsIdSerializer(serializers.ModelSerializer):
id = serializers.Field()
class Meta:
- model = SiteDeployment
+ model = SiteDeployments
fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
@@ -1292,7 +1292,7 @@
UserDashboardView: UserDashboardViewSerializer,
- SiteDeployment: SiteDeploymentSerializer,
+ SiteDeployments: SiteDeploymentsSerializer,
PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
@@ -3811,10 +3811,10 @@
-class SiteDeploymentList(generics.ListCreateAPIView):
- queryset = SiteDeployment.objects.select_related().all()
- serializer_class = SiteDeploymentSerializer
- id_serializer_class = SiteDeploymentIdSerializer
+class SiteDeploymentsList(generics.ListCreateAPIView):
+ queryset = SiteDeployments.objects.select_related().all()
+ serializer_class = SiteDeploymentsSerializer
+ id_serializer_class = SiteDeploymentsIdSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
@@ -3826,7 +3826,7 @@
return self.serializer_class
def get_queryset(self):
- return SiteDeployment.select_by_user(self.request.user)
+ return SiteDeployments.select_by_user(self.request.user)
def create(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.DATA, files=request.FILES)
@@ -3835,21 +3835,21 @@
obj = serializer.object
obj.caller = request.user
if obj.can_update(request.user):
- return super(SiteDeploymentList, self).create(request, *args, **kwargs)
+ return super(SiteDeploymentsList, self).create(request, *args, **kwargs)
else:
raise Exception("failed obj.can_update")
- ret = super(SiteDeploymentList, self).create(request, *args, **kwargs)
+ ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs)
if (ret.status_code%100 != 200):
raise Exception(ret.data)
return ret
-class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
- queryset = SiteDeployment.objects.select_related().all()
- serializer_class = SiteDeploymentSerializer
- id_serializer_class = SiteDeploymentIdSerializer
+class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
+ queryset = SiteDeployments.objects.select_related().all()
+ serializer_class = SiteDeploymentsSerializer
+ id_serializer_class = SiteDeploymentsIdSerializer
def get_serializer_class(self):
no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
@@ -3859,7 +3859,7 @@
return self.serializer_class
def get_queryset(self):
- return SiteDeployment.select_by_user(self.request.user)
+ return SiteDeployments.select_by_user(self.request.user)
# update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
@@ -3870,9 +3870,9 @@
filled with defaults. I solved it another way, so this code may soon be
abandoned.
-class SiteDeploymentNew(GenericAPIView):
- serializer_class = SiteDeploymentSerializer
- id_serializer_class = SiteDeploymentIdSerializer
+class SiteDeploymentsNew(GenericAPIView):
+ serializer_class = SiteDeploymentsSerializer
+ id_serializer_class = SiteDeploymentsIdSerializer
def get(self, request, *args, **kwargs):
return self.makenew(request, *args, **kwargs)
@@ -3885,7 +3885,7 @@
return self.serializer_class
def makenew(self, request, *args, **kwargs):
- obj = SiteDeployment()
+ obj = SiteDeployments()
serializer = self.get_serializer(obj)
return Response(serializer.data)
"""
diff --git a/planetstack/model_policies/model_policy_Slice.py b/planetstack/model_policies/model_policy_Slice.py
index 7b436b4..56e2f53 100644
--- a/planetstack/model_policies/model_policy_Slice.py
+++ b/planetstack/model_policies/model_policy_Slice.py
@@ -1,8 +1,8 @@
def handle(slice):
- from core.models import SiteDeployment,SliceDeployment,Deployment,Network,NetworkSlice,NetworkTemplate
+ from core.models import SiteDeployments,SliceDeployment,Deployment,Network,NetworkSlice,NetworkTemplate
from collections import defaultdict
- site_deployments = SiteDeployment.objects.all()
+ site_deployments = SiteDeployments.objects.all()
site_deploy_lookup = defaultdict(list)
for site_deployment in site_deployments:
site_deploy_lookup[site_deployment.site].append(site_deployment.deployment)
diff --git a/planetstack/model_policies/model_policy_User.py b/planetstack/model_policies/model_policy_User.py
index cc8bbe6..7af6ff3 100644
--- a/planetstack/model_policies/model_policy_User.py
+++ b/planetstack/model_policies/model_policy_User.py
@@ -1,10 +1,10 @@
from core.models import *
def handle(user):
- from core.models import Deployment,SiteDeployment,UserDeployment
+ from core.models import Deployment,SiteDeployments,UserDeployment
from collections import defaultdict
deployments = Deployment.objects.all()
- site_deployments = SiteDeployment.objects.all()
+ site_deployments = SiteDeployments.objects.all()
site_deploy_lookup = defaultdict(list)
for site_deployment in site_deployments:
site_deploy_lookup[site_deployment.site].append(site_deployment.deployment)
diff --git a/planetstack/openstack_observer/steps/sync_site_deployments.py b/planetstack/openstack_observer/steps/sync_site_deployments.py
index 27b8648..b5e9f9a 100644
--- a/planetstack/openstack_observer/steps/sync_site_deployments.py
+++ b/planetstack/openstack_observer/steps/sync_site_deployments.py
@@ -6,9 +6,9 @@
from core.models.site import *
from observer.ansible import *
-class SyncSiteDeployment(OpenStackSyncStep):
+class SyncSiteDeployments(OpenStackSyncStep):
requested_interval=0
- provides=[SiteDeployment, Site]
+ provides=[SiteDeployments, Site]
def sync_record(self, site_deployment):
diff --git a/planetstack/openstack_observer/steps/sync_site_privileges.py b/planetstack/openstack_observer/steps/sync_site_privileges.py
index 78da7b2..d1a1fed 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, SiteDeployment
+from core.models import User, UserDeployment, SitePrivilege, SiteDeployments
class SyncSitePrivileges(OpenStackSyncStep):
requested_interval=0
@@ -18,7 +18,7 @@
def sync_record(self, site_priv):
# sync site privileges at all site deployments
- site_deployments = SiteDeployment.objects.filter(site=site_priv.site)
+ site_deployments = SiteDeployments.objects.filter(site=site_priv.site)
for site_deployment in site_deployments:
user_deployments = UserDeployment.objects.filter(deployment=site_deployment.deployment)
if user_deployments:
diff --git a/planetstack/openstack_observer/steps/sync_sites.py b/planetstack/openstack_observer/steps/sync_sites.py
index 4672878..c560a6a 100644
--- a/planetstack/openstack_observer/steps/sync_sites.py
+++ b/planetstack/openstack_observer/steps/sync_sites.py
@@ -14,7 +14,7 @@
site.save()
def delete_record(self, site):
- site_deployments = SiteDeployment.objects.filter(site=site)
- site_deployment_deleter = SyncSiteDeployment().delete_record
+ site_deployments = SiteDeployments.objects.filter(site=site)
+ site_deployment_deleter = SyncSiteDeployments().delete_record
for site_deployment in site_deployments:
site_deployment_deleter(site_deployment)
diff --git a/planetstack/openstack_observer/steps/sync_slice_deployments.py b/planetstack/openstack_observer/steps/sync_slice_deployments.py
index 2bc2082..c08a5fa 100644
--- a/planetstack/openstack_observer/steps/sync_slice_deployments.py
+++ b/planetstack/openstack_observer/steps/sync_slice_deployments.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 Deployment, SiteDeployment
+from core.models.site import Deployment, SiteDeployments
from core.models.slice import Slice, SliceDeployment
from core.models.userdeployments import UserDeployment
from util.logger import Logger, logging
diff --git a/planetstack/openstack_observer/steps/sync_user_deployments.py b/planetstack/openstack_observer/steps/sync_user_deployments.py
index 69faa9f..54f6130 100644
--- a/planetstack/openstack_observer/steps/sync_user_deployments.py
+++ b/planetstack/openstack_observer/steps/sync_user_deployments.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 SiteDeployment, Deployment
+from core.models.site import SiteDeployments, Deployment
from core.models.user import User
from core.models.userdeployments import UserDeployment
from util.logger import Logger, logging
@@ -39,7 +39,7 @@
roles = []
# setup user deployment home site roles
if user_deployment.user.site:
- site_deployments = SiteDeployment.objects.filter(site=user_deployment.user.site,
+ site_deployments = SiteDeployments.objects.filter(site=user_deployment.user.site,
deployment=user_deployment.deployment)
if site_deployments:
# need the correct tenant id for site at the deployment
@@ -50,7 +50,7 @@
if user_deployment.user.is_admin:
roles.append('admin')
else:
- raise Exception('Internal error. Missing SiteDeployment for user %s'%user_deployment.user.email)
+ raise Exception('Internal error. Missing SiteDeployments for user %s'%user_deployment.user.email)
else:
raise Exception('Siteless user %s'%user_deployment.user.email)