From f3319d7c1e0b20b2f00cf3507e6c4d2e84983cec Mon Sep 17 00:00:00 2001 From: Peter Penchev Date: Fri, 12 Jun 2015 10:41:52 +0300 Subject: [PATCH] StorPool: clean up the last uses of str.format() Replace three logging uses of str.format() with parameters passed directly to LOG.error(), simplifying them in the process by avoiding the need to call six.text_type() ourselves. Replace the remaining use with string concatenation. Suggested by: Sean McGinnis in review 188725 Change-Id: Ie53c394d7f31fa1dccfa4ed5c4b514539c77aa05 --- cinder/volume/drivers/storpool.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/cinder/volume/drivers/storpool.py b/cinder/volume/drivers/storpool.py index d69feaf88..ae49beaf8 100644 --- a/cinder/volume/drivers/storpool.py +++ b/cinder/volume/drivers/storpool.py @@ -179,8 +179,9 @@ class StorPoolDriver(driver.TransferVD, driver.ExtendVD, driver.CloneableVD, self._attach.api().snapshotDelete(snapname) except spapi.ApiError as e: # ARGH! - LOG.error(_LE("Could not delete the temp snapshot {n}: {msg}"). - format(n=snapname, msg=six.text_type(e))) + LOG.error(_LE("Could not delete the temp snapshot %(name)s: " + "%(msg)s"), + {'name': snapname, 'msg': e}) def create_export(self, context, volume): pass @@ -221,8 +222,7 @@ class StorPoolDriver(driver.TransferVD, driver.ExtendVD, driver.CloneableVD, try: self._attach.api() except Exception as e: - LOG.error(_LE("StorPoolDriver API initialization failed: {e}"). - format(e=e)) + LOG.error(_LE("StorPoolDriver API initialization failed: %s"), e) raise def get_volume_stats(self, refresh=False): @@ -294,7 +294,7 @@ class StorPoolDriver(driver.TransferVD, driver.ExtendVD, driver.CloneableVD, self._attach.add(req_id, req) name = req['volume'] self._attach.sync(req_id, None) - return {'device': {'path': '/dev/storpool/{v}'.format(v=name), + return {'device': {'path': '/dev/storpool/' + name, 'storpool_attach_req': req_id}}, volume def _detach_volume(self, context, attach_info, volume, properties, @@ -336,8 +336,9 @@ class StorPoolDriver(driver.TransferVD, driver.ExtendVD, driver.CloneableVD, self._attach.api().snapshotDelete(name) except spapi.ApiError as e: LOG.error( - _LE('Could not remove the temp snapshot {n} for {v}: {e}'). - format(n=name, v=volname, e=six.text_type(e))) + _LE('Could not remove the temp snapshot %(name)s for ' + '%(vol)s: %(err)s'), + {'name': name, 'vol': volname, 'err': e}) def copy_volume_to_image(self, context, volume, image_service, image_meta): req_id = context.request_id @@ -363,8 +364,9 @@ class StorPoolDriver(driver.TransferVD, driver.ExtendVD, driver.CloneableVD, self._attach.api().snapshotDelete(name) except spapi.ApiError as e: LOG.error( - _LE('Could not remove the temp snapshot {n} for {v}: {e}'). - format(n=name, v=volname, e=six.text_type(e))) + _LE('Could not remove the temp snapshot %(name)s for ' + '%(vol)s: %(err)s'), + {'name': name, 'vol': volname, 'err': e}) def copy_image_to_volume(self, context, volume, image_service, image_id): req_id = context.request_id -- 2.45.2