Huawei: Fix exception in update_access not found
When share is deleted in the backend, user is unable to delete share because of error thrown in update_access(). Make backend raise ShareResourceNotFound exception in case share not found during "update_access" operation, because share manager expects it for proper handling of share deletion, thus allowing share to be deleted in this case, without having to use force-delete. After add ShareResourceNotFound exception, it will need a parameter named share id(share['id']), so add share id to share info in create_share_from_snapshot function. Change-Id: I9756ff882e6960b07f5f0abac94057c687830ad0 Closes-Bug: #1585035
This commit is contained in:
parent
c5b0124541
commit
548975ee2d
@ -388,6 +388,7 @@ class V3StorageConnection(driver.HuaweiBase):
|
|||||||
"mount_path": new_share_path.replace("\\", "/"),
|
"mount_path": new_share_path.replace("\\", "/"),
|
||||||
"mount_src":
|
"mount_src":
|
||||||
tempfile.mkdtemp(prefix=constants.TMP_PATH_DST_PREFIX),
|
tempfile.mkdtemp(prefix=constants.TMP_PATH_DST_PREFIX),
|
||||||
|
"id": snapshot['share_id'],
|
||||||
}
|
}
|
||||||
|
|
||||||
old_share_path = self._get_location_path(old_share_name,
|
old_share_path = self._get_location_path(old_share_name,
|
||||||
@ -399,7 +400,8 @@ class V3StorageConnection(driver.HuaweiBase):
|
|||||||
"mount_src":
|
"mount_src":
|
||||||
tempfile.mkdtemp(prefix=constants.TMP_PATH_SRC_PREFIX),
|
tempfile.mkdtemp(prefix=constants.TMP_PATH_SRC_PREFIX),
|
||||||
"snapshot_name": ("share_snapshot_" +
|
"snapshot_name": ("share_snapshot_" +
|
||||||
snapshot['id'].replace("-", "_"))
|
snapshot['id'].replace("-", "_")),
|
||||||
|
"id": snapshot['share_id'],
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -701,14 +703,15 @@ class V3StorageConnection(driver.HuaweiBase):
|
|||||||
' for CIFS shares.')
|
' for CIFS shares.')
|
||||||
raise exception.InvalidShareAccess(reason=message)
|
raise exception.InvalidShareAccess(reason=message)
|
||||||
|
|
||||||
share = self.helper._get_share_by_name(share_name, share_url_type)
|
share_stor = self.helper._get_share_by_name(share_name,
|
||||||
if not share:
|
share_url_type)
|
||||||
err_msg = (_("Can not get share ID by share %s.")
|
if not share_stor:
|
||||||
|
err_msg = (_("Share %s does not exist on the backend.")
|
||||||
% share_name)
|
% share_name)
|
||||||
LOG.error(err_msg)
|
LOG.error(err_msg)
|
||||||
raise exception.InvalidShareAccess(reason=err_msg)
|
raise exception.ShareResourceNotFound(share_id=share['id'])
|
||||||
|
|
||||||
share_id = share['ID']
|
share_id = share_stor['ID']
|
||||||
|
|
||||||
# Check if access already exists
|
# Check if access already exists
|
||||||
access_id = self.helper._get_access_from_share(share_id,
|
access_id = self.helper._get_access_from_share(share_id,
|
||||||
|
@ -1992,7 +1992,7 @@ class HuaweiShareDriverTestCase(test.TestCase):
|
|||||||
self.driver.plugin.helper.login()
|
self.driver.plugin.helper.login()
|
||||||
self.driver.plugin.helper.snapshot_flag = True
|
self.driver.plugin.helper.snapshot_flag = True
|
||||||
|
|
||||||
self.assertRaises(exception.InvalidShareAccess,
|
self.assertRaises(exception.ShareResourceNotFound,
|
||||||
self.driver.create_share_from_snapshot,
|
self.driver.create_share_from_snapshot,
|
||||||
self._context, self.share_nfs,
|
self._context, self.share_nfs,
|
||||||
self.nfs_snapshot, self.share_server)
|
self.nfs_snapshot, self.share_server)
|
||||||
@ -2044,7 +2044,7 @@ class HuaweiShareDriverTestCase(test.TestCase):
|
|||||||
self.driver.plugin.helper.login()
|
self.driver.plugin.helper.login()
|
||||||
self.driver.plugin.helper.snapshot_flag = True
|
self.driver.plugin.helper.snapshot_flag = True
|
||||||
|
|
||||||
self.assertRaises(exception.InvalidShareAccess,
|
self.assertRaises(exception.ShareResourceNotFound,
|
||||||
self.driver.create_share_from_snapshot,
|
self.driver.create_share_from_snapshot,
|
||||||
self._context, self.share_nfs,
|
self._context, self.share_nfs,
|
||||||
self.nfs_snapshot, self.share_server)
|
self.nfs_snapshot, self.share_server)
|
||||||
@ -2318,7 +2318,7 @@ class HuaweiShareDriverTestCase(test.TestCase):
|
|||||||
self.driver.plugin.helper.login()
|
self.driver.plugin.helper.login()
|
||||||
rules = [self.access_ip]
|
rules = [self.access_ip]
|
||||||
self.driver.plugin.helper.share_exist = False
|
self.driver.plugin.helper.share_exist = False
|
||||||
self.assertRaises(exception.InvalidShareAccess,
|
self.assertRaises(exception.ShareResourceNotFound,
|
||||||
self.driver.update_access, self._context,
|
self.driver.update_access, self._context,
|
||||||
self.share_nfs, rules, None, None, self.share_server)
|
self.share_nfs, rules, None, None, self.share_server)
|
||||||
|
|
||||||
@ -2380,7 +2380,7 @@ class HuaweiShareDriverTestCase(test.TestCase):
|
|||||||
def test_allow_access_ip_share_not_exist(self):
|
def test_allow_access_ip_share_not_exist(self):
|
||||||
self.driver.plugin.helper.login()
|
self.driver.plugin.helper.login()
|
||||||
self.driver.plugin.helper.share_exist = False
|
self.driver.plugin.helper.share_exist = False
|
||||||
self.assertRaises(exception.InvalidShareAccess,
|
self.assertRaises(exception.ShareResourceNotFound,
|
||||||
self.driver.allow_access, self._context,
|
self.driver.allow_access, self._context,
|
||||||
self.share_nfs, self.access_ip, self.share_server)
|
self.share_nfs, self.access_ip, self.share_server)
|
||||||
|
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Fix exception in update_access not found in Huawei driver.
|
Loading…
x
Reference in New Issue
Block a user