mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
IBM_Storage: fix host_add_ports (#49420)
iscsi_name and fcaddress fields are not required by default. This commit make sure that no exception is thrown if only on field supplied
This commit is contained in:
parent
6c26256945
commit
335ee5908d
2 changed files with 8 additions and 3 deletions
|
@ -76,7 +76,7 @@ def build_pyxcli_command(fields):
|
||||||
""" Builds the args for pyxcli using the exact args from ansible"""
|
""" Builds the args for pyxcli using the exact args from ansible"""
|
||||||
pyxcli_args = {}
|
pyxcli_args = {}
|
||||||
for field in fields:
|
for field in fields:
|
||||||
if field in AVAILABLE_PYXCLI_FIELDS and fields[field]:
|
if field in AVAILABLE_PYXCLI_FIELDS and fields[field] != '':
|
||||||
pyxcli_args[field] = fields[field]
|
pyxcli_args[field] = fields[field]
|
||||||
return pyxcli_args
|
return pyxcli_args
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ def main():
|
||||||
|
|
||||||
xcli_client = connect_ssl(module)
|
xcli_client = connect_ssl(module)
|
||||||
# required args
|
# required args
|
||||||
ports = None
|
ports = []
|
||||||
try:
|
try:
|
||||||
ports = xcli_client.cmd.host_list_ports(
|
ports = xcli_client.cmd.host_list_ports(
|
||||||
host=module.params.get('host')).as_list
|
host=module.params.get('host')).as_list
|
||||||
|
@ -109,9 +109,14 @@ def main():
|
||||||
port_exists = False
|
port_exists = False
|
||||||
ports = [port.get('port_name') for port in ports]
|
ports = [port.get('port_name') for port in ports]
|
||||||
|
|
||||||
|
fc_ports = (module.params.get('fcaddress')
|
||||||
|
if module.params.get('fcaddress') else [])
|
||||||
|
iscsi_ports = (module.params.get('iscsi_name')
|
||||||
|
if module.params.get('iscsi_name') else [])
|
||||||
for port in ports:
|
for port in ports:
|
||||||
if port in module.params.get('iscsi_name', "") or port in module.params.get('fcaddress', ""):
|
if port in iscsi_ports or port in fc_ports:
|
||||||
port_exists = True
|
port_exists = True
|
||||||
|
break
|
||||||
state_changed = False
|
state_changed = False
|
||||||
if state == 'present' and not port_exists:
|
if state == 'present' and not port_exists:
|
||||||
state_changed = execute_pyxcli_command(
|
state_changed = execute_pyxcli_command(
|
||||||
|
|
Loading…
Reference in a new issue