CP-26866: Add a specific warning when creating a bond on cluster network

Signed-off-by: Ji Jiang <ji.jiang@citrix.com>
This commit is contained in:
Ji Jiang 2018-05-04 09:57:10 +01:00 committed by Konstantina Chremmou
parent 29d82b1498
commit 9ddb253ec0
7 changed files with 64 additions and 22 deletions

View File

@ -236,7 +236,9 @@ namespace XenAdmin.Controls
bool will_disturb_primary = NetworkingHelper.ContainsPrimaryManagement(pifs);
bool will_disturb_secondary = NetworkingHelper.ContainsSecondaryManagement(pifs);
bool will_disturb_clustering = NetworkingHelper.ContainsClusteringPif(pifs);
// It is not allowed to bond primary and secondary interfaces together.
if (will_disturb_primary && will_disturb_secondary)
{
using (var dlg = new ThreeButtonDialog(
@ -251,6 +253,8 @@ namespace XenAdmin.Controls
return DialogResult.Cancel;
}
// Only primary management interface.
// In this case, clustering interface warning is hidden if it happens to be the management interface.
if (will_disturb_primary)
{
Pool pool = Helpers.GetPool(Connection);
@ -280,19 +284,39 @@ namespace XenAdmin.Controls
return dialogResult;
}
// Only secondary interface.
// If there is clustering interface, shows clustering warning. Otherwise, shows secondary interface warning.
if (will_disturb_secondary)
{
DialogResult dialogResult;
using (var dlg = new ThreeButtonDialog(
new ThreeButtonDialog.Details(
SystemIcons.Warning,
Messages.BOND_CREATE_WILL_DISTURB_SECONDARY,
Messages.BOND_CREATE),
ThreeButtonDialog.ButtonOK,
ThreeButtonDialog.ButtonCancel))
if (will_disturb_clustering)
{
dialogResult = dlg.ShowDialog(this);
using (var dlg = new ThreeButtonDialog(
new ThreeButtonDialog.Details(
SystemIcons.Warning,
Messages.BOND_CREATE_WILL_DISTURB_CLUSTERING,
Messages.BOND_CREATE),
ThreeButtonDialog.ButtonOK,
ThreeButtonDialog.ButtonCancel))
{
dialogResult = dlg.ShowDialog(this);
}
}
else
{
using (var dlg = new ThreeButtonDialog(
new ThreeButtonDialog.Details(
SystemIcons.Warning,
Messages.BOND_CREATE_WILL_DISTURB_SECONDARY,
Messages.BOND_CREATE),
ThreeButtonDialog.ButtonOK,
ThreeButtonDialog.ButtonCancel))
{
dialogResult = dlg.ShowDialog(this);
}
}
return dialogResult;
}

View File

@ -250,8 +250,7 @@ namespace XenAdmin.Actions
private void DisableClustering(PIF pif, out List<PBD> gfs2Pbds)
{
gfs2Pbds = new List<PBD>();
var isUsedByClustering = Connection.Cache.Cluster_hosts.Any(cluster => cluster.PIF.opaque_ref == pif.opaque_ref);
if (!isUsedByClustering)
if (!pif.IsUsedByClustering())
return;
var host = Connection.Resolve(pif.host);
@ -286,8 +285,7 @@ namespace XenAdmin.Actions
/// </summary>
private void EnableClustering(PIF pif, List<PBD> gfs2Pbds)
{
var isUsedByClustering = Connection.Cache.Cluster_hosts.Any(cluster => cluster.PIF.opaque_ref == pif.opaque_ref);
if (!isUsedByClustering)
if (!pif.IsUsedByClustering())
return;
var host = Connection.Resolve(pif.host);

View File

@ -339,8 +339,7 @@ namespace XenAdmin.Actions
private static void ClearIP(AsyncAction action, PIF pif, int hi)
{
// if the network is used by clustering, then we don't remove the IP address
var isUsedByClustering = pif.Connection.Cache.Cluster_hosts.Any(cluster => cluster.PIF.opaque_ref == pif.opaque_ref);
if (isUsedByClustering)
if (pif.IsUsedByClustering())
return;
log.DebugFormat("Removing IP address from {0} {1}...", pif.Name(), pif.uuid);

View File

@ -5874,6 +5874,17 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Creating this bond will automatically move the clustering network on one of your selected bond members to the bond itself:
///
///- If your network configuration is incorrect then hosts may permanently lose the connection to the clustering network, which will cause undesired host fences..
/// </summary>
public static string BOND_CREATE_WILL_DISTURB_CLUSTERING {
get {
return ResourceManager.GetString("BOND_CREATE_WILL_DISTURB_CLUSTERING", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Creating this bond will automatically move the management interface on one of your selected bond members to the bond itself:
///

View File

@ -2149,6 +2149,11 @@ Both types of interface cannot be added to the same bond. Choose different bond
<data name="BOND_CREATE_WILL_DISTURB_SECONDARY" xml:space="preserve">
<value>Creating this bond will disrupt traffic through the secondary interfaces on the bond members while the interfaces are moved onto the bond itself.</value>
</data>
<data name="BOND_CREATE_WILL_DISTURB_CLUSTERING" xml:space="preserve">
<value>Creating this bond will automatically move the clustering network on one of your selected bond members to the bond itself:
- If your network configuration is incorrect then hosts may permanently lose the connection to the clustering network, which will cause undesired host fences.</value>
</data>
<data name="BOND_DELETE_CONTINUE" xml:space="preserve">
<value>&amp;Delete bond anyway</value>
</data>

View File

@ -31,6 +31,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using XenAPI;
using XenAdmin.Core;
@ -250,18 +251,17 @@ namespace XenAdmin.Network
public static bool ContainsPrimaryManagement(List<PIF> PIFs)
{
return null != PIFs.Find((Predicate<PIF>)delegate(PIF p)
{
return p.management;
});
return PIFs.Any(p => p.management);
}
public static bool ContainsSecondaryManagement(List<PIF> PIFs)
{
return null != PIFs.Find((Predicate<PIF>)delegate(PIF p)
{
return p.IsSecondaryManagementInterface(true);
});
return PIFs.Any(p => p.IsSecondaryManagementInterface(true));
}
public static bool ContainsClusteringPif(List<PIF> PIFs)
{
return PIFs.Any(p => p.IsUsedByClustering());
}
}

View File

@ -242,6 +242,11 @@ namespace XenAPI
return master.currently_attached;
}
public bool IsUsedByClustering()
{
return Connection.Cache.Cluster_hosts.Any(cluster => cluster.PIF.opaque_ref == opaque_ref);
}
/// <summary>
/// Returns the Bond of which this PIF is a slave, or null if it is not so.
/// </summary>