cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [2/3] git commit: updated refs/heads/4.9 to 96700a0
Date Wed, 12 Apr 2017 04:59:55 GMT
CLOUDSTACK-9591: Fix guest VM ovf xml to remove network nodes

This removes network details from the guest VM template OVF xml before deploying
a VM which would fail in case of dvswitch-based vmware environment with no
dummy/existing vswitch.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/00e1b462
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/00e1b462
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/00e1b462

Branch: refs/heads/4.9
Commit: 00e1b462f62366cbe3135c812de2972eb6af68c2
Parents: 92fd5be
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Thu Mar 30 17:27:19 2017 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Thu Mar 30 18:01:46 2017 +0530

----------------------------------------------------------------------
 .../vmware/mo/HypervisorHostHelper.java         |  76 +++++-
 .../vmware/mo/HypervisorHostHelperTest.java     | 251 +++++++++++++++++--
 2 files changed, 297 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/00e1b462/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
index 71c007d..ef3f0ae 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
@@ -16,17 +16,6 @@
 // under the License.
 package com.cloud.hypervisor.vmware.mo;
 
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.security.InvalidParameterException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
 import com.cloud.exception.CloudException;
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.cloud.hypervisor.vmware.util.VmwareHelper;
@@ -92,6 +81,33 @@ import com.vmware.vim25.VirtualSCSISharing;
 import com.vmware.vim25.VmwareDistributedVirtualSwitchPvlanSpec;
 import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
 import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanSpec;
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.traversal.DocumentTraversal;
+import org.w3c.dom.traversal.NodeFilter;
+import org.w3c.dom.traversal.NodeIterator;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.InvalidParameterException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
 
 public class HypervisorHostHelper {
     private static final Logger s_logger = Logger.getLogger(HypervisorHostHelper.class);
@@ -1477,6 +1493,40 @@ public class HypervisorHostHelper {
         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);
+        }
+        return ovfString;
+    }
+
     public static void importVmFromOVF(VmwareHypervisorHost host, String ovfFilePath, String
vmName, DatastoreMO dsMo, String diskOption, ManagedObjectReference morRp,
             ManagedObjectReference morHost) throws Exception {
 
@@ -1488,9 +1538,9 @@ public class HypervisorHostHelper {
         importSpecParams.setEntityName(vmName);
         importSpecParams.setDeploymentOption("");
         importSpecParams.setDiskProvisioning(diskOption); // diskOption: thin, thick, etc
-        //importSpecParams.setPropertyMapping(null);
 
-        String ovfDescriptor = HttpNfcLeaseMO.readOvfContent(ovfFilePath);
+        String ovfDescriptor = removeOVFNetwork(HttpNfcLeaseMO.readOvfContent(ovfFilePath));
+
         VmwareContext context = host.getContext();
         OvfCreateImportSpecResult ovfImportResult =
                 context.getService().createImportSpec(context.getServiceContent().getOvfManager(),
ovfDescriptor, morRp, dsMo.getMor(), importSpecParams);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/00e1b462/vmware-base/test/com/cloud/hypervisor/vmware/mo/HypervisorHostHelperTest.java
----------------------------------------------------------------------
diff --git a/vmware-base/test/com/cloud/hypervisor/vmware/mo/HypervisorHostHelperTest.java
b/vmware-base/test/com/cloud/hypervisor/vmware/mo/HypervisorHostHelperTest.java
index 6997805..2fc9995 100644
--- a/vmware-base/test/com/cloud/hypervisor/vmware/mo/HypervisorHostHelperTest.java
+++ b/vmware-base/test/com/cloud/hypervisor/vmware/mo/HypervisorHostHelperTest.java
@@ -16,22 +16,7 @@
 // under the License.
 package com.cloud.hypervisor.vmware.mo;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
+import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.vmware.vim25.AboutInfo;
 import com.vmware.vim25.BoolPolicy;
 import com.vmware.vim25.DVPortgroupConfigInfo;
@@ -41,8 +26,21 @@ import com.vmware.vim25.LongPolicy;
 import com.vmware.vim25.ServiceContent;
 import com.vmware.vim25.VMwareDVSPortSetting;
 import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 
-import com.cloud.hypervisor.vmware.util.VmwareContext;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
 
 public class HypervisorHostHelperTest {
     @Mock
@@ -557,4 +555,223 @@ public class HypervisorHostHelperTest {
         String cloudNetworkName = HypervisorHostHelper.composeCloudNetworkName(prefix, vlanId,
svlanId, networkRateMbps, vSwitchName);
         assertEquals("cloud.guest.400.s123.512.1-vSwitch2", cloudNetworkName);
     }
+
+    @Test
+    public void testOvfDomRewriter() {
+        final String ovfString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+                "<!--Generated by VMware ovftool 3.5.0 (build-1274719), UTC time: 2016-10-03T12:49:55.591821Z-->"
+
+                "<Envelope xmlns=\"http://schemas.dmtf.org/ovf/envelope/1\" xmlns:cim=\"http://schemas.dmtf.org/wbem/wscim/1/common\"
xmlns:ovf=\"http://schemas.dmtf.org/ovf/envelope/1\" xmlns:rasd=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData\"
xmlns:vmw=\"http://www.vmware.com/schema/ovf\" xmlns:vssd=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
+                "  <References>\n" +
+                "    <File ovf:href=\"macchinina-vmware-disk1.vmdk\" ovf:id=\"file1\"
ovf:size=\"23303168\"/>\n" +
+                "  </References>\n" +
+                "  <DiskSection>\n" +
+                "    <Info>Virtual disk information</Info>\n" +
+                "    <Disk ovf:capacity=\"50\" ovf:capacityAllocationUnits=\"byte * 2^20\"
ovf:diskId=\"vmdisk1\" ovf:fileRef=\"file1\" ovf:format=\"http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized\"
ovf:populatedSize=\"43319296\"/>\n" +
+                "  </DiskSection>\n" +
+                "  <NetworkSection>\n" +
+                "    <Info>The list of logical networks</Info>\n" +
+                "    <Network ovf:name=\"bridged\">\n" +
+                "      <Description>The bridged network</Description>\n" +
+                "    </Network>\n" +
+                "  </NetworkSection>\n" +
+                "  <VirtualSystem ovf:id=\"vm\">\n" +
+                "    <Info>A virtual machine</Info>\n" +
+                "    <Name>macchinina-vmware</Name>\n" +
+                "    <OperatingSystemSection ovf:id=\"101\" vmw:osType=\"otherLinux64Guest\">\n"
+
+                "      <Info>The kind of installed guest operating system</Info>\n"
+
+                "    </OperatingSystemSection>\n" +
+                "    <VirtualHardwareSection>\n" +
+                "      <Info>Virtual hardware requirements</Info>\n" +
+                "      <System>\n" +
+                "        <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>\n"
+
+                "        <vssd:InstanceID>0</vssd:InstanceID>\n" +
+                "        <vssd:VirtualSystemIdentifier>macchinina-vmware</vssd:VirtualSystemIdentifier>\n"
+
+                "        <vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>\n"
+
+                "      </System>\n" +
+                "      <Item>\n" +
+                "        <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>\n"
+
+                "        <rasd:Description>Number of Virtual CPUs</rasd:Description>\n"
+
+                "        <rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>\n"
+
+                "        <rasd:InstanceID>1</rasd:InstanceID>\n" +
+                "        <rasd:ResourceType>3</rasd:ResourceType>\n" +
+                "        <rasd:VirtualQuantity>1</rasd:VirtualQuantity>\n" +
+                "      </Item>\n" +
+                "      <Item>\n" +
+                "        <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>\n"
+
+                "        <rasd:Description>Memory Size</rasd:Description>\n"
+
+                "        <rasd:ElementName>256MB of memory</rasd:ElementName>\n"
+
+                "        <rasd:InstanceID>2</rasd:InstanceID>\n" +
+                "        <rasd:ResourceType>4</rasd:ResourceType>\n" +
+                "        <rasd:VirtualQuantity>256</rasd:VirtualQuantity>\n"
+
+                "      </Item>\n" +
+                "      <Item>\n" +
+                "        <rasd:Address>0</rasd:Address>\n" +
+                "        <rasd:Description>SCSI Controller</rasd:Description>\n"
+
+                "        <rasd:ElementName>scsiController0</rasd:ElementName>\n"
+
+                "        <rasd:InstanceID>3</rasd:InstanceID>\n" +
+                "        <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>\n"
+
+                "        <rasd:ResourceType>6</rasd:ResourceType>\n" +
+                "      </Item>\n" +
+                "      <Item>\n" +
+                "        <rasd:Address>0</rasd:Address>\n" +
+                "        <rasd:Description>IDE Controller</rasd:Description>\n"
+
+                "        <rasd:ElementName>ideController0</rasd:ElementName>\n"
+
+                "        <rasd:InstanceID>4</rasd:InstanceID>\n" +
+                "        <rasd:ResourceType>5</rasd:ResourceType>\n" +
+                "      </Item>\n" +
+                "      <Item ovf:required=\"false\">\n" +
+                "        <rasd:AddressOnParent>0</rasd:AddressOnParent>\n" +
+                "        <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>\n"
+
+                "        <rasd:ElementName>cdrom0</rasd:ElementName>\n" +
+                "        <rasd:InstanceID>5</rasd:InstanceID>\n" +
+                "        <rasd:Parent>4</rasd:Parent>\n" +
+                "        <rasd:ResourceType>15</rasd:ResourceType>\n" +
+                "      </Item>\n" +
+                "      <Item>\n" +
+                "        <rasd:AddressOnParent>0</rasd:AddressOnParent>\n" +
+                "        <rasd:ElementName>disk0</rasd:ElementName>\n" +
+                "        <rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>\n"
+
+                "        <rasd:InstanceID>6</rasd:InstanceID>\n" +
+                "        <rasd:Parent>3</rasd:Parent>\n" +
+                "        <rasd:ResourceType>17</rasd:ResourceType>\n" +
+                "      </Item>\n" +
+                "      <Item>\n" +
+                "        <rasd:AddressOnParent>2</rasd:AddressOnParent>\n" +
+                "        <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>\n"
+
+                "        <rasd:Connection>bridged</rasd:Connection>\n" +
+                "        <rasd:Description>E1000 ethernet adapter on &quot;bridged&quot;</rasd:Description>\n"
+
+                "        <rasd:ElementName>ethernet0</rasd:ElementName>\n" +
+                "        <rasd:InstanceID>7</rasd:InstanceID>\n" +
+                "        <rasd:ResourceSubType>E1000</rasd:ResourceSubType>\n"
+
+                "        <rasd:ResourceType>10</rasd:ResourceType>\n" +
+                "        <vmw:Config ovf:required=\"false\" vmw:key=\"wakeOnLanEnabled\"
vmw:value=\"false\"/>\n" +
+                "      </Item>\n" +
+                "      <Item ovf:required=\"false\">\n" +
+                "        <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>\n"
+
+                "        <rasd:ElementName>video</rasd:ElementName>\n" +
+                "        <rasd:InstanceID>8</rasd:InstanceID>\n" +
+                "        <rasd:ResourceType>24</rasd:ResourceType>\n" +
+                "        <vmw:Config ovf:required=\"false\" vmw:key=\"enable3DSupport\"
vmw:value=\"false\"/>\n" +
+                "        <vmw:Config ovf:required=\"false\" vmw:key=\"useAutoDetect\"
vmw:value=\"false\"/>\n" +
+                "        <vmw:Config ovf:required=\"false\" vmw:key=\"videoRamSizeInKB\"
vmw:value=\"4096\"/>\n" +
+                "      </Item>\n" +
+                "      <Item ovf:required=\"false\">\n" +
+                "        <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>\n"
+
+                "        <rasd:ElementName>vmci</rasd:ElementName>\n" +
+                "        <rasd:InstanceID>9</rasd:InstanceID>\n" +
+                "        <rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType>\n"
+
+                "        <rasd:ResourceType>1</rasd:ResourceType>\n" +
+                "      </Item>\n" +
+                "      <vmw:Config ovf:required=\"false\" vmw:key=\"cpuHotAddEnabled\"
vmw:value=\"false\"/>\n" +
+                "      <vmw:Config ovf:required=\"false\" vmw:key=\"cpuHotRemoveEnabled\"
vmw:value=\"false\"/>\n" +
+                "      <vmw:Config ovf:required=\"false\" vmw:key=\"firmware\" vmw:value=\"bios\"/>\n"
+
+                "      <vmw:Config ovf:required=\"false\" vmw:key=\"memoryHotAddEnabled\"
vmw:value=\"false\"/>\n" +
+                "    </VirtualHardwareSection>\n" +
+                "    <AnnotationSection ovf:required=\"false\">\n" +
+                "      <Info>A human-readable annotation</Info>\n" +
+                "      <Annotation>macchinina-vmware</Annotation>\n" +
+                "    </AnnotationSection>\n" +
+                "  </VirtualSystem>\n" +
+                "</Envelope>";
+
+        final String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+                "<!--Generated by VMware ovftool 3.5.0 (build-1274719), UTC time: 2016-10-03T12:49:55.591821Z-->"
+
+                "<Envelope xmlns=\"http://schemas.dmtf.org/ovf/envelope/1\" xmlns:cim=\"http://schemas.dmtf.org/wbem/wscim/1/common\"
xmlns:ovf=\"http://schemas.dmtf.org/ovf/envelope/1\" xmlns:rasd=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData\"
xmlns:vmw=\"http://www.vmware.com/schema/ovf\" xmlns:vssd=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
+                "  <References>\n" +
+                "    <File ovf:href=\"macchinina-vmware-disk1.vmdk\" ovf:id=\"file1\"
ovf:size=\"23303168\"/>\n" +
+                "  </References>\n" +
+                "  <DiskSection>\n" +
+                "    <Info>Virtual disk information</Info>\n" +
+                "    <Disk ovf:capacity=\"50\" ovf:capacityAllocationUnits=\"byte * 2^20\"
ovf:diskId=\"vmdisk1\" ovf:fileRef=\"file1\" ovf:format=\"http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized\"
ovf:populatedSize=\"43319296\"/>\n" +
+                "  </DiskSection>\n  \n" +
+                "  <VirtualSystem ovf:id=\"vm\">\n" +
+                "    <Info>A virtual machine</Info>\n" +
+                "    <Name>macchinina-vmware</Name>\n" +
+                "    <OperatingSystemSection ovf:id=\"101\" vmw:osType=\"otherLinux64Guest\">\n"
+
+                "      <Info>The kind of installed guest operating system</Info>\n"
+
+                "    </OperatingSystemSection>\n" +
+                "    <VirtualHardwareSection>\n" +
+                "      <Info>Virtual hardware requirements</Info>\n" +
+                "      <System>\n" +
+                "        <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>\n"
+
+                "        <vssd:InstanceID>0</vssd:InstanceID>\n" +
+                "        <vssd:VirtualSystemIdentifier>macchinina-vmware</vssd:VirtualSystemIdentifier>\n"
+
+                "        <vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>\n"
+
+                "      </System>\n" +
+                "      <Item>\n" +
+                "        <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>\n"
+
+                "        <rasd:Description>Number of Virtual CPUs</rasd:Description>\n"
+
+                "        <rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>\n"
+
+                "        <rasd:InstanceID>1</rasd:InstanceID>\n" +
+                "        <rasd:ResourceType>3</rasd:ResourceType>\n" +
+                "        <rasd:VirtualQuantity>1</rasd:VirtualQuantity>\n" +
+                "      </Item>\n" +
+                "      <Item>\n" +
+                "        <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>\n"
+
+                "        <rasd:Description>Memory Size</rasd:Description>\n"
+
+                "        <rasd:ElementName>256MB of memory</rasd:ElementName>\n"
+
+                "        <rasd:InstanceID>2</rasd:InstanceID>\n" +
+                "        <rasd:ResourceType>4</rasd:ResourceType>\n" +
+                "        <rasd:VirtualQuantity>256</rasd:VirtualQuantity>\n"
+
+                "      </Item>\n" +
+                "      <Item>\n" +
+                "        <rasd:Address>0</rasd:Address>\n" +
+                "        <rasd:Description>SCSI Controller</rasd:Description>\n"
+
+                "        <rasd:ElementName>scsiController0</rasd:ElementName>\n"
+
+                "        <rasd:InstanceID>3</rasd:InstanceID>\n" +
+                "        <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>\n"
+
+                "        <rasd:ResourceType>6</rasd:ResourceType>\n" +
+                "      </Item>\n" +
+                "      <Item>\n" +
+                "        <rasd:Address>0</rasd:Address>\n" +
+                "        <rasd:Description>IDE Controller</rasd:Description>\n"
+
+                "        <rasd:ElementName>ideController0</rasd:ElementName>\n"
+
+                "        <rasd:InstanceID>4</rasd:InstanceID>\n" +
+                "        <rasd:ResourceType>5</rasd:ResourceType>\n" +
+                "      </Item>\n" +
+                "      <Item ovf:required=\"false\">\n" +
+                "        <rasd:AddressOnParent>0</rasd:AddressOnParent>\n" +
+                "        <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>\n"
+
+                "        <rasd:ElementName>cdrom0</rasd:ElementName>\n" +
+                "        <rasd:InstanceID>5</rasd:InstanceID>\n" +
+                "        <rasd:Parent>4</rasd:Parent>\n" +
+                "        <rasd:ResourceType>15</rasd:ResourceType>\n" +
+                "      </Item>\n" +
+                "      <Item>\n" +
+                "        <rasd:AddressOnParent>0</rasd:AddressOnParent>\n" +
+                "        <rasd:ElementName>disk0</rasd:ElementName>\n" +
+                "        <rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>\n"
+
+                "        <rasd:InstanceID>6</rasd:InstanceID>\n" +
+                "        <rasd:Parent>3</rasd:Parent>\n" +
+                "        <rasd:ResourceType>17</rasd:ResourceType>\n" +
+                "      </Item>\n      \n" +
+                "      <Item ovf:required=\"false\">\n" +
+                "        <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>\n"
+
+                "        <rasd:ElementName>video</rasd:ElementName>\n" +
+                "        <rasd:InstanceID>8</rasd:InstanceID>\n" +
+                "        <rasd:ResourceType>24</rasd:ResourceType>\n" +
+                "        <vmw:Config ovf:required=\"false\" vmw:key=\"enable3DSupport\"
vmw:value=\"false\"/>\n" +
+                "        <vmw:Config ovf:required=\"false\" vmw:key=\"useAutoDetect\"
vmw:value=\"false\"/>\n" +
+                "        <vmw:Config ovf:required=\"false\" vmw:key=\"videoRamSizeInKB\"
vmw:value=\"4096\"/>\n" +
+                "      </Item>\n" +
+                "      <Item ovf:required=\"false\">\n" +
+                "        <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>\n"
+
+                "        <rasd:ElementName>vmci</rasd:ElementName>\n" +
+                "        <rasd:InstanceID>9</rasd:InstanceID>\n" +
+                "        <rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType>\n"
+
+                "        <rasd:ResourceType>1</rasd:ResourceType>\n" +
+                "      </Item>\n" +
+                "      <vmw:Config ovf:required=\"false\" vmw:key=\"cpuHotAddEnabled\"
vmw:value=\"false\"/>\n" +
+                "      <vmw:Config ovf:required=\"false\" vmw:key=\"cpuHotRemoveEnabled\"
vmw:value=\"false\"/>\n" +
+                "      <vmw:Config ovf:required=\"false\" vmw:key=\"firmware\" vmw:value=\"bios\"/>\n"
+
+                "      <vmw:Config ovf:required=\"false\" vmw:key=\"memoryHotAddEnabled\"
vmw:value=\"false\"/>\n" +
+                "    </VirtualHardwareSection>\n" +
+                "    <AnnotationSection ovf:required=\"false\">\n" +
+                "      <Info>A human-readable annotation</Info>\n" +
+                "      <Annotation>macchinina-vmware</Annotation>\n" +
+                "    </AnnotationSection>\n" +
+                "  </VirtualSystem>\n" +
+                "</Envelope>";
+        assertEquals(expected, HypervisorHostHelper.removeOVFNetwork(ovfString));
+    }
 }


Mime
View raw message