diff --git a/XenAdmin/SettingsPanels/ClusteringEditPage.Designer.cs b/XenAdmin/SettingsPanels/ClusteringEditPage.Designer.cs index c773da352..ba8fbd54b 100644 --- a/XenAdmin/SettingsPanels/ClusteringEditPage.Designer.cs +++ b/XenAdmin/SettingsPanels/ClusteringEditPage.Designer.cs @@ -30,20 +30,25 @@ { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ClusteringEditPage)); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.labelTitle = new XenAdmin.Controls.Common.AutoHeightLabel(); this.CheckBoxEnableClustering = new System.Windows.Forms.CheckBox(); this.labelNetwork = new System.Windows.Forms.Label(); + this.comboBoxNetwork = new XenAdmin.Controls.NetworkComboBox(); this.tableLayoutInfo = new System.Windows.Forms.TableLayoutPanel(); + this.pictureBoxInfo2 = new System.Windows.Forms.PictureBox(); this.pictureBoxInfo1 = new System.Windows.Forms.PictureBox(); this.labelWarning = new System.Windows.Forms.Label(); this.labelInfo = new System.Windows.Forms.Label(); this.labelHostCountWarning = new System.Windows.Forms.Label(); - this.pictureBoxInfo2 = new System.Windows.Forms.PictureBox(); - this.labelTitle = new XenAdmin.Controls.Common.AutoHeightLabel(); - this.comboBoxNetwork = new XenAdmin.Controls.NetworkComboBox(); + this.tableLayoutPanelNetworkWarning = new System.Windows.Forms.TableLayoutPanel(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.labelInconsistentNetwork = new System.Windows.Forms.Label(); this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutInfo.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxInfo1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxInfo2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxInfo1)).BeginInit(); + this.tableLayoutPanelNetworkWarning.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // tableLayoutPanel1 @@ -53,9 +58,16 @@ this.tableLayoutPanel1.Controls.Add(this.CheckBoxEnableClustering, 0, 1); this.tableLayoutPanel1.Controls.Add(this.labelNetwork, 0, 2); this.tableLayoutPanel1.Controls.Add(this.comboBoxNetwork, 1, 2); - this.tableLayoutPanel1.Controls.Add(this.tableLayoutInfo, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.tableLayoutInfo, 0, 4); + this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanelNetworkWarning, 1, 3); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; // + // labelTitle + // + resources.ApplyResources(this.labelTitle, "labelTitle"); + this.tableLayoutPanel1.SetColumnSpan(this.labelTitle, 2); + this.labelTitle.Name = "labelTitle"; + // // CheckBoxEnableClustering // resources.ApplyResources(this.CheckBoxEnableClustering, "CheckBoxEnableClustering"); @@ -68,17 +80,35 @@ resources.ApplyResources(this.labelNetwork, "labelNetwork"); this.labelNetwork.Name = "labelNetwork"; // + // comboBoxNetwork + // + this.comboBoxNetwork.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxNetwork.FormattingEnabled = true; + this.comboBoxNetwork.IncludeOnlyEnabledNetworksInComboBox = false; + this.comboBoxNetwork.IncludeOnlyNetworksWithIPAddresses = false; + this.comboBoxNetwork.IncludePoolNameInComboBox = false; + resources.ApplyResources(this.comboBoxNetwork, "comboBoxNetwork"); + this.comboBoxNetwork.Name = "comboBoxNetwork"; + this.comboBoxNetwork.SelectedIndexChanged += new System.EventHandler(this.comboBoxNetwork_SelectedIndexChanged); + // // tableLayoutInfo // resources.ApplyResources(this.tableLayoutInfo, "tableLayoutInfo"); this.tableLayoutPanel1.SetColumnSpan(this.tableLayoutInfo, 2); - this.tableLayoutInfo.Controls.Add(this.pictureBoxInfo2, 0, 2); + this.tableLayoutInfo.Controls.Add(this.pictureBoxInfo2, 0, 1); this.tableLayoutInfo.Controls.Add(this.pictureBoxInfo1, 0, 0); this.tableLayoutInfo.Controls.Add(this.labelWarning, 1, 0); - this.tableLayoutInfo.Controls.Add(this.labelInfo, 1, 2); - this.tableLayoutInfo.Controls.Add(this.labelHostCountWarning, 1, 3); + this.tableLayoutInfo.Controls.Add(this.labelInfo, 1, 1); + this.tableLayoutInfo.Controls.Add(this.labelHostCountWarning, 1, 2); this.tableLayoutInfo.Name = "tableLayoutInfo"; // + // pictureBoxInfo2 + // + resources.ApplyResources(this.pictureBoxInfo2, "pictureBoxInfo2"); + this.pictureBoxInfo2.Image = global::XenAdmin.Properties.Resources._000_Info3_h32bit_16; + this.pictureBoxInfo2.Name = "pictureBoxInfo2"; + this.pictureBoxInfo2.TabStop = false; + // // pictureBoxInfo1 // resources.ApplyResources(this.pictureBoxInfo1, "pictureBoxInfo1"); @@ -101,28 +131,24 @@ resources.ApplyResources(this.labelHostCountWarning, "labelHostCountWarning"); this.labelHostCountWarning.Name = "labelHostCountWarning"; // - // pictureBoxInfo2 + // tableLayoutPanelNetworkWarning // - resources.ApplyResources(this.pictureBoxInfo2, "pictureBoxInfo2"); - this.pictureBoxInfo2.Image = global::XenAdmin.Properties.Resources._000_Info3_h32bit_16; - this.pictureBoxInfo2.Name = "pictureBoxInfo2"; - this.pictureBoxInfo2.TabStop = false; + resources.ApplyResources(this.tableLayoutPanelNetworkWarning, "tableLayoutPanelNetworkWarning"); + this.tableLayoutPanelNetworkWarning.Controls.Add(this.pictureBox1, 0, 0); + this.tableLayoutPanelNetworkWarning.Controls.Add(this.labelInconsistentNetwork, 1, 0); + this.tableLayoutPanelNetworkWarning.Name = "tableLayoutPanelNetworkWarning"; // - // labelTitle + // pictureBox1 // - resources.ApplyResources(this.labelTitle, "labelTitle"); - this.tableLayoutPanel1.SetColumnSpan(this.labelTitle, 2); - this.labelTitle.Name = "labelTitle"; + this.pictureBox1.Image = global::XenAdmin.Properties.Resources._000_Alert2_h32bit_16; + resources.ApplyResources(this.pictureBox1, "pictureBox1"); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.TabStop = false; // - // comboBoxNetwork + // labelInconsistentNetwork // - this.comboBoxNetwork.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxNetwork.FormattingEnabled = true; - this.comboBoxNetwork.IncludeOnlyEnabledNetworksInComboBox = false; - this.comboBoxNetwork.IncludeOnlyNetworksWithIPAddresses = false; - this.comboBoxNetwork.IncludePoolNameInComboBox = false; - resources.ApplyResources(this.comboBoxNetwork, "comboBoxNetwork"); - this.comboBoxNetwork.Name = "comboBoxNetwork"; + resources.ApplyResources(this.labelInconsistentNetwork, "labelInconsistentNetwork"); + this.labelInconsistentNetwork.Name = "labelInconsistentNetwork"; // // ClusteringEditPage // @@ -134,8 +160,11 @@ this.tableLayoutPanel1.PerformLayout(); this.tableLayoutInfo.ResumeLayout(false); this.tableLayoutInfo.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxInfo1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxInfo2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxInfo1)).EndInit(); + this.tableLayoutPanelNetworkWarning.ResumeLayout(false); + this.tableLayoutPanelNetworkWarning.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); } @@ -153,6 +182,9 @@ private System.Windows.Forms.Label labelInfo; private System.Windows.Forms.Label labelHostCountWarning; private System.Windows.Forms.PictureBox pictureBoxInfo2; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanelNetworkWarning; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.Label labelInconsistentNetwork; } } diff --git a/XenAdmin/SettingsPanels/ClusteringEditPage.cs b/XenAdmin/SettingsPanels/ClusteringEditPage.cs index 8813653a1..e51f1ddae 100644 --- a/XenAdmin/SettingsPanels/ClusteringEditPage.cs +++ b/XenAdmin/SettingsPanels/ClusteringEditPage.cs @@ -29,11 +29,10 @@ * SUCH DAMAGE. */ -using System.Collections.Generic; +using System; using System.Drawing; using System.Linq; using System.Windows.Forms; -using System.Windows.Forms.VisualStyles; using XenAdmin.Actions; using XenAdmin.Controls; using XenAdmin.Core; @@ -45,11 +44,20 @@ namespace XenAdmin.SettingsPanels { private Pool pool; private bool clusteringEnabled; + private XenRef commonNetwork; + private readonly ToolTip SelectNetworkToolTip; public ClusteringEditPage() { InitializeComponent(); Text = Messages.CLUSTERING; + tableLayoutPanelNetworkWarning.Visible = false; + SelectNetworkToolTip = new ToolTip + { + IsBalloon = true, + ToolTipIcon = ToolTipIcon.Warning, + ToolTipTitle = Messages.MUST_SELECT_NETWORK + }; } public string SubText @@ -82,39 +90,27 @@ namespace XenAdmin.SettingsPanels public void SetXenObjects(IXenObject orig, IXenObject clone) { pool = Helpers.GetPoolOfOne(clone.Connection); - labelWarning.Visible = false; - pictureBoxInfo1.Visible = false; - var existingCluster = pool.Connection.Cache.Clusters.FirstOrDefault(); clusteringEnabled = existingCluster != null; - CheckBoxEnableClustering.Checked = clusteringEnabled; + labelWarning.Visible = pictureBoxInfo1.Visible = false; LoadNetworks(existingCluster); - - if (clusteringEnabled) - { - comboBoxNetwork.Enabled = labelNetwork.Enabled = false; - } - - var gfs2Attached = clone.Connection.Cache.SRs.Any(sr => sr.GetSRType(true) == SR.SRTypes.gfs2 && !sr.IsDetached()); - - if (clusteringEnabled && gfs2Attached) - { - DisableControls(Messages.GFS2_SR_ATTACHED); - } - - if (!clusteringEnabled && pool.ha_enabled) - { - DisableControls(Messages.GFS2_HA_ENABLED); - } - - labelHostCountWarning.Visible = clone.Connection.Cache.HostCount < 3; + SetPage(); } - public bool ValidToSave { get { return true; }} + public bool ValidToSave + { + get + { + return clusteringEnabled || comboBoxNetwork.SelectedItem != null || !CheckBoxEnableClustering.Checked; + } + } public void ShowLocalValidationMessages() { - + if (!ValidToSave) + { + HelpersGUI.ShowBalloonMessage(comboBoxNetwork, SelectNetworkToolTip); + } } public void Cleanup() @@ -135,17 +131,58 @@ namespace XenAdmin.SettingsPanels { comboBoxNetwork.IncludeOnlyEnabledNetworksInComboBox = false; comboBoxNetwork.IncludeOnlyNetworksWithIPAddresses = true; - var clusterHostOnMaster = cluster == null - ? null - : pool.Connection.ResolveAll(cluster.cluster_hosts).FirstOrDefault(c => c.host.opaque_ref == pool.master.opaque_ref); - - comboBoxNetwork.PopulateComboBox(pool.Connection, item => clusterHostOnMaster != null && item.Network.PIFs.Any(pif => pif.opaque_ref == clusterHostOnMaster.PIF.opaque_ref)); - if (comboBoxNetwork.Items.Count == 0) + if (cluster == null) { - DisableControls(Messages.GFS2_NO_NETWORK); + comboBoxNetwork.PopulateComboBox(pool.Connection, item => false); + if (comboBoxNetwork.Items.Count == 0) + DisableControls(Messages.GFS2_NO_NETWORK); } + else + { + DelegatedAsyncAction action = new DelegatedAsyncAction(pool.Connection, + string.Empty, string.Empty, string.Empty, + delegate(Session session) + { + commonNetwork = Cluster.get_network(session, cluster.opaque_ref); + }, + true); + action.Completed += action_Completed; + + action.RunAsync(); + } + } + + private void action_Completed(ActionBase sender) + { + var action = (AsyncAction) sender; + if (!action.Succeeded) + commonNetwork = null; + + Program.Invoke(ParentForm, delegate + { + comboBoxNetwork.PopulateComboBox(pool.Connection, item => commonNetwork != null && item.Network.opaque_ref.Equals(commonNetwork.opaque_ref)); + tableLayoutPanelNetworkWarning.Visible = commonNetwork == null || comboBoxNetwork.SelectedItem == null; + }); + } + + private void SetPage() + { + CheckBoxEnableClustering.Checked = clusteringEnabled; + + if (clusteringEnabled) + { + var gfs2Attached = pool.Connection.Cache.SRs.Any(sr => sr.GetSRType(true) == SR.SRTypes.gfs2 && !sr.IsDetached()); + if (gfs2Attached) + DisableControls(Messages.GFS2_SR_ATTACHED); + else + comboBoxNetwork.Enabled = labelNetwork.Enabled = false; + } + else if (pool.ha_enabled) + DisableControls(Messages.GFS2_HA_ENABLED); + + labelHostCountWarning.Visible = pool.Connection.Cache.HostCount < 3; } private void DisableControls(string message) @@ -156,5 +193,11 @@ namespace XenAdmin.SettingsPanels } #endregion + + private void comboBoxNetwork_SelectedIndexChanged(object sender, System.EventArgs e) + { + if (!clusteringEnabled) + CheckBoxEnableClustering.Checked = comboBoxNetwork.SelectedItem != null; + } } } diff --git a/XenAdmin/SettingsPanels/ClusteringEditPage.resx b/XenAdmin/SettingsPanels/ClusteringEditPage.resx index 8543f760d..23c86929f 100644 --- a/XenAdmin/SettingsPanels/ClusteringEditPage.resx +++ b/XenAdmin/SettingsPanels/ClusteringEditPage.resx @@ -166,10 +166,7 @@ NoControl - 7, 75 - - - 7, 3, 3, 3 + 3, 75 107, 17 @@ -202,10 +199,10 @@ NoControl - 22, 102 + 20, 102 - 22, 0, 3, 0 + 20, 3, 3, 3 50, 13 @@ -229,7 +226,7 @@ 2 - 78, 98 + 76, 98 223, 21 @@ -249,6 +246,9 @@ 3 + + True + 2 @@ -259,17 +259,11 @@ NoControl - 3, 51 - - - 3, 6, 3, 0 + 3, 42 16, 16 - - AutoSize - 8 @@ -292,20 +286,20 @@ NoControl - 3, 6 + 3, 3 - 3, 6, 3, 3 + 3, 3, 3, 20 16, 16 - - AutoSize - 4 + + False + pictureBoxInfo1 @@ -328,13 +322,13 @@ NoControl - 22, 6 + 25, 3 - 0, 6, 3, 0 + 3, 3, 3, 20 - 459, 19 + 456, 16 5 @@ -364,13 +358,13 @@ NoControl - 22, 51 + 25, 42 - 0, 6, 3, 0 + 3, 3, 3, 3 - 459, 26 + 456, 26 6 @@ -393,20 +387,17 @@ True - - Fill - NoControl - 22, 83 + 25, 74 - 0, 6, 3, 0 + 3, 3, 3, 3 - 459, 107 + 307, 13 7 @@ -430,13 +421,13 @@ Fill - 3, 125 + 3, 175 - 4 + 3 - 484, 190 + 484, 140 6 @@ -454,7 +445,106 @@ 4 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="pictureBoxInfo2" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="pictureBoxInfo1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelWarning" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="labelInfo" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="labelHostCountWarning" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,Absolute,20,AutoSize,0,Percent,100" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="pictureBoxInfo2" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="pictureBoxInfo1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelWarning" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="labelInfo" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="labelHostCountWarning" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,Percent,100,Absolute,20,Absolute,20,Absolute,20,Absolute,20" /></TableLayoutSettings> + + + True + + + GrowAndShrink + + + 2 + + + NoControl + + + 3, 3 + + + 16, 16 + + + 0 + + + pictureBox1 + + + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanelNetworkWarning + + + 0 + + + True + + + Fill + + + NoControl + + + 25, 3 + + + 3, 3, 3, 3 + + + 383, 38 + + + 1 + + + Inconsistent cluster network. This is normal during creation or deletion of bond. + + + labelInconsistentNetwork + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanelNetworkWarning + + + 1 + + + Fill + + + 76, 125 + + + 1 + + + 411, 44 + + + 7 + + + tableLayoutPanelNetworkWarning + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 5 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="pictureBox1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelInconsistentNetwork" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0" /></TableLayoutSettings> Fill @@ -463,7 +553,7 @@ 0, 0 - 4 + 5 490, 318 @@ -484,7 +574,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelTitle" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="CheckBoxEnableClustering" Row="1" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="labelNetwork" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="comboBoxNetwork" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="tableLayoutInfo" Row="3" RowSpan="1" Column="0" ColumnSpan="2" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,Percent,100" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelTitle" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="CheckBoxEnableClustering" Row="1" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="labelNetwork" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="comboBoxNetwork" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="tableLayoutInfo" Row="4" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="tableLayoutPanelNetworkWarning" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,Absolute,50,Percent,100" /></TableLayoutSettings> True