diff --git a/manila/share/drivers/huawei/v3/connection.py b/manila/share/drivers/huawei/v3/connection.py index dac3f0ce75..4195bbb9ee 100644 --- a/manila/share/drivers/huawei/v3/connection.py +++ b/manila/share/drivers/huawei/v3/connection.py @@ -388,6 +388,7 @@ class V3StorageConnection(driver.HuaweiBase): "mount_path": new_share_path.replace("\\", "/"), "mount_src": tempfile.mkdtemp(prefix=constants.TMP_PATH_DST_PREFIX), + "id": snapshot['share_id'], } old_share_path = self._get_location_path(old_share_name, @@ -399,7 +400,8 @@ class V3StorageConnection(driver.HuaweiBase): "mount_src": tempfile.mkdtemp(prefix=constants.TMP_PATH_SRC_PREFIX), "snapshot_name": ("share_snapshot_" + - snapshot['id'].replace("-", "_")) + snapshot['id'].replace("-", "_")), + "id": snapshot['share_id'], } try: @@ -701,14 +703,15 @@ class V3StorageConnection(driver.HuaweiBase): ' for CIFS shares.') raise exception.InvalidShareAccess(reason=message) - share = self.helper._get_share_by_name(share_name, share_url_type) - if not share: - err_msg = (_("Can not get share ID by share %s.") + share_stor = self.helper._get_share_by_name(share_name, + share_url_type) + if not share_stor: + err_msg = (_("Share %s does not exist on the backend.") % share_name) 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 access_id = self.helper._get_access_from_share(share_id, diff --git a/manila/tests/share/drivers/huawei/test_huawei_nas.py b/manila/tests/share/drivers/huawei/test_huawei_nas.py index f24fae0b6c..43d99152f1 100644 --- a/manila/tests/share/drivers/huawei/test_huawei_nas.py +++ b/manila/tests/share/drivers/huawei/test_huawei_nas.py @@ -1992,7 +1992,7 @@ class HuaweiShareDriverTestCase(test.TestCase): self.driver.plugin.helper.login() self.driver.plugin.helper.snapshot_flag = True - self.assertRaises(exception.InvalidShareAccess, + self.assertRaises(exception.ShareResourceNotFound, self.driver.create_share_from_snapshot, self._context, self.share_nfs, self.nfs_snapshot, self.share_server) @@ -2044,7 +2044,7 @@ class HuaweiShareDriverTestCase(test.TestCase): self.driver.plugin.helper.login() self.driver.plugin.helper.snapshot_flag = True - self.assertRaises(exception.InvalidShareAccess, + self.assertRaises(exception.ShareResourceNotFound, self.driver.create_share_from_snapshot, self._context, self.share_nfs, self.nfs_snapshot, self.share_server) @@ -2318,7 +2318,7 @@ class HuaweiShareDriverTestCase(test.TestCase): self.driver.plugin.helper.login() rules = [self.access_ip] self.driver.plugin.helper.share_exist = False - self.assertRaises(exception.InvalidShareAccess, + self.assertRaises(exception.ShareResourceNotFound, self.driver.update_access, self._context, 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): self.driver.plugin.helper.login() self.driver.plugin.helper.share_exist = False - self.assertRaises(exception.InvalidShareAccess, + self.assertRaises(exception.ShareResourceNotFound, self.driver.allow_access, self._context, self.share_nfs, self.access_ip, self.share_server) diff --git a/releasenotes/notes/fix-huawei-exception-a09b73234ksd94kd.yaml b/releasenotes/notes/fix-huawei-exception-a09b73234ksd94kd.yaml new file mode 100644 index 0000000000..34a9a482db --- /dev/null +++ b/releasenotes/notes/fix-huawei-exception-a09b73234ksd94kd.yaml @@ -0,0 +1,3 @@ +--- +fixes: + - Fix exception in update_access not found in Huawei driver.