summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2012-02-07 11:23:59 -0800
committerVishvananda Ishaya <vishvananda@gmail.com>2012-02-07 15:33:31 -0800
commita933e3628ba8cc2fb985665a724799ee0a58aa16 (patch)
treef992524d4d4563adde5bddfa0a97f88758d215bd
parent16882ad36b630fe8cc6c80a51cebf1a7f8f7cbf9 (diff)
Check return code instead of output for iscsiadm
* iscsiadm returns 255 on no records * Refixes bug 922232 Change-Id: If177c3c79c6ad974c2bed0ad72a62e956af451e0
-rw-r--r--nova/virt/libvirt/volume.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/nova/virt/libvirt/volume.py b/nova/virt/libvirt/volume.py
index 2bcf60d72..b1e609690 100644
--- a/nova/virt/libvirt/volume.py
+++ b/nova/virt/libvirt/volume.py
@@ -108,10 +108,16 @@ class LibvirtISCSIVolumeDriver(LibvirtVolumeDriver):
iscsi_properties = connection_info['data']
# NOTE(vish): if we are on the same host as nova volume, the
# discovery makes the target so we don't need to
- # run --op new
- (out, err) = self._run_iscsiadm(iscsi_properties, ())
- if err and err.strip() == "iscsiadm: no records found!":
- self._run_iscsiadm(iscsi_properties, ('--op', 'new'))
+ # run --op new. Therefore, we check to see if the
+ # target exists, and if we get 255 (Not Found), then
+ # we run --op new
+ try:
+ self._run_iscsiadm(iscsi_properties, ())
+ except exception.ProcessExecutionError as exc:
+ if exc.exit_code == 255:
+ self._run_iscsiadm(iscsi_properties, ('--op', 'new'))
+ else:
+ raise
if iscsi_properties.get('auth_method'):
self._iscsiadm_update(iscsi_properties,