This is an automated email from the ASF dual-hosted git repository.

sureshanaparti pushed a commit to branch 4.16
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.16 by this push:
     new 5f93bc8  assume a property is one when it isn't a number (#5647)
5f93bc8 is described below

commit 5f93bc8948e8c3af4fee65ea40f050eed4b3d0ba
Author: dahn <[email protected]>
AuthorDate: Mon Jan 3 08:23:18 2022 +0100

    assume a property is one when it isn't a number (#5647)
    
    Co-authored-by: Daan Hoogland <[email protected]>
---
 .../main/java/com/cloud/storage/template/OVAProcessor.java   | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/com/cloud/storage/template/OVAProcessor.java 
b/core/src/main/java/com/cloud/storage/template/OVAProcessor.java
index b5d78ac..d62897f 100644
--- a/core/src/main/java/com/cloud/storage/template/OVAProcessor.java
+++ b/core/src/main/java/com/cloud/storage/template/OVAProcessor.java
@@ -246,7 +246,17 @@ public class OVAProcessor extends AdapterBase implements 
Processor {
             NodeList diskElements = new 
OVFHelper().getElementsByTagNameAndPrefix(ovfDoc, "Disk", "ovf");
             for (int i = 0; i < diskElements.getLength(); i++) {
                 Element disk = (Element)diskElements.item(i);
-                long diskSize = 
Long.parseLong(disk.getAttribute("ovf:capacity"));
+                String diskSizeValue = disk.getAttribute("ovf:capacity");
+                long diskSize = 1;
+                try {
+                    diskSize = Long.parseLong(diskSizeValue);
+                } catch (NumberFormatException e) {
+                    // ASSUMEably the diskSize contains a property for 
replacement
+                    LOGGER.warn(String.format("the disksize for disk %s is not 
a valid number: %s", disk.getAttribute("diskId"), diskSizeValue));
+                    // TODO parse the property to get any value can not be 
done at registration time
+                    //  and will have to be done at deploytime, so for 
orchestration purposes
+                    //  we now assume, a value of one
+                }
                 String allocationUnits = 
disk.getAttribute("ovf:capacityAllocationUnits");
                 diskSize = OVFHelper.getDiskVirtualSize(diskSize, 
allocationUnits, ovfFileName);
                 virtualSize += diskSize;

Reply via email to