Restored icons showing updated state of pools and hosts.

Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
This commit is contained in:
Konstantina Chremmou 2023-07-03 20:50:12 +01:00
parent 8f18678acc
commit 9473452657
9 changed files with 82 additions and 59 deletions

View File

@ -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>(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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -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()

View File

@ -2816,6 +2816,16 @@ namespace XenAdmin.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap pool_unpatched {
get {
object obj = ResourceManager.GetObject("pool_unpatched", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@ -1144,4 +1144,7 @@
<data name="_015_Download_h32bit_16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\015_Download_h32bit_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pool_unpatched" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\pool_unpatched.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -4541,6 +4541,7 @@
<None Include="Images\linx_16x.png" />
<None Include="Images\yinhekylin_16x.png" />
<None Include="Images\pool_32.png" />
<None Include="Images\pool_unpatched.png" />
<Content Include="Images\queued.png" />
<Content Include="Images\Refresh16.png" />
<None Include="Images\saved_searches_16.png" />
@ -6779,4 +6780,4 @@
<PropertyGroup>
<PostBuildEvent>copy "$(ProjectDir)\ReportViewer\resource_report.rdlc" "$(TargetDir)"</PostBuildEvent>
</PropertyGroup>
</Project>
</Project>

View File

@ -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,

View File

@ -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;
}

View File

@ -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<IXenConnection> connections)
{
List<Pool_patch> patches = Pool_patch.GetAllThatApply(host,connections);
List<Pool_patch> 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<Pool_patch> AppliedPatches()
{
List<Pool_patch> patches = new List<Pool_patch>();