2023-01-24 15:29:31 +01:00
|
|
|
|
/* Copyright (c) Cloud Software Group, Inc.
|
2017-11-23 11:59:15 +01:00
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-12-12 14:36:09 +01:00
|
|
|
|
using System.ComponentModel;
|
2017-11-23 11:59:15 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using XenAdmin.Controls;
|
|
|
|
|
using XenAdmin.Core;
|
2017-12-12 14:36:09 +01:00
|
|
|
|
using XenAdmin.Dialogs;
|
2017-11-23 11:59:15 +01:00
|
|
|
|
using XenAPI;
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Wizards.NewSRWizard_Pages
|
|
|
|
|
{
|
|
|
|
|
public partial class ChooseSrProvisioningPage : XenTabPage
|
|
|
|
|
{
|
|
|
|
|
public ChooseSrProvisioningPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2017-12-12 14:36:09 +01:00
|
|
|
|
Cluster_CollectionChangedWithInvoke = Program.ProgramInvokeHandler(Cluster_CollectionChanged);
|
2017-11-23 11:59:15 +01:00
|
|
|
|
}
|
2019-03-22 15:06:27 +01:00
|
|
|
|
|
2017-12-12 14:36:09 +01:00
|
|
|
|
private readonly CollectionChangeEventHandler Cluster_CollectionChangedWithInvoke;
|
2019-03-22 15:06:27 +01:00
|
|
|
|
|
2017-11-23 11:59:15 +01:00
|
|
|
|
#region XenTabPage overrides
|
|
|
|
|
|
2019-03-22 15:06:27 +01:00
|
|
|
|
public override string Text => Messages.PROVISIONING;
|
2017-11-23 11:59:15 +01:00
|
|
|
|
|
2019-03-22 15:06:27 +01:00
|
|
|
|
public override string PageTitle => Messages.CHOOSE_SR_PROVISIONING_PAGE_TITLE;
|
|
|
|
|
|
|
|
|
|
public override string HelpID => "Provisioning";
|
2017-11-23 11:59:15 +01:00
|
|
|
|
|
|
|
|
|
#endregion
|
2017-11-28 11:51:44 +01:00
|
|
|
|
|
2019-03-22 15:06:27 +01:00
|
|
|
|
public bool IsGfs2 => radioButtonGfs2.Checked;
|
2017-11-28 11:51:44 +01:00
|
|
|
|
|
2017-12-12 14:36:09 +01:00
|
|
|
|
private void RefreshPage()
|
2017-11-28 11:51:44 +01:00
|
|
|
|
{
|
2017-12-12 14:36:09 +01:00
|
|
|
|
var clusteringEnabled = Connection.Cache.Clusters.Any();
|
|
|
|
|
var restrictGfs2 = Helpers.FeatureForbidden(Connection, Host.RestrictCorosync);
|
|
|
|
|
var gfs2Allowed = !restrictGfs2 && clusteringEnabled;
|
2017-11-28 11:51:44 +01:00
|
|
|
|
|
|
|
|
|
radioButtonGfs2.Enabled = labelGFS2.Enabled = gfs2Allowed;
|
2017-12-12 14:36:09 +01:00
|
|
|
|
|
|
|
|
|
if (!gfs2Allowed)
|
|
|
|
|
{
|
|
|
|
|
radioButtonLvm.Checked = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tableLayoutInfo.Visible = !gfs2Allowed;
|
2019-03-22 15:06:27 +01:00
|
|
|
|
labelInfo.Text = restrictGfs2
|
2017-11-28 11:51:44 +01:00
|
|
|
|
? Messages.GFS2_INCORRECT_POOL_LICENSE
|
|
|
|
|
: Messages.GFS2_REQUIRES_CLUSTERING_ENABLED;
|
2019-03-22 15:06:27 +01:00
|
|
|
|
linkLabelPoolProperties.Visible = !clusteringEnabled && !restrictGfs2;
|
|
|
|
|
|
|
|
|
|
RefreshWarnings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshWarnings()
|
|
|
|
|
{
|
|
|
|
|
if (radioButtonGfs2.Checked)
|
|
|
|
|
{
|
|
|
|
|
bool disabledMultipathExists = false;
|
|
|
|
|
|
|
|
|
|
foreach (Host host in Connection.Cache.Hosts)
|
|
|
|
|
{
|
|
|
|
|
if (!host.MultipathEnabled())
|
|
|
|
|
{
|
|
|
|
|
disabledMultipathExists = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tableLayoutWarning.Visible = disabledMultipathExists;
|
|
|
|
|
labelWarning.Text = Connection.Cache.Hosts.Length > 1
|
|
|
|
|
? Messages.CHOOSE_SR_PROVISIONING_PAGE_MULTIPATHING_MANY
|
|
|
|
|
: Messages.CHOOSE_SR_PROVISIONING_PAGE_MULTIPATHING_ONE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tableLayoutWarning.Visible = false;
|
|
|
|
|
}
|
2017-12-12 14:36:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-19 14:54:01 +01:00
|
|
|
|
protected override void PageLoadedCore(PageLoadedDirection direction)
|
2017-12-12 14:36:09 +01:00
|
|
|
|
{
|
|
|
|
|
RefreshPage();
|
2019-03-22 15:06:27 +01:00
|
|
|
|
|
|
|
|
|
foreach (var host in Connection.Cache.Hosts)
|
|
|
|
|
host.PropertyChanged += Host_PropertyChanged;
|
|
|
|
|
|
2017-12-12 14:36:09 +01:00
|
|
|
|
Connection.Cache.RegisterCollectionChanged<Cluster>(Cluster_CollectionChangedWithInvoke);
|
2019-03-22 15:06:27 +01:00
|
|
|
|
Connection.Cache.RegisterCollectionChanged<Host>(Host_CollectionChangedWithInvoke);
|
2017-12-12 14:36:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-19 14:54:01 +01:00
|
|
|
|
protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel)
|
2017-12-12 14:36:09 +01:00
|
|
|
|
{
|
2019-03-22 15:06:27 +01:00
|
|
|
|
foreach (var host in Connection.Cache.Hosts)
|
|
|
|
|
host.PropertyChanged -= Host_PropertyChanged;
|
|
|
|
|
|
2017-12-12 14:36:09 +01:00
|
|
|
|
Connection.Cache.DeregisterCollectionChanged<Cluster>(Cluster_CollectionChangedWithInvoke);
|
2019-03-22 15:06:27 +01:00
|
|
|
|
Connection.Cache.DeregisterCollectionChanged<Host>(Host_CollectionChangedWithInvoke);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Cluster_CollectionChanged(object sender, CollectionChangeEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Program.AssertOnEventThread();
|
|
|
|
|
RefreshPage();
|
2017-12-12 14:36:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-22 15:06:27 +01:00
|
|
|
|
private void Host_CollectionChangedWithInvoke(object sender, CollectionChangeEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Host host = e.Element as Host;
|
|
|
|
|
if (host == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (e.Action == CollectionChangeAction.Add)
|
|
|
|
|
host.PropertyChanged += Host_PropertyChanged;
|
|
|
|
|
else if (e.Action == CollectionChangeAction.Remove)
|
|
|
|
|
host.PropertyChanged -= Host_PropertyChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Host_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
switch (e.PropertyName)
|
|
|
|
|
{
|
|
|
|
|
case "multipathing":
|
|
|
|
|
RefreshWarnings();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-12-12 14:36:09 +01:00
|
|
|
|
private void linkLabelPoolProperties_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var pool = Helpers.GetPoolOfOne(Connection);
|
|
|
|
|
|
|
|
|
|
if (pool == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
using (PropertiesDialog propertiesDialog = new PropertiesDialog(pool))
|
|
|
|
|
{
|
|
|
|
|
propertiesDialog.SelectClusteringEditPage();
|
|
|
|
|
propertiesDialog.ShowDialog(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-22 15:06:27 +01:00
|
|
|
|
private void radioButtonGfs2_CheckedChanged(object sender, System.EventArgs e)
|
2017-12-12 14:36:09 +01:00
|
|
|
|
{
|
2019-03-22 15:06:27 +01:00
|
|
|
|
if (radioButtonGfs2.Checked)
|
|
|
|
|
RefreshWarnings();
|
|
|
|
|
}
|
2017-12-12 14:36:09 +01:00
|
|
|
|
|
2019-03-22 15:06:27 +01:00
|
|
|
|
private void radioButtonLvm_CheckedChanged(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (radioButtonLvm.Checked)
|
|
|
|
|
RefreshWarnings();
|
2017-11-28 11:51:44 +01:00
|
|
|
|
}
|
2017-11-23 11:59:15 +01:00
|
|
|
|
}
|
|
|
|
|
}
|