Merge pull request #11628 from srvg/bug/11624

fix AnsibleError object name in subelements plugin
This commit is contained in:
Brian Coca 2015-07-17 11:54:57 -04:00
commit 319812542f

View file

@ -30,7 +30,7 @@ class LookupModule(LookupBase):
def run(self, terms, variables, **kwargs):
def _raise_terms_error(msg=""):
raise errors.AnsibleError(
raise AnsibleError(
"subelements lookup expects a list of two or three items, "
+ msg)
terms = listify_lookup_plugin_terms(terms, variables, loader=self._loader)
@ -66,7 +66,7 @@ class LookupModule(LookupBase):
ret = []
for item0 in elementlist:
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:
# this particular item is to be skipped
continue
@ -82,18 +82,18 @@ class LookupModule(LookupBase):
if skip_missing:
continue
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 isinstance(subvalue[subkey], dict):
if skip_missing:
continue
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:
subvalue = subvalue[subkey]
else: # lastsubkey
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:
sublist = subvalue.pop(subkey, [])
for item1 in sublist: