From f7730d31df65ec166b2bdb6667162dc22f7d4fd6 Mon Sep 17 00:00:00 2001 From: Avishay Traeger Date: Tue, 4 Jun 2013 11:46:20 +0300 Subject: [PATCH] Log iSCSI target output on error. Add the command output on error to aid in debugging. Change-Id: Ib505eaeba7f1ca0e54e99dec8ebbbf71df3e5a51 Fixes: bug 1186991 --- cinder/brick/iscsi/iscsi.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cinder/brick/iscsi/iscsi.py b/cinder/brick/iscsi/iscsi.py index 574869707..d09ae7ab5 100644 --- a/cinder/brick/iscsi/iscsi.py +++ b/cinder/brick/iscsi/iscsi.py @@ -167,9 +167,10 @@ class TgtAdm(TargetAdmin): '--update', name, run_as_root=True) - except exception.ProcessExecutionError, e: + except exception.ProcessExecutionError as e: LOG.error(_("Failed to create iscsi target for volume " - "id:%(vol_id)s.") % locals()) + "id:%(vol_id)s: %(e)s") + % {'vol_id': vol_id, 'e': str(e)}) #Don't forget to remove the persistent file we created os.unlink(volume_path) @@ -205,9 +206,10 @@ class TgtAdm(TargetAdmin): '--delete', iqn, run_as_root=True) - except exception.ProcessExecutionError, e: + except exception.ProcessExecutionError as e: LOG.error(_("Failed to remove iscsi target for volume " - "id:%(vol_id)s.") % locals()) + "id:%(vol_id)s: %(e)s") + % {'vol_id': vol_id, 'e': str(e)}) raise exception.ISCSITargetRemoveFailed(volume_id=vol_id) os.unlink(volume_path) @@ -259,10 +261,11 @@ class IetAdm(TargetAdmin): f = open(conf_file, 'a+') f.write(volume_conf) f.close() - except exception.ProcessExecutionError, e: + except exception.ProcessExecutionError as e: vol_id = name.split(':')[1] LOG.error(_("Failed to create iscsi target for volume " - "id:%(vol_id)s.") % locals()) + "id:%(vol_id)s: %(e)s") + % {'vol_id': vol_id, 'e': str(e)}) raise exception.ISCSITargetCreateFailed(volume_id=vol_id) return tid -- 2.45.2