fix AnsibleError object name in subelements plugin

fixes #11624
pull/11628/head
Serge van Ginderachter 9 years ago
parent bc5a7fce79
commit 8d1549900c

@ -30,7 +30,7 @@ class LookupModule(LookupBase):
def run(self, terms, variables, **kwargs): def run(self, terms, variables, **kwargs):
def _raise_terms_error(msg=""): def _raise_terms_error(msg=""):
raise errors.AnsibleError( raise AnsibleError(
"subelements lookup expects a list of two or three items, " "subelements lookup expects a list of two or three items, "
+ msg) + msg)
terms = listify_lookup_plugin_terms(terms, variables, loader=self._loader) terms = listify_lookup_plugin_terms(terms, variables, loader=self._loader)
@ -66,7 +66,7 @@ class LookupModule(LookupBase):
ret = [] ret = []
for item0 in elementlist: for item0 in elementlist:
if not isinstance(item0, dict): if not isinstance(item0, dict):
raise errors.AnsibleError("subelements lookup expects a dictionary, got '%s'" % item0) raise AnsibleError("subelements lookup expects a dictionary, got '%s'" % item0)
if item0.get('skipped', False) is not False: if item0.get('skipped', False) is not False:
# this particular item is to be skipped # this particular item is to be skipped
continue continue
@ -82,18 +82,18 @@ class LookupModule(LookupBase):
if skip_missing: if skip_missing:
continue continue
else: else:
raise errors.AnsibleError("could not find '%s' key in iterated item '%s'" % (subkey, subvalue)) raise AnsibleError("could not find '%s' key in iterated item '%s'" % (subkey, subvalue))
if not lastsubkey: if not lastsubkey:
if not isinstance(subvalue[subkey], dict): if not isinstance(subvalue[subkey], dict):
if skip_missing: if skip_missing:
continue continue
else: else:
raise errors.AnsibleError("the key %s should point to a dictionary, got '%s'" % (subkey, subvalue[subkey])) raise AnsibleError("the key %s should point to a dictionary, got '%s'" % (subkey, subvalue[subkey]))
else: else:
subvalue = subvalue[subkey] subvalue = subvalue[subkey]
else: # lastsubkey else: # lastsubkey
if not isinstance(subvalue[subkey], list): if not isinstance(subvalue[subkey], list):
raise errors.AnsibleError("the key %s should point to a list, got '%s'" % (subkey, subvalue[subkey])) raise AnsibleError("the key %s should point to a list, got '%s'" % (subkey, subvalue[subkey]))
else: else:
sublist = subvalue.pop(subkey, []) sublist = subvalue.pop(subkey, [])
for item1 in sublist: for item1 in sublist:

Loading…
Cancel
Save