Skip to content

fix: strip all whitespace from relation key/value parsing#511

Closed
dirtycache wants to merge 5 commits into
bb-Ricardo:mainfrom
dirtycache:fix/multiline-relation-whitespace
Closed

fix: strip all whitespace from relation key/value parsing#511
dirtycache wants to merge 5 commits into
bb-Ricardo:mainfrom
dirtycache:fix/multiline-relation-whitespace

Conversation

@dirtycache

Copy link
Copy Markdown

Summary

  • configparser joins multi-line config values with \n, so relation entries on continuation lines start with a leading newline character
  • The previous .strip(' "') only stripped spaces and quotes, leaving the \n in the compiled regex pattern
  • This caused re.search() to silently fail for any multi-line vm_platform_from_annotation_relation value — the regex required a literal newline before the pattern text
  • Changed to .strip() which strips all whitespace including newlines; fixes both the annotation-specific block and the general *_relation block

Test plan

  • Verify vm_platform_from_annotation_relation written across multiple continuation lines in settings.ini correctly matches VM annotations on the next sync
  • Confirm annotation-based platform overrides (e.g. BIG-IP VEs → TMOS, vThunder → ACOS) apply as expected
  • Verify single-line relation values continue to work unchanged

Lab Admin added 5 commits June 17, 2026 16:57
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.
…rsing

configparser joins multi-line values with \n, so relation entries on
continuation lines start with a leading newline. The previous strip(' "')
left that newline in the regex pattern, causing matches to fail unless
the annotation itself started with a newline.

Using strip() fixes multi-line *_relation config values in settings.ini.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant