def _check_iscsi_response(self, out, **kwargs): LUN_BAD_LUN_UUID = 18990505 LUN_NO_SUCH_SNAPSHOT = 18990532 if not self.check_value_valid(out, ['error', 'code'], int): raise exception.MalformedResponse(cmd='_check_iscsi_response', reason=_('no error code found')) code = out['error']['code'] exc = None message = '' if code == LUN_BAD_LUN_UUID: exc = exception.SynoLUNNotExist(**kwargs) message = 'Bad LUN UUID' elif code == LUN_NO_SUCH_SNAPSHOT: exc = exception.SnapshotNotFound(**kwargs) message = 'No such snapshot' else: data = 'internal error' exc = exception.VolumeBackendAPIException(data=data) message = 'Internal error' message = '%s [%d]' % (message, code) return (message, exc)
def test_remove_export_error_get_lun_mapped(self): self.driver.common.remove_iscsi_export = mock.Mock() self.driver.common.get_iqn_and_trgid = mock.Mock() self.driver.common.is_lun_mapped = (mock.Mock( side_effect=exception.SynoLUNNotExist(message='dont care'))) result = self.driver.remove_export(CONTEXT, VOLUME) self.assertIsNone(result) self.driver.common.get_iqn_and_trgid.assert_not_called() self.driver.common.remove_iscsi_export.assert_not_called()