This change renamed a number of misnamed related fields (e.g. site_privileges->sitepr...
Sapan Bhatia [Wed, 12 Nov 2014 02:47:45 +0000 (21:47 -0500)]
12 files changed:
planetstack/core/dashboard/views/customize.py
planetstack/core/models/flavor.py
planetstack/core/models/network.py
planetstack/core/models/planetstackspecific.py
planetstack/core/models/reservation.py
planetstack/core/models/serviceresource.py
planetstack/core/models/site.py
planetstack/core/models/slice.py
planetstack/core/models/user.py
planetstack/core/models/userdeployments.py
planetstack/ec2_observer/deleters/user_deleter.py
planetstack/openstack/reservationagent.py

index 212cc4d..2c399eb 100644 (file)
@@ -12,7 +12,7 @@ class DashboardCustomize(View):
             dashboards = [x.strip() for x in dashboards.split(",")]\r
             dashboards = [DashboardView.objects.get(name=x) for x in dashboards]\r
 \r
-        request.user.dashboardViews.all().delete()\r
+        request.user.userdashboardviews.all().delete()\r
 \r
         for i,dashboard in enumerate(dashboards):\r
             udbv = UserDashboardView(user=request.user, dashboardView=dashboard, order=i)\r
index 04747af..20002dd 100644 (file)
@@ -29,7 +29,7 @@ class FlavorParameterType(PlCoreBase):
     def __unicode__(self):  return u'%s' % (self.name)
 
 class FlavorParameter(PlCoreBase):
-    parameter = models.ForeignKey(FlavorParameterType, related_name="parameters", help_text="The type of the parameter")
+    parameter = models.ForeignKey(FlavorParameterType, related_name="flavorparameters", help_text="The type of the parameter")
     value = models.CharField(help_text="The value of this parameter", max_length=1024)
 
     flavor = models.ForeignKey(Flavor,related_name='flavorparameter')
index ee239a7..02650e1 100644 (file)
@@ -125,8 +125,8 @@ class NetworkDeployments(PlCoreBase):
     deleted_objects = DeploymentLinkDeletionManager()
 
     # Stores the openstack ids at various deployments
-    network = models.ForeignKey(Network)
-    deployment = models.ForeignKey(Deployment)
+    network = models.ForeignKey(Network, related_name='networkdeployments')
+    deployment = models.ForeignKey(Deployment, related_name='networkdeployments')
     net_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum network")
     router_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum router id")
     subnet_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum subnet id")
@@ -149,8 +149,8 @@ class NetworkSlice(PlCoreBase):
     # This object exists solely so we can implement the permission check when
     # adding slices to networks. It adds no additional fields to the relation.
 
-    network = models.ForeignKey(Network)
-    slice = models.ForeignKey(Slice)
+    network = models.ForeignKey(Network,related_name='networkslices')
+    slice = models.ForeignKey(Slice,related_name='networkslices')
 
     def save(self, *args, **kwds):
         slice = self.slice
@@ -178,8 +178,8 @@ class NetworkSlice(PlCoreBase):
         return qs
 
 class NetworkSliver(PlCoreBase):
-    network = models.ForeignKey(Network)
-    sliver = models.ForeignKey(Sliver)
+    network = models.ForeignKey(Network,relatedname='networkslivers')
+    sliver = models.ForeignKey(Sliver,relatedname='networkslivers')
     ip = models.GenericIPAddressField(help_text="Sliver ip address", blank=True, null=True)
     port_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum port id")
 
@@ -227,7 +227,7 @@ class NetworkParameterType(PlCoreBase):
     def __unicode__(self):  return u'%s' % (self.name)
 
 class NetworkParameter(PlCoreBase):
-    parameter = models.ForeignKey(NetworkParameterType, related_name="parameters", help_text="The type of the parameter")
+    parameter = models.ForeignKey(NetworkParameterType, related_name="networkparameters", help_text="The type of the parameter")
     value = models.CharField(help_text="The value of this parameter", max_length=1024)
 
     # The required fields to do a ObjectType lookup, and object_id assignment
index 9007a51..2102a6e 100644 (file)
@@ -20,8 +20,8 @@ class PlanetStackRole(PlCoreBase):
     def __unicode__(self):  return u'%s' % (self.role)
 
 class PlanetStackPrivilege(PlCoreBase):
-    user = models.ForeignKey('User', related_name='planetstack_privileges')
-    planetstack = models.ForeignKey('PlanetStack', related_name='planetstack_privileges', default=1)
+    user = models.ForeignKey('User', related_name='planetstackprivileges')
+    planetstack = models.ForeignKey('PlanetStack', related_name='planetstackprivileges', default=1)
     role = models.ForeignKey('PlanetStackRole')
 
     def __unicode__(self):  return u'%s %s %s' % (self.planetstack, self.user, self.role)
index db3769f..4dd1274 100644 (file)
@@ -32,10 +32,10 @@ class Reservation(PlCoreBase):
         return qs
 
 class ReservedResource(PlCoreBase):
-    sliver = models.ForeignKey(Sliver, related_name="reservedResourrces")
-    resource = models.ForeignKey(ServiceResource, related_name="reservedResources")
+    sliver = models.ForeignKey(Sliver, related_name="reservedresources")
+    resource = models.ForeignKey(ServiceResource, related_name="reservedresources")
     quantity = models.IntegerField(default=1)
-    reservationSet = models.ForeignKey(Reservation, related_name="reservedResources")
+    reservationSet = models.ForeignKey(Reservation, related_name="reservedresources")
 
     class Meta(PlCoreBase.Meta):
        verbose_name_plural = "Reserved Resources"
index e849425..2f88dc9 100644 (file)
@@ -8,7 +8,7 @@ from core.models import ServiceClass
 # Create your models here.
 
 class ServiceResource(PlCoreBase):
-    serviceClass = models.ForeignKey(ServiceClass, related_name = "resources")
+    serviceClass = models.ForeignKey(ServiceClass, related_name = "serviceresources")
     name = models.CharField(max_length=32)
     maxUnitsDeployment = models.IntegerField(default=1)
     maxUnitsNode = models.IntegerField(default=1)
index f562b92..09eb786 100644 (file)
@@ -141,9 +141,9 @@ class SiteRole(PlCoreBase):
 
 class SitePrivilege(PlCoreBase):
 
-    user = models.ForeignKey('User', related_name='site_privileges')
-    site = models.ForeignKey('Site', related_name='site_privileges')
-    role = models.ForeignKey('SiteRole')
+    user = models.ForeignKey('User', related_name='siteprivileges')
+    site = models.ForeignKey('Site', related_name='siteprivileges')
+    role = models.ForeignKey('SiteRole',related_name='siteprivileges')
 
     def __unicode__(self):  return u'%s %s %s' % (self.site, self.user, self.role)
 
@@ -229,9 +229,9 @@ class DeploymentPrivilege(PlCoreBase):
     objects = DeploymentLinkManager()
     deleted_objects = DeploymentLinkDeletionManager()
 
-    user = models.ForeignKey('User', related_name='deployment_privileges')
-    deployment = models.ForeignKey('Deployment', related_name='deployment_privileges')
-    role = models.ForeignKey('DeploymentRole')
+    user = models.ForeignKey('User', related_name='deploymentprivileges')
+    deployment = models.ForeignKey('Deployment', related_name='deploymentprivileges')
+    role = models.ForeignKey('DeploymentRole',related_name='deploymentprivileges')
 
     def __unicode__(self):  return u'%s %s %s' % (self.deployment, self.user, self.role)
 
index e1fad4c..d438bdf 100644 (file)
@@ -102,9 +102,9 @@ class SliceRole(PlCoreBase):
     def __unicode__(self):  return u'%s' % (self.role)
 
 class SlicePrivilege(PlCoreBase):
-    user = models.ForeignKey('User', related_name='slice_privileges')
-    slice = models.ForeignKey('Slice', related_name='slice_privileges')
-    role = models.ForeignKey('SliceRole')
+    user = models.ForeignKey('User', related_name='sliceprivileges')
+    slice = models.ForeignKey('Slice', related_name='sliceprivileges')
+    role = models.ForeignKey('SliceRole',related_name='sliceprivileges')
 
     def __unicode__(self):  return u'%s %s %s' % (self.slice, self.user, self.role)
 
index a935d22..7063f4f 100644 (file)
@@ -183,7 +183,7 @@ class User(AbstractBaseUser, DiffModelMixIn):
     def get_dashboards(self):
         DEFAULT_DASHBOARDS=["Tenant"]
 
-        dashboards = sorted(list(self.dashboardViews.all()), key=attrgetter('order'))
+        dashboards = sorted(list(self.userdashboardviews.all()), key=attrgetter('order'))
         dashboards = [x.dashboardView for x in dashboards]
 
         if not dashboards:
@@ -285,6 +285,6 @@ class User(AbstractBaseUser, DiffModelMixIn):
         self.delete(*args, **kwds)
 
 class UserDashboardView(PlCoreBase):
-     user = models.ForeignKey(User, related_name="dashboardViews")
-     dashboardView = models.ForeignKey(DashboardView, related_name="dashboardViews")
+     user = models.ForeignKey(User, related_name='userdashboardviews')
+     dashboardView = models.ForeignKey(DashboardView, related_name='userdashboardviews')
      order = models.IntegerField(default=0)
index 6cc2643..d0337ba 100644 (file)
@@ -6,12 +6,12 @@ from django.db.models import F, Q
 from core.models import PlCoreBase,Site,User,Deployment
 from core.models import Deployment,DeploymentLinkManager,DeploymentLinkDeletionManager
 
-class UserDeployments(PlCoreBase):
+class UserDeployment(PlCoreBase):
     objects = DeploymentLinkManager()
     deleted_objects = DeploymentLinkDeletionManager()
 
-    user = models.ForeignKey(User)
-    deployment = models.ForeignKey(Deployment)
+    user = models.ForeignKey(User,related_name='userdeployments')
+    deployment = models.ForeignKey(Deployment,related_name='userdeployments')
     kuser_id = models.CharField(null=True, blank=True, max_length=200, help_text="Keystone user id")
 
     def __unicode__(self):  return u'%s %s' % (self.user, self.deployment.name)
index ab5651e..3f93060 100644 (file)
@@ -1,4 +1,4 @@
-from core.models import User, UserDeployments
+from core.models import User, UserDeployment
 from observer.deleter import Deleter
 from observer.deleters.user_deployment_deleter import UserDeploymentDeleter
 
index 86c4e91..0fe406b 100644 (file)
@@ -21,7 +21,7 @@ class ReservationAgent:
                 if reservation.endTime <= tNow:
                     print "    deleting expired reservation"
                     reservation.delete()
-                for reservedResource in reservation.reservedResources.all():
+                for reservedResource in reservation.reservedresources.all():
                     sliver_resources = slivers.get(reservedResource.sliver.id, {})
                     sliver_resources[reservedResource.resource.name] = reservedResource.quantity
                     slivers[reservedResource.sliver.id] = sliver_resources