Skip to content

Bug: Invalid query parameters applied to VM API #63

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

Closed
loganbest opened this issue Jan 13, 2020 · 3 comments · Fixed by #103
Closed

Bug: Invalid query parameters applied to VM API #63

loganbest opened this issue Jan 13, 2020 · 3 comments · Fixed by #103
Labels
bug Something isn't working PR Submitted
Milestone

Comments

@loganbest
Copy link
Contributor

loganbest commented Jan 13, 2020

ISSUE TYPE
  • Bug Report
SUMMARY

When using the query_filters option and the serial filter, all virtual machines are returned due to serial not being a valid query filter (or field) for virtual machines. Netbox ignores invalid query parameters and returns all results matching the other (if any) filters.

The offending line is here:
https://github.com/netbox-community/ansible_modules/blob/devel/plugins/inventory/netbox.py#L418

Some additional parsing of query parameters is needed to remove anything invalid for virtual-machines.

Original Ansible Core Issues:
ansible/ansible#57376

@tyler-8 was the original reporter.

STEPS TO REPRODUCE
  • Add device with serial number ABC1234 to Netbox
  • Add VM to netbox
# netbox_inventory.yml
plugin: netbox
api_endpoint: http://localhost:8000
validate_certs: True
config_context: False
group_by:
  - device_roles
query_filters:
  - serial: ABC1234
EXPECTED RESULTS

One device returned in inventory

ACTUAL RESULTS

One device and one VM returned in inventory

@FragmentedPacket
Copy link
Contributor

@tyler-8 I've implemented a fix for this. Do you mind testing this?

@FragmentedPacket FragmentedPacket added this to the v0.1.7 milestone Feb 16, 2020
@tyler-8
Copy link

tyler-8 commented Feb 20, 2020

Thanks @FragmentedPacket - totally forgot about this. Thank you for taking the time. I'll get our team to try it out and let you know if there are any wacky side effects. Looking at the code it seems like it'll do the trick.

@FragmentedPacket
Copy link
Contributor

Sounds good, Tyler. Feel free to re-open if issue is still occurring or misbhaving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR Submitted
Projects
None yet
3 participants