Logging audit for trove/backup module
Adjust log messages to conform to logging standards. Change-Id: Id11f7fec952a7f9d4af3c4b40d3283d8871026d4 Partial-Bug: #1324206
This commit is contained in:
parent
f2967bd915
commit
e1f227c8e4
|
@ -26,6 +26,8 @@ from trove.taskmanager import api
|
|||
from trove.common.remote import create_swift_client
|
||||
from trove.common import utils
|
||||
from trove.quota.quota import run_with_quotas
|
||||
from trove.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -100,7 +102,8 @@ class Backup(object):
|
|||
datastore_version_id=ds_version.id,
|
||||
deleted=False)
|
||||
except exception.InvalidModelError as ex:
|
||||
LOG.exception("Unable to create Backup record:")
|
||||
LOG.exception(_("Unable to create backup record for "
|
||||
"instance: %s"), instance_id)
|
||||
raise exception.BackupCreationError(str(ex))
|
||||
|
||||
backup_info = {'id': db_info.id,
|
||||
|
@ -235,9 +238,8 @@ class Backup(object):
|
|||
def _delete_resources():
|
||||
backup = cls.get_by_id(context, backup_id)
|
||||
if backup.is_running:
|
||||
msg = ("Backup %s cannot be delete because it is running." %
|
||||
backup_id)
|
||||
raise exception.UnprocessableEntity(msg)
|
||||
msg = _("Backup %s cannot be deleted because it is running.")
|
||||
raise exception.UnprocessableEntity(msg % backup_id)
|
||||
cls.verify_swift_auth_token(context)
|
||||
api.API(context).delete_backup(backup_id)
|
||||
|
||||
|
@ -280,7 +282,8 @@ class DBBackup(DatabaseModelBase):
|
|||
if self.location:
|
||||
last_slash = self.location.rfind("/")
|
||||
if last_slash < 0:
|
||||
raise ValueError("Bad location for backup object.")
|
||||
raise ValueError(_("Bad location for backup object: %s")
|
||||
% self.location)
|
||||
return self.location[last_slash + 1:]
|
||||
else:
|
||||
return None
|
||||
|
@ -303,10 +306,11 @@ class DBBackup(DatabaseModelBase):
|
|||
obj = parts[-1]
|
||||
container = parts[-2]
|
||||
client = create_swift_client(context)
|
||||
LOG.info(_("Checking if backup exist in '%s'") % self.location)
|
||||
LOG.debug("Checking if backup exists in %s" % self.location)
|
||||
resp = client.head_object(container, obj)
|
||||
if verify_checksum:
|
||||
LOG.info(_("Checking if backup checksum matches swift."))
|
||||
LOG.debug("Checking if backup checksum matches swift "
|
||||
"for backup %s" % self.id)
|
||||
# swift returns etag in double quotes
|
||||
# e.g. '"dc3b0827f276d8d78312992cc60c2c3f"'
|
||||
swift_checksum = resp['etag'].strip('"')
|
||||
|
|
|
@ -36,7 +36,7 @@ class BackupController(wsgi.Controller):
|
|||
"""
|
||||
Return all backups information for a tenant ID.
|
||||
"""
|
||||
LOG.debug("Listing Backups for tenant '%s'" % tenant_id)
|
||||
LOG.debug("Listing backups for tenant %s" % tenant_id)
|
||||
datastore = req.GET.get('datastore')
|
||||
context = req.environ[wsgi.CONTEXT_KEY]
|
||||
backups, marker = Backup.list(context, datastore)
|
||||
|
@ -47,14 +47,14 @@ class BackupController(wsgi.Controller):
|
|||
|
||||
def show(self, req, tenant_id, id):
|
||||
"""Return a single backup."""
|
||||
LOG.info(_("Showing a backup for tenant '%s'") % tenant_id)
|
||||
LOG.info(_("id : '%s'\n\n") % id)
|
||||
LOG.debug("Showing a backup for tenant %s ID: '%s'"
|
||||
% (tenant_id, id))
|
||||
context = req.environ[wsgi.CONTEXT_KEY]
|
||||
backup = Backup.get_by_id(context, id)
|
||||
return wsgi.Result(views.BackupView(backup).data(), 200)
|
||||
|
||||
def create(self, req, body, tenant_id):
|
||||
LOG.debug("Creating a Backup for tenant '%s'" % tenant_id)
|
||||
LOG.info(_("Creating a backup for tenant %s"), tenant_id)
|
||||
context = req.environ[wsgi.CONTEXT_KEY]
|
||||
data = body['backup']
|
||||
instance = data['instance']
|
||||
|
@ -65,7 +65,9 @@ class BackupController(wsgi.Controller):
|
|||
return wsgi.Result(views.BackupView(backup).data(), 202)
|
||||
|
||||
def delete(self, req, tenant_id, id):
|
||||
LOG.debug("Delete Backup for tenant: %s, ID: %s" % (tenant_id, id))
|
||||
LOG.info(_('Deleting backup for tenant %(tenant_id)s '
|
||||
'ID: %(backup_id)s') %
|
||||
{'tenant_id': tenant_id, 'backup_id': id})
|
||||
context = req.environ[wsgi.CONTEXT_KEY]
|
||||
Backup.delete(context, id)
|
||||
return wsgi.Result(None, 202)
|
||||
|
|
Loading…
Reference in New Issue