summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-09-21 13:48:25 +0000
committerTarmac <>2010-09-21 13:48:25 +0000
commitce0a9b7b36ba816c347f10a1804aedf337ad35da (patch)
treec9d789f62e15eb59414ece49572da64dd8a0a99d /nova
parent4e727faf450154d89687b1a33dae2159d5b691a0 (diff)
parent435a78e48ca63297af9c15ee826dbe0c6b8e7813 (diff)
Implements quotas with overrides for instances, volumes, and floating ips.
Diffstat (limited to 'nova')
-rw-r--r--nova/endpoint/cloud.py1
-rw-r--r--nova/quota.py9
2 files changed, 5 insertions, 5 deletions
diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py
index 28aee37d2..261e3e001 100644
--- a/nova/endpoint/cloud.py
+++ b/nova/endpoint/cloud.py
@@ -315,7 +315,6 @@ class CloudController(object):
@rbac.allow('projectmanager', 'sysadmin')
def create_volume(self, context, size, **kwargs):
# check quota
- size = int(size)
if quota.allowed_volumes(context, 1, size) < 1:
logging.warn("Quota exceeeded for %s, tried to create %sG volume",
context.project.id, size)
diff --git a/nova/quota.py b/nova/quota.py
index f0e51feeb..edbb83111 100644
--- a/nova/quota.py
+++ b/nova/quota.py
@@ -37,7 +37,7 @@ flags.DEFINE_integer('quota_gigabytes', 1000,
flags.DEFINE_integer('quota_floating_ips', 10,
'number of floating ips allowed per project')
-def _get_quota(context, project_id):
+def get_quota(context, project_id):
rval = {'instances': FLAGS.quota_instances,
'cores': FLAGS.quota_cores,
'volumes': FLAGS.quota_volumes,
@@ -57,7 +57,7 @@ def allowed_instances(context, num_instances, instance_type):
project_id = context.project.id
used_instances, used_cores = db.instance_data_get_for_project(context,
project_id)
- quota = _get_quota(context, project_id)
+ quota = get_quota(context, project_id)
allowed_instances = quota['instances'] - used_instances
allowed_cores = quota['cores'] - used_cores
type_cores = instance_types.INSTANCE_TYPES[instance_type]['vcpus']
@@ -72,9 +72,10 @@ def allowed_volumes(context, num_volumes, size):
project_id = context.project.id
used_volumes, used_gigabytes = db.volume_data_get_for_project(context,
project_id)
- quota = _get_quota(context, project_id)
+ quota = get_quota(context, project_id)
allowed_volumes = quota['volumes'] - used_volumes
allowed_gigabytes = quota['gigabytes'] - used_gigabytes
+ size = int(size)
num_gigabytes = num_volumes * size
allowed_volumes = min(allowed_volumes,
int(allowed_gigabytes // size))
@@ -85,7 +86,7 @@ def allowed_floating_ips(context, num_floating_ips):
"""Check quota and return min(num_floating_ips, allowed_floating_ips)"""
project_id = context.project.id
used_floating_ips = db.floating_ip_count_by_project(context, project_id)
- quota = _get_quota(context, project_id)
+ quota = get_quota(context, project_id)
allowed_floating_ips = quota['floating_ips'] - used_floating_ips
return min(num_floating_ips, allowed_floating_ips)