From 6e9adc46870816eb08f686537612ab1e319da504 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Fri, 29 May 2015 16:59:12 +0000 Subject: [PATCH] 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. --- cloud/openstack/os_server.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cloud/openstack/os_server.py b/cloud/openstack/os_server.py index f54b150388d..036d4edded7 100644 --- a/cloud/openstack/os_server.py +++ b/cloud/openstack/os_server.py @@ -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'):