From 3a7d1c1cd99aad78372ca380d7c01bfeaa4f77aa Mon Sep 17 00:00:00 2001 From: minglumlu Date: Fri, 23 Jun 2017 09:53:15 +0100 Subject: [PATCH] CA-254479,CA-223802,XSO-672: distinct the VM IP addresses which are retrieved from XAPI. --- XenAdmin/Actions/GUIActions/ExportResourceReportAction.cs | 1 + XenAdmin/ConsoleView/XSVNCScreen.cs | 3 ++- XenModel/XenAPI-Extensions/VIF.cs | 6 ++++-- XenModel/XenSearch/Common.cs | 5 ++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/XenAdmin/Actions/GUIActions/ExportResourceReportAction.cs b/XenAdmin/Actions/GUIActions/ExportResourceReportAction.cs index cf6de48c8..bc129ed69 100755 --- a/XenAdmin/Actions/GUIActions/ExportResourceReportAction.cs +++ b/XenAdmin/Actions/GUIActions/ExportResourceReportAction.cs @@ -803,6 +803,7 @@ namespace XenAdmin.Actions } } } + addresses = new ComparableList(addresses.Distinct()); if (MacInfo.Length == 0) MacInfo = Messages.HYPHEN; diff --git a/XenAdmin/ConsoleView/XSVNCScreen.cs b/XenAdmin/ConsoleView/XSVNCScreen.cs index c9cd90aa9..b190b0be2 100644 --- a/XenAdmin/ConsoleView/XSVNCScreen.cs +++ b/XenAdmin/ConsoleView/XSVNCScreen.cs @@ -366,7 +366,7 @@ namespace XenAdmin.ConsoleView PIF pif = Helpers.FindPIF(network, host); foreach (var networkInfo in networks.Where(n => n.Key.StartsWith(String.Format("{0}/ip", vif.device)))) { - if (networkInfo.Key.EndsWith("ip")) // IPv4 address + if (networkInfo.Key.EndsWith("ip") || networkInfo.Key.Contains("ipv4")) // IPv4 address { if (pif == null) ipAddressesForNetworksWithoutPifs.Add(networkInfo.Value); @@ -387,6 +387,7 @@ namespace XenAdmin.ConsoleView } } } + ipAddresses = ipAddresses.Distinct().ToList(); ipAddresses.AddRange(ipv6Addresses); // make sure IPv4 addresses are scanned first (CA-102755) // add IP addresses for networks without PIFs diff --git a/XenModel/XenAPI-Extensions/VIF.cs b/XenModel/XenAPI-Extensions/VIF.cs index d66ec0c0d..4bda145d0 100644 --- a/XenModel/XenAPI-Extensions/VIF.cs +++ b/XenModel/XenAPI-Extensions/VIF.cs @@ -63,13 +63,15 @@ namespace XenAPI if (vmGuestMetrics != null) { // PR-1373 - VM_guest_metrics.networks is a dictionary of IP addresses in the format: - // [["0/ip", ], ["0/ipv6/0", ], ["0/ipv6/1", ]] + // [["0/ip", ], + // ["0/ipv4/0", ], ["0/ipv4/1", ], + // ["0/ipv6/0", ], ["0/ipv6/1", ]] return (from network in vmGuestMetrics.networks where network.Key.StartsWith(string.Format("{0}/ip", this.device)) orderby network.Key - select network.Value).ToList(); + select network.Value).Distinct().ToList(); } } diff --git a/XenModel/XenSearch/Common.cs b/XenModel/XenSearch/Common.cs index f0c69b18a..c63503413 100644 --- a/XenModel/XenSearch/Common.cs +++ b/XenModel/XenSearch/Common.cs @@ -1123,7 +1123,9 @@ namespace XenAdmin.XenSearch foreach (VIF vif in vifs) { // PR-1373 - VM_guest_metrics.networks is a dictionary of IP addresses in the format: - // [["0/ip", ], ["0/ipv6/0", ], ["0/ipv6/1", ]] + // [["0/ip", ], + // ["0/ipv4/0", ], ["0/ipv4/1", ], + // ["0/ipv6/0", ], ["0/ipv6/1", ]] foreach (var network in metrics.networks.Where(n => n.Key.StartsWith(String.Format("{0}/ip", vif.device)))) { ComparableAddress ipAddress; @@ -1133,6 +1135,7 @@ namespace XenAdmin.XenSearch addresses.Add(ipAddress); } } + addresses =new ComparableList(addresses.Distinct()); } else if (o is Host) {