Skip to content

Commit

Permalink
Parse out '@' in volume['host'] to do discovery
Browse files Browse the repository at this point in the history
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
  • Loading branch information
j-griffith committed Nov 27, 2013
1 parent 79d8072 commit d869dee
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions cinder/volume/driver.py
Expand Up @@ -499,9 +499,20 @@ def _do_iscsi_discovery(self, volume):

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):
Expand Down

0 comments on commit d869dee

Please sign in to comment.