CA-361078: Parse OVFs without a Limit element in the vCPUs section

VMWare OVFs don't export the value

Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com>
This commit is contained in:
Danilo Del Busso 2022-02-18 09:07:23 +00:00 committed by Konstantina Chremmou
parent 8493ee5e90
commit a578b6924c

View File

@ -533,13 +533,14 @@ namespace XenAdmin.Actions.OvfActions
//There may be more than one entries corresponding to CPUs
//The VirtualQuantity in each one is Cores
foreach (RASD_Type rasd in rasds)
foreach (var rasd in rasds)
{
cpuCount += rasd.VirtualQuantity.Value;
// CA-361078: Older versions of CHC/XC used to set the limit to 100,000 by default, and use
// VirtualQuantity for max vCPUs.
// This way, we keep backwards compatibility with older OVFs.
maxCpusCount += rasd.Limit.Value >= 100_000 ? rasd.VirtualQuantity.Value : rasd.Limit.Value;
var limit = rasd.Limit?.Value ?? 100_000;
maxCpusCount += limit >= 100_000 ? rasd.VirtualQuantity.Value : limit;
}
}