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 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;
|
2018-06-29 20:49:28 +02:00
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
protected override string SuccessMessagePerPool(Pool pool)
|
2018-06-22 16:57:31 +02:00
|
|
|
|
{
|
|
|
|
|
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-26 15:04:51 +02:00
|
|
|
|
protected override string UserCancellationMessage()
|
|
|
|
|
{
|
|
|
|
|
return Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_CANCELLATION;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-20 14:23:49 +01:00
|
|
|
|
protected override string ReconsiderCancellationMessage()
|
|
|
|
|
{
|
|
|
|
|
return Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_CANCELLATION_RECONSIDER;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-29 20:49:28 +02:00
|
|
|
|
protected override List<HostPlan> GenerateHostPlans(Pool pool, out List<Host> applicableHosts)
|
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
|
2018-08-03 17:11:06 +02:00
|
|
|
|
? Updates.GetMinimalPatches(UpdateAlert, ApplyUpdatesToNewVersion && !automatedUpdatesRestricted)
|
2018-06-19 13:56:14 +02:00
|
|
|
|
: Updates.GetMinimalPatches(pool.Connection);
|
2017-03-28 12:17:26 +02:00
|
|
|
|
|
2018-06-19 13:56:14 +02:00
|
|
|
|
if (minimalPatches == null)
|
2018-06-29 20:49:28 +02:00
|
|
|
|
{
|
|
|
|
|
applicableHosts = new List<Host>();
|
|
|
|
|
return new List<HostPlan>();
|
|
|
|
|
}
|
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-29 20:49:28 +02:00
|
|
|
|
applicableHosts = new List<Host>(hosts);
|
|
|
|
|
return hosts.Select(h => GetUpdatePlanActionsForHost(h, hosts, minimalPatches, uploadedPatches, PatchFromDisk)).ToList();
|
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
|
|
|
|
}
|
|
|
|
|
}
|