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

netbox: inventory: Fix config context for VMs #53898

Open
wants to merge 2 commits into
base: devel
from

Conversation

Projects
None yet
3 participants
@kb-light
Copy link

commented Mar 16, 2019

SUMMARY

Use correct API path for virtual machines. The ID is not globally unique so the decision between devices and VMs need to be done within the plugin.

Fixes: #53393

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

Netbox inventory plugin

ADDITIONAL INFORMATION

API path for devices: /api/dcim/devices/<device_id>
API path for virtual machines: /api/virtualization/virtual-machines/<vm_id>

Currently the only differentiation seems to be the naming of the role variable ('device_role' for devices and 'role' for VMs).

@ansibot

This comment has been minimized.

@kb-light

This comment has been minimized.

Copy link
Author

commented Mar 16, 2019

Another solution could be tagging each host with 'is_device'/'is_vm' (or similar) to decide between the API source. This would provide independence from netbox API but needs more changes to the code. (Maybe the tags could be used for grouping, too)

lib/ansible/plugins/inventory/netbox.py Outdated
url = self.api_endpoint + "/api/dcim/devices/" + str(host["id"])
# User 'device_role' vs. 'role' to differ between devices and virtual-machines
if 'device_role' in host:
url = self.api_endpoint + "/api/dcim/devices/" + str(host["id"])

This comment has been minimized.

Copy link
@bcoca

bcoca Mar 18, 2019

Member

problem with original, but still str is not portable, use to_text.

This comment has been minimized.

Copy link
@kb-light

kb-light Mar 20, 2019

Author

Since this is a problem with the original script, it should be fixed for the whole script in a separate pull request.

This comment has been minimized.

Copy link
@kb-light

kb-light Mar 30, 2019

Author

str() changed to to_text() for the whole script.

@ansibot ansibot removed the needs_triage label Mar 18, 2019

@ansibot ansibot added the stale_ci label Mar 28, 2019

@kb-light kb-light force-pushed the kb-light:nb_inv_config_context branch to f4629bc Mar 30, 2019

@kb-light kb-light changed the title [WIP] netbox: inventory: Fix config context for VMs netbox: inventory: Fix config context for VMs Mar 30, 2019

@ansibot ansibot added needs_revision and removed WIP labels Mar 30, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.