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:
@@ -1094,15 +1094,21 @@ class Proxy(_base_proxy.BaseBlockStorageProxy):
|
|||||||
backup.reset(self, status)
|
backup.reset(self, status)
|
||||||
|
|
||||||
# ====== LIMITS ======
|
# ====== LIMITS ======
|
||||||
def get_limits(self):
|
def get_limits(self, project=None):
|
||||||
"""Retrieves limits
|
"""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
|
:returns: A Limit object, including both
|
||||||
:class:`~openstack.block_storage.v3.limits.AbsoluteLimit` and
|
:class:`~openstack.block_storage.v3.limits.AbsoluteLimit` and
|
||||||
:class:`~openstack.block_storage.v3.limits.RateLimit`
|
:class:`~openstack.block_storage.v3.limits.RateLimit`
|
||||||
:rtype: :class:`~openstack.block_storage.v3.limits.Limit`
|
: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):
|
def get_capabilities(self, host):
|
||||||
"""Get a backend's capabilites
|
"""Get a backend's capabilites
|
||||||
|
@@ -17,7 +17,6 @@ from openstack.block_storage.v3 import quota_set as _qs
|
|||||||
from openstack.cloud import _utils
|
from openstack.cloud import _utils
|
||||||
from openstack.cloud import exc
|
from openstack.cloud import exc
|
||||||
from openstack import exceptions
|
from openstack import exceptions
|
||||||
from openstack import proxy
|
|
||||||
from openstack import warnings as os_warnings
|
from openstack import warnings as os_warnings
|
||||||
|
|
||||||
|
|
||||||
@@ -279,7 +278,6 @@ class BlockStorageCloudMixin:
|
|||||||
volumes.append(volume)
|
volumes.append(volume)
|
||||||
return volumes
|
return volumes
|
||||||
|
|
||||||
# TODO(stephenfin): Convert to use proxy
|
|
||||||
def get_volume_limits(self, name_or_id=None):
|
def get_volume_limits(self, name_or_id=None):
|
||||||
"""Get volume limits for the current project
|
"""Get volume limits for the current project
|
||||||
|
|
||||||
@@ -288,23 +286,12 @@ class BlockStorageCloudMixin:
|
|||||||
:returns: The volume ``Limit`` object if found, else None.
|
:returns: The volume ``Limit`` object if found, else None.
|
||||||
"""
|
"""
|
||||||
params = {}
|
params = {}
|
||||||
project_id = None
|
|
||||||
error_msg = "Failed to get limits"
|
|
||||||
if name_or_id:
|
if name_or_id:
|
||||||
proj = self.get_project(name_or_id)
|
project = self.get_project(name_or_id)
|
||||||
if not proj:
|
if not project:
|
||||||
raise exc.OpenStackCloudException("project does not exist")
|
raise exc.OpenStackCloudException("project does not exist")
|
||||||
project_id = proj.id
|
params['project'] = project
|
||||||
params['tenant_id'] = project_id
|
return self.block_storage.get_limits(**params)
|
||||||
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
|
|
||||||
|
|
||||||
def get_volume_id(self, name_or_id):
|
def get_volume_id(self, name_or_id):
|
||||||
"""Get ID of a volume.
|
"""Get ID of a volume.
|
||||||
|
Reference in New Issue
Block a user