2017-01-16 20:59:50 +01:00
|
|
|
|
/* Copyright (c) Citrix Systems, Inc.
|
2013-06-24 13:41:48 +02: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;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using XenAdmin.Controls;
|
|
|
|
|
using XenAdmin.Core;
|
|
|
|
|
using XenAdmin.Diagnostics.Checks;
|
|
|
|
|
using XenAdmin.Diagnostics.Hotfixing;
|
|
|
|
|
using XenAdmin.Wizards.PatchingWizard;
|
|
|
|
|
using XenAPI;
|
|
|
|
|
using System.Linq;
|
2018-03-05 14:43:56 +01:00
|
|
|
|
using CheckGroup = System.Collections.Generic.KeyValuePair<string, System.Collections.Generic.List<XenAdmin.Diagnostics.Checks.Check>>;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Wizards.RollingUpgradeWizard
|
|
|
|
|
{
|
|
|
|
|
public partial class RollingUpgradeWizardPrecheckPage : PatchingWizard_PrecheckPage
|
|
|
|
|
{
|
|
|
|
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
|
|
|
|
public RollingUpgradeWizardPrecheckPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2018-07-06 18:45:00 +02:00
|
|
|
|
ManualUpgrade = true;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddEventHandlersToMasters()
|
|
|
|
|
{
|
|
|
|
|
foreach (Host master in SelectedMasters)
|
|
|
|
|
{
|
|
|
|
|
master.Connection.ConnectionStateChanged += connection_ConnectionChanged;
|
|
|
|
|
master.Connection.CachePopulated += connection_ConnectionChanged;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RemoveEventHandlersToMasters()
|
|
|
|
|
{
|
|
|
|
|
foreach (Host master in SelectedMasters)
|
|
|
|
|
{
|
|
|
|
|
master.Connection.ConnectionStateChanged -= connection_ConnectionChanged;
|
|
|
|
|
master.Connection.CachePopulated -= connection_ConnectionChanged;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void connection_ConnectionChanged(object sender, EventArgs eventArgs)
|
|
|
|
|
{
|
2018-07-03 16:17:57 +02:00
|
|
|
|
Program.Invoke(this, RefreshRechecks);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 01:31:46 +01:00
|
|
|
|
protected override void PageLoadedCore(PageLoadedDirection direction)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
if (direction == PageLoadedDirection.Back)
|
|
|
|
|
{
|
|
|
|
|
RefreshRechecks();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var selectedMasters = new List<Host>(SelectedMasters);
|
|
|
|
|
RemoveEventHandlersToMasters();
|
|
|
|
|
SelectedServers.Clear();
|
|
|
|
|
foreach (Host selectedMaster in selectedMasters)
|
|
|
|
|
{
|
|
|
|
|
Host master = selectedMaster;
|
|
|
|
|
if (master != null)
|
|
|
|
|
{
|
|
|
|
|
Pool pool = Helpers.GetPoolOfOne(master.Connection);
|
|
|
|
|
if (pool != null)
|
2017-09-03 04:33:29 +02:00
|
|
|
|
SelectedServers.AddRange(pool.HostsToUpgrade());
|
2013-06-24 13:41:48 +02:00
|
|
|
|
else
|
|
|
|
|
SelectedServers.Add(master);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AddEventHandlersToMasters();
|
|
|
|
|
labelPrechecksFirstLine.Text = Messages.ROLLINGUPGRADE_PRECHECKS;
|
|
|
|
|
RefreshRechecks();
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 00:55:50 +01:00
|
|
|
|
protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
RemoveEventHandlersToMasters();
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-20 13:33:26 +01:00
|
|
|
|
public override void PageCancelled(ref bool cancel)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
RemoveEventHandlersToMasters();
|
2018-12-20 13:33:26 +01:00
|
|
|
|
base.PageCancelled(ref cancel);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string PageTitle
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Messages.UPGRADE_PRECHECKS_TITLE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Text
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Messages.UPGRADE_PRECHECKS_TEXT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string HelpID
|
|
|
|
|
{
|
|
|
|
|
get { return "Upgradeprechecks"; }
|
|
|
|
|
}
|
|
|
|
|
|
CP-30335: Rearrange the RPU wizard pages
- Moved Install Location (RollingUpgradeWizard_SelectInstallMethod) page immediatelly after the Upgrade Mode page (and before the Prechecks page)
- Added a new page, called Extras, which contains the updates and supp pack installation options. These options have been moved here from the "Upgrade Mode" and "Ready To Upgrade" pages. This page is also inserted before the Prechecks
- There is no "Ready To Upgrade" page anymore. So the wizard pages are:
- when automatic mode is selected: Before You Start, Select Pools, Upgrade Mode, Installer Location, Extras, Prechecks, Apply Upgrade.
- when manual mode is selected: Before You Start, Select Pools, Upgrade Mode, Extras, Prechecks, Apply Upgrade.
Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
2019-01-17 15:01:49 +01:00
|
|
|
|
public override string NextText(bool isLastPage)
|
|
|
|
|
{
|
|
|
|
|
return Messages.START_UPGRADE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-05 14:43:56 +01:00
|
|
|
|
protected override List<CheckGroup> GenerateChecks(Pool_patch patch)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-03-05 14:43:56 +01:00
|
|
|
|
var groups = new List<CheckGroup>();
|
2017-03-22 11:59:32 +01:00
|
|
|
|
|
2018-07-06 13:49:16 +02:00
|
|
|
|
List<Host> hostsToUpgrade = new List<Host>();
|
|
|
|
|
List<Host> hostsToUpgradeOrUpdate = new List<Host>();
|
|
|
|
|
foreach (var pool in SelectedPools)
|
|
|
|
|
{
|
|
|
|
|
var poolHostsToUpgrade = pool.HostsToUpgrade();
|
|
|
|
|
hostsToUpgrade.AddRange(poolHostsToUpgrade);
|
|
|
|
|
hostsToUpgradeOrUpdate.AddRange(ApplyUpdatesToNewVersion
|
|
|
|
|
? HostsToUpgradeOrUpdate(pool)
|
|
|
|
|
: poolHostsToUpgrade);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-22 11:59:32 +01:00
|
|
|
|
//XenCenter version check (if any of the selected server version is not the latest)
|
|
|
|
|
var latestCrVersion = Updates.XenServerVersions.FindAll(item => item.LatestCr).OrderByDescending(v => v.Version).FirstOrDefault();
|
|
|
|
|
if (latestCrVersion != null &&
|
2018-07-06 13:49:16 +02:00
|
|
|
|
hostsToUpgradeOrUpdate.Any(host => new Version(Helpers.HostProductVersion(host)) < latestCrVersion.Version))
|
2017-03-22 11:59:32 +01:00
|
|
|
|
{
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_XENCENTER_VERSION, new List<Check> {new XenCenterVersionCheck(null)}));
|
2017-03-22 11:59:32 +01:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2018-07-06 13:49:16 +02:00
|
|
|
|
//HostMaintenanceModeCheck checks - for hosts that will be upgraded or updated
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var livenessChecks = new List<Check>();
|
2018-07-06 13:49:16 +02:00
|
|
|
|
foreach (Host host in hostsToUpgradeOrUpdate)
|
2018-10-09 18:58:33 +02:00
|
|
|
|
livenessChecks.Add(new HostLivenessCheck(host, hostsToUpgrade.Contains(host)));
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_HOST_LIVENESS_STATUS, livenessChecks));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2018-07-06 13:49:16 +02:00
|
|
|
|
//HA checks - for each pool
|
2018-07-11 01:48:34 +02:00
|
|
|
|
var haChecks = (from Host server in SelectedMasters
|
2018-07-06 18:43:38 +02:00
|
|
|
|
select new HAOffCheck(server) as Check).ToList();
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_HA_STATUS, haChecks));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2018-07-06 13:49:16 +02:00
|
|
|
|
//Checking can evacuate host - for hosts that will be upgraded or updated
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var evacuateChecks = new List<Check>();
|
2018-07-06 13:49:16 +02:00
|
|
|
|
foreach (Host host in hostsToUpgradeOrUpdate)
|
2018-02-28 12:20:00 +01:00
|
|
|
|
evacuateChecks.Add(new AssertCanEvacuateUpgradeCheck(host));
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_CANEVACUATE_STATUS, evacuateChecks));
|
2014-05-21 15:34:43 +02:00
|
|
|
|
|
2018-07-06 13:49:16 +02:00
|
|
|
|
//PBDsPluggedCheck - for hosts that will be upgraded or updated
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var pbdChecks = new List<Check>();
|
2018-07-06 13:49:16 +02:00
|
|
|
|
foreach (Host host in hostsToUpgradeOrUpdate)
|
2018-02-28 12:20:00 +01:00
|
|
|
|
pbdChecks.Add(new PBDsPluggedCheck(host));
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_STORAGE_CONNECTIONS_STATUS, pbdChecks));
|
2018-02-28 12:20:00 +01:00
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2018-07-06 13:49:16 +02:00
|
|
|
|
//HotfixesCheck - for hosts that will be upgraded
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var hotfixChecks = new List<Check>();
|
2018-07-06 13:49:16 +02:00
|
|
|
|
foreach (var host in hostsToUpgrade)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
if (new HotfixFactory().IsHotfixRequired(host) && !ManualUpgrade)
|
2018-02-28 12:20:00 +01:00
|
|
|
|
hotfixChecks.Add(new HostHasHotfixCheck(host));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2018-02-28 12:20:00 +01:00
|
|
|
|
if (hotfixChecks.Count > 0)
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_UPGRADE_HOTFIX_STATUS, hotfixChecks));
|
2018-02-28 12:20:00 +01:00
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2016-10-26 18:28:11 +02:00
|
|
|
|
//iSL (StorageLink) check - CA-223486: only for pre-Creedence
|
2018-07-06 13:49:16 +02:00
|
|
|
|
var preCreedenceServers = hostsToUpgrade.Where(h => !Helpers.CreedenceOrGreater(h)).ToList();
|
2016-10-27 12:39:01 +02:00
|
|
|
|
if (preCreedenceServers.Any())
|
2014-05-21 14:47:51 +02:00
|
|
|
|
{
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var srLinkChecks = new List<Check>();
|
2016-10-27 12:39:01 +02:00
|
|
|
|
foreach (Host host in preCreedenceServers)
|
2018-02-28 12:20:00 +01:00
|
|
|
|
srLinkChecks.Add(new HostHasUnsupportedStorageLinkSRCheck(host));
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_STORAGELINK_STATUS, srLinkChecks));
|
2014-05-21 14:47:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-06 13:49:16 +02:00
|
|
|
|
//SafeToUpgradeCheck - in automatic mode only, for hosts that will be upgraded
|
2015-06-24 18:25:58 +02:00
|
|
|
|
if (!ManualUpgrade)
|
2015-06-04 16:24:04 +02:00
|
|
|
|
{
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var upgradeChecks = new List<Check>();
|
2018-07-06 13:49:16 +02:00
|
|
|
|
foreach (var host in hostsToUpgrade)
|
2018-02-28 12:20:00 +01:00
|
|
|
|
upgradeChecks.Add(new SafeToUpgradeCheck(host));
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_SAFE_TO_UPGRADE, upgradeChecks));
|
2015-06-04 16:24:04 +02:00
|
|
|
|
}
|
2018-07-13 14:14:36 +02:00
|
|
|
|
|
2018-07-09 11:59:09 +02:00
|
|
|
|
var gfs2Checks = new List<Check>();
|
|
|
|
|
foreach (Pool pool in SelectedPools.Where(p =>
|
|
|
|
|
Helpers.KolkataOrGreater(p.Connection) && !Helpers.LimaOrGreater(p.Connection)))
|
|
|
|
|
{
|
|
|
|
|
Host host = pool.Connection.Resolve(pool.master);
|
|
|
|
|
gfs2Checks.Add(new PoolHasGFS2SR(host));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gfs2Checks.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_CLUSTERING_STATUS, gfs2Checks));
|
|
|
|
|
}
|
2015-06-04 16:24:04 +02:00
|
|
|
|
|
2018-07-04 02:20:35 +02:00
|
|
|
|
//Checking automated updates are possible if apply updates checkbox is ticked
|
2018-06-21 14:51:48 +02:00
|
|
|
|
if (ApplyUpdatesToNewVersion)
|
|
|
|
|
{
|
2018-07-11 01:48:34 +02:00
|
|
|
|
var automatedUpdateChecks = (from Host server in SelectedMasters
|
2018-07-06 18:43:38 +02:00
|
|
|
|
select new AutomatedUpdatesLicenseCheck(server) as Check).ToList();
|
2018-06-21 14:51:48 +02:00
|
|
|
|
|
2018-07-04 02:20:35 +02:00
|
|
|
|
automatedUpdateChecks.Add(new CfuAvailabilityCheck());
|
2018-07-03 22:53:55 +02:00
|
|
|
|
|
2018-07-04 02:20:35 +02:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_AUTOMATED_UPDATES_POSSIBLE,
|
|
|
|
|
automatedUpdateChecks));
|
2018-06-21 14:51:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-28 12:20:00 +01:00
|
|
|
|
return groups;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<Host> SelectedMasters { private get; set; }
|
2018-07-06 18:45:00 +02:00
|
|
|
|
public bool ManualUpgrade { set; private get; }
|
2018-07-06 13:49:16 +02:00
|
|
|
|
|
|
|
|
|
#region private methods
|
|
|
|
|
public static List<Host> HostsToUpgradeOrUpdate(Pool pool)
|
|
|
|
|
{
|
|
|
|
|
var result = new List<Host>();
|
|
|
|
|
|
|
|
|
|
if (pool == null)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
var master = Helpers.GetMaster(pool);
|
|
|
|
|
if (master == null)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
if (pool.IsMasterUpgraded())
|
|
|
|
|
{
|
|
|
|
|
foreach (var h in pool.Connection.Cache.Hosts)
|
|
|
|
|
{
|
|
|
|
|
if (h.LongProductVersion() != master.LongProductVersion()) // host needs to be upgraded
|
|
|
|
|
result.Add(h); // host
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//check update sequence for already-upgraded hosts
|
|
|
|
|
var us = Updates.GetPatchSequenceForHost(h, Updates.GetMinimalPatches(master));
|
|
|
|
|
if (us != null && us.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
result.Add(h);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
result.AddRange(pool.Connection.Cache.Hosts);
|
|
|
|
|
|
|
|
|
|
result.Sort();
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|