1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

os_server: Add some error checking for the 'nics' parameter

If this parameter was not of the right type, the module would fail with a
traceback, with a "AttributeError: 'str' object has no attribute 'get'"
exception.

It now gives a proper error message on type errors.
This commit is contained in:
Sam Thursfield 2015-05-29 16:59:12 +00:00 committed by Matt Clay
parent 317ea13759
commit eba767902c

View file

@ -372,7 +372,14 @@ def _network_args(module, cloud):
args = []
nics = module.params['nics']
if type(nics) != list:
module.fail_json(msg='The \'nics\' parameter must be a list.')
for net in _parse_nics(nics):
if type(net) != dict:
module.fail_json(
msg='Each entry in the \'nics\' parameter must be a dict.')
if net.get('net-id'):
args.append(net)
elif net.get('net-name'):