You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/01/05 09:59:58 UTC

[GitHub] [cloudstack] sureshanaparti commented on a change in pull request #5825: [Vmware][Deploy-as-is] Add the list of supported namespaces per document and refactor OVF parsing

sureshanaparti commented on a change in pull request #5825:
URL: https://github.com/apache/cloudstack/pull/5825#discussion_r778689350



##########
File path: api/src/main/java/com/cloud/agent/api/storage/OVFHelper.java
##########
@@ -366,21 +387,25 @@ private DatadiskTO generateDiskTO(OVFFile file, OVFDisk disk, String ovfParentPa
                 isIso, bootable, controller, controllerSubType, diskNumber, configuration);
     }
 
-    protected List<OVFDisk> extractDisksFromOvfDocumentTree(Document doc) {
-        NodeList disks = doc.getElementsByTagName("Disk");
-        NodeList ovfDisks = doc.getElementsByTagName("ovf:Disk");
-        NodeList items = doc.getElementsByTagName("Item");
+    protected NodeList getElementByTagNameAndSupportedNamespaces(Document doc, List<String> namespaces, String tagName) {
+        NodeList nodeList = null;
+        for (String namespace : namespaces) {
+            nodeList = doc.getElementsByTagNameNS(namespace, tagName);
+            if (nodeList.getLength() > 0) {
+                break;
+            }
+        }
+        return nodeList;
+    }
 
-        int totalDisksLength = disks.getLength() + ovfDisks.getLength();
+    protected List<OVFDisk> extractDisksFromOvfDocumentTree(Document doc, List<String> supportedNamespaces) {
+        NodeList disks = getElementByTagNameAndSupportedNamespaces(doc, supportedNamespaces, "Disk");
+        NodeList items = getElementByTagNameAndSupportedNamespaces(doc, supportedNamespaces, "Item");

Review comment:
       @nvazquez Any possibility of different namespaces for Disk and Item?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org