added max_slivers (instance) quota attribute to slice model
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()