Skip to content

vmware: reuse VLANs from VLAN groups the settings name as global - #624

Open
tyderian1978 wants to merge 1 commit into
bb-Ricardo:developmentfrom
tyderian1978:fix/vlan-global-groups
Open

tyderian1978 wants to merge 1 commit into
bb-Ricardo:developmentfrom
tyderian1978:fix/vlan-global-groups

Conversation

@tyderian1978

Copy link
Copy Markdown

Disclaimer: AI generated, based off the work we're doing with Netbox.

What happens

A VLAN in a VLAN group without a scope is never matched by get_vlan_object_if_exists(). A grouped VLAN matches only when the group's scope covers the site or cluster, and only a VLAN with neither site nor group counts as global. Where another tool keeps the VLANs in such a group (ours are filled from Infoblox, with their prefixes), every VLAN netbox-sync discovers gets a duplicate without site or group, and the interfaces are linked to the duplicate: we had 135 duplicates of 119 VLAN IDs. The vlan_group_relation_* options don't help, since they only choose the group of a VLAN being created, and a single scope can't cover hosts in sites of different site groups.

Fix

A new option, vlan_global_groups: a comma separated list of VLAN groups without a scope whose VLANs are valid everywhere. Matching order becomes: a VLAN of the site, a VLAN in a group scoped to the site or cluster, a VLAN in one of these groups, a VLAN with neither site nor group. Naming a scoped group doesn't make it global. Unset, nothing changes, so matching by VLAN ID alone stays opt-in (see the discussion in #471). settings-example.ini is regenerated with -g.

Tests

tests/test_vlan_global_groups.py:

  • unset, the lookup is unchanged: a VLAN without site and group is used, and a VLAN in an unscoped group alone isn't reused;
  • a named group's VLAN is reused, ahead of a VLAN without site and group, with the group name matched case-insensitively;
  • a VLAN of the site, or in a group scoped to the site, still wins;
  • naming a scoped group doesn't make it match outside its scope;
  • other VLAN IDs are unaffected;
  • the option is unset by default and parses as a list.

Three fail on development without the change. Full suite: 616 passed, 8 skipped.

Also checked end to end against vcsim and NetBox 4.7.2, with an unscoped group holding two of the VLAN IDs. Before, the interfaces stay on netbox-sync's own VLANs. After, those two interfaces move to the group's VLANs in one run, the others are untouched, no VLAN is created, and the group's VLANs keep their names (netbox-sync adds its tags, as for any VLAN it uses). A dry run against our five vCenters moves 1,674 VM interfaces onto the group's VLANs (85 VLAN IDs, each to the VLAN with the same ID) and leaves the two VLAN IDs the group doesn't have on their own VLANs.

A VLAN in a VLAN group without a scope is never matched:
get_vlan_object_if_exists() matches a grouped VLAN only when the group's
scope covers the site or cluster, and takes a VLAN as global only when it
has neither site nor group. Where another tool keeps the VLANs in such a
group (for example filled from an IPAM, with their prefixes), every VLAN
discovered in vCenter therefore got a duplicate without site or group, and
the interfaces were linked to the duplicate. The vlan_group_relation_*
options don't help: they only choose the group of a VLAN being created.

The new option vlan_global_groups names unscoped VLAN groups whose VLANs
are valid everywhere. Matching order: a VLAN of the site, a VLAN in a group
scoped to the site or cluster, a VLAN in one of these groups, a VLAN with
neither site nor group. A scoped group isn't made global by naming it.
Unset, nothing changes.
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