cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DaanHoogland <...@git.apache.org>
Subject [GitHub] cloudstack pull request #2022: CLOUDSTACK-9591: Fix systemvmtemplate to not ...
Date Thu, 30 Mar 2017 12:59:21 GMT
Github user DaanHoogland commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/2022#discussion_r108918688
  
    --- Diff: vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java ---
    @@ -1477,6 +1493,40 @@ public static String resolveHostNameInUrl(DatacenterMO dcMo, String
url) {
             return url;
         }
     
    +    public static String removeOVFNetwork(final String ovfString)  {
    +        if (ovfString == null || ovfString.isEmpty()) {
    +            return ovfString;
    +        }
    +        try {
    +            final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    +            final Document doc = factory.newDocumentBuilder().parse(new ByteArrayInputStream(ovfString.getBytes()));
    +            final DocumentTraversal traversal = (DocumentTraversal) doc;
    +            final NodeIterator iterator = traversal.createNodeIterator(doc.getDocumentElement(),
NodeFilter.SHOW_ELEMENT, null, true);
    +            for (Node n = iterator.nextNode(); n != null; n = iterator.nextNode()) {
    +                final Element e = (Element) n;
    +                if ("NetworkSection".equals(e.getTagName())) {
    +                    if (e.getParentNode() != null) {
    +                        e.getParentNode().removeChild(e);
    +                    }
    +                } else if ("rasd:Connection".equals(e.getTagName())) {
    +                    if (e.getParentNode() != null && e.getParentNode().getParentNode()
!= null) {
    +                        e.getParentNode().getParentNode().removeChild(e.getParentNode());
    +                    }
    +                }
    +            }
    +            final DOMSource domSource = new DOMSource(doc);
    +            final StringWriter writer = new StringWriter();
    +            final StreamResult result = new StreamResult(writer);
    +            final TransformerFactory tf = TransformerFactory.newInstance();
    +            final Transformer transformer = tf.newTransformer();
    +            transformer.transform(domSource, result);
    +            return writer.toString();
    +        } catch (SAXException | IOException | ParserConfigurationException | TransformerException
e) {
    +            s_logger.warn("Unexpected exception caught while removing network elements
from OVF:", e);
    --- End diff --
    
    thanks for this.
    I'd log a warn without, and a debug with the stacktrace.That way an admin had better control
on what is seen in the logs.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message