From ad389244ba5737d01f0c28e6704fc93b83dace9e Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Wed, 15 Nov 2017 11:00:12 -0500 Subject: 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 --- nova/volume/cinder.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'nova/volume/cinder.py') 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 /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) -- cgit v1.2.1