Skip to content

Commit

Permalink
Handle NoneType parsing in nios_inventory.py (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
anagha-infoblox authored Sep 30, 2021
1 parent 8c45eb7 commit 859d33c
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
from ..module_utils.api import WapiInventory
from ..module_utils.api import normalize_extattrs, flatten_extattrs
from ansible.module_utils.six import iteritems
from ansible.errors import AnsibleError


class InventoryModule(BaseInventoryPlugin):
Expand All @@ -73,9 +74,10 @@ def parse(self, inventory, loader, path, cache=True): # Plugin interface (2)
extattrs = normalize_extattrs(self.get_option('extattrs'))
return_fields = ['name', 'view', 'extattrs', 'ipv4addrs']

print(host_filter)
hosts = wapi.get_object('record:host', host_filter, extattrs=extattrs, return_fields=return_fields) or []

hosts = wapi.get_object('record:host', host_filter, extattrs=extattrs, return_fields=return_fields)
if not hosts:
raise AnsibleError("host record is not present")

for host in hosts:
group_name = self.inventory.add_group(host['view'])
Expand Down

0 comments on commit 859d33c

Please sign in to comment.