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:
parent
11f4340a44
commit
6e9adc4687
1 changed files with 7 additions and 0 deletions
|
@ -372,7 +372,14 @@ def _network_args(module, cloud):
|
||||||
args = []
|
args = []
|
||||||
nics = module.params['nics']
|
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):
|
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'):
|
if net.get('net-id'):
|
||||||
args.append(net)
|
args.append(net)
|
||||||
elif net.get('net-name'):
|
elif net.get('net-name'):
|
||||||
|
|
Loading…
Reference in a new issue