Skip to content

Commit bf3d133

Browse files
committed
Merge remote-tracking branch 'origin/4.16'
2 parents 11e59b3 + 5f93bc8 commit bf3d133

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

core/src/main/java/com/cloud/storage/template/OVAProcessor.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,17 @@ public long getTemplateVirtualSize(String templatePath, String templateName) thr
246246
NodeList diskElements = new OVFHelper().getElementsByTagNameAndPrefix(ovfDoc, "Disk", "ovf");
247247
for (int i = 0; i < diskElements.getLength(); i++) {
248248
Element disk = (Element)diskElements.item(i);
249-
long diskSize = Long.parseLong(disk.getAttribute("ovf:capacity"));
249+
String diskSizeValue = disk.getAttribute("ovf:capacity");
250+
long diskSize = 1;
251+
try {
252+
diskSize = Long.parseLong(diskSizeValue);
253+
} catch (NumberFormatException e) {
254+
// ASSUMEably the diskSize contains a property for replacement
255+
LOGGER.warn(String.format("the disksize for disk %s is not a valid number: %s", disk.getAttribute("diskId"), diskSizeValue));
256+
// TODO parse the property to get any value can not be done at registration time
257+
// and will have to be done at deploytime, so for orchestration purposes
258+
// we now assume, a value of one
259+
}
250260
String allocationUnits = disk.getAttribute("ovf:capacityAllocationUnits");
251261
diskSize = OVFHelper.getDiskVirtualSize(diskSize, allocationUnits, ovfFileName);
252262
virtualSize += diskSize;

0 commit comments

Comments
 (0)