diff --git a/XenAdmin/Diagnostics/Checks/RebootPendingOnMasterCheck.cs b/XenAdmin/Diagnostics/Checks/RebootPendingOnMasterCheck.cs new file mode 100644 index 000000000..a0d2d689b --- /dev/null +++ b/XenAdmin/Diagnostics/Checks/RebootPendingOnMasterCheck.cs @@ -0,0 +1,130 @@ +/* Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, + * with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +using System.Collections.Generic; +using System.Linq; +using XenAdmin.Core; +using XenAdmin.Diagnostics.Hotfixing; +using XenAdmin.Diagnostics.Problems; +using XenAdmin.Diagnostics.Problems.HostProblem; +using XenAdmin.Diagnostics.Problems.PoolProblem; +using XenAPI; + +namespace XenAdmin.Diagnostics.Checks +{ + class RestartHostOrToolstackPendingOnMasterCheck : Check + { + public string UpdateUuid { get; private set; } + private readonly Pool pool; + + public RestartHostOrToolstackPendingOnMasterCheck(Pool pool, string updateUuid) + : base(Helpers.GetMaster(pool.Connection)) + { + this.pool = pool; + this.UpdateUuid = updateUuid; + } + + protected override Problem RunCheck() + { + if (!Host.IsLive()) + return new HostNotLiveWarning(this, Host); + + var elyOrGreater = Helpers.ElyOrGreater(Host); + + double bootTime = Host.BootTime(); + double agentStart = Host.AgentStartTime(); + + //check reboot + if (elyOrGreater) + { + foreach (var updateRef in Host.updates_requiring_reboot) + { + var update = Host.Connection.Resolve(updateRef); + + if (string.IsNullOrEmpty(UpdateUuid) || //automated mode, any update + string.Equals(update.uuid, UpdateUuid, System.StringComparison.InvariantCultureIgnoreCase)) //normal mode the given update + { + return new MasterIsPendingRestartHostProblem(this, pool); + } + } + } + else + { + 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)); + + foreach (Pool_patch patch in hostRestartRequiredPatches) + { + if (string.IsNullOrEmpty(UpdateUuid) //automated mode, any update + || string.Equals(patch.uuid, UpdateUuid, System.StringComparison.InvariantCultureIgnoreCase)) //normal mode the given update + { + return new MasterIsPendingRestartHostProblem(this, pool); + } + } + } + + //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)); + foreach (Pool_patch patch in toolstackRestartRequiredPatches) + { + if (string.IsNullOrEmpty(UpdateUuid)) //automated mode + { + return new MasterIsPendingRestartToolstackProblem(this, pool); + } + + if (!elyOrGreater) //normal mode pre-Ely + { + if (bootTime == 0.0 || agentStart == 0.0) + return null; //fine + + if (string.Equals(patch.uuid, UpdateUuid, System.StringComparison.InvariantCultureIgnoreCase)) + return new MasterIsPendingRestartToolstackProblem(this, pool); + } + else //normal mode Ely+ + { + var poolUpdate = Host.Connection.Resolve(patch.pool_update); + if (poolUpdate != null && string.Equals(UpdateUuid, poolUpdate.uuid, System.StringComparison.InvariantCultureIgnoreCase)) + { + return new MasterIsPendingRestartToolstackProblem(this, pool); + } + } + } + return null; + } + + public override string Description + { + get { return Messages.PENDING_RESTART_CHECK; } + } + } +} diff --git a/XenAdmin/Diagnostics/Problems/PoolProblem/MasterIsPendingRestartProblems.cs b/XenAdmin/Diagnostics/Problems/PoolProblem/MasterIsPendingRestartProblems.cs new file mode 100644 index 000000000..5c86fa249 --- /dev/null +++ b/XenAdmin/Diagnostics/Problems/PoolProblem/MasterIsPendingRestartProblems.cs @@ -0,0 +1,94 @@ +/* Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, + * with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading; +using XenAdmin.Core; +using XenAdmin.Diagnostics.Checks; +using XenAdmin.Diagnostics.Hotfixing; +using XenAdmin.Properties; +using XenAPI; + +namespace XenAdmin.Diagnostics.Problems.PoolProblem +{ + class MasterIsPendingRestartHostProblem : PoolProblem + { + public MasterIsPendingRestartHostProblem(RestartHostOrToolstackPendingOnMasterCheck check, Pool pool) + : base(check, pool) + { } + + public override string Description + { + get + { + return string.Format( + ((RestartHostOrToolstackPendingOnMasterCheck)Check).UpdateUuid != null + ? Messages.PROBLEM_MASTER_PENDING_RESTART_HOST_THIS_UPDATE + : Messages.PROBLEM_MASTER_PENDING_RESTART_HOST, + Helpers.GetName(Pool).Ellipsise(30)); + } + } + + public override string HelpMessage + { + get { return null; } + } + } + + class MasterIsPendingRestartToolstackProblem : PoolProblem + { + public MasterIsPendingRestartToolstackProblem(RestartHostOrToolstackPendingOnMasterCheck check, Pool pool) + : base(check, pool) + { } + + public override string Description + { + get + { + return string.Format( + ((RestartHostOrToolstackPendingOnMasterCheck)Check).UpdateUuid != null + ? Messages.PROBLEM_MASTER_PENDING_RESTART_TOOLSTACK_THIS_UPDATE + : Messages.PROBLEM_MASTER_PENDING_RESTART_TOOLSTACK, + Helpers.GetName(Pool).Ellipsise(30)); + } + } + + public override string HelpMessage + { + get { return null; } + } + } +} diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs index 09801c586..42541730a 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs @@ -493,6 +493,17 @@ namespace XenAdmin.Wizards.PatchingWizard } } + if (patch != null || WizardMode == WizardMode.AutomatedUpdates) + { + checks.Add(new KeyValuePair>(Messages.CHECKING_FOR_PENDING_RESTART, new List())); + checkGroup = checks[checks.Count - 1].Value; + + foreach (var pool in SelectedPools) + { + checkGroup.Add(new RestartHostOrToolstackPendingOnMasterCheck(pool, WizardMode == WizardMode.AutomatedUpdates ? null : patch.uuid)); + } + } + return checks; } @@ -541,6 +552,17 @@ namespace XenAdmin.Wizards.PatchingWizard } } + if (update != null || WizardMode == WizardMode.AutomatedUpdates) + { + checks.Add(new KeyValuePair>(Messages.CHECKING_FOR_PENDING_RESTART, new List())); + checkGroup = checks[checks.Count - 1].Value; + + foreach (var pool in SelectedPools) + { + checkGroup.Add(new RestartHostOrToolstackPendingOnMasterCheck(pool, WizardMode == WizardMode.AutomatedUpdates ? null : update.uuid)); + } + } + return checks; } diff --git a/XenAdmin/XenAdmin.csproj b/XenAdmin/XenAdmin.csproj index 084dc89f5..3f6a4345c 100644 --- a/XenAdmin/XenAdmin.csproj +++ b/XenAdmin/XenAdmin.csproj @@ -224,10 +224,12 @@ + + @@ -6886,4 +6888,4 @@ copy "$(ProjectDir)\..\packages\putty.exe" "$(TargetDir)" - + \ No newline at end of file diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 2ec2c5b9e..0e1bb2ae8 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -6785,6 +6785,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Checking for pending restart. + /// + public static string CHECKING_FOR_PENDING_RESTART { + get { + return ResourceManager.GetString("CHECKING_FOR_PENDING_RESTART", resourceCulture); + } + } + /// /// Looks up a localized string similar to Checking HA and WLB status. /// @@ -27316,6 +27325,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Pending restart check. + /// + public static string PENDING_RESTART_CHECK { + get { + return ResourceManager.GetString("PENDING_RESTART_CHECK", resourceCulture); + } + } + /// /// Looks up a localized string similar to Interval must be a multiple of 5. /// @@ -28209,6 +28227,42 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to {0}: The master needs to be rebooted first. + /// + public static string PROBLEM_MASTER_PENDING_RESTART_HOST { + get { + return ResourceManager.GetString("PROBLEM_MASTER_PENDING_RESTART_HOST", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0}: This update requires the master to be rebooted first. + /// + public static string PROBLEM_MASTER_PENDING_RESTART_HOST_THIS_UPDATE { + get { + return ResourceManager.GetString("PROBLEM_MASTER_PENDING_RESTART_HOST_THIS_UPDATE", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0}: Toolstack on master needs to be restarted first. + /// + public static string PROBLEM_MASTER_PENDING_RESTART_TOOLSTACK { + get { + return ResourceManager.GetString("PROBLEM_MASTER_PENDING_RESTART_TOOLSTACK", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0}: This update requires the toolstack on master to be restarted first. + /// + public static string PROBLEM_MASTER_PENDING_RESTART_TOOLSTACK_THIS_UPDATE { + get { + return ResourceManager.GetString("PROBLEM_MASTER_PENDING_RESTART_TOOLSTACK_THIS_UPDATE", resourceCulture); + } + } + /// /// Looks up a localized string similar to Pool '{0}'. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index e2c432d4d..c322eed3b 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -291,15 +291,15 @@ Disabled PVS-Accelerator for selected VMs - - Disable IGMP snooping - Disable Changed Block Tracking Disabling Changed Block Tracking for VM '{0}' + + Disable IGMP snooping + Disable live patching @@ -2465,6 +2465,9 @@ Do you want to assign it to the schedule '{2}' instead? Checking VM migration status + + Checking for pending restart + Checking HA and WLB status @@ -6846,8 +6849,8 @@ Size: {3} Licensing Error - - Unlicensed + + License expired No licenses available @@ -6871,9 +6874,6 @@ Size: {3} [XenServer] Online this text could be improved - - License expired - This field is disabled due to license restrictions on the server. @@ -6972,6 +6972,9 @@ Standard features only Activation keys can only be applied to one Free [XenServer] product at a time. + + Unlicensed + Unsupported @@ -9508,6 +9511,9 @@ File not found Title + + Pending restart check + Performance Graphs @@ -9807,6 +9813,18 @@ Please reconnect the host and try again Duplicate MAC address + + {0}: The master needs to be rebooted first + + + {0}: This update requires the master to be rebooted first + + + {0}: Toolstack on master needs to be restarted first + + + {0}: This update requires the toolstack on master to be restarted first + Pool '{0}'