Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle NoneType parsing in nios_inventory.py #81

Merged
merged 2 commits into from
Sep 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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