Adds extend_share for Quobyte shares

Adds extend_share (and shrink_share) to the Quobyte driver.
Both are mapped to a common resize operation in the backend.

Implements: blueprint extend-quobyte-share

Change-Id: I3395310e4658d68f098da6980ecc5a6832458f5a
This commit is contained in:
Silvan Kaiser 2016-01-08 10:27:31 +01:00
parent 42ca76e4f1
commit 15be2869a0
3 changed files with 64 additions and 3 deletions

View File

@ -55,7 +55,7 @@ Mapping of share drivers and share features support
+----------------------------------------+-----------------------------+-----------------------+--------------+--------------+------------------------+----------------------------+
| IBM GPFS | DHSS = False(K) | \- | L | \- | K | K |
+----------------------------------------+-----------------------------+-----------------------+--------------+--------------+------------------------+----------------------------+
| Quobyte | DHSS = False (K) | \- | \- | \- | \- | \- |
| Quobyte | DHSS = False (K) | \- | M | M | \- | \- |
+----------------------------------------+-----------------------------+-----------------------+--------------+--------------+------------------------+----------------------------+
| Windows SMB | DHSS = True (L) & False (L) | L | L | L | L | L |
+----------------------------------------+-----------------------------+-----------------------+--------------+--------------+------------------------+----------------------------+

View File

@ -68,9 +68,15 @@ CONF.register_opts(quobyte_manila_share_opts)
class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
"""Map share commands to Quobyte volumes."""
"""Map share commands to Quobyte volumes.
DRIVER_VERSION = '1.0.1'
Version history:
1.0 - Initial driver.
1.0.1 - Adds ensure_share() implementation.
1.1 - Adds extend_share() and shrink_share() implementation.
"""
DRIVER_VERSION = '1.1'
def __init__(self, *args, **kwargs):
super(QuobyteShareDriver, self).__init__(False, *args, **kwargs)
@ -136,6 +142,12 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
"""
return project_id
def _resize_share(self, share, new_size):
# TODO(kaisers): check and update existing quota if already present
self.rpc.call('setQuota', {"consumer": {"type": 3,
"identifier": share["name"]},
"limits": {"type": 5, "value": new_size}})
def _resolve_volume_name(self, volume_name, tenant_domain):
"""Resolve a volume name to the global volume uuid."""
result = self.rpc.call('resolveVolumeName', dict(
@ -249,3 +261,25 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
self.rpc.call('exportVolume', dict(
volume_uuid=volume_uuid,
remove_allow_ip=access['access_to']))
def extend_share(self, ext_share, ext_size, share_server=None):
"""Uses resize_share to extend a share.
:param ext_share: Share model.
:param ext_size: New size of share (new_size > share['size']).
:param share_server: Currently not used.
"""
self._resize_share(share=ext_share, new_size=ext_size)
def shrink_share(self, shrink_share, shrink_size, share_server=None):
"""Uses resize_share to shrink a share.
Quobyte uses soft quotas. If a shares current size is bigger than
the new shrunken size no data is lost. Data can be continuously read
from the share but new writes receive out of disk space replies.
:param shrink_share: Share model.
:param shrink_size: New size of share (new_size < share['size']).
:param share_server: Currently not used.
"""
self._resize_share(share=shrink_share, new_size=shrink_size)

View File

@ -312,3 +312,30 @@ class QuobyteShareDriverTestCase(test.TestCase):
(mock_qb_resolve_volname.
assert_called_once_with(self.share['name'],
self.share['project_id']))
@mock.patch.object(quobyte.QuobyteShareDriver, "_resize_share")
def test_extend_share(self, mock_qsd_resize_share):
self._driver.extend_share(ext_share=self.share,
ext_size=2,
share_server=None)
mock_qsd_resize_share.assert_called_once_with(share=self.share,
new_size=2)
def test_resize_share(self):
self._driver.rpc.call = mock.Mock(wraps=fake_rpc_handler)
self._driver._resize_share(share=self.share, new_size=7)
self._driver.rpc.call.assert_has_calls([
mock.call('setQuota',
{"consumer": {"type": 3,
"identifier": self.share["name"]},
"limits": {"type": 5, "value": 7}})])
@mock.patch.object(quobyte.QuobyteShareDriver, "_resize_share")
def test_shrink_share(self, mock_qsd_resize_share):
self._driver.shrink_share(shrink_share=self.share,
shrink_size=3,
share_server=None)
mock_qsd_resize_share.assert_called_once_with(share=self.share,
new_size=3)