summaryrefslogtreecommitdiff
path: root/nova/quota.py
diff options
context:
space:
mode:
authormelanie witt <melwittt@gmail.com>2017-03-31 17:37:08 +0000
committermelanie witt <melwittt@gmail.com>2017-06-19 21:51:46 +0000
commit23e5036fbaf4ae9622027b129a6cd209029e52e5 (patch)
treee172d8150ae9992e0c0f679efae7d227cbe78caf /nova/quota.py
parent10cdcad85aa2f97d5af539a1c559f69022a65942 (diff)
downloadnova-23e5036fbaf4ae9622027b129a6cd209029e52e5.tar.gz
Count floating ips to check quota
This changes floating ips from a ReservableResource to a CountableResource and replaces quota reserve/commit/rollback with check_deltas accordingly. Note that floating ip quota is only relevant to nova-network and will be obsolete when nova-network is removed. Part of blueprint cells-count-resources-to-check-quota-in-api Change-Id: I9e6c16ebe73f2af11bcc47899f25289f08c1204a
Diffstat (limited to 'nova/quota.py')
-rw-r--r--nova/quota.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/nova/quota.py b/nova/quota.py
index 87bd897efb..4fd72bd30b 100644
--- a/nova/quota.py
+++ b/nova/quota.py
@@ -1900,6 +1900,12 @@ def _fixed_ip_count(context, project_id):
return {'project': {'fixed_ips': count}}
+def _floating_ip_count(context, project_id):
+ # NOTE(melwitt): This assumes a single cell.
+ count = objects.FloatingIPList.get_count_by_project(context, project_id)
+ return {'project': {'floating_ips': count}}
+
+
def _server_group_count(context, project_id, user_id=None):
"""Get the counts of server groups in the database.
@@ -1934,9 +1940,9 @@ resources = [
ReservableResource('ram', '_sync_instances', 'ram'),
CountableResource('security_groups', _security_group_count,
'security_groups'),
- ReservableResource('floating_ips', '_sync_floating_ips',
- 'floating_ips'),
CountableResource('fixed_ips', _fixed_ip_count, 'fixed_ips'),
+ CountableResource('floating_ips', _floating_ip_count,
+ 'floating_ips'),
AbsoluteResource('metadata_items', 'metadata_items'),
AbsoluteResource('injected_files', 'injected_files'),
AbsoluteResource('injected_file_content_bytes',