From 9473452657bb98b0055fa5224fbd644b51812af6 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Mon, 3 Jul 2023 20:50:12 +0100 Subject: [PATCH] Restored icons showing updated state of pools and hosts. Signed-off-by: Konstantina Chremmou --- XenAdmin/Images.cs | 82 ++++++++++++++-------- XenAdmin/Images/pool_unpatched.png | Bin 0 -> 4578 bytes XenAdmin/MainWindow.cs | 9 +++ XenAdmin/Properties/Resources.Designer.cs | 10 +++ XenAdmin/Properties/Resources.resx | 3 + XenAdmin/XenAdmin.csproj | 3 +- XenModel/Icons.cs | 4 +- XenModel/Utils/Helpers.cs | 9 ++- XenModel/XenAPI-Extensions/Host.cs | 21 ------ 9 files changed, 82 insertions(+), 59 deletions(-) create mode 100644 XenAdmin/Images/pool_unpatched.png diff --git a/XenAdmin/Images.cs b/XenAdmin/Images.cs index 4e29d5d71..5961b85f6 100644 --- a/XenAdmin/Images.cs +++ b/XenAdmin/Images.cs @@ -70,6 +70,8 @@ namespace XenAdmin ImageList16.Images.Add("000_HostUnpatched_h32bit_16.png", XenAdmin.Properties.Resources._000_HostUnpatched_h32bit_16); ImageList16.Images.Add("server_up_16.png", XenAdmin.Properties.Resources.server_up_16); ImageList16.Images.Add("000_ServerErrorFile_h32bit_16.png", XenAdmin.Properties.Resources._000_ServerErrorFile_h32bit_16); + ImageList16.Images.Add("000_Server_h32bit_16-w-alert.png", Properties.Resources._000_Server_h32bit_16_w_alert); + ImageList16.Images.Add("000_StartVM_h32bit_16.png", XenAdmin.Properties.Resources._000_StartVM_h32bit_16); ImageList16.Images.Add("000_VMDisabled_h32bit_16.png", XenAdmin.Properties.Resources._000_VMDisabled_h32bit_16); ImageList16.Images.Add("000_StoppedVM_h32bit_16.png", XenAdmin.Properties.Resources._000_StoppedVM_h32bit_16); @@ -86,11 +88,11 @@ namespace XenAdmin ImageList16.Images.Add("000_VMSnapshotDiskMemory_h32bit_16.png", XenAdmin.Properties.Resources._000_VMSnapshotDiskMemory_h32bit_16); ImageList16.Images.Add("_000_ScheduledVMsnapshotDiskOnly_h32bit_16.png", XenAdmin.Properties.Resources._000_ScheduledVMsnapshotDiskOnly_h32bit_16); ImageList16.Images.Add("_000_ScheduledVMsnapshotDiskMemory_h32bit_16.png", XenAdmin.Properties.Resources._000_ScheduledVMsnapshotDiskMemory_h32bit_16); + ImageList16.Images.Add("000_PoolConnected_h32bit_16.png", XenAdmin.Properties.Resources._000_PoolConnected_h32bit_16); ImageList16.Images.Add("pool_up_16.png", XenAdmin.Properties.Resources.pool_up_16); - + ImageList16.Images.Add("pool_unpatched.png", Properties.Resources.pool_unpatched); ImageList16.Images.Add("000_Pool_h32bit_16-w-alert.png", Properties.Resources._000_Pool_h32bit_16_w_alert); - ImageList16.Images.Add("000_Server_h32bit_16-w-alert.png", Properties.Resources._000_Server_h32bit_16_w_alert); ImageList16.Images.Add("000_Storage_h32bit_16.png", XenAdmin.Properties.Resources._000_Storage_h32bit_16); ImageList16.Images.Add("000_StorageBroken_h32bit_16.png", XenAdmin.Properties.Resources._000_StorageBroken_h32bit_16); @@ -459,55 +461,74 @@ namespace XenAdmin public static Icons GetIconFor(Host host) { + Host_metrics metrics = host.Connection.Resolve(host.metrics); - Host_metrics metrics = host.Connection.Resolve(host.metrics); - bool host_is_live = metrics != null && metrics.live; - - if (host_is_live) + if (metrics != null && metrics.live) { if (host.IsFreeLicenseOrExpired()) - { return Icons.ServerUnlicensed; - } + if (host.HasCrashDumps()) - { return Icons.HostHasCrashDumps; - } - if (host.current_operations.ContainsValue(host_allowed_operations.evacuate) - || !host.enabled) - { + + if (host.current_operations.ContainsValue(host_allowed_operations.evacuate) || !host.enabled) return Icons.HostEvacuate; - } - else if (Helpers.IsOlderThanCoordinator(host)) - { + + if (Helpers.IsOlderThanCoordinator(host)) return Icons.HostOlderThanCoordinator; + + if (Helpers.CloudOrGreater(host)) + { + if (Updates.CdnUpdateInfoPerConnection.TryGetValue(host.Connection, out var updateInfo)) + { + var hostUpdateInfo = updateInfo?.HostsWithUpdates.FirstOrDefault(u => u.HostOpaqueRef == host.opaque_ref); + + if (hostUpdateInfo?.UpdateIDs.Length > 0) + return Icons.HostUnpatched; + } } else { - return Icons.HostConnected; + if (Updates.RecommendedPatchesForHost(host).Count > 0) + return Icons.HostUnpatched; } + + return Icons.HostConnected; } - else - { - // XenAdmin.XenSearch.Group puts a fake host in the treeview for disconnected - // XenConnections. So here we give the yellow 'connection in progress' icon which formerly - // applied only to XenConnections. - if (host.Connection.InProgress && !host.Connection.IsConnected) - return Icons.HostConnecting; - else - return Icons.HostDisconnected; - } + + // XenAdmin.XenSearch.Group puts a fake host in the treeview for disconnected + // XenConnections. So here we give the yellow 'connection in progress' icon which formerly + // applied only to XenConnections. + if (host.Connection.InProgress && !host.Connection.IsConnected) + return Icons.HostConnecting; + + return Icons.HostDisconnected; } public static Icons GetIconFor(Pool pool) { if (!pool.Connection.IsConnected) return Icons.HostDisconnected; + if (pool.Connection.Cache.Hosts.Any(h => h.IsFreeLicenseOrExpired())) return Icons.PoolUnlicensed; - if (pool.IsPoolFullyUpgraded()) - return Icons.PoolConnected; - return Icons.PoolNotFullyUpgraded; + + if (!pool.IsPoolFullyUpgraded()) + return Icons.PoolNotFullyUpgraded; + + if (Helpers.CloudOrGreater(pool.Connection)) + { + if (Updates.CdnUpdateInfoPerConnection.TryGetValue(pool.Connection, out var updateInfo) && + updateInfo?.Updates.Length > 0) + return Icons.PoolUnPatched; + } + else + { + if (pool.Connection.Cache.Hosts.Any(h => Updates.RecommendedPatchesForHost(h).Count > 0)) + return Icons.PoolUnPatched; + } + + return Icons.PoolConnected; } public static Icons GetIconFor(XenAPI.Network network) @@ -860,6 +881,7 @@ namespace XenAdmin public static Bitmap PDChevronRight = Properties.Resources.PDChevronRight; public static Bitmap PDChevronUp = Properties.Resources.PDChevronUp; public static Bitmap PDChevronUpOver = Properties.Resources.PDChevronUpOver; + public static Bitmap pool_unpatched = Properties.Resources.pool_unpatched; public static Bitmap pool_up_16 = Properties.Resources.pool_up_16; public static Bitmap redhat_16x = Properties.Resources.redhat_16x; public static Bitmap Refresh16 = Properties.Resources.Refresh16; diff --git a/XenAdmin/Images/pool_unpatched.png b/XenAdmin/Images/pool_unpatched.png new file mode 100644 index 0000000000000000000000000000000000000000..c58ac8672a60590778b61c0c1f6a82bf8aa168f4 GIT binary patch literal 4578 zcmeHKdr%X19*=^6u{zXpg0||iSf;dYvRU$COGF50Qi%kJ0zTR7BWxiLvkM8R=qbL@ zik{U`4_iyC)WM>joR6q5pjLcM$7@w6K2YJ>`lz*6JW;vd2IMiTvNGu}CBuuGht=(YCC5qU)$%Yrs&)50J4z5nvHqH@!rq6Ooy38t7w!J07> zLatZs*+x>;2kD5wHU1y8R)2Thr__Az%2$vs!Zwyzdn4w_pM&=pKdD-mTu^X3ec1Ky zW15PehgxGsuD-JV;G5;eagOEKndWU*3di2w>w(v6*Owk%$o+iv;eiL&ZX69Qhi8=d z?Q3|twCc06A@H&p3&R@3>D6Cw6DHohSsMP&VJch3*_|o#j*3KsRQch0A*G`+tUSLt@IdG0v z(-{^2NdKwy`HC7()utA_BDwBBk?*F!(9c$4?^XtWIydZe{Mt+8xR_}t^=9W{?`Y+vz1geoG$=h*z5cJi%&`-3kYvo0CmnD@l@=NO-~S&j3pB5qgN z)y7#*146F(N%l8x_xR6wD5_05M(H-(-Sc*kxVnAx;?xl#o*~b^`~KwNOADTfsJ&_D zRn;}2XmZ*8+>cysdA~ilxqW6wp{U}a^W?9q?2(}G@>oz{>4rp{v|A+vWjE6jx77hE zPb7+taXSbyo8}=iZDDO1_|frGFvLq$Hw7q4eZ6m!LuNi!jM;m&(^@{1|y`kJ84KRkxNh{!OiAj@FX!5?W7ny zC4Nd51bEZHSv>E+rBav6C2>Vc>`seR78MmGMKLLcAwUD+@@+ifMr>S|0MUsNPjjS` zb?~g+1__vi*`CX5U>K}Jul%z*42Eua8`s4G;6v&r98#GCm0GRR-WD96kOx4z9Qs`g z&II~YnnH8-Tqj8<>Xupcxs|>UZ20Y$Q<_hlV<2A6bKTg?6mclz9 zX^Lb>l?tIzvjUMbB#o$51c9hYioqCEMKY+o7nI({@q~?}1traO5m(QsZc5-6*4)h>`|IYJ2_B`0;&v^M0QdlBnAiJ0BQ-L zQUQS10z`vroixGQohG|IM*|B^L4sxXvH>&{MesyC!P5W~#UgQ3iASO)Oon3^E{}W< zmEmYFeLKZ6`Tt8>XdfuLGwC{(1N-NDMV&pBN-yYq>wL{&z0Cwc-nPIAvNHsZ$fGH* zp8%_KiOeEw78=Ztu7Z6fXMd*{)D)ve2_=J&Q4FXj6{@Ndk#~y4g3RgfumC6hMJY&nB`}lHZ@+Xt#A!G zYu`%&p+B!TB>1=bjSCtj33Il>;4odRkB>E}&oAB_Gf|rybY@B0v83Q7Q~W|}%w}_? zA~C!qVAO$(p>b~%osO%68tUMWF@4#V%5j}Q*-krwNqrUyIz9+TGvc}w(`g1hXEa#Z|WZ0D=C6@T>R#mONalvI%%o; z#Mah~@|8v(f8@o~vQ7Dgfs-C@P8mLI$M`nve!VAatZwu4Ntwf9>%;PtcX!pydF+|? rcQbkA7wj^%cy2E7!*5OH9fP0ku9~r8{1G0cN~BMi9=|^>bJ>3Y%vh*q literal 0 HcmV?d00001 diff --git a/XenAdmin/MainWindow.cs b/XenAdmin/MainWindow.cs index 60fc29a99..661cdba79 100755 --- a/XenAdmin/MainWindow.cs +++ b/XenAdmin/MainWindow.cs @@ -259,6 +259,7 @@ namespace XenAdmin OtherConfigAndTagsWatcher.RegisterEventHandlers(); Alert.RegisterAlertCollectionChanged(XenCenterAlerts_CollectionChanged); Updates.UpdateAlertCollectionChanged += Updates_CollectionChanged; + Updates.CdnUpdateInfoChanged += Cdn_UpdateInfoChanged; Updates.CheckForClientUpdatesStarted += ClientUpdatesCheck_Started; Updates.CheckForClientUpdatesCompleted += ClientUpdatesCheck_Completed; ConnectionsManager.History.CollectionChanged += History_CollectionChanged; @@ -274,6 +275,7 @@ namespace XenAdmin OtherConfigAndTagsWatcher.DeregisterEventHandlers(); Alert.DeregisterAlertCollectionChanged(XenCenterAlerts_CollectionChanged); Updates.UpdateAlertCollectionChanged -= Updates_CollectionChanged; + Updates.CdnUpdateInfoChanged -= Cdn_UpdateInfoChanged; Updates.CheckForClientUpdatesStarted -= ClientUpdatesCheck_Started; Updates.CheckForClientUpdatesCompleted -= ClientUpdatesCheck_Completed; ConnectionsManager.History.CollectionChanged -= History_CollectionChanged; @@ -2650,6 +2652,11 @@ namespace XenAdmin navigationPane.SelectObject(obj); } + private void Cdn_UpdateInfoChanged(IXenConnection obj) + { + RequestRefreshTreeView(); + } + private void Updates_CollectionChanged(CollectionChangeEventArgs e) { Program.Invoke(this, () => @@ -2668,6 +2675,8 @@ namespace XenAdmin TitleIcon.Image = NotificationsSubModeItem.GetImage(NotificationsSubMode.Updates, updatesCount); } }); + + RequestRefreshTreeView();//to update item icons } private void ClientUpdatesCheck_Completed() diff --git a/XenAdmin/Properties/Resources.Designer.cs b/XenAdmin/Properties/Resources.Designer.cs index 05ef7d5e6..d0a9c1164 100755 --- a/XenAdmin/Properties/Resources.Designer.cs +++ b/XenAdmin/Properties/Resources.Designer.cs @@ -2816,6 +2816,16 @@ namespace XenAdmin.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap pool_unpatched { + get { + object obj = ResourceManager.GetObject("pool_unpatched", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/XenAdmin/Properties/Resources.resx b/XenAdmin/Properties/Resources.resx index 5f1c47613..15fbc9fcd 100755 --- a/XenAdmin/Properties/Resources.resx +++ b/XenAdmin/Properties/Resources.resx @@ -1144,4 +1144,7 @@ ..\Images\015_Download_h32bit_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Images\pool_unpatched.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/XenAdmin/XenAdmin.csproj b/XenAdmin/XenAdmin.csproj index 36b41ddd5..329ec3334 100755 --- a/XenAdmin/XenAdmin.csproj +++ b/XenAdmin/XenAdmin.csproj @@ -4541,6 +4541,7 @@ + @@ -6779,4 +6780,4 @@ copy "$(ProjectDir)\ReportViewer\resource_report.rdlc" "$(TargetDir)" - \ No newline at end of file + diff --git a/XenModel/Icons.cs b/XenModel/Icons.cs index 95df8cb63..a820f933d 100644 --- a/XenModel/Icons.cs +++ b/XenModel/Icons.cs @@ -41,6 +41,7 @@ namespace XenAdmin HostUnpatched, HostOlderThanCoordinator, HostHasCrashDumps, + ServerUnlicensed, VmRunning, VmRunningDisabled, @@ -62,9 +63,8 @@ namespace XenAdmin PoolConnected, PoolNotFullyUpgraded, - + PoolUnPatched, PoolUnlicensed, - ServerUnlicensed, Storage, StorageBroken, diff --git a/XenModel/Utils/Helpers.cs b/XenModel/Utils/Helpers.cs index 0b7f4986e..b974ea5ab 100755 --- a/XenModel/Utils/Helpers.cs +++ b/XenModel/Utils/Helpers.cs @@ -409,13 +409,12 @@ namespace XenAdmin.Core public static bool IsOlderThanCoordinator(Host host) { - Host coordinator = Helpers.GetCoordinator(host.Connection); + Host coordinator = GetCoordinator(host.Connection); + if (coordinator == null || coordinator.opaque_ref == host.opaque_ref) return false; - else if (Helpers.ProductVersionCompare(Helpers.HostProductVersion(host), Helpers.HostProductVersion(coordinator)) >= 0) - return false; - else - return true; + + return ProductVersionCompare(HostProductVersion(host), HostProductVersion(coordinator)) < 0; } diff --git a/XenModel/XenAPI-Extensions/Host.cs b/XenModel/XenAPI-Extensions/Host.cs index 28ac38214..e555018c1 100644 --- a/XenModel/XenAPI-Extensions/Host.cs +++ b/XenModel/XenAPI-Extensions/Host.cs @@ -35,7 +35,6 @@ using System.Linq; using System.Threading; using XenAdmin; using XenAdmin.Core; -using XenAdmin.Network; using System.Diagnostics; using System.Web.Script.Serialization; @@ -700,26 +699,6 @@ namespace XenAPI logging = SetDictionaryKey(logging, "syslog_destination", value); } - public static bool IsFullyPatched(Host host,IEnumerable connections) - { - List patches = Pool_patch.GetAllThatApply(host,connections); - - List appliedPatches - = host.AppliedPatches(); - - if (appliedPatches.Count == patches.Count) - return true; - - foreach (Pool_patch patch in patches) - { - Pool_patch patch1 = patch; - if (!appliedPatches.Exists(otherPatch => string.Equals(patch1.uuid, otherPatch.uuid, StringComparison.OrdinalIgnoreCase))) - return false; - } - - return true; - } - public virtual List AppliedPatches() { List patches = new List();