summaryrefslogtreecommitdiff
path: root/nova/volume/cinder.py
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem.os@gmail.com>2017-11-15 11:00:12 -0500
committerMatt Riedemann <mriedem.os@gmail.com>2018-02-08 19:08:14 -0500
commitad389244ba5737d01f0c28e6704fc93b83dace9e (patch)
tree5e9f3f5f604e5c3704506b7b3cfe9f4ab32f8e9d /nova/volume/cinder.py
parentbca425a33f52584051348a3ace832be8151299a7 (diff)
downloadnova-ad389244ba5737d01f0c28e6704fc93b83dace9e.tar.gz
Add the ability to get absolute limits from Cinder
This will be used in a later patch to check quota usage for volume snapshots before attempting to create new volume snapshots, so we can avoid an OverLimit error. Change-Id: Ica7c087708e86494d285fc3905a5740fd1356e5f Related-Bug: #1731986
Diffstat (limited to 'nova/volume/cinder.py')
-rw-r--r--nova/volume/cinder.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py
index 34be704a8b..9337e71e9a 100644
--- a/nova/volume/cinder.py
+++ b/nova/volume/cinder.py
@@ -543,6 +543,23 @@ class API(object):
def update(self, context, volume_id, fields):
raise NotImplementedError()
+ @translate_cinder_exception
+ def get_absolute_limits(self, context):
+ """Returns quota limit and usage information for the given tenant
+
+ See the <volumev3>/v3/{project_id}/limits API reference for details.
+
+ :param context: The nova RequestContext for the user request. Note
+ that the limit information returned from Cinder is specific to
+ the project_id within this context.
+ :returns: dict of absolute limits
+ """
+ # cinderclient returns a generator of AbsoluteLimit objects, so iterate
+ # over the generator and return a dictionary which is easier for the
+ # nova client-side code to handle.
+ limits = cinderclient(context).limits.get().absolute
+ return {limit.name: limit.value for limit in limits}
+
@translate_snapshot_exception
def get_snapshot(self, context, snapshot_id):
item = cinderclient(context).volume_snapshots.get(snapshot_id)