CA-272770: Check whether the selected ISO SR supports VDI creation before copying the Fixup ISO on it.

Also, minor layout correction, and usability enhancement: do not disable
the controls under the radio button when the latter is deselected.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2019-09-06 15:31:37 +01:00
parent 61f6f89c25
commit d52008aaf9
5 changed files with 73 additions and 57 deletions

View File

@ -110,8 +110,8 @@
//
this.tableLayoutPanel2.SetColumnSpan(this.m_comboBoxISOLibraries, 2);
this.m_comboBoxISOLibraries.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
resources.ApplyResources(this.m_comboBoxISOLibraries, "m_comboBoxISOLibraries");
this.m_comboBoxISOLibraries.FormattingEnabled = true;
resources.ApplyResources(this.m_comboBoxISOLibraries, "m_comboBoxISOLibraries");
this.m_comboBoxISOLibraries.Name = "m_comboBoxISOLibraries";
this.m_comboBoxISOLibraries.SelectedIndexChanged += new System.EventHandler(this.m_comboBoxISOLibraries_SelectedIndexChanged);
//

View File

@ -117,10 +117,13 @@ namespace XenAdmin.Wizards.ImportWizard
/// Performs certain checks on the pages's input data and shows/hides an error accordingly
/// </summary>
/// <param name="checks">The checks to perform</param>
private void PerformCheck(params CheckDelegate[] checks)
private bool PerformCheck(params CheckDelegate[] checks)
{
m_buttonNextEnabled = m_ctrlError.PerformCheck(checks);
var success = m_ctrlError.PerformCheck(checks);
m_buttonNextEnabled = success;
m_pictureBoxInfo.Visible = m_labelFixupISOInfo.Visible = success;
OnPageUpdated();
return success;
}
private bool IsIsoSrSelectable(SR sr)
@ -209,6 +212,21 @@ namespace XenAdmin.Wizards.ImportWizard
return false;
}
private bool CheckCanCreateVdiOnIsoSr(out string error)
{
error = string.Empty;
SM sm = null;
if (SelectedIsoSR != null)
sm = SM.GetByType(Connection, SelectedIsoSR.type);
if (sm != null && sm.capabilities.Contains("VDI_CREATE"))
return true;
error = Messages.IMPORT_OPTIONS_PAGE_CANNOT_USE_SELECTED_ISO_LIBRARY;
return false;
}
private void PBD_CollectionChanged(object sender, CollectionChangeEventArgs e)
{
if (!(e.Element is PBD pbd))
@ -324,20 +342,26 @@ namespace XenAdmin.Wizards.ImportWizard
private void ValidateSelection()
{
SelectedIsoSR = m_comboBoxISOLibraries.SelectedItem is ToStringWrapper<SR> wrapper ? wrapper.item : null;
if (SelectedIsoSR == null)
if (m_radioButtonDontRunOSFixups.Checked)
{
m_pictureBoxInfo.Visible = m_labelFixupISOInfo.Visible = false;
m_buttonNextEnabled = false;
m_buttonNextEnabled = true;
m_pictureBoxInfo.Visible = m_labelFixupISOInfo.Visible = m_ctrlError.Visible = false;
OnPageUpdated();
return;
}
PerformCheck(CheckFixupIsoInXencenterInstallation);
SelectedIsoSR = m_radioButtonRunOSFixups.Checked && m_comboBoxISOLibraries.SelectedItem is ToStringWrapper<SR> wrapper
? wrapper.item
: null;
m_pictureBoxInfo.Visible = m_labelFixupISOInfo.Visible = !m_ctrlError.Visible;
if (m_ctrlError.Visible)
if (!PerformCheck((out string error) =>
{
error = null;
return SelectedIsoSR != null;
}))
return;
if (!PerformCheck(CheckFixupIsoInXencenterInstallation))
return;
var isoName = OVF.GetISOFixupFileName();
@ -352,6 +376,9 @@ namespace XenAdmin.Wizards.ImportWizard
}
}
if (!PerformCheck(CheckCanCreateVdiOnIsoSr))
return;
m_labelFixupISOInfo.Text = Messages.IMPORT_OPTIONS_PAGE_USE_SELECTED_ISO_LIBRARY;
}
@ -361,6 +388,9 @@ namespace XenAdmin.Wizards.ImportWizard
private void m_comboBoxISOLibraries_SelectedIndexChanged(object sender, EventArgs e)
{
if (!m_radioButtonRunOSFixups.Checked)
m_radioButtonRunOSFixups.Checked = true;
ValidateSelection();
if (IsNewISOLibraryItem())
@ -374,24 +404,13 @@ namespace XenAdmin.Wizards.ImportWizard
private void m_radioButtonRunOSFixups_CheckedChanged(object sender, EventArgs e)
{
if (m_radioButtonRunOSFixups.Checked)
{
m_labelLocationFixupISO.Enabled = true;
m_comboBoxISOLibraries.Enabled = true;
ValidateSelection();
}
}
private void m_radioButtonDontRunOSFixups_CheckedChanged(object sender, EventArgs e)
{
if (m_radioButtonDontRunOSFixups.Checked)
{
m_labelLocationFixupISO.Enabled = false;
m_comboBoxISOLibraries.Enabled = false;
m_pictureBoxInfo.Visible = false;
m_labelFixupISOInfo.Visible = false;
m_buttonNextEnabled = true;
OnPageUpdated();
}
ValidateSelection();
}
#endregion

View File

@ -112,16 +112,16 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="m_ctrlError.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="m_ctrlError.AutoSizeMode" type="System.Windows.Forms.AutoSizeMode, System.Windows.Forms">
<value>GrowAndShrink</value>
</data>
@ -140,7 +140,7 @@
<data name="m_labelIntro.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="m_labelIntro.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 0</value>
</data>
@ -192,7 +192,7 @@ Operating System Fixup is supplied as a bootable ISO image which is attached to
<value>m_radioButtonDontRunOSFixups</value>
</data>
<data name="&gt;&gt;m_radioButtonDontRunOSFixups.Type" xml:space="preserve">
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;m_radioButtonDontRunOSFixups.Parent" xml:space="preserve">
<value>tableLayoutPanel2</value>
@ -258,7 +258,7 @@ Operating System Fixup is supplied as a bootable ISO image which is attached to
<value>m_radioButtonRunOSFixups</value>
</data>
<data name="&gt;&gt;m_radioButtonRunOSFixups.Type" xml:space="preserve">
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;m_radioButtonRunOSFixups.Parent" xml:space="preserve">
<value>tableLayoutPanel2</value>
@ -308,23 +308,14 @@ Operating System Fixup is supplied as a bootable ISO image which is attached to
<data name="m_labelLocationFixupISO.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="m_labelLocationFixupISO.Enabled" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="m_labelLocationFixupISO.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="m_labelLocationFixupISO.Location" type="System.Drawing.Point, System.Drawing">
<value>23, 193</value>
</data>
<data name="m_labelLocationFixupISO.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
</data>
<data name="m_labelLocationFixupISO.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 3, 0, 3</value>
<value>23, 196</value>
</data>
<data name="m_labelLocationFixupISO.Size" type="System.Drawing.Size, System.Drawing">
<value>130, 19</value>
<value>130, 13</value>
</data>
<data name="m_labelLocationFixupISO.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
@ -339,7 +330,7 @@ Operating System Fixup is supplied as a bootable ISO image which is attached to
<value>m_labelLocationFixupISO</value>
</data>
<data name="&gt;&gt;m_labelLocationFixupISO.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;m_labelLocationFixupISO.Parent" xml:space="preserve">
<value>tableLayoutPanel2</value>
@ -347,9 +338,6 @@ Operating System Fixup is supplied as a bootable ISO image which is attached to
<data name="&gt;&gt;m_labelLocationFixupISO.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="m_comboBoxISOLibraries.Enabled" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="m_comboBoxISOLibraries.Location" type="System.Drawing.Point, System.Drawing">
<value>159, 192</value>
</data>
@ -387,7 +375,7 @@ Operating System Fixup is supplied as a bootable ISO image which is attached to
<value>m_pictureBoxInfo</value>
</data>
<data name="&gt;&gt;m_pictureBoxInfo.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;m_pictureBoxInfo.Parent" xml:space="preserve">
<value>tableLayoutPanel2</value>
@ -395,23 +383,20 @@ Operating System Fixup is supplied as a bootable ISO image which is attached to
<data name="&gt;&gt;m_pictureBoxInfo.ZOrder" xml:space="preserve">
<value>7</value>
</data>
<data name="m_labelFixupISOInfo.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left, Right</value>
</data>
<data name="m_labelFixupISOInfo.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="m_labelFixupISOInfo.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="m_labelFixupISOInfo.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="m_labelFixupISOInfo.Location" type="System.Drawing.Point, System.Drawing">
<value>181, 219</value>
</data>
<data name="m_labelFixupISOInfo.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
<value>181, 220</value>
</data>
<data name="m_labelFixupISOInfo.Size" type="System.Drawing.Size, System.Drawing">
<value>409, 16</value>
<value>409, 13</value>
</data>
<data name="m_labelFixupISOInfo.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
@ -453,7 +438,7 @@ Operating System Fixup is supplied as a bootable ISO image which is attached to
<value>tableLayoutPanel2</value>
</data>
<data name="&gt;&gt;tableLayoutPanel2.Type" xml:space="preserve">
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;tableLayoutPanel2.Parent" xml:space="preserve">
<value>$this</value>
@ -497,7 +482,7 @@ Operating System Fixup is supplied as a bootable ISO image which is attached to
<data name="&gt;&gt;m_ctrlError.ZOrder" xml:space="preserve">
<value>9</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">

View File

@ -18932,6 +18932,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to The Fixup ISO cannot be copied to the selected SR.
/// </summary>
public static string IMPORT_OPTIONS_PAGE_CANNOT_USE_SELECTED_ISO_LIBRARY {
get {
return ResourceManager.GetString("IMPORT_OPTIONS_PAGE_CANNOT_USE_SELECTED_ISO_LIBRARY", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [Choose an ISO SR].
/// </summary>

View File

@ -6674,6 +6674,9 @@ This might result in failure to migrate VMs to this server during the RPU or to
<data name="IMPORT_OPTIONS_PAGE_USE_SELECTED_ISO_LIBRARY" xml:space="preserve">
<value>The Fixup ISO will be automatically copied to the selected SR</value>
</data>
<data name="IMPORT_OPTIONS_PAGE_CANNOT_USE_SELECTED_ISO_LIBRARY" xml:space="preserve">
<value>The Fixup ISO cannot be copied to the selected SR</value>
</data>
<data name="IMPORT_SECURITY_PAGE_ERROR_MISSING_CERTIFICATE" xml:space="preserve">
<value>Could not find the appliance certificate. The file is missing.</value>
</data>