[GitHub] cloudstack pull request #2022: CLOUDSTACK-9591: Fix systemvmtemplate to not ...

2017-03-30 Thread DaanHoogland
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #2022: CLOUDSTACK-9591: Fix systemvmtemplate to not ...

2017-03-30 Thread rhtyd
GitHub user rhtyd opened a pull request:

https://github.com/apache/cloudstack/pull/2022

CLOUDSTACK-9591: Fix systemvmtemplate to not include network details

This removes nic/network specific details while exporting the 
systemvmtemplate for vmware (ova file). Having this causes the ssvms to not 
deploy in dvswitch-based vmware environments that have no vswitch portgroups 
(dummy etc). Tested this on a local Trillian env.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shapeblue/cloudstack 
4.9-systemvm-fix-vmware-portgroups

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/2022.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2022


commit 49a132fdf9a8e97922a4f2e6435c8fb07fea6076
Author: Rohit Yadav 
Date:   2017-03-30T06:09:43Z

appliance: remove nic related rules while exporting ssvm ova

Signed-off-by: Rohit Yadav 




---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---