Skip to content

Commit

Permalink
Restored icons showing updated state of pools and hosts.
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantina Chremmou <[email protected]>
  • Loading branch information
kc284 committed Jul 28, 2023
1 parent 8f18678 commit 9473452
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 59 deletions.
82 changes: 52 additions & 30 deletions XenAdmin/Images.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ static Images()
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);
Expand All @@ -86,11 +88,11 @@ static Images()
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);
Expand Down Expand Up @@ -459,55 +461,74 @@ public static Icons GetIconFor(SR sr)

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)
Expand Down Expand Up @@ -860,6 +881,7 @@ public static class StaticImages
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;
Expand Down
Binary file added XenAdmin/Images/pool_unpatched.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions XenAdmin/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ private void RegisterEvents()
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;
Expand All @@ -274,6 +275,7 @@ private void UnRegisterEvents()
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;
Expand Down Expand Up @@ -2650,6 +2652,11 @@ private void eventsPage_GoToXenObjectRequested(IXenObject obj)
navigationPane.SelectObject(obj);
}

private void Cdn_UpdateInfoChanged(IXenConnection obj)
{
RequestRefreshTreeView();
}

private void Updates_CollectionChanged(CollectionChangeEventArgs e)
{
Program.Invoke(this, () =>
Expand All @@ -2668,6 +2675,8 @@ private void Updates_CollectionChanged(CollectionChangeEventArgs e)
TitleIcon.Image = NotificationsSubModeItem.GetImage(NotificationsSubMode.Updates, updatesCount);
}
});

RequestRefreshTreeView();//to update item icons
}

private void ClientUpdatesCheck_Completed()
Expand Down
10 changes: 10 additions & 0 deletions XenAdmin/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions XenAdmin/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
3 changes: 2 additions & 1 deletion XenAdmin/XenAdmin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down Expand Up @@ -6779,4 +6780,4 @@
<PropertyGroup>
<PostBuildEvent>copy "$(ProjectDir)\ReportViewer\resource_report.rdlc" "$(TargetDir)"</PostBuildEvent>
</PropertyGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions XenModel/Icons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public enum Icons
HostUnpatched,
HostOlderThanCoordinator,
HostHasCrashDumps,
ServerUnlicensed,

VmRunning,
VmRunningDisabled,
Expand All @@ -62,9 +63,8 @@ public enum Icons

PoolConnected,
PoolNotFullyUpgraded,

PoolUnPatched,
PoolUnlicensed,
ServerUnlicensed,

Storage,
StorageBroken,
Expand Down
9 changes: 4 additions & 5 deletions XenModel/Utils/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,12 @@ public static bool ValidateIscsiIQN(string iqn)

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


Expand Down
21 changes: 0 additions & 21 deletions XenModel/XenAPI-Extensions/Host.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
using System.Threading;
using XenAdmin;
using XenAdmin.Core;
using XenAdmin.Network;
using System.Diagnostics;
using System.Web.Script.Serialization;

Expand Down Expand Up @@ -700,26 +699,6 @@ public void SetSysLogDestination(string value)
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>();
Expand Down

0 comments on commit 9473452

Please sign in to comment.