2017-01-16 20:59:50 +01:00
|
|
|
|
/* Copyright (c) Citrix Systems, Inc.
|
2016-03-14 17:10:16 +01:00
|
|
|
|
* 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 XenAdmin.Wizards.PatchingWizard.PlanActions;
|
|
|
|
|
using XenAPI;
|
2016-03-24 19:24:12 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using XenAdmin.Core;
|
2017-03-24 17:43:19 +01:00
|
|
|
|
using XenAdmin.Alerts;
|
2016-03-14 17:10:16 +01:00
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Wizards.PatchingWizard
|
|
|
|
|
{
|
2018-06-19 13:56:14 +02:00
|
|
|
|
public partial class PatchingWizard_AutomatedUpdatesPage : AutomatedUpdatesBasePage
|
2016-03-14 17:10:16 +01:00
|
|
|
|
{
|
2017-03-24 17:43:19 +01:00
|
|
|
|
public XenServerPatchAlert UpdateAlert { private get; set; }
|
|
|
|
|
public WizardMode WizardMode { private get; set; }
|
2018-06-22 11:58:08 +02:00
|
|
|
|
|
2018-02-05 13:36:49 +01:00
|
|
|
|
public KeyValuePair<XenServerPatch, string> PatchFromDisk { private get; set; }
|
2016-03-24 19:24:12 +01:00
|
|
|
|
|
2016-12-10 15:44:15 +01:00
|
|
|
|
public PatchingWizard_AutomatedUpdatesPage()
|
2016-03-14 17:10:16 +01:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-19 13:56:14 +02:00
|
|
|
|
#region XenTabPage overrides
|
2016-03-14 17:10:16 +01:00
|
|
|
|
public override string Text
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-03-16 14:22:23 +01:00
|
|
|
|
return Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_TEXT;
|
2016-03-14 17:10:16 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string PageTitle
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-03-16 14:22:23 +01:00
|
|
|
|
return Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_TITLE;
|
2016-03-14 17:10:16 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string HelpID
|
|
|
|
|
{
|
|
|
|
|
get { return ""; }
|
|
|
|
|
}
|
2018-06-19 13:56:14 +02:00
|
|
|
|
#endregion
|
2016-03-14 17:10:16 +01:00
|
|
|
|
|
2018-06-19 13:56:14 +02:00
|
|
|
|
#region AutomatedUpdatesBesePage overrides
|
2018-06-22 16:57:31 +02:00
|
|
|
|
|
|
|
|
|
protected override string BlurbText()
|
2016-06-17 15:15:59 +02:00
|
|
|
|
{
|
2018-06-20 10:42:01 +02:00
|
|
|
|
return WizardMode == WizardMode.AutomatedUpdates
|
|
|
|
|
? Messages.PATCHINGWIZARD_UPLOAD_AND_INSTALL_TITLE_AUTOMATED_MODE
|
|
|
|
|
: Messages.PATCHINGWIZARD_UPLOAD_AND_INSTALL_TITLE_NEW_VERSION_AUTOMATED_MODE;
|
2016-06-17 15:15:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-22 16:57:31 +02:00
|
|
|
|
protected override string SuccessMessageOnCompletion(bool multiplePools)
|
|
|
|
|
{
|
|
|
|
|
return multiplePools ? Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_SUCCESS_MANY : Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_SUCCESS_ONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string FailureMessageOnCompletion(bool multiplePools)
|
|
|
|
|
{
|
|
|
|
|
return multiplePools ? Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_ERROR_MANY : Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_ERROR_ONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string SuccessMessagePerPool()
|
|
|
|
|
{
|
|
|
|
|
return Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_SUCCESS_ONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string FailureMessagePerPool(bool multipleErrors)
|
|
|
|
|
{
|
|
|
|
|
return multipleErrors ? Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_ERROR_POOL_MANY : Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_ERROR_POOL_ONE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-25 01:59:21 +02:00
|
|
|
|
protected override void GeneratePlanActions(Pool pool, List<HostPlan> planActions, List<PlanAction> finalActions)
|
2016-03-14 17:10:16 +01:00
|
|
|
|
{
|
2018-06-19 13:56:14 +02:00
|
|
|
|
bool automatedUpdatesRestricted = pool.Connection.Cache.Hosts.Any(Host.RestrictBatchHotfixApply);
|
2016-03-24 19:24:12 +01:00
|
|
|
|
|
2018-06-19 13:56:14 +02:00
|
|
|
|
var minimalPatches = WizardMode == WizardMode.NewVersion
|
|
|
|
|
? Updates.GetMinimalPatches(pool.Connection, UpdateAlert, ApplyUpdatesToNewVersion && !automatedUpdatesRestricted)
|
|
|
|
|
: Updates.GetMinimalPatches(pool.Connection);
|
2017-03-28 12:17:26 +02:00
|
|
|
|
|
2018-06-19 13:56:14 +02:00
|
|
|
|
if (minimalPatches == null)
|
|
|
|
|
return;
|
2016-03-24 19:24:12 +01:00
|
|
|
|
|
2018-06-19 13:56:14 +02:00
|
|
|
|
var uploadedPatches = new List<XenServerPatch>();
|
|
|
|
|
var hosts = pool.Connection.Cache.Hosts.ToList();
|
|
|
|
|
hosts.Sort();//master first
|
2016-03-24 19:24:12 +01:00
|
|
|
|
|
2018-06-19 13:56:14 +02:00
|
|
|
|
foreach (var host in hosts)
|
2018-06-05 23:26:16 +02:00
|
|
|
|
{
|
2018-06-22 11:58:08 +02:00
|
|
|
|
var hostActions = GetUpdatePlanActionsForHost(host, hosts, minimalPatches, uploadedPatches, PatchFromDisk);
|
2018-06-19 13:56:14 +02:00
|
|
|
|
if (hostActions.UpdatesPlanActions != null && hostActions.UpdatesPlanActions.Count > 0)
|
|
|
|
|
planActions.Add(hostActions);
|
2016-03-31 16:40:23 +02:00
|
|
|
|
}
|
2016-03-24 19:24:12 +01:00
|
|
|
|
|
2018-06-19 13:56:14 +02:00
|
|
|
|
//add a revert pre-check action for this pool
|
|
|
|
|
var problemsToRevert = ProblemsResolvedPreCheck.Where(p => hosts.ToList().Select(h => h.uuid).ToList().Contains(p.Check.Host.uuid)).ToList();
|
|
|
|
|
if (problemsToRevert.Count > 0)
|
|
|
|
|
finalActions.Add(new UnwindProblemsAction(problemsToRevert, string.Format(Messages.REVERTING_RESOLVED_PRECHECKS_POOL, pool.Connection.Name)));
|
2018-06-05 23:26:16 +02:00
|
|
|
|
}
|
2018-06-19 13:56:14 +02:00
|
|
|
|
#endregion
|
2016-03-14 17:10:16 +01:00
|
|
|
|
}
|
|
|
|
|
}
|