Merge "move Google backup exceptions"

This commit is contained in:
Zuul 2019-05-09 22:02:09 +00:00 committed by Gerrit Code Review
commit 6c46c0c3fe
3 changed files with 19 additions and 19 deletions

View File

@ -115,16 +115,29 @@ CONF.register_opts(gcsbackup_service_opts)
OAUTH_EXCEPTIONS = None
# Google Cloud Storage(GCS) backup driver
class GCSConnectionFailure(exception.BackupDriverException):
message = _("Google Cloud Storage connection failure: %(reason)s")
class GCSApiFailure(exception.BackupDriverException):
message = _("Google Cloud Storage api failure: %(reason)s")
class GCSOAuth2Failure(exception.BackupDriverException):
message = _("Google Cloud Storage oauth2 failure: %(reason)s")
def gcs_logger(func):
def func_wrapper(self, *args, **kwargs):
try:
return func(self, *args, **kwargs)
except errors.Error as err:
raise exception.GCSApiFailure(reason=err)
raise GCSApiFailure(reason=err)
except OAUTH_EXCEPTIONS as err:
raise exception.GCSOAuth2Failure(reason=err)
raise GCSOAuth2Failure(reason=err)
except Exception as err:
raise exception.GCSConnectionFailure(reason=err)
raise GCSConnectionFailure(reason=err)
return func_wrapper

View File

@ -1301,19 +1301,6 @@ class NexentaException(VolumeDriverException):
message = "%(reason)s"
# Google Cloud Storage(GCS) backup driver
class GCSConnectionFailure(BackupDriverException):
message = _("Google Cloud Storage connection failure: %(reason)s")
class GCSApiFailure(BackupDriverException):
message = _("Google Cloud Storage api failure: %(reason)s")
class GCSOAuth2Failure(BackupDriverException):
message = _("Google Cloud Storage oauth2 failure: %(reason)s")
# Kaminario K2
class KaminarioCinderDriverException(VolumeDriverException):
message = _("KaminarioCinderDriver failure: %(reason)s")

View File

@ -427,7 +427,7 @@ class GoogleBackupDriverTestCase(test.TestCase):
container=container_name)
service = google_dr.GoogleBackupDriver(self.ctxt)
self.volume_file.seek(0)
self.assertRaises(exception.GCSApiFailure,
self.assertRaises(google_dr.GCSApiFailure,
service.backup,
backup, self.volume_file)
@ -439,7 +439,7 @@ class GoogleBackupDriverTestCase(test.TestCase):
container=container_name)
service = google_dr.GoogleBackupDriver(self.ctxt)
self.volume_file.seek(0)
self.assertRaises(exception.GCSOAuth2Failure,
self.assertRaises(google_dr.GCSOAuth2Failure,
service.backup,
backup, self.volume_file)
@ -507,7 +507,7 @@ class GoogleBackupDriverTestCase(test.TestCase):
service = google_dr.GoogleBackupDriver(self.ctxt)
with tempfile.NamedTemporaryFile() as volume_file:
self.assertRaises(exception.GCSConnectionFailure,
self.assertRaises(google_dr.GCSConnectionFailure,
service.restore,
backup, volume_id, volume_file)