From 517b4cc45bd83222b832594023f0cc40d1c84bb5 Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Tue, 6 Dec 2016 11:27:53 +0000 Subject: [PATCH] CA-207011: Don't allow XC to create more than one SMB ISO SR on the same share This commit uses the same logic that is used for NFS ISOs. Signed-off-by: Gabor Apati-Nagy --- .../Frontends/CIFS_ISO.Designer.cs | 9 ++ .../NewSRWizard_Pages/Frontends/CIFS_ISO.cs | 18 +++- .../NewSRWizard_Pages/Frontends/CIFS_ISO.resx | 85 ++++++++++++++----- XenModel/Messages.Designer.cs | 9 ++ XenModel/Messages.resx | 3 + 5 files changed, 99 insertions(+), 25 deletions(-) diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFS_ISO.Designer.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFS_ISO.Designer.cs index 7b9f5c0a9..7a1ac6975 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFS_ISO.Designer.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFS_ISO.Designer.cs @@ -39,6 +39,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends this.labelCifsShareName = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.passwordFailure1 = new XenAdmin.Controls.Common.PasswordFailure(); this.comboBoxCifsSharename = new System.Windows.Forms.ComboBox(); this.groupBoxLogin.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); @@ -104,12 +105,19 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends // tableLayoutPanel1 // resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1"); + this.tableLayoutPanel1.Controls.Add(this.passwordFailure1, 1, 3); this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); this.tableLayoutPanel1.Controls.Add(this.labelCifsShareName, 0, 1); this.tableLayoutPanel1.Controls.Add(this.label22, 1, 2); this.tableLayoutPanel1.Controls.Add(this.comboBoxCifsSharename, 1, 1); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; // + // passwordFailure1 + // + resources.ApplyResources(this.passwordFailure1, "passwordFailure1"); + this.passwordFailure1.Name = "passwordFailure1"; + this.passwordFailure1.TabStop = false; + // // comboBoxCifsSharename // this.comboBoxCifsSharename.FormattingEnabled = true; @@ -148,5 +156,6 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends private System.Windows.Forms.Label label1; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.ComboBox comboBoxCifsSharename; + private Controls.Common.PasswordFailure passwordFailure1; } } diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFS_ISO.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFS_ISO.cs index 918e7d764..fd2c3c1d9 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFS_ISO.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFS_ISO.cs @@ -50,6 +50,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends private bool m_disasterRecoveryTask; private SR m_srToReattach; + private List my_srs = new List(); #endregion public CIFS_ISO() @@ -68,7 +69,8 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends public override bool EnableNext() { return SrWizardHelpers.ValidateCifsSharename(comboBoxCifsSharename.Text) - && !(checkBoxUseDifferentUsername.Checked && String.IsNullOrEmpty(textBoxCifsUsername.Text)); + && !(checkBoxUseDifferentUsername.Checked && String.IsNullOrEmpty(textBoxCifsUsername.Text)) + && !passwordFailure1.Visible; } public override bool EnablePrevious() @@ -81,7 +83,6 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends public override void PopulatePage() { - var my_srs = new List(); var add_srs = new List(); foreach (IXenConnection c in ConnectionsManager.XenConnectionsCopy) { @@ -165,9 +166,22 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends private void textBoxCifsSharename_TextChanged(object sender, EventArgs e) { + passwordFailure1.PerformCheck(IsSRNameUnique); + OnPageUpdated(); } + private bool IsSRNameUnique(out string error) + { + error = string.Empty; + if (my_srs.Contains(comboBoxCifsSharename.Text)) + { + error = string.Format(Messages.SMB_ISO_ALREADY_ATTACHED, Connection.FriendlyName); + return false; + } + return true; + } + private void checkBoxUseDifferentUsername_CheckedChanged(object sender, EventArgs e) { groupBoxLogin.Enabled = checkBoxUseDifferentUsername.Checked; diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFS_ISO.resx b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFS_ISO.resx index d9a3dbcf4..dbd0c5e29 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFS_ISO.resx +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFS_ISO.resx @@ -112,20 +112,20 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + True - + NoControl - + 17, 130 @@ -142,7 +142,7 @@ checkBoxUseDifferentUsername - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 $this @@ -175,7 +175,7 @@ labelCifsPassword - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 groupBoxLogin @@ -205,7 +205,7 @@ labelCifsUsername - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 groupBoxLogin @@ -229,7 +229,7 @@ textBoxCifsPassword - System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 groupBoxLogin @@ -253,7 +253,7 @@ textBoxCifsUsername - System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 groupBoxLogin @@ -313,13 +313,13 @@ label22 - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 - 2 + 3 Left @@ -352,13 +352,13 @@ labelCifsShareName - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 - 1 + 2 True @@ -372,6 +372,45 @@ 2 + + True + + + GrowAndShrink + + + Fill + + + This SMB ISO storage is already attached + + + 82, 102 + + + 0, 0, 0, 0 + + + 418, 20 + + + 5 + + + False + + + passwordFailure1 + + + XenAdmin.Controls.Common.PasswordFailure, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + + + tableLayoutPanel1 + + + 0 + 85, 59 @@ -385,13 +424,13 @@ comboBoxCifsSharename - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 - 3 + 4 Top @@ -403,10 +442,10 @@ 0, 0, 0, 0 - 3 + 4 - 500, 102 + 500, 122 0 @@ -415,7 +454,7 @@ tableLayoutPanel1 - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 $this @@ -424,7 +463,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="labelCifsShareName" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label22" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="comboBoxCifsSharename" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,100,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="passwordFailure1" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="labelCifsShareName" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label22" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="comboBoxCifsSharename" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,100,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20" /></TableLayoutSettings> Fill @@ -448,15 +487,15 @@ label1 - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 - 0 + 1 - + True diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 41f6319f8..2b77e6e57 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -30776,6 +30776,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to This SMB ISO storage is already attached to '{0}'. + /// + public static string SMB_ISO_ALREADY_ATTACHED { + get { + return ResourceManager.GetString("SMB_ISO_ALREADY_ATTACHED", resourceCulture); + } + } + /// /// Looks up a localized string similar to {0} (snapshot). /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 6644fb4fa..33bb1a69a 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -10698,6 +10698,9 @@ Do you want to connect to the pool master '{1}'? smaller than + + This SMB ISO storage is already attached to '{0}' + Snapshots