CP-28431: Block updates/upgrades from Kolkata if clustering enabled (#2124)

* CP-28431: Block updates and upgrades from Kolkata onwards if clustering enabled
* CP-28431: Rename files and change from Pool Check to [Host] Check
* CP-28431: Change description message

Signed-off-by: Seren Corbett <seren.corbett@citrix.com>
This commit is contained in:
serencorbett1 2018-07-09 10:59:09 +01:00 committed by Konstantina Chremmou
parent 3c2463040a
commit 63d09dd117
8 changed files with 262 additions and 0 deletions

View File

@ -0,0 +1,70 @@
/* 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.Linq;
using XenAdmin.Core;
using XenAPI;
using XenAdmin.Diagnostics.Problems;
using XenAdmin.Diagnostics.Problems.HostProblem;
namespace XenAdmin.Diagnostics.Checks
{
class PoolHasGFS2SR : Check
{
public PoolHasGFS2SR(Host host)
: base(host)
{
}
protected override Problem RunCheck()
{
if (!Host.IsLive())
return new HostNotLiveWarning(this, Host);
var clusteringEnabled = Host.Connection.Cache.Cluster_hosts.Any(cluster => cluster.enabled);
var hasGfs2Sr = Host.Connection.Cache.SRs.Any(sr => sr.GetSRType(true) == SR.SRTypes.gfs2);
if (clusteringEnabled || hasGfs2Sr)
return new Problems.PoolProblem.PoolHasGFS2SRProblem(this, Helpers.GetPoolOfOne(Host.Connection), clusteringEnabled, hasGfs2Sr);
return null;
}
public override string Description
{
get
{
return string.Format(Messages.CLUSTERING_STATUS_CHECK, Helpers.GetPoolOfOne(Host.Connection));
}
}
}
}

View File

@ -0,0 +1,82 @@
/* 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 XenAdmin.Diagnostics.Checks;
using XenAPI;
namespace XenAdmin.Diagnostics.Problems.PoolProblem
{
class PoolHasGFS2SRProblem : PoolProblem
{
public bool clusterEnabled;
public bool gfs2;
public PoolHasGFS2SRProblem(Check check, Pool pool, bool clusteringEnabled, bool hasGfs2Sr)
: base(check, pool)
{
clusterEnabled = clusteringEnabled;
gfs2 = hasGfs2Sr;
}
public override string Description
{
get
{
if (clusterEnabled && gfs2)
{
return string.Format(Messages.GFS2_UPDATE_UPGRADE_CLUSTER_SR_ERROR, Pool);
}
if (clusterEnabled)
{
return string.Format(Messages.GFS2_UPDATE_UPGRADE_CLUSTER_ERROR, Pool);
}
if (gfs2)
{
return string.Format(Messages.GFS2_UPDATE_UPGRADE_SR_ERROR, Pool);
}
return null;
}
}
public override string HelpMessage
{
get
{
return "";
}
}
}
}

View File

@ -436,6 +436,24 @@ namespace XenAdmin.Wizards.PatchingWizard
groups.Add(new CheckGroup(Messages.CHECKING_CANEVACUATE_STATUS, evacuateChecks));
}
if (WizardMode == WizardMode.NewVersion)
{
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));
}
}
return groups;
}

View File

@ -215,6 +215,19 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard
groups.Add(new CheckGroup(Messages.CHECKING_SAFE_TO_UPGRADE, upgradeChecks));
}
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));
}
return groups;
}

View File

@ -708,6 +708,7 @@
<Compile Include="TabPages\UsbPage.Designer.cs">
<DependentUpon>UsbPage.cs</DependentUpon>
</Compile>
<Compile Include="Diagnostics\Problems\PoolProblem\PoolHasGFS2SRProblem.cs" />
<Compile Include="Wizards\BallooningWizard.cs">
<SubType>Form</SubType>
</Compile>
@ -994,6 +995,7 @@
<SubType>Component</SubType>
</Compile>
<Compile Include="Wizards\PatchingWizard\UpgradeProgressDescriptor.cs" />
<Compile Include="Diagnostics\Checks\PoolHasGFS2SR.cs" />
<Compile Include="XenSearch\TreeNodeGroupAcceptor.cs">
</Compile>
<Compile Include="Dialogs\FolderChangeDialog.cs">

View File

@ -6967,6 +6967,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Checking clustering status.
/// </summary>
public static string CHECKING_CLUSTERING_STATUS {
get {
return ResourceManager.GetString("CHECKING_CLUSTERING_STATUS", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Checking for pending restart.
/// </summary>
@ -7201,6 +7210,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Clustering status check.
/// </summary>
public static string CLUSTERING_STATUS_CHECK {
get {
return ResourceManager.GetString("CLUSTERING_STATUS_CHECK", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &amp;Collapse Children.
/// </summary>
@ -16271,6 +16289,33 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Pool {0} cannot have clustering enabled..
/// </summary>
public static string GFS2_UPDATE_UPGRADE_CLUSTER_ERROR {
get {
return ResourceManager.GetString("GFS2_UPDATE_UPGRADE_CLUSTER_ERROR", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Pool {0} cannot have clustering enabled or a thinly provisioned (GFS2) SR present..
/// </summary>
public static string GFS2_UPDATE_UPGRADE_CLUSTER_SR_ERROR {
get {
return ResourceManager.GetString("GFS2_UPDATE_UPGRADE_CLUSTER_SR_ERROR", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Pool {0} cannot have a thinly provisioned (GFS2) SR present..
/// </summary>
public static string GFS2_UPDATE_UPGRADE_SR_ERROR {
get {
return ResourceManager.GetString("GFS2_UPDATE_UPGRADE_SR_ERROR", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to GPU.
/// </summary>

View File

@ -2527,6 +2527,9 @@ Do you want to assign it to the schedule '{2}' instead?</value>
<data name="CHECKING_CANEVACUATE_STATUS" xml:space="preserve">
<value>Checking VM migration status</value>
</data>
<data name="CHECKING_CLUSTERING_STATUS" xml:space="preserve">
<value>Checking clustering status</value>
</data>
<data name="CHECKING_FOR_PENDING_RESTART" xml:space="preserve">
<value>Checking for pending restart</value>
</data>
@ -2608,6 +2611,9 @@ Do you want to assign it to the schedule '{2}' instead?</value>
<data name="CLUSTERING" xml:space="preserve">
<value>Clustering</value>
</data>
<data name="CLUSTERING_STATUS_CHECK" xml:space="preserve">
<value>Clustering status check</value>
</data>
<data name="COLLAPSE_CHILDREN" xml:space="preserve">
<value>&amp;Collapse Children</value>
</data>
@ -5698,6 +5704,15 @@ Warning: to prevent data loss you must ensure that the LUN is not in use by any
<data name="GFS2_SR_ATTACHED" xml:space="preserve">
<value>Clustering cannot be disabled because there are thinly provisioned (GFS2) storage repositories attached to this pool.</value>
</data>
<data name="GFS2_UPDATE_UPGRADE_CLUSTER_ERROR" xml:space="preserve">
<value>Pool {0} cannot have clustering enabled.</value>
</data>
<data name="GFS2_UPDATE_UPGRADE_CLUSTER_SR_ERROR" xml:space="preserve">
<value>Pool {0} cannot have clustering enabled or a thinly provisioned (GFS2) SR present.</value>
</data>
<data name="GFS2_UPDATE_UPGRADE_SR_ERROR" xml:space="preserve">
<value>Pool {0} cannot have a thinly provisioned (GFS2) SR present.</value>
</data>
<data name="GPU" xml:space="preserve">
<value>GPU</value>
</data>

View File

@ -423,6 +423,23 @@ namespace XenAdmin.Core
return platform_version != null && productVersionCompare(platform_version, "2.5.50") >= 0;
}
/// <param name="conn">May be null, in which case true is returned.</param>
public static bool LimaOrGreater(IXenConnection conn)
{
return conn == null || LimaOrGreater(Helpers.GetMaster(conn));
}
/// Lima platform version is 2.7.0
/// <param name="host">May be null, in which case true is returned.</param>
public static bool LimaOrGreater(Host host)
{
if (host == null)
return true;
string platform_version = HostPlatformVersion(host);
return platform_version != null && productVersionCompare(platform_version, "2.6.50") >= 0;
}
/// <summary>
/// Cream (Creedence SP1) has API version 2.4
/// </summary>