mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
add extattrs as an option when using nios lookup (#35371)
This commit is contained in:
parent
0fb916c35e
commit
f849dc9cad
1 changed files with 11 additions and 1 deletions
|
@ -44,6 +44,10 @@ options:
|
|||
description: a dict object that is used to filter the return objects
|
||||
required: False
|
||||
default: null
|
||||
extattrs:
|
||||
descrpition: a dict object that is used to filter on extattrs
|
||||
required: false
|
||||
default: null
|
||||
"""
|
||||
|
||||
EXAMPLES = """
|
||||
|
@ -93,6 +97,7 @@ obj_type:
|
|||
from ansible.plugins.lookup import LookupBase
|
||||
from ansible.module_utils.net_tools.nios.api import nios_provider_spec
|
||||
from ansible.module_utils.net_tools.nios.api import get_connector
|
||||
from ansible.module_utils.net_tools.nios.api import normalize_extattrs, flatten_extattrs
|
||||
from ansible.errors import AnsibleError
|
||||
|
||||
|
||||
|
@ -106,6 +111,11 @@ class LookupModule(LookupBase):
|
|||
|
||||
return_fields = kwargs.pop('return_fields', None)
|
||||
filter_data = kwargs.pop('filter', {})
|
||||
extattrs = normalize_extattrs(kwargs.pop('extattrs', {}))
|
||||
provider = kwargs.pop('provider', {})
|
||||
connector = get_connector(**provider)
|
||||
return connector.get_object(obj_type, filter_data, return_fields=return_fields)
|
||||
res = connector.get_object(obj_type, filter_data, return_fields=return_fields)
|
||||
for obj in res:
|
||||
if 'extattrs' in obj:
|
||||
obj['extattrs'] = flatten_extattrs(obj['extattrs'])
|
||||
return res
|
||||
|
|
Loading…
Reference in a new issue