From: john-griffith Date: Wed, 27 Nov 2013 23:38:22 +0000 (-0700) Subject: Parse out '@' in volume['host'] to do discovery X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=d869dee85aa9d32d1a397b954f6583d6bfa60c18;p=openstack-build%2Fcinder-build.git Parse out '@' in volume['host'] to do discovery The backup method of getting iscsi info is to use iscsiadm discovery, however currently that method just uses volume['host'] which in the case of multi-backend will use "host@backend-name". This will cause the discovery to fail of course, so this change just parses out the '@' symbol if it's present and avoids the problem in the first place. This also beefs up the error logging and exception catching a bit. Parsing out the '@' symbol all the time should be safe as the accepted valid chars for hostnames are digits, a-z and hyphens. Change-Id: Ic45a38bf4c56a4aec6847ab0d29e3b41d35bd3d2 Closes-Bug: #1250673 --- diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index bd59f2138..d94b856cf 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -499,9 +499,20 @@ class ISCSIDriver(VolumeDriver): volume_name = volume['name'] - (out, _err) = self._execute('iscsiadm', '-m', 'discovery', - '-t', 'sendtargets', '-p', volume['host'], - run_as_root=True) + try: + # NOTE(griff) We're doing the split straight away which should be + # safe since using '@' in hostname is considered invalid + + (out, _err) = self._execute('iscsiadm', '-m', 'discovery', + '-t', 'sendtargets', '-p', + volume['host'].split('@')[0], + run_as_root=True) + except processutils.ProcessExecutionError as ex: + LOG.error(_("ISCSI discovery attempt failed for:%s") % + volume['host'].split('@')[0]) + LOG.debug(_("Error from iscsiadm -m discovery: %s") % ex.stderr) + return None + for target in out.splitlines(): if (self.configuration.iscsi_ip_address in target and volume_name in target):