Repository navigation
suppress pkg_resources DeprecationWarning from vmware-vapi-runtime on setuptools >= 81 - #510
dirtycache wants to merge 4 commits into
Conversation
Allows overriding a VM's platform in NetBox based on a regex match against the vCenter annotation (notes) field. Useful when vSphere misreports the guest OS — F5 BIG-IP/BIG-IQ VE VMs identify as CentOS but carry identifying text in their annotation. Patterns are compiled with re.DOTALL and matched via re.search so they span newlines and match anywhere in the annotation without anchoring. Takes priority over vm_platform_relation when both would match. The annotation is now always read from vCenter regardless of the skip_vm_comments setting, so platform detection works even when comment syncing is disabled.
Introduces a new config option that allows the same IP address to appear on multiple VM interfaces simultaneously without triggering duplicate-assignment warnings or being skipped. A common real-world scenario is isolated HA peer-to-peer VLANs where the same /30 addressing scheme is reused across many VM pairs. The IPs are unique within each link VLAN but overlap globally, causing netbox-sync's in-memory duplicate check to warn and skip the second (and subsequent) interface assignments. When an IP falls within a configured overlapping subnet, netbox-sync creates a separate NetBox IP address object per interface rather than sharing a single object. The existing duplicate-check logic for all other IPs is unchanged.
vmware-vapi-runtime 2.52.0 imports pkg_resources at runtime in vmware/vapi/l10n/bundle.py. setuptools >= 81 added a DeprecationWarning to pkg_resources, causing a UserWarning to be emitted on every run when the vSphere source is configured. Suppress the specific warning at startup until the vapi stack is upgraded to 9.x, where the import is replaced with importlib.resources.
|
This branch carries the #509 changes as well (config.py / connection.py / settings-example.ini) and no longer merges onto |
|
Ack, will try the rebase and report. Thanks! |
|
With |
Problem
Users running netbox-sync with a vSphere source on systems where setuptools >= 81 is installed receive a
UserWarningon every run:This warning originates in
vmware-vapi-runtime 2.52.0(vmware/vapi/l10n/bundle.py), which importspkg_resourcesat runtime. setuptools 81.0.0 (released February 2026) added aDeprecationWarningtopkg_resources/__init__.py, causing this to surface for anyone on a current setuptools.Because the warning is emitted to stderr, it bypasses the
>/dev/nullin the documented cron entry and produces unwanted email noise for cron-based deployments.Root cause
vmware-vapi-runtime 2.52.0usespkg_resources.resource_string()to load.propertiesresource files from the package. The modern stdlib replacement isimportlib.resources, which is available in all Python versions netbox-sync supports (3.6+).Broadcom has already made this fix in
vmware-vapi-runtime 9.1.0.0, where the import is replaced withimportlib.resources. However, upgrading the full vapi stack (vmware-vapi-runtime, vmware-vapi-common-client, vmware-vcenter) from 2.52.0/8.0.3.0 to 9.1.0.0 is a non-trivial change:vcf-sdk-python, the rebranded VMware Cloud Foundation SDK)That upgrade is worth pursuing separately once the compatibility implications are fully assessed.
Fix
Suppress the specific warning at startup in
netbox-sync.py, before any vmware modules are imported:The filter is scoped to the exact warning message rather than suppressing all
UserWarnings. It will become a harmless no-op once the vapi stack is eventually upgraded to 9.x.Alternatives considered
setuptools < 81: Treats the symptom, keeps the codebase on aging build tooling, and still leaves a time bomb whenpkg_resourcesis eventually removed from setuptools entirely.-Wflag on the Python invocation: Only helps users following the exact documented cron entry; does not help systemd, Docker, Kubernetes, or direct invocations.2>&1): The documented cron entry already does this; the problem affects users who route stderr to logs or rely on cron email for error alerting.