Merge pull request #343 from stephen-turner/CA-161460

CA-161460: XenCenter should fail gracefully if patch download fails
This commit is contained in:
Stephen Turner 2015-02-23 14:36:29 +00:00
commit f55a1fc892
7 changed files with 106 additions and 40 deletions

View File

@ -34,7 +34,7 @@
this.labelProgress = new System.Windows.Forms.Label();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.flickerFreeListBox1 = new XenAdmin.Controls.FlickerFreeListBox();
this.diskSpaceErrorLinkLabel = new System.Windows.Forms.LinkLabel();
this.errorLinkLabel = new System.Windows.Forms.LinkLabel();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
@ -45,7 +45,7 @@
this.tableLayoutPanel1.Controls.Add(this.labelProgress, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.progressBar1, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.flickerFreeListBox1, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.diskSpaceErrorLinkLabel, 1, 2);
this.tableLayoutPanel1.Controls.Add(this.errorLinkLabel, 1, 2);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
//
// label2
@ -74,12 +74,12 @@
this.flickerFreeListBox1.Name = "flickerFreeListBox1";
this.flickerFreeListBox1.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.flickerFreeListBox1_DrawItem);
//
// diskSpaceErrorLinkLabel
// errorLinkLabel
//
resources.ApplyResources(this.diskSpaceErrorLinkLabel, "diskSpaceErrorLinkLabel");
this.diskSpaceErrorLinkLabel.Name = "diskSpaceErrorLinkLabel";
this.diskSpaceErrorLinkLabel.TabStop = true;
this.diskSpaceErrorLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.diskspaceErrorLinkLabel_LinkClicked);
resources.ApplyResources(this.errorLinkLabel, "errorLinkLabel");
this.errorLinkLabel.Name = "errorLinkLabel";
this.errorLinkLabel.TabStop = true;
this.errorLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.errorLinkLabel_LinkClicked);
//
// PatchingWizard_UploadPage
//
@ -99,6 +99,6 @@
private System.Windows.Forms.Label labelProgress;
private System.Windows.Forms.ProgressBar progressBar1;
private Controls.FlickerFreeListBox flickerFreeListBox1;
private System.Windows.Forms.LinkLabel diskSpaceErrorLinkLabel;
private System.Windows.Forms.LinkLabel errorLinkLabel;
}
}

View File

@ -1,12 +1,12 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Linq;
using System.Windows.Forms;
using XenAdmin.Actions;
using XenAdmin.Controls;
using XenAdmin.Core;
using XenAdmin.Dialogs;
using XenAPI;
using XenAPI;
namespace XenAdmin.Wizards.PatchingWizard
{
@ -47,8 +47,14 @@ namespace XenAdmin.Wizards.PatchingWizard
public override void PageLoaded(PageLoadedDirection direction)
{
base.PageLoaded(direction);
canUpload = true;
canDownload = true;
UpdateButtons();
if (SelectedUpdateType == UpdateType.Existing)
_patch = SelectedExistingPatch;
if (direction == PageLoadedDirection.Forward)
{
PrepareUploadActions();
@ -134,7 +140,8 @@ namespace XenAdmin.Wizards.PatchingWizard
OnPageUpdated();
}
private bool canUpload = true;
private bool canUpload = true;
private bool canDownload = true;
private DiskSpaceRequirements diskSpaceRequirements;
private void TryUploading()
@ -218,14 +225,19 @@ namespace XenAdmin.Wizards.PatchingWizard
}
private void UpdateButtons()
{
{
if (!canUpload && diskSpaceRequirements != null)
{
diskSpaceErrorLinkLabel.Visible = true;
diskSpaceErrorLinkLabel.Text = diskSpaceRequirements.GetMessageForActionLink();
}
errorLinkLabel.Visible = true;
errorLinkLabel.Text = diskSpaceRequirements.GetMessageForActionLink();
}
else if (!canDownload)
{
errorLinkLabel.Visible = true;
errorLinkLabel.Text = Messages.PATCHINGWIZARD_MORE_INFO;
}
else
diskSpaceErrorLinkLabel.Visible = false;
errorLinkLabel.Visible = false;
}
private void UpdateActionProgress(AsyncAction action)
@ -318,11 +330,14 @@ namespace XenAdmin.Wizards.PatchingWizard
if (action == null)
return;
action.Completed -= multipleAction_Completed;
action.Completed -= multipleAction_Completed;
canDownload = !(action.Exception is PatchDownloadFailedException);
Program.Invoke(this, () =>
{
labelProgress.Text = GetActionDescription(action);
labelProgress.Text = GetActionDescription(action);
UpdateButtons();
});
}
@ -362,8 +377,16 @@ namespace XenAdmin.Wizards.PatchingWizard
return textColor;
}
private void diskspaceErrorLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
private void errorLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (!canDownload)
{
var msg = string.Format(Messages.PATCH_DOWNLOAD_FAILED_MORE_INFO, SelectedExistingPatch.name_label, SelectedExistingPatch.Connection.Name);
new ThreeButtonDialog(
new ThreeButtonDialog.Details(SystemIcons.Error, msg))
.ShowDialog(this);
}
if (diskSpaceRequirements == null)
return;

View File

@ -250,40 +250,40 @@ Please wait for this operation to complete, then click Next to continue with the
<data name="&gt;&gt;flickerFreeListBox1.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="diskSpaceErrorLinkLabel.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<data name="errorLinkLabel.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="diskSpaceErrorLinkLabel.Location" type="System.Drawing.Point, System.Drawing">
<data name="errorLinkLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>627, 354</value>
</data>
<data name="diskSpaceErrorLinkLabel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<data name="errorLinkLabel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
</data>
<data name="diskSpaceErrorLinkLabel.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<data name="errorLinkLabel.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>1, 1, 1, 1</value>
</data>
<data name="diskSpaceErrorLinkLabel.Size" type="System.Drawing.Size, System.Drawing">
<data name="errorLinkLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>70, 18</value>
</data>
<data name="diskSpaceErrorLinkLabel.TabIndex" type="System.Int32, mscorlib">
<data name="errorLinkLabel.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="diskSpaceErrorLinkLabel.Text" xml:space="preserve">
<data name="errorLinkLabel.Text" xml:space="preserve">
<value>&amp;More info...</value>
</data>
<data name="diskSpaceErrorLinkLabel.Visible" type="System.Boolean, mscorlib">
<data name="errorLinkLabel.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;diskSpaceErrorLinkLabel.Name" xml:space="preserve">
<value>diskSpaceErrorLinkLabel</value>
<data name="&gt;&gt;errorLinkLabel.Name" xml:space="preserve">
<value>errorLinkLabel</value>
</data>
<data name="&gt;&gt;diskSpaceErrorLinkLabel.Type" xml:space="preserve">
<data name="&gt;&gt;errorLinkLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;diskSpaceErrorLinkLabel.Parent" xml:space="preserve">
<data name="&gt;&gt;errorLinkLabel.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;diskSpaceErrorLinkLabel.ZOrder" xml:space="preserve">
<data name="&gt;&gt;errorLinkLabel.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="tableLayoutPanel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
@ -317,7 +317,7 @@ Please wait for this operation to complete, then click Next to continue with the
<value>0</value>
</data>
<data name="tableLayoutPanel1.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="label2" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="labelProgress" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="progressBar1" Row="3" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="flickerFreeListBox1" Row="1" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="diskSpaceErrorLinkLabel" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100,AutoSize,0" /&gt;&lt;Rows Styles="AutoSize,0,Percent,100,AutoSize,0,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="label2" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="labelProgress" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="progressBar1" Row="3" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="flickerFreeListBox1" Row="1" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="errorLinkLabel" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100,AutoSize,0" /&gt;&lt;Rows Styles="AutoSize,0,Percent,100,AutoSize,0,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>

View File

@ -2143,6 +2143,7 @@
</EmbeddedResource>
<EmbeddedResource Include="Wizards\PatchingWizard\PatchingWizard_UploadPage.resx">
<DependentUpon>PatchingWizard_UploadPage.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Wizards\PatchingWizard\PatchingWizard_UploadPage.zh-CN.resx">
<DependentUpon>PatchingWizard_UploadPage.cs</DependentUpon>

View File

@ -52,7 +52,7 @@ namespace XenAdmin.Actions
if (patch_ref != null)
return patch_ref;
Description = String.Format(Messages.DOWNLOADING_PATCH_FROM, patch.Connection.Hostname);
Description = String.Format(Messages.DOWNLOADING_PATCH_FROM, patch.Connection.Name);
// 1st download patch from the pool that has it (the connection on the xenobject)
@ -69,6 +69,10 @@ namespace XenAdmin.Actions
(HTTP_actions.get_sss)HTTP_actions.get_pool_patch_download,
Session.uuid, patch.uuid);
}
catch (Exception e)
{
throw new PatchDownloadFailedException(string.Format(Messages.PATCH_DOWNLOAD_FAILED, patch.name_label, patch.Connection.Name), e);
}
finally
{
Connection = null;
@ -169,4 +173,10 @@ namespace XenAdmin.Actions
}
public class PatchDownloadFailedException : ApplicationException
{
public PatchDownloadFailedException(string message, Exception innerException) :
base(message, innerException) { }
}
}

View File

@ -10806,7 +10806,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to Downloading Update from Server {0}....
/// Looks up a localized string similar to Downloading update from &apos;{0}&apos;....
/// </summary>
public static string DOWNLOADING_PATCH_FROM {
get {
@ -23974,7 +23974,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to You need to manually free up more space and try again..
/// Looks up a localized string similar to Free up some space and try again..
/// </summary>
public static string NOT_ENOUGH_SPACE_MESSAGE_NOCLEANUP {
get {
@ -24632,6 +24632,28 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Failed to download {0} from &apos;{1}&apos;.
/// </summary>
public static string PATCH_DOWNLOAD_FAILED {
get {
return ResourceManager.GetString("PATCH_DOWNLOAD_FAILED", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Failed to download the update {0} from &apos;{1}&apos;.
///
///The update is installed on &apos;{1}&apos;, but the update installation file may have since been deleted.
///
///Upload the update from an .xsupdate file instead..
/// </summary>
public static string PATCH_DOWNLOAD_FAILED_MORE_INFO {
get {
return ResourceManager.GetString("PATCH_DOWNLOAD_FAILED_MORE_INFO", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0}
///Date modified: {1}

16
XenModel/Messages.resx Normal file → Executable file
View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
@ -3806,7 +3806,7 @@ This will also delete its subfolders.</value>
<value>{0} is now available</value>
</data>
<data name="DOWNLOADING_PATCH_FROM" xml:space="preserve">
<value>Downloading Update from Server {0}...</value>
<value>Downloading update from '{0}'...</value>
</data>
<data name="DOWNLOAD_AND_EXTRACT_ACTION_DOWNLOADING_DESC" xml:space="preserve">
<value>Downloading {0}</value>
@ -8336,7 +8336,7 @@ It is strongly recommended that you Cancel and apply the latest version of the p
<value>There is not enough space on '{0}' to install update '{1}'.</value>
</data>
<data name="NOT_ENOUGH_SPACE_MESSAGE_NOCLEANUP" xml:space="preserve">
<value>You need to manually free up more space and try again.</value>
<value>Free up some space and try again.</value>
</data>
<data name="NOT_ENOUGH_SPACE_MESSAGE_REQUIRED_SPACE" xml:space="preserve">
<value>Space required: {0}</value>
@ -8728,6 +8728,16 @@ It is strongly recommended that you Cancel and apply the latest version of the p
<data name="PATCH_DESCRIPTION_AND_INSTALLATION_SIZE" xml:space="preserve">
<value>{0}
Installation size: {1}</value>
</data>
<data name="PATCH_DOWNLOAD_FAILED" xml:space="preserve">
<value>Failed to download {0} from '{1}'</value>
</data>
<data name="PATCH_DOWNLOAD_FAILED_MORE_INFO" xml:space="preserve">
<value>Failed to download the update {0} from '{1}'.
The update is installed on '{1}', but the update installation file may have since been deleted.
Upload the update from an .xsupdate file instead.</value>
</data>
<data name="PATCH_EXPANDED_DESCRIPTION" xml:space="preserve">
<value>{0}