From 1a495922edf2ac3b18bfddce0b88dc52fec24e43 Mon Sep 17 00:00:00 2001 From: bhagyashris Date: Wed, 3 Aug 2016 19:41:51 +0530 Subject: [PATCH] Remove context object in oslo.log method Removed context object while logging as Cinder uses oslo.context's RequestContext which means the context object is in scope when doing logging. Change-Id: I7cc434ad10967596f8354775399e0c6c92ab5570 Closes-Bug:#1500896 --- cinder/api/contrib/backups.py | 2 +- cinder/api/contrib/cgsnapshots.py | 2 +- cinder/api/contrib/consistencygroups.py | 15 +++++---------- cinder/api/contrib/snapshot_unmanage.py | 2 +- cinder/api/contrib/volume_transfer.py | 8 +++----- cinder/api/contrib/volume_unmanage.py | 2 +- cinder/api/v1/snapshots.py | 4 ++-- cinder/api/v1/volumes.py | 6 +++--- cinder/api/v2/snapshots.py | 4 ++-- cinder/api/v2/volumes.py | 4 ++-- cinder/backup/api.py | 6 ++---- 11 files changed, 23 insertions(+), 32 deletions(-) diff --git a/cinder/api/contrib/backups.py b/cinder/api/contrib/backups.py index 56fb10698a3..2f120a2be7c 100644 --- a/cinder/api/contrib/backups.py +++ b/cinder/api/contrib/backups.py @@ -58,7 +58,7 @@ class BackupsController(wsgi.Controller): LOG.debug('Delete called for member %s.', id) context = req.environ['cinder.context'] - LOG.info(_LI('Delete backup with id: %s'), id, context=context) + LOG.info(_LI('Delete backup with id: %s'), id) try: backup = self.backup_api.get(context, id) diff --git a/cinder/api/contrib/cgsnapshots.py b/cinder/api/contrib/cgsnapshots.py index 7f3db5daad4..082d996e09a 100644 --- a/cinder/api/contrib/cgsnapshots.py +++ b/cinder/api/contrib/cgsnapshots.py @@ -57,7 +57,7 @@ class CgsnapshotsController(wsgi.Controller): LOG.debug('delete called for member %s', id) context = req.environ['cinder.context'] - LOG.info(_LI('Delete cgsnapshot with id: %s'), id, context=context) + LOG.info(_LI('Delete cgsnapshot with id: %s'), id) try: cgsnapshot = self.cgsnapshot_api.get_cgsnapshot( diff --git a/cinder/api/contrib/consistencygroups.py b/cinder/api/contrib/consistencygroups.py index c0260442e5b..ec0bc2b5345 100644 --- a/cinder/api/contrib/consistencygroups.py +++ b/cinder/api/contrib/consistencygroups.py @@ -71,8 +71,7 @@ class ConsistencyGroupsController(wsgi.Controller): msg = _("Invalid value '%s' for force.") % force raise exc.HTTPBadRequest(explanation=msg) - LOG.info(_LI('Delete consistency group with id: %s'), id, - context=context) + LOG.info(_LI('Delete consistency group with id: %s'), id) try: group = self.consistencygroup_api.get(context, id) @@ -129,8 +128,7 @@ class ConsistencyGroupsController(wsgi.Controller): availability_zone = consistencygroup.get('availability_zone', None) LOG.info(_LI("Creating consistency group %(name)s."), - {'name': name}, - context=context) + {'name': name}) try: new_consistencygroup = self.consistencygroup_api.create( @@ -178,13 +176,11 @@ class ConsistencyGroupsController(wsgi.Controller): if cgsnapshot_id: LOG.info(_LI("Creating consistency group %(name)s from " "cgsnapshot %(snap)s."), - {'name': name, 'snap': cgsnapshot_id}, - context=context) + {'name': name, 'snap': cgsnapshot_id}) elif source_cgid: LOG.info(_LI("Creating consistency group %(name)s from " "source consistency group %(source_cgid)s."), - {'name': name, 'source_cgid': source_cgid}, - context=context) + {'name': name, 'source_cgid': source_cgid}) try: new_consistencygroup = self.consistencygroup_api.create_from_src( @@ -217,8 +213,7 @@ class ConsistencyGroupsController(wsgi.Controller): 'name': name, 'description': description, 'add_volumes': add_volumes, - 'remove_volumes': remove_volumes}, - context=context) + 'remove_volumes': remove_volumes}) # Handle relevant exceptions at wsgi level group = self.consistencygroup_api.get(context, id) diff --git a/cinder/api/contrib/snapshot_unmanage.py b/cinder/api/contrib/snapshot_unmanage.py index bed3d56b593..f817746e0da 100644 --- a/cinder/api/contrib/snapshot_unmanage.py +++ b/cinder/api/contrib/snapshot_unmanage.py @@ -48,7 +48,7 @@ class SnapshotUnmanageController(wsgi.Controller): context = req.environ['cinder.context'] authorize(context) - LOG.info(_LI("Unmanage snapshot with id: %s"), id, context=context) + LOG.info(_LI("Unmanage snapshot with id: %s"), id) try: snapshot = self.volume_api.get_snapshot(context, id) diff --git a/cinder/api/contrib/volume_transfer.py b/cinder/api/contrib/volume_transfer.py index e304a6651b0..8531ae8c878 100644 --- a/cinder/api/contrib/volume_transfer.py +++ b/cinder/api/contrib/volume_transfer.py @@ -95,8 +95,7 @@ class VolumeTransferController(wsgi.Controller): name = name.strip() LOG.info(_LI("Creating transfer of volume %s"), - volume_id, - context=context) + volume_id) try: new_transfer = self.transfer_api.create(context, volume_id, name) @@ -124,8 +123,7 @@ class VolumeTransferController(wsgi.Controller): msg = _("Incorrect request body format") raise exc.HTTPBadRequest(explanation=msg) - LOG.info(_LI("Accepting transfer %s"), transfer_id, - context=context) + LOG.info(_LI("Accepting transfer %s"), transfer_id) try: accepted_transfer = self.transfer_api.accept(context, transfer_id, @@ -145,7 +143,7 @@ class VolumeTransferController(wsgi.Controller): """Delete a transfer.""" context = req.environ['cinder.context'] - LOG.info(_LI("Delete transfer with id: %s"), id, context=context) + LOG.info(_LI("Delete transfer with id: %s"), id) # Not found exception will be handled at the wsgi level self.transfer_api.delete(context, transfer_id=id) diff --git a/cinder/api/contrib/volume_unmanage.py b/cinder/api/contrib/volume_unmanage.py index e6e35abac7c..48b6b4d5ff9 100644 --- a/cinder/api/contrib/volume_unmanage.py +++ b/cinder/api/contrib/volume_unmanage.py @@ -49,7 +49,7 @@ class VolumeUnmanageController(wsgi.Controller): context = req.environ['cinder.context'] authorize(context) - LOG.info(_LI("Unmanage volume with id: %s"), id, context=context) + LOG.info(_LI("Unmanage volume with id: %s"), id) # Not found exception will be handled at the wsgi level vol = self.volume_api.get(context, id) diff --git a/cinder/api/v1/snapshots.py b/cinder/api/v1/snapshots.py index 4df61b52d73..b09dc90576c 100644 --- a/cinder/api/v1/snapshots.py +++ b/cinder/api/v1/snapshots.py @@ -82,7 +82,7 @@ class SnapshotsController(wsgi.Controller): """Delete a snapshot.""" context = req.environ['cinder.context'] - LOG.info(_LI("Delete snapshot with id: %s"), id, context=context) + LOG.info(_LI("Delete snapshot with id: %s"), id) # Not found exception will be handled at the wsgi level snapshot = self.volume_api.get_snapshot(context, id) @@ -140,7 +140,7 @@ class SnapshotsController(wsgi.Controller): force = snapshot.get('force', False) msg = _LI("Create snapshot from volume %s") - LOG.info(msg, volume_id, context=context) + LOG.info(msg, volume_id) if not utils.is_valid_boolstr(force): msg = _("Invalid value '%s' for force. ") % force diff --git a/cinder/api/v1/volumes.py b/cinder/api/v1/volumes.py index 9fc569c1403..2b96c1231d8 100644 --- a/cinder/api/v1/volumes.py +++ b/cinder/api/v1/volumes.py @@ -114,7 +114,7 @@ def _translate_volume_summary_view(context, vol, image_id=None): if image_id: d['image_id'] = image_id - LOG.info(_LI("vol=%s"), vol, context=context) + LOG.info(_LI("vol=%s"), vol) if vol.metadata: d['metadata'] = vol.metadata @@ -148,7 +148,7 @@ class VolumeController(wsgi.Controller): """Delete a volume.""" context = req.environ['cinder.context'] - LOG.info(_LI("Delete volume with id: %s"), id, context=context) + LOG.info(_LI("Delete volume with id: %s"), id) # Not found exception will be handled at the wsgi level volume = self.volume_api.get(context, id) @@ -258,7 +258,7 @@ class VolumeController(wsgi.Controller): elif size is None and kwargs['source_volume'] is not None: size = kwargs['source_volume']['size'] - LOG.info(_LI("Create volume of %s GB"), size, context=context) + LOG.info(_LI("Create volume of %s GB"), size) multiattach = volume.get('multiattach', False) kwargs['multiattach'] = multiattach diff --git a/cinder/api/v2/snapshots.py b/cinder/api/v2/snapshots.py index 87bfa5afc85..b5ed4a27c69 100644 --- a/cinder/api/v2/snapshots.py +++ b/cinder/api/v2/snapshots.py @@ -58,7 +58,7 @@ class SnapshotsController(wsgi.Controller): """Delete a snapshot.""" context = req.environ['cinder.context'] - LOG.info(_LI("Delete snapshot with id: %s"), id, context=context) + LOG.info(_LI("Delete snapshot with id: %s"), id) # Not found exception will be handled at the wsgi level snapshot = self.volume_api.get_snapshot(context, id) @@ -128,7 +128,7 @@ class SnapshotsController(wsgi.Controller): volume = self.volume_api.get(context, volume_id) force = snapshot.get('force', False) msg = _LI("Create snapshot from volume %s") - LOG.info(msg, volume_id, context=context) + LOG.info(msg, volume_id) self.validate_name_and_description(snapshot) # NOTE(thingee): v2 API allows name instead of display_name diff --git a/cinder/api/v2/volumes.py b/cinder/api/v2/volumes.py index 1ff0e8cc8e9..69f6b6be37b 100644 --- a/cinder/api/v2/volumes.py +++ b/cinder/api/v2/volumes.py @@ -68,7 +68,7 @@ class VolumeController(wsgi.Controller): cascade = utils.get_bool_param('cascade', req.params) - LOG.info(_LI("Delete volume with id: %s"), id, context=context) + LOG.info(_LI("Delete volume with id: %s"), id) # Not found exception will be handled at the wsgi level volume = self.volume_api.get(context, id) @@ -253,7 +253,7 @@ class VolumeController(wsgi.Controller): elif size is None and kwargs['source_replica'] is not None: size = kwargs['source_replica']['size'] - LOG.info(_LI("Create volume of %s GB"), size, context=context) + LOG.info(_LI("Create volume of %s GB"), size) if self.ext_mgr.is_loaded('os-image-create'): image_ref = volume.get('imageRef') diff --git a/cinder/backup/api.py b/cinder/backup/api.py index 2d98a7f20dd..6f4db616dba 100644 --- a/cinder/backup/api.py +++ b/cinder/backup/api.py @@ -395,8 +395,7 @@ class API(base.Base): LOG.info(_LI("Creating volume of %(size)s GB for restore of " "backup %(backup_id)s."), - {'size': size, 'backup_id': backup_id}, - context=context) + {'size': size, 'backup_id': backup_id}) volume = self.volume_api.create(context, size, name, description) volume_id = volume['id'] @@ -422,8 +421,7 @@ class API(base.Base): LOG.info(_LI("Overwriting volume %(volume_id)s with restore of " "backup %(backup_id)s"), - {'volume_id': volume_id, 'backup_id': backup_id}, - context=context) + {'volume_id': volume_id, 'backup_id': backup_id}) # Setting the status here rather than setting at start and unrolling # for each error condition, it should be a very small window