cloud: Convert 'get_volume_limits' to use proxy layer

We missed this in 1.0.

Change-Id: I01955f42ca54d23c2a89f4e0636312e25f95b41c
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-07-27 15:09:35 +01:00
parent e8bece4aec
commit d474eb84c6
2 changed files with 12 additions and 19 deletions

View File

@ -1094,15 +1094,21 @@ class Proxy(_base_proxy.BaseBlockStorageProxy):
backup.reset(self, status)
# ====== LIMITS ======
def get_limits(self):
def get_limits(self, project=None):
"""Retrieves limits
:param project: A project to get limits for. The value can be either
the ID of a project or an
:class:`~openstack.identity.v3.project.Project` instance.
:returns: A Limit object, including both
:class:`~openstack.block_storage.v3.limits.AbsoluteLimit` and
:class:`~openstack.block_storage.v3.limits.RateLimit`
:rtype: :class:`~openstack.block_storage.v3.limits.Limit`
"""
return self._get(_limits.Limit, requires_id=False)
params = {}
if project:
params['project_id'] = resource.Resource._get_id(project)
return self._get(_limits.Limit, requires_id=False, **params)
def get_capabilities(self, host):
"""Get a backend's capabilites

View File

@ -17,7 +17,6 @@ from openstack.block_storage.v3 import quota_set as _qs
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack import exceptions
from openstack import proxy
from openstack import warnings as os_warnings
@ -279,7 +278,6 @@ class BlockStorageCloudMixin:
volumes.append(volume)
return volumes
# TODO(stephenfin): Convert to use proxy
def get_volume_limits(self, name_or_id=None):
"""Get volume limits for the current project
@ -288,23 +286,12 @@ class BlockStorageCloudMixin:
:returns: The volume ``Limit`` object if found, else None.
"""
params = {}
project_id = None
error_msg = "Failed to get limits"
if name_or_id:
proj = self.get_project(name_or_id)
if not proj:
project = self.get_project(name_or_id)
if not project:
raise exc.OpenStackCloudException("project does not exist")
project_id = proj.id
params['tenant_id'] = project_id
error_msg = "{msg} for the project: {project} ".format(
msg=error_msg, project=name_or_id
)
data = proxy._json_response(
self.block_storage.get('/limits', params=params)
)
limits = self._get_and_munchify('limits', data)
return limits
params['project'] = project
return self.block_storage.get_limits(**params)
def get_volume_id(self, name_or_id):
"""Get ID of a volume.