Merge pull request #327 from GaborApatiNagy/CP-10798

CP-10798: XenCenter work for CAR-1711: Pre-Checks for hotfix installatio...
This commit is contained in:
Mihaela Stoica 2015-02-12 14:04:44 +00:00
commit 0e8fbfceca
8 changed files with 220 additions and 21 deletions

View File

@ -37,6 +37,7 @@ using System.IO;
using XenAdmin.Diagnostics.Problems.HostProblem;
using System.Text.RegularExpressions;
using System.Xml;
using System.Collections.Generic;
namespace XenAdmin.Diagnostics.Checks
@ -132,6 +133,44 @@ namespace XenAdmin.Diagnostics.Checks
}
}
break;
case "PATCH_PRECHECK_FAILED_OUT_OF_SPACE":
long required = 0;
long found = 0;
foreach (XmlNode node in errorNode.ChildNodes)
{
if (node.Name == "found")
{
long.TryParse(node.InnerText, out found);
}
if (node.Name == "required")
{
long.TryParse(node.InnerText, out required);
}
}
// get reclaimable disk space (excluding current patch)
long reclaimableDiskSpace = 0;
try
{
var args = new Dictionary<string, string>();
if (Patch != null)
args.Add("exclude", Patch.uuid);
var resultReclaimable = Host.call_plugin(host.Connection.Session, host.opaque_ref, "disk-space", "get_reclaimable_disk_space", args);
reclaimableDiskSpace = Convert.ToInt64(resultReclaimable);
}
catch (Failure failure)
{
log.WarnFormat("Plugin call disk-space.get_reclaimable_disk_space on {0} failed with {1}", Host.Name, failure.Message);
}
var operation = XenAdmin.Actions.DiskSpaceRequirements.OperationTypes.install;
var diskSpaceReq = new XenAdmin.Actions.DiskSpaceRequirements(operation, host, Patch.Name, required, found, reclaimableDiskSpace);
return new HostOutOfSpaceProblem(this, host, Patch, diskSpaceReq);
break;
case "":
return null;
default:

View File

@ -0,0 +1,115 @@
/* Copyright (c) Citrix Systems Inc.
* All rights reserved.
*
* 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.
*/
using System.Windows.Forms;
using XenAdmin.Commands;
using XenAdmin.Diagnostics.Checks;
using XenAPI;
using XenAdmin.Dialogs.VMDialogs;
using XenAdmin.Actions;
using XenAdmin.Actions.VMActions;
using System.Collections.Generic;
using XenAdmin.Dialogs;
using System.Drawing;
using System;
namespace XenAdmin.Diagnostics.Problems.HostProblem
{
public class HostOutOfSpaceProblem : HostProblem
{
private readonly DiskSpaceRequirements diskSpaceReq;
private readonly Pool_patch patch;
public HostOutOfSpaceProblem(Check check, Host host, Pool_patch patch, DiskSpaceRequirements diskSpaceReq)
: base(check, host)
{
this.patch = patch;
this.diskSpaceReq = diskSpaceReq;
}
public override string Description
{
get { return string.Format(Messages.NOT_ENOUGH_SPACE_MESSAGE_INSTALL, Server.Name, patch.Name); }
}
protected override AsyncAction CreateAction(out bool cancelled)
{
AsyncAction action = null;
if (diskSpaceReq.CanCleanup)
{
Program.Invoke(Program.MainWindow, delegate()
{
DialogResult r = new ThreeButtonDialog(
new ThreeButtonDialog.Details(
SystemIcons.Warning,
diskSpaceReq.GetSpaceRequirementsMessage()),
new ThreeButtonDialog.TBDButton(Messages.YES, DialogResult.Yes, ThreeButtonDialog.ButtonType.ACCEPT, true),
ThreeButtonDialog.ButtonNo
).ShowDialog(Program.MainWindow);
if (r == DialogResult.Yes)
{
action = new CleanupDiskSpaceAction(this.Server, patch, true);
}
});
}
else
{
Program.Invoke(Program.MainWindow, delegate()
{
new ThreeButtonDialog(
new ThreeButtonDialog.Details(SystemIcons.Warning, diskSpaceReq.GetSpaceRequirementsMessage()))
.ShowDialog();
});
}
cancelled = action == null;
return action;
}
public override string HelpMessage
{
get { return diskSpaceReq.GetMessageForActionLink(); }
}
public override bool IsFixable
{
get
{
return false;
}
}
}
}

View File

@ -222,7 +222,7 @@ namespace XenAdmin.Wizards.PatchingWizard
if (!canUpload && diskSpaceRequirements != null)
{
diskSpaceErrorLinkLabel.Visible = true;
diskSpaceErrorLinkLabel.Text = diskSpaceRequirements.CanCleanup ? Messages.PATCHINGWIZARD_CLEANUP : Messages.PATCHINGWIZARD_MORE_INFO;
diskSpaceErrorLinkLabel.Text = diskSpaceRequirements.GetMessageForActionLink();
}
else
diskSpaceErrorLinkLabel.Visible = false;

View File

@ -194,6 +194,7 @@
<Compile Include="Diagnostics\Checks\AssertCanEvacuateCheck.cs" />
<Compile Include="Diagnostics\Checks\AssertCanEvacuateUpgradeCheck.cs" />
<Compile Include="Diagnostics\Checks\HostHasUnsupportedStorageLinkSRCheck.cs" />
<Compile Include="Diagnostics\Problems\HostProblem\HostOutOfSpaceProblem.cs" />
<Compile Include="Diagnostics\Problems\ProblemWithInformationUrl.cs" />
<Compile Include="Diagnostics\Problems\SRProblem\UnsupportedStorageLinkSrIsPresentProblem.cs" />
<Compile Include="Diagnostics\Problems\VMProblem\InvalidVCPUConfiguration.cs" />

View File

@ -147,7 +147,7 @@ namespace XenAdmin.Actions
public override string Message
{
get { return String.Format(Messages.NOT_ENOUGH_SPACE_MESSAGE, host, fileName); }
get { return String.Format(Messages.NOT_ENOUGH_SPACE_MESSAGE_UPLOAD, host, fileName); }
}
}
}

View File

@ -123,7 +123,9 @@ namespace XenAdmin.Actions
log.WarnFormat("Plugin call disk-space.get_reclaimable_disk_space on {0} failed with {1}", Host.Name, failure.Message);
}
DiskSpaceRequirements = new DiskSpaceRequirements(Host, updateName, requiredDiskSpace, availableDiskSpace, reclaimableDiskSpace);
var operation = Actions.DiskSpaceRequirements.OperationTypes.upload;
DiskSpaceRequirements = new DiskSpaceRequirements(operation, Host, updateName, requiredDiskSpace, availableDiskSpace, reclaimableDiskSpace);
log.WarnFormat("Cleanup message: \r\n{0}", DiskSpaceRequirements.GetSpaceRequirementsMessage());
}
@ -132,14 +134,18 @@ namespace XenAdmin.Actions
public class DiskSpaceRequirements
{
public readonly OperationTypes Operation;
public readonly Host Host;
public readonly string UpdateName;
public readonly long RequiredDiskSpace;
public readonly long AvailableDiskSpace;
public readonly long ReclaimableDiskSpace;
public DiskSpaceRequirements(Host host, string updateName, long requiredDiskSpace, long availableDiskSpace, long reclaimableDiskSpace)
public enum OperationTypes { install, upload }
public DiskSpaceRequirements(OperationTypes operation, Host host, string updateName, long requiredDiskSpace, long availableDiskSpace, long reclaimableDiskSpace)
{
Operation = operation;
Host = host;
UpdateName = updateName;
RequiredDiskSpace = requiredDiskSpace;
@ -149,14 +155,23 @@ namespace XenAdmin.Actions
public bool CanCleanup
{
get { return RequiredDiskSpace < ReclaimableDiskSpace; }
get { return ReclaimableDiskSpace + AvailableDiskSpace > RequiredDiskSpace && RequiredDiskSpace > 0; }
}
public string GetSpaceRequirementsMessage()
{
StringBuilder sbMessage = new StringBuilder();
sbMessage.AppendFormat(Messages.NOT_ENOUGH_SPACE_MESSAGE, Host.Name, UpdateName);
switch (Operation)
{
case OperationTypes.install :
sbMessage.AppendFormat(Messages.NOT_ENOUGH_SPACE_MESSAGE_INSTALL, Host.Name, UpdateName);
break;
case OperationTypes.upload :
sbMessage.AppendFormat(Messages.NOT_ENOUGH_SPACE_MESSAGE_UPLOAD, Host.Name, UpdateName);
break;
}
sbMessage.AppendLine();
sbMessage.AppendLine();
sbMessage.AppendFormat(Messages.NOT_ENOUGH_SPACE_MESSAGE_REQUIRED_SPACE, Util.DiskSizeString(RequiredDiskSpace));
@ -170,5 +185,10 @@ namespace XenAdmin.Actions
sbMessage.AppendLine(Messages.NOT_ENOUGH_SPACE_MESSAGE_NOCLEANUP);
return sbMessage.ToString();
}
public string GetMessageForActionLink()
{
return CanCleanup ? Messages.PATCHINGWIZARD_CLEANUP : Messages.PATCHINGWIZARD_MORE_INFO;
}
}
}

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -10473,14 +10473,14 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to Docker Processes Properties.
/// Looks up a localized string similar to Docker Processes.
/// </summary>
public static string DOCKER_PROCESS_TAB_TITLE {
get {
return ResourceManager.GetString("DOCKER_PROCESS_TAB_TITLE", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to does not use.
/// </summary>
@ -17915,34 +17915,34 @@ namespace XenAdmin {
return ResourceManager.GetString("LABEL_SYNC", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to the informaiton is not valid.
/// Looks up a localized string similar to The information is not available..
/// </summary>
public static string LAST_REFRESH_FAIL {
get {
return ResourceManager.GetString("LAST_REFRESH_FAIL", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to loading the information.
/// Looks up a localized string similar to Loading....
/// </summary>
public static string LAST_REFRESH_IN_PROGRESS {
get {
return ResourceManager.GetString("LAST_REFRESH_IN_PROGRESS", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to last refresh.
/// Looks up a localized string similar to Last refresh: {0}.
/// </summary>
public static string LAST_REFRESH_SUCCESS {
get {
return ResourceManager.GetString("LAST_REFRESH_SUCCESS", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to was last week.
/// </summary>
@ -23731,11 +23731,11 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to There is not enough space on &apos;{0}&apos; to upload update &apos;{1}&apos;..
/// Looks up a localized string similar to This host does not have enough disk space to install this update.
/// </summary>
public static string NOT_ENOUGH_SPACE_MESSAGE {
public static string NOT_ENOUGH_SPACE_DESCRIPTION {
get {
return ResourceManager.GetString("NOT_ENOUGH_SPACE_MESSAGE", resourceCulture);
return ResourceManager.GetString("NOT_ENOUGH_SPACE_DESCRIPTION", resourceCulture);
}
}
@ -23757,6 +23757,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to There is not enough space on &apos;{0}&apos; to install update &apos;{1}&apos;..
/// </summary>
public static string NOT_ENOUGH_SPACE_MESSAGE_INSTALL {
get {
return ResourceManager.GetString("NOT_ENOUGH_SPACE_MESSAGE_INSTALL", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You need to manually free up more space and try again..
/// </summary>
@ -23775,6 +23784,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to There is not enough space on &apos;{0}&apos; to upload update &apos;{1}&apos;..
/// </summary>
public static string NOT_ENOUGH_SPACE_MESSAGE_UPLOAD {
get {
return ResourceManager.GetString("NOT_ENOUGH_SPACE_MESSAGE_UPLOAD", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Not in any folder.
/// </summary>

View File

@ -8242,8 +8242,8 @@ It is strongly recommended that you Cancel and apply the latest version of the p
<data name="NOT_CONTAINS" xml:space="preserve">
<value>does not contain</value>
</data>
<data name="NOT_ENOUGH_SPACE_MESSAGE" xml:space="preserve">
<value>There is not enough space on '{0}' to upload update '{1}'.</value>
<data name="NOT_ENOUGH_SPACE_DESCRIPTION" xml:space="preserve">
<value>This host does not have enough disk space to install this update</value>
</data>
<data name="NOT_ENOUGH_SPACE_MESSAGE_AVAILABLE_SPACE" xml:space="preserve">
<value>Space available: {0}</value>
@ -8251,12 +8251,18 @@ It is strongly recommended that you Cancel and apply the latest version of the p
<data name="NOT_ENOUGH_SPACE_MESSAGE_CLEANUP" xml:space="preserve">
<value>XenCenter can free up {0} by removing residual update files. Do you wish to proceed with the cleanup?</value>
</data>
<data name="NOT_ENOUGH_SPACE_MESSAGE_INSTALL" xml:space="preserve">
<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>
</data>
<data name="NOT_ENOUGH_SPACE_MESSAGE_REQUIRED_SPACE" xml:space="preserve">
<value>Space required: {0}</value>
</data>
<data name="NOT_ENOUGH_SPACE_MESSAGE_UPLOAD" xml:space="preserve">
<value>There is not enough space on '{0}' to upload update '{1}'.</value>
</data>
<data name="NOT_IN_A_FOLDER" xml:space="preserve">
<value>Not in any folder</value>
</data>