CP-28282: Update the disk space precheck to calculate the required space according to the new workflow (apply all hotfixes to a host before moving to the next one)

- this commit covers the post-Ely case, where updates are uploaded to storage repositories

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2018-06-13 17:24:33 +01:00
parent 2efc1b8685
commit c702399d95
7 changed files with 94 additions and 20 deletions

View File

@ -85,6 +85,33 @@ namespace XenAdmin.Diagnostics.Checks
if (action.Succeeded && action.DiskSpaceRequirements.AvailableDiskSpace < size)
return new HostOutOfSpaceProblem(this, Host, action.DiskSpaceRequirements);
// check the disk space for uploading the update files to the pool's SRs (only needs to be done once, so only run this on master)
if (elyOrGreater && Host.IsMaster())
{
var allPatches = updateSequence.Values.SelectMany(p => p).Distinct().ToList();
var maxFileSize = allPatches.Max(p => p.DownloadSize);
var availableSRs = Host.Connection.Cache.SRs.Where(sr => sr.SupportsVdiCreate() && !sr.IsDetached()).ToList();
var maxSrSize = availableSRs.Max(sr => sr.FreeSpace());
// can accomodate the largest file?
if (maxSrSize < maxFileSize)
{
return new HostOutOfSpaceProblem(this, Host,
new DiskSpaceRequirements(DiskSpaceRequirements.OperationTypes.automatedUpdatesUploadOne, Host, null, maxFileSize, maxSrSize, 0));
}
// can accomodate all files?
var totalFileSize = allPatches.Sum(p => p.DownloadSize);
var totalAvailableSpace = availableSRs.Sum(sr => sr.FreeSpace());
if (totalAvailableSpace < totalFileSize)
{
return new HostOutOfSpaceProblem(this, Host,
new DiskSpaceRequirements(DiskSpaceRequirements.OperationTypes.automatedUpdatesUploadAll, Host, null, totalFileSize, totalAvailableSpace, 0));
}
}
return null;
}

View File

@ -30,16 +30,11 @@
*/
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;
using System.Diagnostics;
@ -97,6 +92,10 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem
case DiskSpaceRequirements.OperationTypes.automatedUpdates :
return string.Format(Messages.NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE, ServerName);
case DiskSpaceRequirements.OperationTypes.automatedUpdatesUploadOne:
case DiskSpaceRequirements.OperationTypes.automatedUpdatesUploadAll:
return string.Format(Messages.NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE_UPLOAD, ServerName);
default:
Debug.Assert(false);
return string.Empty;

View File

@ -173,7 +173,7 @@ namespace XenAdmin.Actions
public readonly long AvailableDiskSpace;
public readonly long ReclaimableDiskSpace;
public enum OperationTypes { install, upload, automatedUpdates }
public enum OperationTypes { install, upload, automatedUpdates, automatedUpdatesUploadOne, automatedUpdatesUploadAll }
public DiskSpaceRequirements(OperationTypes operation, Host host, string updateName, long requiredDiskSpace, long availableDiskSpace, long reclaimableDiskSpace)
{
@ -205,6 +205,12 @@ namespace XenAdmin.Actions
case OperationTypes.automatedUpdates :
sbMessage.AppendFormat(Messages.NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE, Host.Name());
break;
case OperationTypes.automatedUpdatesUploadOne:
sbMessage.AppendFormat(Messages.NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE_UPLOAD_ONE, Host.Name());
break;
case OperationTypes.automatedUpdatesUploadAll:
sbMessage.AppendFormat(Messages.NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE_UPLOAD_ALL, Host.Name());
break;
}
sbMessage.AppendLine();

View File

@ -165,6 +165,7 @@ namespace XenAdmin.Actions
string timestamp = "";
string priority = "";
string installationSize = "";
string downloadSize = "";
foreach (XmlAttribute attrib in version.Attributes)
{
@ -190,13 +191,15 @@ namespace XenAdmin.Actions
priority = attrib.Value;
else if (attrib.Name == "installation-size")
installationSize = attrib.Value;
else if (attrib.Name == "download-size")
downloadSize = attrib.Value;
}
var conflictingPatches = GetPatchDependencies(version, ConflictingPatchesNode, ConflictingPatchNode);
var requiredPatches = GetPatchDependencies(version, RequiredPatchesNode, RequiredPatchNode);
XenServerPatches.Add(new XenServerPatch(uuid, name, description, guidance, guidance_mandatory, patchVersion, url,
patchUrl, timestamp, priority, installationSize, conflictingPatches, requiredPatches));
patchUrl, timestamp, priority, installationSize, downloadSize, conflictingPatches, requiredPatches));
}
}
}

View File

@ -50,6 +50,7 @@ namespace XenAdmin.Core
public readonly DateTime TimeStamp;
public readonly int Priority;
public readonly long InstallationSize; // installation size, in btyes
public readonly long DownloadSize; // download size, in btyes
public readonly List<string> ConflictingPatches;
public readonly List<string> RequiredPatches;
@ -57,7 +58,7 @@ namespace XenAdmin.Core
private const int DEFAULT_PRIORITY = 2;
public XenServerPatch(string uuid, string name, string description, string guidance, string guidance_mandatory , string version, string url,
string patchUrl, string timestamp, string priority, string installationSize)
string patchUrl, string timestamp, string priority, string installationSize, string downloadSize)
{
_uuid = uuid;
Name = name;
@ -72,11 +73,13 @@ namespace XenAdmin.Core
Priority = DEFAULT_PRIORITY;
if (!Int64.TryParse(installationSize, out InstallationSize))
InstallationSize = 0;
if (!Int64.TryParse(downloadSize, out DownloadSize))
DownloadSize = 0;
}
public XenServerPatch(string uuid, string name, string description, string guidance, string guidance_mandatory, string version, string url,
string patchUrl, string timestamp, string priority, string installationSize, List<string> conflictingPatches, List<string> requiredPatches)
: this(uuid, name, description, guidance, guidance_mandatory, version, url, patchUrl, timestamp, priority, installationSize)
string patchUrl, string timestamp, string priority, string installationSize, string downloadSize, List<string> conflictingPatches, List<string> requiredPatches)
: this(uuid, name, description, guidance, guidance_mandatory, version, url, patchUrl, timestamp, priority, installationSize, downloadSize)
{
ConflictingPatches = conflictingPatches;

View File

@ -19,7 +19,7 @@ namespace XenAdmin {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Messages {
@ -26217,6 +26217,33 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to There is not enough space to upload the required updates..
/// </summary>
public static string NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE_UPLOAD {
get {
return ResourceManager.GetString("NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE_UPLOAD", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to There is not enough space on your SRs to upload all the update files required by the automated updates..
/// </summary>
public static string NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE_UPLOAD_ALL {
get {
return ResourceManager.GetString("NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE_UPLOAD_ALL", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to There is not enough space on any of the SRs to upload an update file required by the automated updates..
/// </summary>
public static string NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE_UPLOAD_ONE {
get {
return ResourceManager.GetString("NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE_UPLOAD_ONE", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Space available: {0}.
/// </summary>
@ -27086,7 +27113,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to One or more of the automated update processes were not completed successfully..
/// Looks up a localized string similar to One or more of the automated updates processes were not completed successfully..
/// </summary>
public static string PATCHINGWIZARD_AUTOUPDATINGPAGE_ERROR_MANY {
get {
@ -27095,7 +27122,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to The automated update process was not completed successfuly..
/// Looks up a localized string similar to The automated updates process was not completed successfuly..
/// </summary>
public static string PATCHINGWIZARD_AUTOUPDATINGPAGE_ERROR_ONE {
get {
@ -27131,7 +27158,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to All automated update processes were completed successfuly..
/// Looks up a localized string similar to All automated updates processes were completed successfuly..
/// </summary>
public static string PATCHINGWIZARD_AUTOUPDATINGPAGE_SUCCESS_MANY {
get {
@ -27140,7 +27167,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to The automated update process was completed successfuly..
/// Looks up a localized string similar to The automated updates process was completed successfuly..
/// </summary>
public static string PATCHINGWIZARD_AUTOUPDATINGPAGE_SUCCESS_ONE {
get {

View File

@ -2138,6 +2138,11 @@ To continue, either select different NICs for the bond, or disable HA, create th
<value>This bond cannot be created because both management and secondary interfaces exist on your selected bond members.
Both types of interface cannot be added to the same bond. Choose different bond members, or move the management interfaces before creating the bond.</value>
</data>
<data name="BOND_CREATE_WILL_DISTURB_CLUSTERING" xml:space="preserve">
<value>Creating this bond will automatically move the clustering network on one of your selected bond members to the bond itself:
- If your network configuration is incorrect then hosts may permanently lose the connection to the clustering network, which will cause undesired host fences.</value>
</data>
<data name="BOND_CREATE_WILL_DISTURB_PRIMARY" xml:space="preserve">
<value>Creating this bond will automatically move the management interface on one of your selected bond members to the bond itself:
@ -2149,11 +2154,6 @@ Both types of interface cannot be added to the same bond. Choose different bond
<data name="BOND_CREATE_WILL_DISTURB_SECONDARY" xml:space="preserve">
<value>Creating this bond will disrupt traffic through the secondary interfaces on the bond members while the interfaces are moved onto the bond itself.</value>
</data>
<data name="BOND_CREATE_WILL_DISTURB_CLUSTERING" xml:space="preserve">
<value>Creating this bond will automatically move the clustering network on one of your selected bond members to the bond itself:
- If your network configuration is incorrect then hosts may permanently lose the connection to the clustering network, which will cause undesired host fences.</value>
</data>
<data name="BOND_DELETE_CONTINUE" xml:space="preserve">
<value>&amp;Delete bond anyway</value>
</data>
@ -9103,6 +9103,15 @@ It is strongly recommended that you Cancel and apply the latest version of the p
<data name="NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE" xml:space="preserve">
<value>There is not enough space to update '{0}' with automated updates.</value>
</data>
<data name="NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE_UPLOAD" xml:space="preserve">
<value>There is not enough space to upload the required updates.</value>
</data>
<data name="NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE_UPLOAD_ALL" xml:space="preserve">
<value>There is not enough space on your SRs to upload all the update files required by the automated updates.</value>
</data>
<data name="NOT_ENOUGH_SPACE_MESSAGE_AUTO_UPDATE_UPLOAD_ONE" xml:space="preserve">
<value>There is not enough space on any of the SRs to upload an update file required by the automated updates.</value>
</data>
<data name="NOT_ENOUGH_SPACE_MESSAGE_AVAILABLE_SPACE" xml:space="preserve">
<value>Space available: {0}</value>
</data>