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:
parent
7f990ffa16
commit
ff55def55b
@ -89,9 +89,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
|
|||||||
or CONF.share_backend_name or 'Quobyte')
|
or CONF.share_backend_name or 'Quobyte')
|
||||||
|
|
||||||
def _fetch_existing_access(self, context, share):
|
def _fetch_existing_access(self, context, share):
|
||||||
volume_uuid = self._resolve_volume_name(
|
volume_uuid = self._resolve_volume_name(share['name'],
|
||||||
share['name'],
|
share['project_id'])
|
||||||
self._get_project_name(context, share['project_id']))
|
|
||||||
result = self.rpc.call('getConfiguration', {})
|
result = self.rpc.call('getConfiguration', {})
|
||||||
if result is None:
|
if result is None:
|
||||||
raise exception.QBException(
|
raise exception.QBException(
|
||||||
@ -184,7 +183,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
|
|||||||
self.rpc.call('setQuota', {"quotas": [
|
self.rpc.call('setQuota', {"quotas": [
|
||||||
{"consumer":
|
{"consumer":
|
||||||
[{"type": "VOLUME",
|
[{"type": "VOLUME",
|
||||||
"identifier": share["name"],
|
"identifier": self._resolve_volume_name(share["name"],
|
||||||
|
share['project_id']),
|
||||||
"tenant_id": share["project_id"]}],
|
"tenant_id": share["project_id"]}],
|
||||||
"limits": [{"type": "LOGICAL_DISK_SPACE",
|
"limits": [{"type": "LOGICAL_DISK_SPACE",
|
||||||
"value": newsize_bytes}]}
|
"value": newsize_bytes}]}
|
||||||
@ -223,9 +223,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
|
|||||||
raise exception.QBException(
|
raise exception.QBException(
|
||||||
_('Quobyte driver only supports NFS shares'))
|
_('Quobyte driver only supports NFS shares'))
|
||||||
|
|
||||||
volume_uuid = self._resolve_volume_name(
|
volume_uuid = self._resolve_volume_name(share['name'],
|
||||||
share['name'],
|
share['project_id'])
|
||||||
self._get_project_name(context, share['project_id']))
|
|
||||||
|
|
||||||
if not volume_uuid:
|
if not volume_uuid:
|
||||||
# create tenant, expect ERROR_GARBAGE_ARGS if it already exists
|
# 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):
|
def delete_share(self, context, share, share_server=None):
|
||||||
"""Delete the corresponding Quobyte volume."""
|
"""Delete the corresponding Quobyte volume."""
|
||||||
volume_uuid = self._resolve_volume_name(
|
volume_uuid = self._resolve_volume_name(share['name'],
|
||||||
share['name'],
|
share['project_id'])
|
||||||
self._get_project_name(context, share['project_id']))
|
|
||||||
if not volume_uuid:
|
if not volume_uuid:
|
||||||
LOG.warning("No volume found for "
|
LOG.warning("No volume found for "
|
||||||
"share %(project_id)s/%(name)s",
|
"share %(project_id)s/%(name)s",
|
||||||
@ -281,9 +279,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
|
|||||||
the backend
|
the backend
|
||||||
"""
|
"""
|
||||||
|
|
||||||
volume_uuid = self._resolve_volume_name(
|
volume_uuid = self._resolve_volume_name(share['name'],
|
||||||
share['name'],
|
share['project_id'])
|
||||||
self._get_project_name(context, share['project_id']))
|
|
||||||
|
|
||||||
LOG.debug("Ensuring Quobyte share %s", share['name'])
|
LOG.debug("Ensuring Quobyte share %s", share['name'])
|
||||||
|
|
||||||
@ -303,9 +300,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
|
|||||||
raise exception.InvalidShareAccess(
|
raise exception.InvalidShareAccess(
|
||||||
_('Quobyte driver only supports ip access control'))
|
_('Quobyte driver only supports ip access control'))
|
||||||
|
|
||||||
volume_uuid = self._resolve_volume_name(
|
volume_uuid = self._resolve_volume_name(share['name'],
|
||||||
share['name'],
|
share['project_id'])
|
||||||
self._get_project_name(context, share['project_id']))
|
|
||||||
ro = access['access_level'] == (constants.ACCESS_LEVEL_RO)
|
ro = access['access_level'] == (constants.ACCESS_LEVEL_RO)
|
||||||
call_params = {
|
call_params = {
|
||||||
"volume_uuid": volume_uuid,
|
"volume_uuid": volume_uuid,
|
||||||
@ -322,9 +318,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
|
|||||||
self._get_project_name(context, share['project_id']))
|
self._get_project_name(context, share['project_id']))
|
||||||
return
|
return
|
||||||
|
|
||||||
volume_uuid = self._resolve_volume_name(
|
volume_uuid = self._resolve_volume_name(share['name'],
|
||||||
share['name'],
|
share['project_id'])
|
||||||
self._get_project_name(context, share['project_id']))
|
|
||||||
call_params = {
|
call_params = {
|
||||||
"volume_uuid": volume_uuid,
|
"volume_uuid": volume_uuid,
|
||||||
"remove_allow_ip": access['access_to']}
|
"remove_allow_ip": access['access_to']}
|
||||||
|
@ -416,7 +416,9 @@ class QuobyteShareDriverTestCase(test.TestCase):
|
|||||||
mock_qsd_resize_share.assert_called_once_with(share=self.share,
|
mock_qsd_resize_share.assert_called_once_with(share=self.share,
|
||||||
new_size=2)
|
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)
|
self._driver.rpc.call = mock.Mock(wraps=fake_rpc_handler)
|
||||||
manila_size = 7
|
manila_size = 7
|
||||||
newsize_bytes = manila_size * units.Gi
|
newsize_bytes = manila_size * units.Gi
|
||||||
@ -427,7 +429,7 @@ class QuobyteShareDriverTestCase(test.TestCase):
|
|||||||
"quotas": [{
|
"quotas": [{
|
||||||
"consumer": [{
|
"consumer": [{
|
||||||
"type": "VOLUME",
|
"type": "VOLUME",
|
||||||
"identifier": self.share["name"],
|
"identifier": "fake_volume_uuid",
|
||||||
"tenant_id": self.share["project_id"]
|
"tenant_id": self.share["project_id"]
|
||||||
}],
|
}],
|
||||||
"limits": [{
|
"limits": [{
|
||||||
@ -437,6 +439,8 @@ class QuobyteShareDriverTestCase(test.TestCase):
|
|||||||
}]}
|
}]}
|
||||||
self._driver.rpc.call.assert_has_calls([
|
self._driver.rpc.call.assert_has_calls([
|
||||||
mock.call('setQuota', exp_params)])
|
mock.call('setQuota', exp_params)])
|
||||||
|
mock_qb_resolv.assert_called_once_with(self.share['name'],
|
||||||
|
self.share['project_id'])
|
||||||
|
|
||||||
@mock.patch.object(quobyte.QuobyteShareDriver,
|
@mock.patch.object(quobyte.QuobyteShareDriver,
|
||||||
"_resolve_volume_name",
|
"_resolve_volume_name",
|
||||||
|
@ -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.
|
Loading…
Reference in New Issue
Block a user