From f849dc9cad93f512554823fe3f26f171b45dfcf9 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Fri, 26 Jan 2018 06:33:44 -0500 Subject: [PATCH] add extattrs as an option when using nios lookup (#35371) --- lib/ansible/plugins/lookup/nios.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/lookup/nios.py b/lib/ansible/plugins/lookup/nios.py index 5236bef492..e545f25fb8 100644 --- a/lib/ansible/plugins/lookup/nios.py +++ b/lib/ansible/plugins/lookup/nios.py @@ -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