Merge "move synology driver exceptions"
This commit is contained in:
commit
05ddc36dd7
@ -1323,19 +1323,6 @@ class KaminarioRetryableException(VolumeDriverException):
|
|||||||
message = _("Kaminario retryable exception: %(reason)s")
|
message = _("Kaminario retryable exception: %(reason)s")
|
||||||
|
|
||||||
|
|
||||||
# Synology driver
|
|
||||||
class SynoAPIHTTPError(VolumeDriverException):
|
|
||||||
message = _("HTTP exit code: [%(code)s]")
|
|
||||||
|
|
||||||
|
|
||||||
class SynoAuthError(VolumeDriverException):
|
|
||||||
message = _("Synology driver authentication failed: %(reason)s.")
|
|
||||||
|
|
||||||
|
|
||||||
class SynoLUNNotExist(VolumeDriverException):
|
|
||||||
message = _("LUN not found by UUID: %(uuid)s.")
|
|
||||||
|
|
||||||
|
|
||||||
class AttachmentSpecsNotFound(NotFound):
|
class AttachmentSpecsNotFound(NotFound):
|
||||||
message = _("Attachment %(attachment_id)s has no "
|
message = _("Attachment %(attachment_id)s has no "
|
||||||
"key %(specs_key)s.")
|
"key %(specs_key)s.")
|
||||||
|
@ -439,7 +439,7 @@ class SynoAPIRequestTestCase(test.TestCase):
|
|||||||
'success': False
|
'success': False
|
||||||
}, http_client.OK))
|
}, http_client.OK))
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.request.request,
|
self.request.request,
|
||||||
FAKE_API,
|
FAKE_API,
|
||||||
FAKE_METHOD,
|
FAKE_METHOD,
|
||||||
@ -516,7 +516,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
mock.Mock(side_effect=[
|
mock.Mock(side_effect=[
|
||||||
out,
|
out,
|
||||||
out,
|
out,
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
|
|
||||||
result = self.common._get_node_uuid()
|
result = self.common._get_node_uuid()
|
||||||
(self.common.exec_webapi.
|
(self.common.exec_webapi.
|
||||||
@ -529,7 +529,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.assertRaises(exception.VolumeDriverException,
|
self.assertRaises(exception.VolumeDriverException,
|
||||||
self.common._get_node_uuid)
|
self.common._get_node_uuid)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common._get_node_uuid)
|
self.common._get_node_uuid)
|
||||||
|
|
||||||
def test__get_pool_info(self):
|
def test__get_pool_info(self):
|
||||||
@ -543,7 +543,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
mock.Mock(side_effect=[
|
mock.Mock(side_effect=[
|
||||||
out,
|
out,
|
||||||
out,
|
out,
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
result = self.common._get_pool_info()
|
result = self.common._get_pool_info()
|
||||||
(self.common.exec_webapi.
|
(self.common.exec_webapi.
|
||||||
assert_called_with('SYNO.Core.Storage.Volume',
|
assert_called_with('SYNO.Core.Storage.Volume',
|
||||||
@ -556,7 +556,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.assertRaises(exception.MalformedResponse,
|
self.assertRaises(exception.MalformedResponse,
|
||||||
self.common._get_pool_info)
|
self.common._get_pool_info)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common._get_pool_info)
|
self.common._get_pool_info)
|
||||||
|
|
||||||
self.conf.synology_pool_name = ''
|
self.conf.synology_pool_name = ''
|
||||||
@ -633,7 +633,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
mock.Mock(side_effect=[
|
mock.Mock(side_effect=[
|
||||||
out,
|
out,
|
||||||
out,
|
out,
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
result = self.common._get_lun_info(VOLUME['name'],
|
result = self.common._get_lun_info(VOLUME['name'],
|
||||||
['is_mapped'])
|
['is_mapped'])
|
||||||
(self.common.exec_webapi.
|
(self.common.exec_webapi.
|
||||||
@ -649,7 +649,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.common._get_lun_info,
|
self.common._get_lun_info,
|
||||||
VOLUME['name'])
|
VOLUME['name'])
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common._get_lun_info,
|
self.common._get_lun_info,
|
||||||
VOLUME['name'])
|
VOLUME['name'])
|
||||||
|
|
||||||
@ -663,7 +663,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
mock.Mock(side_effect=[
|
mock.Mock(side_effect=[
|
||||||
lun_info,
|
lun_info,
|
||||||
lun_info,
|
lun_info,
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
|
|
||||||
result = self.common._get_lun_uuid(VOLUME['name'])
|
result = self.common._get_lun_uuid(VOLUME['name'])
|
||||||
self.assertEqual(LUN_UUID, result)
|
self.assertEqual(LUN_UUID, result)
|
||||||
@ -673,7 +673,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.common._get_lun_uuid,
|
self.common._get_lun_uuid,
|
||||||
VOLUME['name'])
|
VOLUME['name'])
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common._get_lun_uuid,
|
self.common._get_lun_uuid,
|
||||||
VOLUME['name'])
|
VOLUME['name'])
|
||||||
|
|
||||||
@ -688,7 +688,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
lun_info,
|
lun_info,
|
||||||
lun_info,
|
lun_info,
|
||||||
lun_info,
|
lun_info,
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
|
|
||||||
result = self.common._get_lun_status(VOLUME['name'])
|
result = self.common._get_lun_status(VOLUME['name'])
|
||||||
self.assertEqual((lun_info['status'], lun_info['is_action_locked']),
|
self.assertEqual((lun_info['status'], lun_info['is_action_locked']),
|
||||||
@ -704,7 +704,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.common._get_lun_status,
|
self.common._get_lun_status,
|
||||||
VOLUME['name'])
|
VOLUME['name'])
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common._get_lun_status,
|
self.common._get_lun_status,
|
||||||
VOLUME['name'])
|
VOLUME['name'])
|
||||||
|
|
||||||
@ -723,7 +723,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
mock.Mock(side_effect=[
|
mock.Mock(side_effect=[
|
||||||
out,
|
out,
|
||||||
out,
|
out,
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
result = self.common._get_snapshot_info(DS_SNAPSHOT_UUID,
|
result = self.common._get_snapshot_info(DS_SNAPSHOT_UUID,
|
||||||
additional=['status'])
|
additional=['status'])
|
||||||
(self.common.exec_webapi.
|
(self.common.exec_webapi.
|
||||||
@ -739,7 +739,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.common._get_snapshot_info,
|
self.common._get_snapshot_info,
|
||||||
DS_SNAPSHOT_UUID)
|
DS_SNAPSHOT_UUID)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common._get_snapshot_info,
|
self.common._get_snapshot_info,
|
||||||
DS_SNAPSHOT_UUID)
|
DS_SNAPSHOT_UUID)
|
||||||
|
|
||||||
@ -754,7 +754,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
snapshot_info,
|
snapshot_info,
|
||||||
snapshot_info,
|
snapshot_info,
|
||||||
snapshot_info,
|
snapshot_info,
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
|
|
||||||
result = self.common._get_snapshot_status(DS_SNAPSHOT_UUID)
|
result = self.common._get_snapshot_status(DS_SNAPSHOT_UUID)
|
||||||
self.assertEqual((snapshot_info['status'],
|
self.assertEqual((snapshot_info['status'],
|
||||||
@ -771,7 +771,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.common._get_snapshot_status,
|
self.common._get_snapshot_status,
|
||||||
DS_SNAPSHOT_UUID)
|
DS_SNAPSHOT_UUID)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common._get_snapshot_status,
|
self.common._get_snapshot_status,
|
||||||
DS_SNAPSHOT_UUID)
|
DS_SNAPSHOT_UUID)
|
||||||
|
|
||||||
@ -876,7 +876,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.common.exec_webapi = (
|
self.common.exec_webapi = (
|
||||||
mock.Mock(side_effect=[
|
mock.Mock(side_effect=[
|
||||||
out,
|
out,
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
self.conf.safe_get = (
|
self.conf.safe_get = (
|
||||||
mock.Mock(side_effect=[
|
mock.Mock(side_effect=[
|
||||||
self.conf.use_chap_auth,
|
self.conf.use_chap_auth,
|
||||||
@ -888,7 +888,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.common._target_create,
|
self.common._target_create,
|
||||||
VOLUME['id'])
|
VOLUME['id'])
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common._target_create,
|
self.common._target_create,
|
||||||
VOLUME['id'])
|
VOLUME['id'])
|
||||||
|
|
||||||
@ -903,7 +903,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.common.exec_webapi = (
|
self.common.exec_webapi = (
|
||||||
mock.Mock(side_effect=[
|
mock.Mock(side_effect=[
|
||||||
out,
|
out,
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
|
|
||||||
result = self.common._target_delete(TRG_ID)
|
result = self.common._target_delete(TRG_ID)
|
||||||
(self.common.exec_webapi.
|
(self.common.exec_webapi.
|
||||||
@ -913,7 +913,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
target_id=str(TRG_ID)))
|
target_id=str(TRG_ID)))
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common._target_delete,
|
self.common._target_delete,
|
||||||
TRG_ID)
|
TRG_ID)
|
||||||
|
|
||||||
@ -929,7 +929,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
mock.Mock(side_effect=[
|
mock.Mock(side_effect=[
|
||||||
out,
|
out,
|
||||||
out,
|
out,
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
self.common._get_lun_uuid = mock.Mock(return_value=LUN_UUID)
|
self.common._get_lun_uuid = mock.Mock(return_value=LUN_UUID)
|
||||||
|
|
||||||
result = self.common._lun_map_unmap_target(VOLUME['name'],
|
result = self.common._lun_map_unmap_target(VOLUME['name'],
|
||||||
@ -955,7 +955,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
target_ids=[str(TRG_ID)]))
|
target_ids=[str(TRG_ID)]))
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common._lun_map_unmap_target,
|
self.common._lun_map_unmap_target,
|
||||||
VOLUME['name'],
|
VOLUME['name'],
|
||||||
True,
|
True,
|
||||||
@ -994,13 +994,13 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.common.exec_webapi = (
|
self.common.exec_webapi = (
|
||||||
mock.Mock(side_effect=[
|
mock.Mock(side_effect=[
|
||||||
out,
|
out,
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
|
|
||||||
result = self.common._modify_lun_name(VOLUME['name'],
|
result = self.common._modify_lun_name(VOLUME['name'],
|
||||||
NEW_VOLUME['name'])
|
NEW_VOLUME['name'])
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common._modify_lun_name,
|
self.common._modify_lun_name,
|
||||||
VOLUME['name'],
|
VOLUME['name'],
|
||||||
NEW_VOLUME['name'])
|
NEW_VOLUME['name'])
|
||||||
@ -1012,7 +1012,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
('normal', True),
|
('normal', True),
|
||||||
('normal', False),
|
('normal', False),
|
||||||
('cloning', False),
|
('cloning', False),
|
||||||
exception.SynoLUNNotExist(message='dont care')]))
|
common.SynoLUNNotExist(message='dont care')]))
|
||||||
|
|
||||||
result = self.common._check_lun_status_normal(VOLUME['name'])
|
result = self.common._check_lun_status_normal(VOLUME['name'])
|
||||||
self.assertEqual(1, _patched_sleep.call_count)
|
self.assertEqual(1, _patched_sleep.call_count)
|
||||||
@ -1023,7 +1023,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
result = self.common._check_lun_status_normal(VOLUME['name'])
|
result = self.common._check_lun_status_normal(VOLUME['name'])
|
||||||
self.assertFalse(result)
|
self.assertFalse(result)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoLUNNotExist,
|
self.assertRaises(common.SynoLUNNotExist,
|
||||||
self.common._check_lun_status_normal,
|
self.common._check_lun_status_normal,
|
||||||
VOLUME['name'])
|
VOLUME['name'])
|
||||||
|
|
||||||
@ -1034,7 +1034,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
('Healthy', True),
|
('Healthy', True),
|
||||||
('Healthy', False),
|
('Healthy', False),
|
||||||
('Unhealthy', False),
|
('Unhealthy', False),
|
||||||
exception.SynoLUNNotExist(message='dont care')]))
|
common.SynoLUNNotExist(message='dont care')]))
|
||||||
|
|
||||||
result = self.common._check_snapshot_status_healthy(DS_SNAPSHOT_UUID)
|
result = self.common._check_snapshot_status_healthy(DS_SNAPSHOT_UUID)
|
||||||
self.assertEqual(1, _patched_sleep.call_count)
|
self.assertEqual(1, _patched_sleep.call_count)
|
||||||
@ -1045,7 +1045,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
result = self.common._check_snapshot_status_healthy(DS_SNAPSHOT_UUID)
|
result = self.common._check_snapshot_status_healthy(DS_SNAPSHOT_UUID)
|
||||||
self.assertFalse(result)
|
self.assertFalse(result)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoLUNNotExist,
|
self.assertRaises(common.SynoLUNNotExist,
|
||||||
self.common._check_snapshot_status_healthy,
|
self.common._check_snapshot_status_healthy,
|
||||||
DS_SNAPSHOT_UUID)
|
DS_SNAPSHOT_UUID)
|
||||||
|
|
||||||
@ -1072,7 +1072,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
result = self.common._check_iscsi_response(out, uuid=LUN_UUID)
|
result = self.common._check_iscsi_response(out, uuid=LUN_UUID)
|
||||||
self.assertEqual('Bad LUN UUID [18990505]', result[0])
|
self.assertEqual('Bad LUN UUID [18990505]', result[0])
|
||||||
self.assertIsInstance(result[1],
|
self.assertIsInstance(result[1],
|
||||||
(exception.SynoLUNNotExist))
|
(common.SynoLUNNotExist))
|
||||||
|
|
||||||
out['error'].update(code=18990532)
|
out['error'].update(code=18990532)
|
||||||
result = self.common._check_iscsi_response(out,
|
result = self.common._check_iscsi_response(out,
|
||||||
@ -1144,8 +1144,8 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
|
|
||||||
self.common.exec_webapi = (
|
self.common.exec_webapi = (
|
||||||
mock.Mock(side_effect=
|
mock.Mock(side_effect=
|
||||||
exception.SynoAuthError(message='dont care')))
|
common.SynoAuthError(message='dont care')))
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common._check_ds_version)
|
self.common._check_ds_version)
|
||||||
|
|
||||||
def test__check_ds_ability(self):
|
def test__check_ds_ability(self):
|
||||||
@ -1193,8 +1193,8 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
|
|
||||||
self.common.exec_webapi = (
|
self.common.exec_webapi = (
|
||||||
mock.Mock(side_effect=
|
mock.Mock(side_effect=
|
||||||
exception.SynoAuthError(message='dont care')))
|
common.SynoAuthError(message='dont care')))
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common._check_ds_ability)
|
self.common._check_ds_ability)
|
||||||
|
|
||||||
@mock.patch.object(common.LOG, 'exception')
|
@mock.patch.object(common.LOG, 'exception')
|
||||||
@ -1229,7 +1229,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.common._check_iscsi_response = (
|
self.common._check_iscsi_response = (
|
||||||
mock.Mock(return_value=
|
mock.Mock(return_value=
|
||||||
('Bad LUN UUID',
|
('Bad LUN UUID',
|
||||||
exception.SynoLUNNotExist(message='dont care'))))
|
common.SynoLUNNotExist(message='dont care'))))
|
||||||
self.common._check_storage_response = (
|
self.common._check_storage_response = (
|
||||||
mock.Mock(return_value=
|
mock.Mock(return_value=
|
||||||
('Internal error',
|
('Internal error',
|
||||||
@ -1240,7 +1240,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.assertEqual(0, _logexc.call_count)
|
self.assertEqual(0, _logexc.call_count)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoLUNNotExist,
|
self.assertRaises(common.SynoLUNNotExist,
|
||||||
self.common.check_response,
|
self.common.check_response,
|
||||||
bad_out1)
|
bad_out1)
|
||||||
self.assertRaises(exception.VolumeBackendAPIException,
|
self.assertRaises(exception.VolumeBackendAPIException,
|
||||||
@ -1277,7 +1277,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
param2='value2')
|
param2='value2')
|
||||||
self.assertDictEqual(expected, result)
|
self.assertDictEqual(expected, result)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAPIHTTPError,
|
self.assertRaises(common.SynoAPIHTTPError,
|
||||||
self.common.exec_webapi,
|
self.common.exec_webapi,
|
||||||
api,
|
api,
|
||||||
method,
|
method,
|
||||||
@ -1307,13 +1307,13 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.common._get_lun_info = (
|
self.common._get_lun_info = (
|
||||||
mock.Mock(side_effect=[
|
mock.Mock(side_effect=[
|
||||||
LUN_INFO,
|
LUN_INFO,
|
||||||
exception.SynoAuthError(message='dont care'),
|
common.SynoAuthError(message='dont care'),
|
||||||
bad_lun_info]))
|
bad_lun_info]))
|
||||||
|
|
||||||
result = self.common.is_lun_mapped(VOLUME['name'])
|
result = self.common.is_lun_mapped(VOLUME['name'])
|
||||||
self.assertEqual(LUN_INFO['is_mapped'], result)
|
self.assertEqual(LUN_INFO['is_mapped'], result)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common.is_lun_mapped,
|
self.common.is_lun_mapped,
|
||||||
VOLUME['name'])
|
VOLUME['name'])
|
||||||
|
|
||||||
@ -1373,7 +1373,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
mock.Mock(side_effect=[
|
mock.Mock(side_effect=[
|
||||||
out,
|
out,
|
||||||
out,
|
out,
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
self.common._check_lun_status_normal = (
|
self.common._check_lun_status_normal = (
|
||||||
mock.Mock(side_effect=[True, False, True]))
|
mock.Mock(side_effect=[True, False, True]))
|
||||||
|
|
||||||
@ -1392,7 +1392,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.common.create_volume,
|
self.common.create_volume,
|
||||||
VOLUME)
|
VOLUME)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common.create_volume,
|
self.common.create_volume,
|
||||||
VOLUME)
|
VOLUME)
|
||||||
|
|
||||||
@ -1404,8 +1404,8 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
self.common.exec_webapi = (
|
self.common.exec_webapi = (
|
||||||
mock.Mock(side_effect=[
|
mock.Mock(side_effect=[
|
||||||
out,
|
out,
|
||||||
exception.SynoLUNNotExist(message='dont care'),
|
common.SynoLUNNotExist(message='dont care'),
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
|
|
||||||
result = self.common.delete_volume(VOLUME)
|
result = self.common.delete_volume(VOLUME)
|
||||||
self.common._get_lun_uuid.assert_called_with(VOLUME['name'])
|
self.common._get_lun_uuid.assert_called_with(VOLUME['name'])
|
||||||
@ -1419,7 +1419,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
result = self.common.delete_volume(VOLUME)
|
result = self.common.delete_volume(VOLUME)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common.delete_volume,
|
self.common.delete_volume,
|
||||||
VOLUME)
|
VOLUME)
|
||||||
|
|
||||||
@ -1564,9 +1564,9 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
SNAPSHOT)
|
SNAPSHOT)
|
||||||
|
|
||||||
self.common.exec_webapi = (
|
self.common.exec_webapi = (
|
||||||
mock.Mock(side_effect=exception.SynoAuthError(reason='dont care')))
|
mock.Mock(side_effect=common.SynoAuthError(reason='dont care')))
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common.create_snapshot,
|
self.common.create_snapshot,
|
||||||
SNAPSHOT)
|
SNAPSHOT)
|
||||||
|
|
||||||
@ -1612,7 +1612,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
DS_SNAPSHOT_UUID,
|
DS_SNAPSHOT_UUID,
|
||||||
DS_SNAPSHOT_UUID,
|
DS_SNAPSHOT_UUID,
|
||||||
exception.SnapshotMetadataNotFound(message='dont care'),
|
exception.SnapshotMetadataNotFound(message='dont care'),
|
||||||
exception.SynoAuthError(message='dont care')]))
|
common.SynoAuthError(message='dont care')]))
|
||||||
self.common._check_lun_status_normal = (
|
self.common._check_lun_status_normal = (
|
||||||
mock.Mock(side_effect=[True, False, True, True]))
|
mock.Mock(side_effect=[True, False, True, True]))
|
||||||
self.common.extend_volume = mock.Mock()
|
self.common.extend_volume = mock.Mock()
|
||||||
@ -1644,7 +1644,7 @@ class SynoCommonTestCase(test.TestCase):
|
|||||||
new_volume,
|
new_volume,
|
||||||
SNAPSHOT)
|
SNAPSHOT)
|
||||||
|
|
||||||
self.assertRaises(exception.SynoAuthError,
|
self.assertRaises(common.SynoAuthError,
|
||||||
self.common.create_volume_from_snapshot,
|
self.common.create_volume_from_snapshot,
|
||||||
new_volume,
|
new_volume,
|
||||||
SNAPSHOT)
|
SNAPSHOT)
|
||||||
|
@ -315,7 +315,7 @@ class SynoISCSIDriverTestCase(test.TestCase):
|
|||||||
self.driver.common.remove_iscsi_export = mock.Mock()
|
self.driver.common.remove_iscsi_export = mock.Mock()
|
||||||
self.driver.common.get_iqn_and_trgid = mock.Mock()
|
self.driver.common.get_iqn_and_trgid = mock.Mock()
|
||||||
self.driver.common.is_lun_mapped = (
|
self.driver.common.is_lun_mapped = (
|
||||||
mock.Mock(side_effect=exception.SynoLUNNotExist(
|
mock.Mock(side_effect=common.SynoLUNNotExist(
|
||||||
message='dont care')))
|
message='dont care')))
|
||||||
|
|
||||||
result = self.driver.remove_export(CONTEXT, VOLUME)
|
result = self.driver.remove_export(CONTEXT, VOLUME)
|
||||||
|
@ -82,6 +82,18 @@ CONF = cfg.CONF
|
|||||||
CONF.register_opts(cinder_opts, group=configuration.SHARED_CONF_GROUP)
|
CONF.register_opts(cinder_opts, group=configuration.SHARED_CONF_GROUP)
|
||||||
|
|
||||||
|
|
||||||
|
class SynoAPIHTTPError(exception.VolumeDriverException):
|
||||||
|
message = _("HTTP exit code: [%(code)s]")
|
||||||
|
|
||||||
|
|
||||||
|
class SynoAuthError(exception.VolumeDriverException):
|
||||||
|
message = _("Synology driver authentication failed: %(reason)s.")
|
||||||
|
|
||||||
|
|
||||||
|
class SynoLUNNotExist(exception.VolumeDriverException):
|
||||||
|
message = _("LUN not found by UUID: %(uuid)s.")
|
||||||
|
|
||||||
|
|
||||||
class AESCipher(object):
|
class AESCipher(object):
|
||||||
"""Encrypt with OpenSSL-compatible way"""
|
"""Encrypt with OpenSSL-compatible way"""
|
||||||
|
|
||||||
@ -172,7 +184,7 @@ class Session(object):
|
|||||||
if one_time_pass and not device_id:
|
if one_time_pass and not device_id:
|
||||||
self._did = result['data']['did']
|
self._did = result['data']['did']
|
||||||
else:
|
else:
|
||||||
raise exception.SynoAuthError(reason=_('Login failed.'))
|
raise SynoAuthError(reason=_('Login failed.'))
|
||||||
|
|
||||||
def _random_AES_passphrase(self, length):
|
def _random_AES_passphrase(self, length):
|
||||||
available = ('0123456789'
|
available = ('0123456789'
|
||||||
@ -284,7 +296,7 @@ def _connection_checker(func):
|
|||||||
for attempts in range(2):
|
for attempts in range(2):
|
||||||
try:
|
try:
|
||||||
return func(self, *args, **kwargs)
|
return func(self, *args, **kwargs)
|
||||||
except exception.SynoAuthError as e:
|
except SynoAuthError as e:
|
||||||
if attempts < 1:
|
if attempts < 1:
|
||||||
LOG.debug('Session might have expired.'
|
LOG.debug('Session might have expired.'
|
||||||
' Trying to relogin')
|
' Trying to relogin')
|
||||||
@ -383,8 +395,7 @@ class APIRequest(object):
|
|||||||
|
|
||||||
if ('error' in result and 'code' in result["error"]
|
if ('error' in result and 'code' in result["error"]
|
||||||
and result['error']['code'] == 105):
|
and result['error']['code'] == 105):
|
||||||
raise exception.SynoAuthError(reason=_('Session might have '
|
raise SynoAuthError(reason=_('Session might have expired.'))
|
||||||
'expired.'))
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -813,7 +824,7 @@ class SynoCommon(object):
|
|||||||
message = ''
|
message = ''
|
||||||
|
|
||||||
if code == LUN_BAD_LUN_UUID:
|
if code == LUN_BAD_LUN_UUID:
|
||||||
exc = exception.SynoLUNNotExist(**kwargs)
|
exc = SynoLUNNotExist(**kwargs)
|
||||||
message = 'Bad LUN UUID'
|
message = 'Bad LUN UUID'
|
||||||
elif code == LUN_NO_SUCH_SNAPSHOT:
|
elif code == LUN_NO_SUCH_SNAPSHOT:
|
||||||
exc = exception.SnapshotNotFound(**kwargs)
|
exc = exception.SnapshotNotFound(**kwargs)
|
||||||
@ -944,7 +955,7 @@ class SynoCommon(object):
|
|||||||
result = self.synoexec(api, method, version, **kwargs)
|
result = self.synoexec(api, method, version, **kwargs)
|
||||||
|
|
||||||
if 'http_status' in result and 200 != result['http_status']:
|
if 'http_status' in result and 200 != result['http_status']:
|
||||||
raise exception.SynoAPIHTTPError(code=result['http_status'])
|
raise SynoAPIHTTPError(code=result['http_status'])
|
||||||
|
|
||||||
result['api_info'] = {'api': api,
|
result['api_info'] = {'api': api,
|
||||||
'method': method,
|
'method': method,
|
||||||
@ -1085,7 +1096,7 @@ class SynoCommon(object):
|
|||||||
|
|
||||||
self.check_response(out)
|
self.check_response(out)
|
||||||
|
|
||||||
except exception.SynoLUNNotExist:
|
except SynoLUNNotExist:
|
||||||
LOG.warning('LUN does not exist')
|
LOG.warning('LUN does not exist')
|
||||||
except Exception:
|
except Exception:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
|
@ -142,7 +142,7 @@ class SynoISCSIDriver(driver.ISCSIDriver):
|
|||||||
try:
|
try:
|
||||||
if not self.common.is_lun_mapped(volume['name']):
|
if not self.common.is_lun_mapped(volume['name']):
|
||||||
return
|
return
|
||||||
except exception.SynoLUNNotExist:
|
except common.SynoLUNNotExist:
|
||||||
LOG.warning("Volume not exist")
|
LOG.warning("Volume not exist")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user