mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-24 22:06:59 +01:00
Merge pull request #3017 from danilo-delbusso/task/last-updated_CP-38583
CP-38582: Show `Last updated` field in General `TabPage`
This commit is contained in:
commit
2798315b46
@ -75,7 +75,7 @@ namespace XenAdmin.Diagnostics.Checks
|
||||
if (bootTime == 0.0 || agentStart == 0.0)
|
||||
return null; //fine
|
||||
|
||||
var hostRestartRequiredPatches = Host.AppliedPatches().Where(p => p.after_apply_guidance.Contains(after_apply_guidance.restartHost) && ((double)Util.ToUnixTime(p.AppliedOn(Host)) > agentStart));
|
||||
var hostRestartRequiredPatches = Host.AppliedPatches().Where(p => p.after_apply_guidance.Contains(after_apply_guidance.restartHost) && Util.ToUnixTime(p.AppliedOn(Host)) > agentStart);
|
||||
|
||||
foreach (Pool_patch patch in hostRestartRequiredPatches)
|
||||
{
|
||||
@ -88,7 +88,7 @@ namespace XenAdmin.Diagnostics.Checks
|
||||
}
|
||||
|
||||
//check toolstack restart
|
||||
var toolstackRestartRequiredPatches = Host.AppliedPatches().Where(p => p.after_apply_guidance.Contains(after_apply_guidance.restartXAPI) && ((double)Util.ToUnixTime(p.AppliedOn(Host)) > agentStart));
|
||||
var toolstackRestartRequiredPatches = Host.AppliedPatches().Where(p => p.after_apply_guidance.Contains(after_apply_guidance.restartXAPI) && Util.ToUnixTime(p.AppliedOn(Host)) > agentStart);
|
||||
foreach (Pool_patch patch in toolstackRestartRequiredPatches)
|
||||
{
|
||||
if (string.IsNullOrEmpty(UpdateUuid)) //automated mode
|
||||
|
@ -992,8 +992,21 @@ namespace XenAdmin.TabPages
|
||||
if (host == null || host.software_version == null)
|
||||
return;
|
||||
|
||||
var softwareVersionDate = DateTime.MinValue;
|
||||
var unixMinDateTime = Util.GetUnixMinDateTime();
|
||||
|
||||
if (host.software_version.ContainsKey("date"))
|
||||
pdSectionVersion.AddEntry(Messages.SOFTWARE_VERSION_DATE, host.software_version["date"]);
|
||||
{
|
||||
string buildDate = host.software_version["date"];
|
||||
|
||||
if ((Util.TryParseIso8601DateTime(host.software_version["date"], out softwareVersionDate) ||
|
||||
Util.TryParseNonIso8601DateTime(host.software_version["date"], out softwareVersionDate)) &&
|
||||
softwareVersionDate > unixMinDateTime)
|
||||
buildDate = HelpersGUI.DateTimeToString(softwareVersionDate.ToLocalTime(), Messages.DATEFORMAT_DMY, true);
|
||||
|
||||
pdSectionVersion.AddEntry(Messages.SOFTWARE_VERSION_DATE, buildDate);
|
||||
}
|
||||
|
||||
if (!Helpers.ElyOrGreater(host) && host.software_version.ContainsKey("build_number"))
|
||||
pdSectionVersion.AddEntry(Messages.SOFTWARE_VERSION_BUILD_NUMBER, host.software_version["build_number"]);
|
||||
if (host.software_version.ContainsKey("product_version"))
|
||||
@ -1008,6 +1021,11 @@ namespace XenAdmin.TabPages
|
||||
}
|
||||
if (host.software_version.ContainsKey("dbv"))
|
||||
pdSectionVersion.AddEntry("DBV", host.software_version["dbv"]);
|
||||
|
||||
if (Helpers.Post82X(host) && Helpers.XapiEqualOrGreater_22_19_0(host) &&
|
||||
host.last_software_update > softwareVersionDate && host.last_software_update > unixMinDateTime)
|
||||
pdSectionVersion.AddEntry(Messages.SOFTWARE_VERSION_LAST_UPDATED,
|
||||
HelpersGUI.DateTimeToString(host.last_software_update.ToLocalTime(), Messages.DATEFORMAT_DMY, true));
|
||||
}
|
||||
|
||||
private void GenerateCPUBox()
|
||||
@ -1584,11 +1602,10 @@ namespace XenAdmin.TabPages
|
||||
s.AddEntry(Messages.CONTAINER_IMAGE, dockerContainer.image.Length != 0 ? dockerContainer.image : Messages.NONE);
|
||||
s.AddEntry(Messages.CONTAINER, dockerContainer.container.Length != 0 ? dockerContainer.container : Messages.NONE);
|
||||
s.AddEntry(Messages.CONTAINER_COMMAND, dockerContainer.command.Length != 0 ? dockerContainer.command : Messages.NONE);
|
||||
var ports = dockerContainer.PortList.Select(p => p.Description);
|
||||
if (ports.Count() > 0)
|
||||
{
|
||||
var ports = dockerContainer.PortList.Select(p => p.Description).ToList();
|
||||
if (ports.Count > 0)
|
||||
s.AddEntry(Messages.CONTAINER_PORTS, string.Join(Environment.NewLine, ports));
|
||||
}
|
||||
|
||||
s.AddEntry(Messages.UUID, dockerContainer.uuid.Length != 0 ? dockerContainer.uuid : Messages.NONE);
|
||||
}
|
||||
|
||||
|
11
XenModel/Messages.Designer.cs
generated
11
XenModel/Messages.Designer.cs
generated
@ -19,7 +19,7 @@ namespace XenAdmin {
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Messages {
|
||||
@ -35089,6 +35089,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Last updated.
|
||||
/// </summary>
|
||||
public static string SOFTWARE_VERSION_LAST_UPDATED {
|
||||
get {
|
||||
return ResourceManager.GetString("SOFTWARE_VERSION_LAST_UPDATED", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Version.
|
||||
/// </summary>
|
||||
|
@ -12157,6 +12157,9 @@ Reverting to this snapshot will revert the VM back to the point in time that the
|
||||
<data name="SOFTWARE_VERSION_DATE" xml:space="preserve">
|
||||
<value>Build date</value>
|
||||
</data>
|
||||
<data name="SOFTWARE_VERSION_LAST_UPDATED" xml:space="preserve">
|
||||
<value>Last updated</value>
|
||||
</data>
|
||||
<data name="SOFTWARE_VERSION_PRODUCT_VERSION" xml:space="preserve">
|
||||
<value>Version</value>
|
||||
</data>
|
||||
@ -14874,4 +14877,4 @@ Any disk in your VM's DVD drive will be ejected when installing {1}.</value>
|
||||
<data name="YOU_ARE_HERE" xml:space="preserve">
|
||||
<value>You are here</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
@ -434,6 +434,11 @@ namespace XenAdmin.Core
|
||||
return coordinator == null || ProductVersionCompare(coordinator.GetXapiVersion(), "22.19.0") >= 0;
|
||||
}
|
||||
|
||||
public static bool XapiEqualOrGreater_22_19_0(Host host)
|
||||
{
|
||||
return host == null || ProductVersionCompare(host.GetXapiVersion(), "22.19.0") >= 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -354,10 +354,16 @@ namespace XenAdmin
|
||||
public const long TicksBefore1970 = 621355968000000000;
|
||||
|
||||
public static readonly string[] Iso8601DateFormats = {"yyyyMMddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssZ"};
|
||||
public static readonly string[] NonIso8601DateFormats = { "yyyy-MM-dd" };
|
||||
|
||||
public static DateTime GetUnixMinDateTime()
|
||||
{
|
||||
return new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
public static long TicksToSecondsSince1970(long ticks)
|
||||
{
|
||||
return (long)Math.Floor(new TimeSpan(ticks - (TicksBefore1970)).TotalSeconds);
|
||||
return (long)Math.Floor(new TimeSpan(ticks - TicksBefore1970).TotalSeconds);
|
||||
}
|
||||
|
||||
public static bool TryParseIso8601DateTime(string toParse, out DateTime result)
|
||||
@ -366,6 +372,12 @@ namespace XenAdmin
|
||||
DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out result);
|
||||
}
|
||||
|
||||
public static bool TryParseNonIso8601DateTime(string toParse, out DateTime result)
|
||||
{
|
||||
return DateTime.TryParseExact(toParse, NonIso8601DateFormats, CultureInfo.InvariantCulture,
|
||||
DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out result);
|
||||
}
|
||||
|
||||
public static string ToISO8601DateTime(DateTime t)
|
||||
{
|
||||
return t.ToUniversalTime().ToString(Iso8601DateFormats[0], CultureInfo.InvariantCulture);
|
||||
@ -373,13 +385,13 @@ namespace XenAdmin
|
||||
|
||||
public static double ToUnixTime(DateTime time)
|
||||
{
|
||||
TimeSpan diff = time - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
TimeSpan diff = time - GetUnixMinDateTime();
|
||||
return diff.TotalSeconds;
|
||||
}
|
||||
|
||||
public static DateTime FromUnixTime(double time)
|
||||
{
|
||||
DateTime bootTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
DateTime bootTime = GetUnixMinDateTime();
|
||||
return bootTime.AddSeconds(time);
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,9 @@ namespace XenAPI
|
||||
List<XenRef<Certificate>> certificates,
|
||||
string[] editions,
|
||||
List<update_guidances> pending_guidances,
|
||||
bool tls_verification_enabled)
|
||||
bool tls_verification_enabled,
|
||||
DateTime last_software_update
|
||||
)
|
||||
{
|
||||
this.uuid = uuid;
|
||||
this.name_label = name_label;
|
||||
@ -179,6 +181,7 @@ namespace XenAPI
|
||||
this.editions = editions;
|
||||
this.pending_guidances = pending_guidances;
|
||||
this.tls_verification_enabled = tls_verification_enabled;
|
||||
this.last_software_update = last_software_update;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -273,6 +276,7 @@ namespace XenAPI
|
||||
editions = record.editions;
|
||||
pending_guidances = record.pending_guidances;
|
||||
tls_verification_enabled = record.tls_verification_enabled;
|
||||
last_software_update = record.last_software_update;
|
||||
}
|
||||
|
||||
internal void UpdateFrom(Proxy_Host proxy)
|
||||
@ -340,6 +344,7 @@ namespace XenAPI
|
||||
editions = proxy.editions == null ? new string[] {} : (string [])proxy.editions;
|
||||
pending_guidances = proxy.pending_guidances == null ? null : Helper.StringArrayToEnumList<update_guidances>(proxy.pending_guidances);
|
||||
tls_verification_enabled = (bool)proxy.tls_verification_enabled;
|
||||
last_software_update = proxy.last_software_update;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -476,6 +481,8 @@ namespace XenAPI
|
||||
pending_guidances = Helper.StringArrayToEnumList<update_guidances>(Marshalling.ParseStringArray(table, "pending_guidances"));
|
||||
if (table.ContainsKey("tls_verification_enabled"))
|
||||
tls_verification_enabled = Marshalling.ParseBool(table, "tls_verification_enabled");
|
||||
if (table.ContainsKey("last_software_update"))
|
||||
last_software_update = Marshalling.ParseDateTime(table, "last_software_update");
|
||||
}
|
||||
|
||||
public Proxy_Host ToProxy()
|
||||
@ -544,6 +551,7 @@ namespace XenAPI
|
||||
result_.editions = editions;
|
||||
result_.pending_guidances = pending_guidances == null ? new string[] {} : Helper.ObjectListToStringArray(pending_guidances);
|
||||
result_.tls_verification_enabled = tls_verification_enabled;
|
||||
result_.last_software_update = last_software_update;
|
||||
return result_;
|
||||
}
|
||||
|
||||
@ -618,7 +626,8 @@ namespace XenAPI
|
||||
Helper.AreEqual2(this._certificates, other._certificates) &&
|
||||
Helper.AreEqual2(this._editions, other._editions) &&
|
||||
Helper.AreEqual2(this._pending_guidances, other._pending_guidances) &&
|
||||
Helper.AreEqual2(this._tls_verification_enabled, other._tls_verification_enabled);
|
||||
Helper.AreEqual2(this._tls_verification_enabled, other._tls_verification_enabled) &&
|
||||
Helper.AreEqual2(this._last_software_update, other.last_software_update);
|
||||
}
|
||||
|
||||
public override string SaveChanges(Session session, string opaqueRef, Host server)
|
||||
@ -4890,5 +4899,23 @@ namespace XenAPI
|
||||
}
|
||||
}
|
||||
private bool _tls_verification_enabled = false;
|
||||
|
||||
/// <summary>
|
||||
/// Date and time when the last software update was applied
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(XenDateTimeConverter))]
|
||||
public virtual DateTime last_software_update
|
||||
{
|
||||
get { return _last_software_update; }
|
||||
set
|
||||
{
|
||||
if (!Helper.AreEqual(value, _last_software_update))
|
||||
{
|
||||
_last_software_update = value;
|
||||
NotifyPropertyChanged("last_software_update");
|
||||
}
|
||||
}
|
||||
}
|
||||
private DateTime _last_software_update;
|
||||
}
|
||||
}
|
||||
|
@ -9101,6 +9101,7 @@ namespace XenAPI
|
||||
public string [] editions;
|
||||
public string [] pending_guidances;
|
||||
public bool tls_verification_enabled;
|
||||
public DateTime last_software_update;
|
||||
}
|
||||
|
||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
||||
|
Loading…
Reference in New Issue
Block a user