[
https://issues.apache.org/jira/browse/CLOUDSTACK-9591?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15949012#comment-15949012
]
ASF GitHub Bot commented on CLOUDSTACK-9591:
--------------------------------------------
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.
> VMware dvSwitch Requires a Dummy, Standard vSwitch
> --------------------------------------------------
>
> Key: CLOUDSTACK-9591
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9591
> Project: CloudStack
> Issue Type: Bug
> Security Level: Public(Anyone can view this level - this is the
> default.)
> Components: VMware
> Affects Versions: 4.6.2, 4.7.0, 4.7.1, 4.8.0, 4.9.0
> Reporter: John Burwell
> Priority: Minor
>
> When using the VMware dvSwitch, templates fail to register and VMs with the
> following secondary storage error:
> createImportSpec error: Host did not have any virtual network defined.
> Defining dummy, standard vSwitch on the same network works around this issue.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)