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

Merge pull request #10715 from mscherer/fix_import_errors_lookup_plugin

Add/correct missing imports for AnsibleError in v2 lookup plugins
This commit is contained in:
Toshio Kuratomi 2015-04-14 15:16:10 -07:00
commit 67e59c5429
3 changed files with 6 additions and 4 deletions

View file

@ -19,7 +19,7 @@ __metaclass__ = type
from itertools import product from itertools import product
from ansible.errors import * from ansible.errors import AnsibleError
from ansible.plugins.lookup import LookupBase from ansible.plugins.lookup import LookupBase
from ansible.utils.listify import listify_lookup_plugin_terms from ansible.utils.listify import listify_lookup_plugin_terms
@ -42,7 +42,7 @@ class LookupModule(LookupBase):
my_list = terms[:] my_list = terms[:]
if len(my_list) == 0: if len(my_list) == 0:
raise errors.AnsibleError("with_cartesian requires at least one element in each list") raise AnsibleError("with_cartesian requires at least one element in each list")
return [self._flatten(x) for x in product(*my_list, fillvalue=None)] return [self._flatten(x) for x in product(*my_list, fillvalue=None)]

View file

@ -17,6 +17,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from ansible.errors import AnsibleError
from ansible.plugins.lookup import LookupBase from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase): class LookupModule(LookupBase):
@ -24,6 +25,6 @@ class LookupModule(LookupBase):
def run(self, terms, varibles=None, **kwargs): def run(self, terms, varibles=None, **kwargs):
if not isinstance(terms, dict): if not isinstance(terms, dict):
raise errors.AnsibleError("with_dict expects a dict") raise AnsibleError("with_dict expects a dict")
return self._flatten_hash_to_list(terms) return self._flatten_hash_to_list(terms)

View file

@ -17,6 +17,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from ansible.errors import AnsibleError
from ansible.plugins.lookup import LookupBase from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase): class LookupModule(LookupBase):
@ -27,7 +28,7 @@ class LookupModule(LookupBase):
def run(self, terms, variables, **kwargs): def run(self, terms, variables, **kwargs):
if not isinstance(terms, list): if not isinstance(terms, list):
raise errors.AnsibleError("with_indexed_items expects a list") raise AnsibleError("with_indexed_items expects a list")
items = self._flatten(terms) items = self._flatten(terms)
return zip(range(len(items)), items) return zip(range(len(items)), items)