Use volume_uuid in _resize_share of Quobyte Driver

Adds resolving the volume name to volume id when resizing
and cleans up _resolve_volume_name calls.

Closes-Bug: #1774604

Change-Id: I37ecd611c94f9b0019b87d5186f96aed93130f88
This commit is contained in:
Silvan Kaiser 2018-06-01 12:38:19 +02:00
parent 7f990ffa16
commit ff55def55b
3 changed files with 25 additions and 21 deletions

View File

@ -89,9 +89,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
or CONF.share_backend_name or 'Quobyte')
def _fetch_existing_access(self, context, share):
volume_uuid = self._resolve_volume_name(
share['name'],
self._get_project_name(context, share['project_id']))
volume_uuid = self._resolve_volume_name(share['name'],
share['project_id'])
result = self.rpc.call('getConfiguration', {})
if result is None:
raise exception.QBException(
@ -184,7 +183,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
self.rpc.call('setQuota', {"quotas": [
{"consumer":
[{"type": "VOLUME",
"identifier": share["name"],
"identifier": self._resolve_volume_name(share["name"],
share['project_id']),
"tenant_id": share["project_id"]}],
"limits": [{"type": "LOGICAL_DISK_SPACE",
"value": newsize_bytes}]}
@ -223,9 +223,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
raise exception.QBException(
_('Quobyte driver only supports NFS shares'))
volume_uuid = self._resolve_volume_name(
share['name'],
self._get_project_name(context, share['project_id']))
volume_uuid = self._resolve_volume_name(share['name'],
share['project_id'])
if not volume_uuid:
# create tenant, expect ERROR_GARBAGE_ARGS if it already exists
@ -251,9 +250,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
def delete_share(self, context, share, share_server=None):
"""Delete the corresponding Quobyte volume."""
volume_uuid = self._resolve_volume_name(
share['name'],
self._get_project_name(context, share['project_id']))
volume_uuid = self._resolve_volume_name(share['name'],
share['project_id'])
if not volume_uuid:
LOG.warning("No volume found for "
"share %(project_id)s/%(name)s",
@ -281,9 +279,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
the backend
"""
volume_uuid = self._resolve_volume_name(
share['name'],
self._get_project_name(context, share['project_id']))
volume_uuid = self._resolve_volume_name(share['name'],
share['project_id'])
LOG.debug("Ensuring Quobyte share %s", share['name'])
@ -303,9 +300,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
raise exception.InvalidShareAccess(
_('Quobyte driver only supports ip access control'))
volume_uuid = self._resolve_volume_name(
share['name'],
self._get_project_name(context, share['project_id']))
volume_uuid = self._resolve_volume_name(share['name'],
share['project_id'])
ro = access['access_level'] == (constants.ACCESS_LEVEL_RO)
call_params = {
"volume_uuid": volume_uuid,
@ -322,9 +318,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
self._get_project_name(context, share['project_id']))
return
volume_uuid = self._resolve_volume_name(
share['name'],
self._get_project_name(context, share['project_id']))
volume_uuid = self._resolve_volume_name(share['name'],
share['project_id'])
call_params = {
"volume_uuid": volume_uuid,
"remove_allow_ip": access['access_to']}

View File

@ -416,7 +416,9 @@ class QuobyteShareDriverTestCase(test.TestCase):
mock_qsd_resize_share.assert_called_once_with(share=self.share,
new_size=2)
def test_resize_share(self):
@mock.patch.object(quobyte.QuobyteShareDriver, "_resolve_volume_name",
return_value="fake_volume_uuid")
def test_resize_share(self, mock_qb_resolv):
self._driver.rpc.call = mock.Mock(wraps=fake_rpc_handler)
manila_size = 7
newsize_bytes = manila_size * units.Gi
@ -427,7 +429,7 @@ class QuobyteShareDriverTestCase(test.TestCase):
"quotas": [{
"consumer": [{
"type": "VOLUME",
"identifier": self.share["name"],
"identifier": "fake_volume_uuid",
"tenant_id": self.share["project_id"]
}],
"limits": [{
@ -437,6 +439,8 @@ class QuobyteShareDriverTestCase(test.TestCase):
}]}
self._driver.rpc.call.assert_has_calls([
mock.call('setQuota', exp_params)])
mock_qb_resolv.assert_called_once_with(self.share['name'],
self.share['project_id'])
@mock.patch.object(quobyte.QuobyteShareDriver,
"_resolve_volume_name",

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixed a bug in the Quobyte driver that allowed share resizing to
incorrectly address the share to be resized in the backend.