open_iscsi fails to login when discovery returns multiple portals #29309 (#35262)

This commit is contained in:
Colins-Git 2018-01-30 15:03:35 -08:00 committed by René Moser
parent 62b87bc925
commit ac7e62ec08

View file

@ -171,7 +171,7 @@ def target_loggedon(module, target):
module.fail_json(cmd=cmd, rc=rc, msg=err)
def target_login(module, target):
def target_login(module, target, portal=None, port=None):
node_auth = module.params['node_auth']
node_user = module.params['node_user']
node_pass = module.params['node_pass']
@ -187,6 +187,9 @@ def target_login(module, target):
module.fail_json(cmd=cmd, rc=rc, msg=err)
cmd = '%s --mode node --targetname %s --login' % (iscsiadm_cmd, target)
if portal is not None and port is not None:
cmd += ' --portal %s:%s' % (portal, port)
(rc, out, err) = module.run_command(cmd)
if rc > 0:
@ -333,7 +336,7 @@ def main():
result['devicenodes'] = target_device_node(module, target)
elif not check:
if login:
target_login(module, target)
target_login(module, target, portal, port)
# give udev some time
time.sleep(1)
result['devicenodes'] = target_device_node(module, target)