From fc7602825b5f34080925b787e16c60cfe11550ec Mon Sep 17 00:00:00 2001 From: Jeff Mattson Date: Tue, 19 Nov 2024 09:57:58 -0500 Subject: [PATCH] handle duplicate portgroups --- src/TopoMojo.Hypervisor/vSphere/NetworkManager.cs | 2 +- src/TopoMojo.Hypervisor/vSphere/NsxNetworkManager.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/TopoMojo.Hypervisor/vSphere/NetworkManager.cs b/src/TopoMojo.Hypervisor/vSphere/NetworkManager.cs index 2487b3e..7339447 100644 --- a/src/TopoMojo.Hypervisor/vSphere/NetworkManager.cs +++ b/src/TopoMojo.Hypervisor/vSphere/NetworkManager.cs @@ -35,7 +35,7 @@ public async Task Initialize() foreach (var pg in existing) pg.Timestamp = ts; - _pgAllocation = existing.ToDictionary(p => p.Net); + _pgAllocation = existing.DistinctBy(p => p.Net).ToDictionary(p => p.Net); _vlanManager.Activate( _pgAllocation.Values.Select(p => new Vlan diff --git a/src/TopoMojo.Hypervisor/vSphere/NsxNetworkManager.cs b/src/TopoMojo.Hypervisor/vSphere/NsxNetworkManager.cs index 04dd0f4..c97c4c7 100644 --- a/src/TopoMojo.Hypervisor/vSphere/NsxNetworkManager.cs +++ b/src/TopoMojo.Hypervisor/vSphere/NsxNetworkManager.cs @@ -295,6 +295,9 @@ config.defaultPortConfig is VMwareDVSPortSetting setting } } + string info = string.Join('\n', [.. list.Select(p => $"{p.Net}::{p.Key}")]); + _logger.LogDebug("{info}", info); + return [.. list]; }