Add error handling when Swift is not installed
So far, when Swift wasn't installed, there was no error handlig in trove API. This change adds LogsNotAvailable exception which is raised when swift endpoints are not available. Change-Id: I9a8a75b40bde90163560cdd758f17f9a98a41f0a Story: #2005378 Task: #30360 Signed-off-by: Kasper Hasior <k.hasior@samsung.com>
This commit is contained in:
parent
c590106f79
commit
99b30c3737
trove
@ -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 "
|
||||
|
@ -368,7 +368,8 @@ class Controller(object):
|
||||
exception.LocalStorageNotSupported,
|
||||
exception.DatastoreOperationNotSupported,
|
||||
exception.ClusterInstanceOperationNotSupported,
|
||||
exception.ClusterDatastoreNotSupported
|
||||
exception.ClusterDatastoreNotSupported,
|
||||
exception.LogsNotAvailable
|
||||
],
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user