Merge "Add error handling when Swift is not installed"

This commit is contained in:
Zuul 2019-04-10 02:00:58 +00:00 committed by Gerrit Code Review
commit eab1b7f236
3 changed files with 19 additions and 1 deletions

View File

@ -684,6 +684,11 @@ class LogAccessForbidden(Forbidden):
message = _("You must be admin to %(action)s log '%(log)s'.")
class LogsNotAvailable(Forbidden):
message = _("Log actions are not supported.")
class SlaveOperationNotSupported(TroveError):
message = _("The '%(operation)s' operation is not supported for slaves in "

View File

@ -368,7 +368,8 @@ class Controller(object):
exception.LocalStorageNotSupported,
exception.DatastoreOperationNotSupported,
exception.ClusterInstanceOperationNotSupported,
exception.ClusterDatastoreNotSupported
exception.ClusterDatastoreNotSupported,
exception.LogsNotAvailable
],
}

View File

@ -484,6 +484,12 @@ class InstanceController(wsgi.Controller):
"""Return all information about all logs for an instance."""
LOG.debug("Listing logs for tenant %s", tenant_id)
context = req.environ[wsgi.CONTEXT_KEY]
try:
backup_model.verify_swift_auth_token(context)
except exception.SwiftNotFound:
raise exception.LogsNotAvailable()
instance = models.Instance.load(context, id)
if not instance:
raise exception.NotFound(uuid=id)
@ -496,6 +502,12 @@ class InstanceController(wsgi.Controller):
"""Processes a guest log."""
LOG.info("Processing log for tenant %s", tenant_id)
context = req.environ[wsgi.CONTEXT_KEY]
try:
backup_model.verify_swift_auth_token(context)
except exception.SwiftNotFound:
raise exception.LogsNotAvailable()
instance = models.Instance.load(context, id)
if not instance:
raise exception.NotFound(uuid=id)