diff --git a/plugins/lookup/nios_next_ip.py b/plugins/lookup/nios_next_ip.py index 9b3dd8cd..287d009d 100644 --- a/plugins/lookup/nios_next_ip.py +++ b/plugins/lookup/nios_next_ip.py @@ -103,20 +103,20 @@ def run(self, terms, variables=None, **kwargs): provider = kwargs.pop('provider', {}) wapi = WapiLookup(provider) + network_view = kwargs.get('network_view', 'default') if isinstance(ipaddress.ip_network(network), ipaddress.IPv6Network): object_type = 'ipv6range' if kwargs.get('use_range', False) else 'ipv6network' else: object_type = 'range' if kwargs.get('use_range', False) else 'network' - network_obj = wapi.get_object(object_type, {'network': network}) + network_obj = wapi.get_object(object_type, {'network': network, 'network_view': network_view}) if network_obj is None: raise AnsibleError('unable to find network object %s' % network) num = kwargs.get('num', 1) exclude_ip = kwargs.get('exclude', []) - network_view = kwargs.get('network_view', 'default') ref_list = [network['_ref'] for network in network_obj if network['network_view'] == network_view] if not ref_list: