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

pull/35524/head
Colins-Git 7 years ago committed by René Moser
parent 62b87bc925
commit ac7e62ec08

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

Loading…
Cancel
Save