From: John Griffith Date: Sat, 16 Aug 2014 15:11:54 +0000 (+0000) Subject: Fix LOG string formatting in image_utils X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=cc7e0b702c9eeafa564fb24d7accfb7a0c5a97db;p=openstack-build%2Fcinder-build.git Fix LOG string formatting in image_utils My recent change to report stats on image fetch and conversion used an incorrectly formatted log message. The result is Trace messages with Key errors in the c-vol log files. This change fixes those messages and gets rid of the key error exception messages in the Logs. Change-Id: Id8377dd7761d93fd854f5f7871c997418c6e4554 Closes-Bug: 1357726 --- diff --git a/cinder/image/image_utils.py b/cinder/image/image_utils.py index b6c372efc..f656e287a 100644 --- a/cinder/image/image_utils.py +++ b/cinder/image/image_utils.py @@ -79,14 +79,15 @@ def convert_image(source, dest, out_format, bps_limit=None): duration = 1 fsz_mb = os.stat(source).st_size / units.Mi mbps = (fsz_mb / duration) - LOG.debug('Image conversion details: src %(src)s, size %(sz).2f MB, ' - 'duration %(duration).2f, destination %(dest)s', - {'src': source, - 'sz': fsz_mb, - 'duration': duration, - 'dest': dest}) - LOG.info(_('Converted %(sz).2f MB image at %(mbps).2f MB/s'), - {'sz': fsz_mb, 'mbps': mbps}) + msg = ("Image conversion details: src %(src)s, size %(sz).2f MB, " + "duration %(duration).2f sec, destination %(dest)s") + LOG.debug(msg % {"src": source, + "sz": fsz_mb, + "duration": duration, + "dest": dest}) + + msg = _("Converted %(sz).2f MB image at %(mbps).2f MB/s") + LOG.info(msg % {"sz": fsz_mb, "mbps": mbps}) def resize_image(source, size, run_as_root=False): @@ -112,11 +113,13 @@ def fetch(context, image_service, image_id, path, _user_id, _project_id): duration = 1 fsz_mb = os.stat(image_file.name).st_size / units.Mi mbps = (fsz_mb / duration) - LOG.debug('Image fetch details: dest %(dest)s, size %(sz).2f MB, ' - 'duration %(duration).2f sec', - {'dest:': image_file.name, 'sz': fsz_mb, 'duration': duration}) - LOG.info(_('Image download %(sz).2f MB at %(mbps).2f MB/s'), - {'sz': fsz_mb, 'mbps': mbps}) + msg = ("Image fetch details: dest %(dest)s, size %(sz).2f MB, " + "duration %(duration).2f sec") + LOG.debug(msg % {"dest": image_file.name, + "sz": fsz_mb, + "duration": duration}) + msg = _("Image download %(sz).2f MB at %(mbps).2f MB/s") + LOG.info(msg % {"sz": fsz_mb, "mbps": mbps}) def fetch_verify_image(context, image_service, image_id, dest, diff --git a/cinder/volume/utils.py b/cinder/volume/utils.py index 068489ec0..7395965a0 100644 --- a/cinder/volume/utils.py +++ b/cinder/volume/utils.py @@ -224,14 +224,14 @@ def copy_volume(srcstr, deststr, size_in_m, blocksize, sync=False, if duration < 1: duration = 1 mbps = (size_in_m / duration) - LOG.debug(('Volume copy details: src %(src)s, dest %(dest)s, ' - 'size %(sz).2f MB, duration %(duration).2f sec'), - {'src': srcstr, - 'dest': deststr, - 'sz': size_in_m, - 'duration': duration}) - LOG.info(_('Volume copy %(sz).2f MB at %(mbps).2f MB/s'), - {'sz': size_in_m, 'duration': mbps}) + mesg = ("Volume copy details: src %(src)s, dest %(dest)s, " + "size %(sz).2f MB, duration %(duration).2f sec") + LOG.debug(mesg % {"src": srcstr, + "dest": deststr, + "sz": size_in_m, + "duration": duration}) + mesg = _("Volume copy %(size_in_m).2f MB at %(mbps).2f MB/s") + LOG.info(mesg % {'size_in_m': size_in_m, 'mbps': mbps}) def clear_volume(volume_size, volume_path, volume_clear=None,