added max_slivers (instance) quota attribute to slice model
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index ed34fff..07029a2 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -641,9 +641,9 @@
class SliceAdmin(PlanetStackBaseAdmin):
form = SliceForm
- fieldList = ['name', 'site', 'serviceClass', 'enabled','description', 'service', 'slice_url']
+ fieldList = ['name', 'site', 'serviceClass', 'enabled','description', 'service', 'slice_url', 'max_slivers']
fieldsets = [('Slice Details', {'fields': fieldList, 'classes':['suit-tab suit-tab-general']}),]
- list_display = ('name', 'site','serviceClass', 'slice_url')
+ list_display = ('name', 'site','serviceClass', 'slice_url', 'max_slivers')
inlines = [SlicePrivilegeInline,SliverInline, TagInline, ReservationInline,SliceNetworkInline]
user_readonly_fields = fieldList
diff --git a/planetstack/core/models/slice.py b/planetstack/core/models/slice.py
index fd91c30..bd41f87 100644
--- a/planetstack/core/models/slice.py
+++ b/planetstack/core/models/slice.py
@@ -20,6 +20,7 @@
description=models.TextField(blank=True,help_text="High level description of the slice and expected activities", max_length=1024)
slice_url = models.URLField(blank=True, max_length=512)
site = models.ForeignKey(Site, related_name='slices', help_text="The Site this Slice belongs to")
+ max_slivers = models.IntegerField(default=10)
imagePreference = models.CharField(default="Ubuntu 12.04 LTS", null=True, blank=True, max_length=256)
service = models.ForeignKey(Service, related_name='service', null=True, blank=True)
network = models.CharField(default="Private Only",null=True, blank=True, max_length=256)
diff --git a/planetstack/observer/steps/sync_slice_deployments.py b/planetstack/observer/steps/sync_slice_deployments.py
index c7b20ce..580edd1 100644
--- a/planetstack/observer/steps/sync_slice_deployments.py
+++ b/planetstack/observer/steps/sync_slice_deployments.py
@@ -61,6 +61,7 @@
next_network = IPNetwork(str(IPAddress(last_network) + last_network.size) + "/24")
return next_network
+
def sync_record(self, slice_deployment):
logger.info("sync'ing slice deployment %s" % slice_deployment)
if not slice_deployment.tenant_id:
@@ -91,9 +92,16 @@
if slice_deployment.id and slice_deployment.tenant_id:
+ # update existing tenant
driver = self.driver.admin_driver(deployment=slice_deployment.deployment.name)
driver.update_tenant(slice_deployment.tenant_id,
description=slice_deployment.slice.description,
- enabled=slice_deployment.slice.enabled)
+ enabled=slice_deployment.slice.enabled)
+
+ if slice_deployment.tenant_id:
+ # update slice/tenant quota
+ driver = self.driver.client_driver(deployment=slice_deployment.deployment.name,
+ tenant=slice_deployment.slice.name)
+ driver.shell.nova.quotas.update(tenant_id=slice_deployment.tenant_id, instances=int(slice_deployment.slice.max_slivers))
slice_deployment.save()
diff --git a/planetstack/observer/steps/sync_slices.py b/planetstack/observer/steps/sync_slices.py
index cc1220c..6cf0772 100644
--- a/planetstack/observer/steps/sync_slices.py
+++ b/planetstack/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
+from core.models.slice import Slice, SliceDeployments
from util.logger import Logger, logging
logger = Logger(level=logging.INFO)
@@ -17,4 +17,7 @@
return Slice.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
def sync_record(self, slice):
- slice.save()
+ for slice_deployment in SliceDeployments.objects.filter(slice=slice):
+ # bump the 'updated' timestamp and trigger observer to update
+ # slice across all deployments
+ slice_deployment.save()