From a3314dbef9e749c3fa255aa9e751ec676cb20965 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 28 May 2018 18:38:17 +0800 Subject: [PATCH] QNAP: driver changes share size when manage share After manage share, driver updates the share size. The share size should not be updated. Change-Id: I5f670495cd61b63d1c0669c274b502a6a691e4e2 Closes-Bug: #1773761 --- manila/share/drivers/qnap/api.py | 3 ++- manila/share/drivers/qnap/qnap.py | 8 +++++--- manila/tests/share/drivers/qnap/test_api.py | 3 ++- ...p-fix-manage-share-size-override-a18acdf1a41909b0.yaml | 5 +++++ 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/bug-1773761-qnap-fix-manage-share-size-override-a18acdf1a41909b0.yaml diff --git a/manila/share/drivers/qnap/api.py b/manila/share/drivers/qnap/api.py index 46c1e39686..ef87cb6407 100644 --- a/manila/share/drivers/qnap/api.py +++ b/manila/share/drivers/qnap/api.py @@ -499,7 +499,6 @@ class QnapAPIExecutor(object): 'action': 'share_property', 'sharename': share_dict['sharename'], 'old_sharename': share_dict['old_sharename'], - 'vol_size': six.text_type(share_dict['new_size']) + 'GB', 'dedup': 'sha512' if share_dict['deduplication'] else 'off', 'compression': '1' if share_dict['compression'] else '0', 'thin_pro': '1' if share_dict['thin_provision'] else '0', @@ -515,6 +514,8 @@ class QnapAPIExecutor(object): 'recycle_bin_administrators_only': '0', 'sid': self.sid, } + if share_dict.get('new_size'): + params['vol_size'] = six.text_type(share_dict['new_size']) + 'GB' sanitized_params = self._sanitize_params(params) sanitized_params = urllib.parse.urlencode(sanitized_params) diff --git a/manila/share/drivers/qnap/qnap.py b/manila/share/drivers/qnap/qnap.py index 1546e4fb4c..085cfa9d45 100644 --- a/manila/share/drivers/qnap/qnap.py +++ b/manila/share/drivers/qnap/qnap.py @@ -17,6 +17,7 @@ Share driver for QNAP Storage. This driver supports QNAP Storage for NFS. """ import datetime +import math import re import time @@ -70,9 +71,11 @@ class QnapShareDriver(driver.ShareDriver): 1.0.3 - Add supports for Thin Provisioning, SSD Cache, Deduplication and Compression. 1.0.4 - Add support for QES fw 2.0.0. + 1.0.5 - Fix bug #1773761, when user tries to manage share, the size + of managed share should not be changed. """ - DRIVER_VERSION = '1.0.4' + DRIVER_VERSION = '1.0.5' def __init__(self, *args, **kwargs): """Initialize QnapShareDriver.""" @@ -837,12 +840,11 @@ class QnapShareDriver(driver.ShareDriver): vol_no = existing_share.find('vol_no').text vol = self.api_executor.get_specific_volinfo(vol_no) - vol_size_gb = int(vol.find('size').text) / units.Gi + vol_size_gb = math.ceil(float(vol.find('size').text) / units.Gi) share_dict = { 'sharename': share_name, 'old_sharename': share_name, - 'new_size': vol_size_gb, 'thin_provision': qnap_thin_provision, 'compression': qnap_compression, 'deduplication': qnap_deduplication, diff --git a/manila/tests/share/drivers/qnap/test_api.py b/manila/tests/share/drivers/qnap/test_api.py index e19a00c047..389c3073e9 100644 --- a/manila/tests/share/drivers/qnap/test_api.py +++ b/manila/tests/share/drivers/qnap/test_api.py @@ -475,7 +475,6 @@ class QnapAPITestCase(QnapShareDriverBaseTestCase): 'action': 'share_property', 'sharename': 'fakeVolId', 'old_sharename': 'fakeVolId', - 'vol_size': '100GB', 'dedup': 'off', 'compression': '1', 'thin_pro': '1', @@ -491,6 +490,8 @@ class QnapAPITestCase(QnapShareDriverBaseTestCase): 'recycle_bin_administrators_only': '0', 'sid': 'fakeSid', } + if expect_share_dict.get('new_size'): + fake_params['vol_size'] = '100GB' sanitized_params = self._sanitize_params(fake_params) fake_url = ( '/cgi-bin/priv/privWizard.cgi?%s' % sanitized_params) diff --git a/releasenotes/notes/bug-1773761-qnap-fix-manage-share-size-override-a18acdf1a41909b0.yaml b/releasenotes/notes/bug-1773761-qnap-fix-manage-share-size-override-a18acdf1a41909b0.yaml new file mode 100644 index 0000000000..a8493b3ce9 --- /dev/null +++ b/releasenotes/notes/bug-1773761-qnap-fix-manage-share-size-override-a18acdf1a41909b0.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixed the QNAP driver so that it does not modify the + share size on the back end when manila manages a share.