Allon Mureinik has uploaded a new change for review.

Change subject: core: Default disk aliases when reading OVFs
......................................................................

core: Default disk aliases when reading OVFs

When reading old-fashioned OVFs (e.g., 3.0), the VM's disks may not have
any aliases.
Since disk aliases are widely assumed throughout the system, this patch
simply adds them when the OVF is read, so you don't have to worry about
them later.

In order to provide a good default, the same default as the upgrade
script was used (VmName_DiskXXX, where XXX is a running number, starting
at 1).
This default obviously requires both the VM's data and the disks' data
to be read from the OVF. In order not to "rock the boat" too much, and
new method was added to IOvfBuilder - FixDiskAliases().

This patch includes:
* The aforementioned API change to IOvfBuilder, its implementation and
  its call in OvfManager.
* A test case for OvfVmReader to test the new logic.
* Sample OVF files for the test case, one with disk aliases and one
  without them.
* A fixup to a bug in RemoveImageTest that generates alias-less disks
  which now is strictly illegal.

Change-Id: I38ad9c56f9b97e174807d3fcbe0b3e43355803ee
Bug-Url: https://bugzilla.redhat.com/872506
Signed-off-by: Allon Mureinik <amure...@redhat.com>
---
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/RemoveImageCommandTest.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/IOvfBuilder.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfManager.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmReader.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
A 
backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/ovf/OvfVmReaderTest.java
A backend/manager/modules/utils/src/test/resources/ovfs/vm_with_disk_aliases.ovf
A 
backend/manager/modules/utils/src/test/resources/ovfs/vm_without_disk_aliases.ovf
10 files changed, 485 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/08/9308/1

diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/RemoveImageCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/RemoveImageCommandTest.java
index 3f99c56..7b48be5 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/RemoveImageCommandTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/RemoveImageCommandTest.java
@@ -125,6 +125,7 @@
         disk.setimageStatus(ImageStatus.OK);
         disk.setappList("");
         disk.setdescription("");
+        disk.setDiskAlias("SomeAlias");
         vm.getDiskList().add(disk);
         vm.getDiskMap().put(imageId, disk);
         return disk;
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/IOvfBuilder.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/IOvfBuilder.java
index 37da935..a02c647 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/IOvfBuilder.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/IOvfBuilder.java
@@ -20,4 +20,10 @@
     void BuildDisk();
 
     void BuildVirtualSystem();
+
+    /**
+     * Assign disk aliases to all the disks if there were none assigned.
+     * This method assumes taht {@link #BuildDisk()} and {@link 
#BuildVirtualSystem()} were already called.
+     */
+    void FixDiskAliases();
 }
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfManager.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfManager.java
index a0f2bfa..419ab78 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfManager.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfManager.java
@@ -91,5 +91,6 @@
         builder.BuildNetwork();
         builder.BuildDisk();
         builder.BuildVirtualSystem();
+        builder.FixDiskAliases();
     }
 }
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
index 3572dbb..12f6998 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
@@ -26,6 +26,7 @@
 import org.ovirt.engine.core.compat.backendcompat.XmlNamespaceManager;
 import org.ovirt.engine.core.compat.backendcompat.XmlNode;
 import org.ovirt.engine.core.compat.backendcompat.XmlNodeList;
+import org.ovirt.engine.core.utils.disks.DiskUtils;
 import org.ovirt.engine.core.utils.linq.LinqUtils;
 import org.ovirt.engine.core.utils.linq.Predicate;
 import org.w3c.dom.Node;
@@ -173,6 +174,19 @@
         readGeneralData();
     }
 
+    /** Fixes disk alias if they are missing */
+    @Override
+    public void FixDiskAliases() {
+        for (int i = 0; i < _images.size(); ++i) {
+            DiskImage disk = _images.get(i);
+            if (StringUtils.isEmpty(disk.getDiskAlias())) {
+                disk.setDiskAlias(DiskUtils.getSuggestedDiskAlias(disk, 
getDiskAliasPrefix(), i + 1));
+            }
+        }
+    }
+
+    protected abstract String getDiskAliasPrefix();
+
     /**
      * Reads vm device attributes from OVF and stores in in the collection
      *
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java
index 07ac175..a6293c6 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java
@@ -160,4 +160,9 @@
             }
         }
     }
+
+    @Override
+    protected String getDiskAliasPrefix() {
+        return _vmTemplate.getname();
+    }
 }
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmReader.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmReader.java
index ca1a5ef..30e6594 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmReader.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmReader.java
@@ -255,6 +255,7 @@
         return null;
     }
 
+    @Override
     protected void readSnapshotsSection(XmlNode section) {
         XmlNodeList list = section.SelectNodes("Snapshot");
         ArrayList<Snapshot> snapshots = new ArrayList<Snapshot>();
@@ -289,4 +290,10 @@
     @Override
     protected void buildNicReference() {
     }
+
+    @Override
+    protected String getDiskAliasPrefix() {
+        return _vm.getvm_name();
+    }
+
 }
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
index 44ce103..d0158d3 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
@@ -376,4 +376,9 @@
             _writer.WriteEndElement();
         }
     }
+
+    @Override
+    public void FixDiskAliases() {
+        // No implementation needed for writer - disks should already have 
aliases.
+    }
 }
diff --git 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/ovf/OvfVmReaderTest.java
 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/ovf/OvfVmReaderTest.java
new file mode 100644
index 0000000..a8458b1
--- /dev/null
+++ 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/ovf/OvfVmReaderTest.java
@@ -0,0 +1,60 @@
+package org.ovirt.engine.core.utils.ovf;
+
+import static org.junit.Assert.assertTrue;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.math.IntRange;
+import org.junit.Test;
+import org.ovirt.engine.core.common.businessentities.DiskImage;
+import org.ovirt.engine.core.common.businessentities.VM;
+import org.ovirt.engine.core.common.businessentities.VmNetworkInterface;
+import org.ovirt.engine.core.compat.backendcompat.XmlDocument;
+
+/** A test case for the {@link OvfVmReader} class. */
+public class OvfVmReaderTest {
+
+    @Test
+    public void testOvfWithDiskAliases() {
+        assertOvf("ovfs/vm_with_disk_aliases.ovf", "someAlias");
+    }
+
+    @Test
+    public void testOvfWithoutDiskAliases() {
+        assertOvf("ovfs/vm_without_disk_aliases.ovf", "vm1_Disk");
+    }
+
+    private static void assertOvf(String ovfPath, String 
expectedDiskAliasPrefix) {
+        VM vm = new VM();
+        ArrayList<DiskImage> disks = new ArrayList<DiskImage>();
+
+        URL ovfUrl = ClassLoader.getSystemResource(ovfPath);
+        XmlDocument ovfDoc = new XmlDocument();
+        ovfDoc.Load(ovfUrl.getFile());
+        OvfVmReader reader =
+                new OvfVmReader(ovfDoc,
+                        vm,
+                        disks,
+                        new ArrayList<VmNetworkInterface>());
+        reader.BuildReference();
+        reader.BuildDisk();
+        reader.BuildVirtualSystem();
+        reader.FixDiskAliases();
+
+        Set<Integer> expectedIndexes =
+                new HashSet<Integer>(Arrays.asList(ArrayUtils.toObject(new 
IntRange(1, disks.size()).toArray())));
+        for (DiskImage disk : disks) {
+            assertTrue("wrong alias " + disk.getDiskAlias(), 
disk.getDiskAlias().startsWith(expectedDiskAliasPrefix));
+            String suffix = 
disk.getDiskAlias().substring(expectedDiskAliasPrefix.length());
+            Integer suffixInteger = Integer.valueOf(suffix);
+            assertTrue("suffix " + suffix + " not expected", 
expectedIndexes.remove(suffixInteger));
+        }
+
+        assertTrue("Did not encounter all suffixes", 
expectedIndexes.isEmpty());
+    }
+}
diff --git 
a/backend/manager/modules/utils/src/test/resources/ovfs/vm_with_disk_aliases.ovf
 
b/backend/manager/modules/utils/src/test/resources/ovfs/vm_with_disk_aliases.ovf
new file mode 100644
index 0000000..086ccef
--- /dev/null
+++ 
b/backend/manager/modules/utils/src/test/resources/ovfs/vm_with_disk_aliases.ovf
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ovf:Envelope xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1/"; 
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData";
 
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData";
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; ovf:version="3.2.0.0">
+  <References>
+    <File 
ovf:href="7e56e28f-b57b-4b1a-a79f-775c91cf0089/aea4f567-620b-43c7-8fad-048bba92e12e"
 ovf:id="aea4f567-620b-43c7-8fad-048bba92e12e" ovf:size="1073741824" 
ovf:description="Active VM"/>
+    <File 
ovf:href="2377179a-acf4-43e4-acda-40815a97ac13/13e67f08-f289-4894-8bfd-0617c0ecf035"
 ovf:id="13e67f08-f289-4894-8bfd-0617c0ecf035" ovf:size="1073741824" 
ovf:description="Active VM"/>
+    <File 
ovf:href="ce56655a-9b17-400e-beeb-b61f54fddead/cbe20636-ea6b-4cca-a740-9d831eec0431"
 ovf:id="cbe20636-ea6b-4cca-a740-9d831eec0431" ovf:size="1073741824" 
ovf:description="Active VM"/>
+    <File 
ovf:href="eda6f6f5-ebaa-4d85-9ec5-efa14bf81c7d/c60d67ef-67b9-439f-97a3-9b3935882e2d"
 ovf:id="c60d67ef-67b9-439f-97a3-9b3935882e2d" ovf:size="1073741824" 
ovf:description="Active VM"/>
+  </References>
+  <Section xsi:type="ovf:NetworkSection_Type">
+    <Info>List of networks</Info>
+    <Network ovf:name="Network 1"/>
+  </Section>
+  <Section xsi:type="ovf:DiskSection_Type">
+    <Info>List of Virtual Disks</Info>
+    <Disk ovf:diskId="aea4f567-620b-43c7-8fad-048bba92e12e" ovf:size="1" 
ovf:actual_size="0" ovf:vm_snapshot_id="ca8128e0-abd3-472c-9208-727a33e3605b" 
ovf:parentRef="" 
ovf:fileRef="7e56e28f-b57b-4b1a-a79f-775c91cf0089/aea4f567-620b-43c7-8fad-048bba92e12e"
 ovf:format="http://www.vmware.com/specifications/vmdk.html#sparse"; 
ovf:volume-format="RAW" ovf:volume-type="Sparse" ovf:disk-interface="VirtIO" 
ovf:boot="false" ovf:disk-alias="someAlias1" ovf:wipe-after-delete="false"/>
+    <Disk ovf:diskId="13e67f08-f289-4894-8bfd-0617c0ecf035" ovf:size="1" 
ovf:actual_size="0" ovf:vm_snapshot_id="ca8128e0-abd3-472c-9208-727a33e3605b" 
ovf:parentRef="" 
ovf:fileRef="2377179a-acf4-43e4-acda-40815a97ac13/13e67f08-f289-4894-8bfd-0617c0ecf035"
 ovf:format="http://www.vmware.com/specifications/vmdk.html#sparse"; 
ovf:volume-format="RAW" ovf:volume-type="Sparse" ovf:disk-interface="VirtIO" 
ovf:boot="false" ovf:disk-alias="someAlias2" ovf:wipe-after-delete="false"/>
+    <Disk ovf:diskId="cbe20636-ea6b-4cca-a740-9d831eec0431" ovf:size="1" 
ovf:actual_size="0" ovf:vm_snapshot_id="ca8128e0-abd3-472c-9208-727a33e3605b" 
ovf:parentRef="" 
ovf:fileRef="ce56655a-9b17-400e-beeb-b61f54fddead/cbe20636-ea6b-4cca-a740-9d831eec0431"
 ovf:format="http://www.vmware.com/specifications/vmdk.html#sparse"; 
ovf:volume-format="RAW" ovf:volume-type="Sparse" ovf:disk-interface="VirtIO" 
ovf:boot="true" ovf:disk-alias="someAlias3" ovf:wipe-after-delete="false"/>
+    <Disk ovf:diskId="c60d67ef-67b9-439f-97a3-9b3935882e2d" ovf:size="1" 
ovf:actual_size="0" ovf:vm_snapshot_id="ca8128e0-abd3-472c-9208-727a33e3605b" 
ovf:parentRef="" 
ovf:fileRef="eda6f6f5-ebaa-4d85-9ec5-efa14bf81c7d/c60d67ef-67b9-439f-97a3-9b3935882e2d"
 ovf:format="http://www.vmware.com/specifications/vmdk.html#sparse"; 
ovf:volume-format="RAW" ovf:volume-type="Sparse" ovf:disk-interface="VirtIO" 
ovf:boot="false" ovf:disk-alias="someAlias4" ovf:wipe-after-delete="false"/>
+  </Section>
+  <Content ovf:id="out" xsi:type="ovf:VirtualSystem_Type">
+    <Description/>
+    <Domain/>
+    <CreationDate>2012/11/15 14:10:52</CreationDate>
+    <ExportDate>2012/11/18 08:26:34</ExportDate>
+    <IsAutoSuspend>false</IsAutoSuspend>
+    <IsSmartcardEnabled>false</IsSmartcardEnabled>
+    <TimeZone>Etc/GMT+12</TimeZone>
+    <default_boot_sequence>0</default_boot_sequence>
+    <VmType>1</VmType>
+    <Name>vm1</Name>
+    <TemplateId>00000000-0000-0000-0000-000000000000</TemplateId>
+    <TemplateName>Blank</TemplateName>
+    <IsInitilized>false</IsInitilized>
+    <IsStateless>false</IsStateless>
+    <Origin>3</Origin>
+    <quota_id>00000000-0000-0000-0000-000000000000</quota_id>
+    <DefaultDisplayType>1</DefaultDisplayType>
+    <MinAllocatedMem>512</MinAllocatedMem>
+    <Section ovf:id="4d19183d-9e72-4185-8a9f-abb6bcfb7783" 
ovf:required="false" xsi:type="ovf:OperatingSystemSection_Type">
+      <Info>Guest Operating System</Info>
+      <Description>Unassigned</Description>
+    </Section>
+    <Section xsi:type="ovf:VirtualHardwareSection_Type">
+      <Info>1 CPU, 512 Memeory</Info>
+      <System>
+        <vssd:VirtualSystemType>ENGINE 3.2.0.0</vssd:VirtualSystemType>
+      </System>
+      <Item>
+        <rasd:Caption>1 virtual cpu</rasd:Caption>
+        <rasd:Description>Number of virtual CPU</rasd:Description>
+        <rasd:InstanceId>1</rasd:InstanceId>
+        <rasd:ResourceType>3</rasd:ResourceType>
+        <rasd:num_of_sockets>1</rasd:num_of_sockets>
+        <rasd:cpu_per_socket>1</rasd:cpu_per_socket>
+      </Item>
+      <Item>
+        <rasd:Caption>512 MB of memory</rasd:Caption>
+        <rasd:Description>Memory Size</rasd:Description>
+        <rasd:InstanceId>2</rasd:InstanceId>
+        <rasd:ResourceType>4</rasd:ResourceType>
+        <rasd:AllocationUnits>MegaBytes</rasd:AllocationUnits>
+        <rasd:VirtualQuantity>512</rasd:VirtualQuantity>
+      </Item>
+      <Item>
+        <rasd:Caption>vm1_Disk2</rasd:Caption>
+        <rasd:InstanceId>aea4f567-620b-43c7-8fad-048bba92e12e</rasd:InstanceId>
+        <rasd:ResourceType>17</rasd:ResourceType>
+        
<rasd:HostResource>7e56e28f-b57b-4b1a-a79f-775c91cf0089/aea4f567-620b-43c7-8fad-048bba92e12e</rasd:HostResource>
+        <rasd:Parent>00000000-0000-0000-0000-000000000000</rasd:Parent>
+        <rasd:Template>00000000-0000-0000-0000-000000000000</rasd:Template>
+        <rasd:ApplicationList/>
+        <rasd:StorageId>06c1beeb-e517-422b-b368-83b30ba5c8b8</rasd:StorageId>
+        
<rasd:StoragePoolId>7b897695-9e6d-4b62-aa53-b5e5827109a3</rasd:StoragePoolId>
+        <rasd:CreationDate>2012/11/15 14:11:32</rasd:CreationDate>
+        <rasd:LastModified>2012/11/15 14:11:32</rasd:LastModified>
+        <rasd:last_modified_date>2012/11/18 08:26:34</rasd:last_modified_date>
+        <Type>disk</Type>
+        <Device>disk</Device>
+        <rasd:Address/>
+        <BootOrder>0</BootOrder>
+        <IsPlugged>true</IsPlugged>
+        <IsReadOnly>false</IsReadOnly>
+        <Alias/>
+      </Item>
+      <Item>
+        <rasd:Caption>vm1_Disk3</rasd:Caption>
+        <rasd:InstanceId>13e67f08-f289-4894-8bfd-0617c0ecf035</rasd:InstanceId>
+        <rasd:ResourceType>17</rasd:ResourceType>
+        
<rasd:HostResource>2377179a-acf4-43e4-acda-40815a97ac13/13e67f08-f289-4894-8bfd-0617c0ecf035</rasd:HostResource>
+        <rasd:Parent>00000000-0000-0000-0000-000000000000</rasd:Parent>
+        <rasd:Template>00000000-0000-0000-0000-000000000000</rasd:Template>
+        <rasd:ApplicationList/>
+        <rasd:StorageId>06c1beeb-e517-422b-b368-83b30ba5c8b8</rasd:StorageId>
+        
<rasd:StoragePoolId>7b897695-9e6d-4b62-aa53-b5e5827109a3</rasd:StoragePoolId>
+        <rasd:CreationDate>2012/11/15 14:12:12</rasd:CreationDate>
+        <rasd:LastModified>2012/11/15 14:12:12</rasd:LastModified>
+        <rasd:last_modified_date>2012/11/18 08:26:34</rasd:last_modified_date>
+        <Type>disk</Type>
+        <Device>disk</Device>
+        <rasd:Address/>
+        <BootOrder>0</BootOrder>
+        <IsPlugged>true</IsPlugged>
+        <IsReadOnly>false</IsReadOnly>
+        <Alias/>
+      </Item>
+      <Item>
+        <rasd:Caption>vm1_Disk1</rasd:Caption>
+        <rasd:InstanceId>cbe20636-ea6b-4cca-a740-9d831eec0431</rasd:InstanceId>
+        <rasd:ResourceType>17</rasd:ResourceType>
+        
<rasd:HostResource>ce56655a-9b17-400e-beeb-b61f54fddead/cbe20636-ea6b-4cca-a740-9d831eec0431</rasd:HostResource>
+        <rasd:Parent>00000000-0000-0000-0000-000000000000</rasd:Parent>
+        <rasd:Template>00000000-0000-0000-0000-000000000000</rasd:Template>
+        <rasd:ApplicationList/>
+        <rasd:StorageId>06c1beeb-e517-422b-b368-83b30ba5c8b8</rasd:StorageId>
+        
<rasd:StoragePoolId>7b897695-9e6d-4b62-aa53-b5e5827109a3</rasd:StoragePoolId>
+        <rasd:CreationDate>2012/11/15 14:11:24</rasd:CreationDate>
+        <rasd:LastModified>2012/11/15 14:11:24</rasd:LastModified>
+        <rasd:last_modified_date>2012/11/18 08:26:34</rasd:last_modified_date>
+        <Type>disk</Type>
+        <Device>disk</Device>
+        <rasd:Address/>
+        <BootOrder>1</BootOrder>
+        <IsPlugged>true</IsPlugged>
+        <IsReadOnly>false</IsReadOnly>
+        <Alias/>
+      </Item>
+      <Item>
+        <rasd:Caption>vm1_Disk4</rasd:Caption>
+        <rasd:InstanceId>c60d67ef-67b9-439f-97a3-9b3935882e2d</rasd:InstanceId>
+        <rasd:ResourceType>17</rasd:ResourceType>
+        
<rasd:HostResource>eda6f6f5-ebaa-4d85-9ec5-efa14bf81c7d/c60d67ef-67b9-439f-97a3-9b3935882e2d</rasd:HostResource>
+        <rasd:Parent>00000000-0000-0000-0000-000000000000</rasd:Parent>
+        <rasd:Template>00000000-0000-0000-0000-000000000000</rasd:Template>
+        <rasd:ApplicationList/>
+        <rasd:StorageId>06c1beeb-e517-422b-b368-83b30ba5c8b8</rasd:StorageId>
+        
<rasd:StoragePoolId>7b897695-9e6d-4b62-aa53-b5e5827109a3</rasd:StoragePoolId>
+        <rasd:CreationDate>2012/11/15 14:13:03</rasd:CreationDate>
+        <rasd:LastModified>2012/11/15 14:13:03</rasd:LastModified>
+        <rasd:last_modified_date>2012/11/18 08:26:34</rasd:last_modified_date>
+        <Type>disk</Type>
+        <Device>disk</Device>
+        <rasd:Address/>
+        <BootOrder>0</BootOrder>
+        <IsPlugged>true</IsPlugged>
+        <IsReadOnly>false</IsReadOnly>
+        <Alias/>
+      </Item>
+      <Item>
+        <rasd:Caption>USB Controller</rasd:Caption>
+        <rasd:InstanceId>3</rasd:InstanceId>
+        <rasd:ResourceType>23</rasd:ResourceType>
+        <rasd:UsbPolicy>DISABLED</rasd:UsbPolicy>
+      </Item>
+      <Item>
+        <rasd:Caption>Graphical Controller</rasd:Caption>
+        <rasd:InstanceId>ebd1dd4a-015c-4a02-9fb5-3feff33811e4</rasd:InstanceId>
+        <rasd:ResourceType>20</rasd:ResourceType>
+        <rasd:VirtualQuantity>1</rasd:VirtualQuantity>
+        <Type>video</Type>
+        <Device>qxl</Device>
+        <rasd:Address/>
+        <BootOrder>0</BootOrder>
+        <IsPlugged>true</IsPlugged>
+        <IsReadOnly>true</IsReadOnly>
+        <Alias/>
+        <SpecParams>
+          <vram>65536</vram>
+        </SpecParams>
+      </Item>
+      <Item>
+        <rasd:ResourceType>0</rasd:ResourceType>
+        <rasd:InstanceId>cc714556-ef46-4607-9791-28e13b57d1c0</rasd:InstanceId>
+        <Type>balloon</Type>
+        <Device>memballoon</Device>
+        <rasd:Address/>
+        <BootOrder>0</BootOrder>
+        <IsPlugged>true</IsPlugged>
+        <IsReadOnly>true</IsReadOnly>
+        <Alias/>
+        <SpecParams>
+          <model>virtio</model>
+        </SpecParams>
+      </Item>
+    </Section>
+    <Section xsi:type="ovf:SnapshotsSection_Type">
+      <Snapshot ovf:id="ca8128e0-abd3-472c-9208-727a33e3605b">
+        <Type>ACTIVE</Type>
+        <Description>Active VM</Description>
+        <CreationDate>2012/11/15 14:11:35</CreationDate>
+      </Snapshot>
+    </Section>
+  </Content>
+</ovf:Envelope>
diff --git 
a/backend/manager/modules/utils/src/test/resources/ovfs/vm_without_disk_aliases.ovf
 
b/backend/manager/modules/utils/src/test/resources/ovfs/vm_without_disk_aliases.ovf
new file mode 100644
index 0000000..2faffc6
--- /dev/null
+++ 
b/backend/manager/modules/utils/src/test/resources/ovfs/vm_without_disk_aliases.ovf
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ovf:Envelope xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1/"; 
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData";
 
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData";
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; ovf:version="3.2.0.0">
+  <References>
+    <File 
ovf:href="7e56e28f-b57b-4b1a-a79f-775c91cf0089/aea4f567-620b-43c7-8fad-048bba92e12e"
 ovf:id="aea4f567-620b-43c7-8fad-048bba92e12e" ovf:size="1073741824" 
ovf:description="Active VM"/>
+    <File 
ovf:href="2377179a-acf4-43e4-acda-40815a97ac13/13e67f08-f289-4894-8bfd-0617c0ecf035"
 ovf:id="13e67f08-f289-4894-8bfd-0617c0ecf035" ovf:size="1073741824" 
ovf:description="Active VM"/>
+    <File 
ovf:href="ce56655a-9b17-400e-beeb-b61f54fddead/cbe20636-ea6b-4cca-a740-9d831eec0431"
 ovf:id="cbe20636-ea6b-4cca-a740-9d831eec0431" ovf:size="1073741824" 
ovf:description="Active VM"/>
+    <File 
ovf:href="eda6f6f5-ebaa-4d85-9ec5-efa14bf81c7d/c60d67ef-67b9-439f-97a3-9b3935882e2d"
 ovf:id="c60d67ef-67b9-439f-97a3-9b3935882e2d" ovf:size="1073741824" 
ovf:description="Active VM"/>
+  </References>
+  <Section xsi:type="ovf:NetworkSection_Type">
+    <Info>List of networks</Info>
+    <Network ovf:name="Network 1"/>
+  </Section>
+  <Section xsi:type="ovf:DiskSection_Type">
+    <Info>List of Virtual Disks</Info>
+    <Disk ovf:diskId="aea4f567-620b-43c7-8fad-048bba92e12e" ovf:size="1" 
ovf:actual_size="0" ovf:vm_snapshot_id="ca8128e0-abd3-472c-9208-727a33e3605b" 
ovf:parentRef="" 
ovf:fileRef="7e56e28f-b57b-4b1a-a79f-775c91cf0089/aea4f567-620b-43c7-8fad-048bba92e12e"
 ovf:format="http://www.vmware.com/specifications/vmdk.html#sparse"; 
ovf:volume-format="RAW" ovf:volume-type="Sparse" ovf:disk-interface="VirtIO" 
ovf:boot="false" ovf:wipe-after-delete="false"/>
+    <Disk ovf:diskId="13e67f08-f289-4894-8bfd-0617c0ecf035" ovf:size="1" 
ovf:actual_size="0" ovf:vm_snapshot_id="ca8128e0-abd3-472c-9208-727a33e3605b" 
ovf:parentRef="" 
ovf:fileRef="2377179a-acf4-43e4-acda-40815a97ac13/13e67f08-f289-4894-8bfd-0617c0ecf035"
 ovf:format="http://www.vmware.com/specifications/vmdk.html#sparse"; 
ovf:volume-format="RAW" ovf:volume-type="Sparse" ovf:disk-interface="VirtIO" 
ovf:boot="false" ovf:wipe-after-delete="false"/>
+    <Disk ovf:diskId="cbe20636-ea6b-4cca-a740-9d831eec0431" ovf:size="1" 
ovf:actual_size="0" ovf:vm_snapshot_id="ca8128e0-abd3-472c-9208-727a33e3605b" 
ovf:parentRef="" 
ovf:fileRef="ce56655a-9b17-400e-beeb-b61f54fddead/cbe20636-ea6b-4cca-a740-9d831eec0431"
 ovf:format="http://www.vmware.com/specifications/vmdk.html#sparse"; 
ovf:volume-format="RAW" ovf:volume-type="Sparse" ovf:disk-interface="VirtIO" 
ovf:boot="true" ovf:wipe-after-delete="false"/>
+    <Disk ovf:diskId="c60d67ef-67b9-439f-97a3-9b3935882e2d" ovf:size="1" 
ovf:actual_size="0" ovf:vm_snapshot_id="ca8128e0-abd3-472c-9208-727a33e3605b" 
ovf:parentRef="" 
ovf:fileRef="eda6f6f5-ebaa-4d85-9ec5-efa14bf81c7d/c60d67ef-67b9-439f-97a3-9b3935882e2d"
 ovf:format="http://www.vmware.com/specifications/vmdk.html#sparse"; 
ovf:volume-format="RAW" ovf:volume-type="Sparse" ovf:disk-interface="VirtIO" 
ovf:boot="false" ovf:wipe-after-delete="false"/>
+  </Section>
+  <Content ovf:id="out" xsi:type="ovf:VirtualSystem_Type">
+    <Description/>
+    <Domain/>
+    <CreationDate>2012/11/15 14:10:52</CreationDate>
+    <ExportDate>2012/11/18 08:26:34</ExportDate>
+    <IsAutoSuspend>false</IsAutoSuspend>
+    <IsSmartcardEnabled>false</IsSmartcardEnabled>
+    <TimeZone>Etc/GMT+12</TimeZone>
+    <default_boot_sequence>0</default_boot_sequence>
+    <VmType>1</VmType>
+    <Name>vm1</Name>
+    <TemplateId>00000000-0000-0000-0000-000000000000</TemplateId>
+    <TemplateName>Blank</TemplateName>
+    <IsInitilized>false</IsInitilized>
+    <IsStateless>false</IsStateless>
+    <Origin>3</Origin>
+    <quota_id>00000000-0000-0000-0000-000000000000</quota_id>
+    <DefaultDisplayType>1</DefaultDisplayType>
+    <MinAllocatedMem>512</MinAllocatedMem>
+    <Section ovf:id="4d19183d-9e72-4185-8a9f-abb6bcfb7783" 
ovf:required="false" xsi:type="ovf:OperatingSystemSection_Type">
+      <Info>Guest Operating System</Info>
+      <Description>Unassigned</Description>
+    </Section>
+    <Section xsi:type="ovf:VirtualHardwareSection_Type">
+      <Info>1 CPU, 512 Memeory</Info>
+      <System>
+        <vssd:VirtualSystemType>ENGINE 3.2.0.0</vssd:VirtualSystemType>
+      </System>
+      <Item>
+        <rasd:Caption>1 virtual cpu</rasd:Caption>
+        <rasd:Description>Number of virtual CPU</rasd:Description>
+        <rasd:InstanceId>1</rasd:InstanceId>
+        <rasd:ResourceType>3</rasd:ResourceType>
+        <rasd:num_of_sockets>1</rasd:num_of_sockets>
+        <rasd:cpu_per_socket>1</rasd:cpu_per_socket>
+      </Item>
+      <Item>
+        <rasd:Caption>512 MB of memory</rasd:Caption>
+        <rasd:Description>Memory Size</rasd:Description>
+        <rasd:InstanceId>2</rasd:InstanceId>
+        <rasd:ResourceType>4</rasd:ResourceType>
+        <rasd:AllocationUnits>MegaBytes</rasd:AllocationUnits>
+        <rasd:VirtualQuantity>512</rasd:VirtualQuantity>
+      </Item>
+      <Item>
+        <rasd:Caption>vm1_Disk2</rasd:Caption>
+        <rasd:InstanceId>aea4f567-620b-43c7-8fad-048bba92e12e</rasd:InstanceId>
+        <rasd:ResourceType>17</rasd:ResourceType>
+        
<rasd:HostResource>7e56e28f-b57b-4b1a-a79f-775c91cf0089/aea4f567-620b-43c7-8fad-048bba92e12e</rasd:HostResource>
+        <rasd:Parent>00000000-0000-0000-0000-000000000000</rasd:Parent>
+        <rasd:Template>00000000-0000-0000-0000-000000000000</rasd:Template>
+        <rasd:ApplicationList/>
+        <rasd:StorageId>06c1beeb-e517-422b-b368-83b30ba5c8b8</rasd:StorageId>
+        
<rasd:StoragePoolId>7b897695-9e6d-4b62-aa53-b5e5827109a3</rasd:StoragePoolId>
+        <rasd:CreationDate>2012/11/15 14:11:32</rasd:CreationDate>
+        <rasd:LastModified>2012/11/15 14:11:32</rasd:LastModified>
+        <rasd:last_modified_date>2012/11/18 08:26:34</rasd:last_modified_date>
+        <Type>disk</Type>
+        <Device>disk</Device>
+        <rasd:Address/>
+        <BootOrder>0</BootOrder>
+        <IsPlugged>true</IsPlugged>
+        <IsReadOnly>false</IsReadOnly>
+        <Alias/>
+      </Item>
+      <Item>
+        <rasd:Caption>vm1_Disk3</rasd:Caption>
+        <rasd:InstanceId>13e67f08-f289-4894-8bfd-0617c0ecf035</rasd:InstanceId>
+        <rasd:ResourceType>17</rasd:ResourceType>
+        
<rasd:HostResource>2377179a-acf4-43e4-acda-40815a97ac13/13e67f08-f289-4894-8bfd-0617c0ecf035</rasd:HostResource>
+        <rasd:Parent>00000000-0000-0000-0000-000000000000</rasd:Parent>
+        <rasd:Template>00000000-0000-0000-0000-000000000000</rasd:Template>
+        <rasd:ApplicationList/>
+        <rasd:StorageId>06c1beeb-e517-422b-b368-83b30ba5c8b8</rasd:StorageId>
+        
<rasd:StoragePoolId>7b897695-9e6d-4b62-aa53-b5e5827109a3</rasd:StoragePoolId>
+        <rasd:CreationDate>2012/11/15 14:12:12</rasd:CreationDate>
+        <rasd:LastModified>2012/11/15 14:12:12</rasd:LastModified>
+        <rasd:last_modified_date>2012/11/18 08:26:34</rasd:last_modified_date>
+        <Type>disk</Type>
+        <Device>disk</Device>
+        <rasd:Address/>
+        <BootOrder>0</BootOrder>
+        <IsPlugged>true</IsPlugged>
+        <IsReadOnly>false</IsReadOnly>
+        <Alias/>
+      </Item>
+      <Item>
+        <rasd:Caption>vm1_Disk1</rasd:Caption>
+        <rasd:InstanceId>cbe20636-ea6b-4cca-a740-9d831eec0431</rasd:InstanceId>
+        <rasd:ResourceType>17</rasd:ResourceType>
+        
<rasd:HostResource>ce56655a-9b17-400e-beeb-b61f54fddead/cbe20636-ea6b-4cca-a740-9d831eec0431</rasd:HostResource>
+        <rasd:Parent>00000000-0000-0000-0000-000000000000</rasd:Parent>
+        <rasd:Template>00000000-0000-0000-0000-000000000000</rasd:Template>
+        <rasd:ApplicationList/>
+        <rasd:StorageId>06c1beeb-e517-422b-b368-83b30ba5c8b8</rasd:StorageId>
+        
<rasd:StoragePoolId>7b897695-9e6d-4b62-aa53-b5e5827109a3</rasd:StoragePoolId>
+        <rasd:CreationDate>2012/11/15 14:11:24</rasd:CreationDate>
+        <rasd:LastModified>2012/11/15 14:11:24</rasd:LastModified>
+        <rasd:last_modified_date>2012/11/18 08:26:34</rasd:last_modified_date>
+        <Type>disk</Type>
+        <Device>disk</Device>
+        <rasd:Address/>
+        <BootOrder>1</BootOrder>
+        <IsPlugged>true</IsPlugged>
+        <IsReadOnly>false</IsReadOnly>
+        <Alias/>
+      </Item>
+      <Item>
+        <rasd:Caption>vm1_Disk4</rasd:Caption>
+        <rasd:InstanceId>c60d67ef-67b9-439f-97a3-9b3935882e2d</rasd:InstanceId>
+        <rasd:ResourceType>17</rasd:ResourceType>
+        
<rasd:HostResource>eda6f6f5-ebaa-4d85-9ec5-efa14bf81c7d/c60d67ef-67b9-439f-97a3-9b3935882e2d</rasd:HostResource>
+        <rasd:Parent>00000000-0000-0000-0000-000000000000</rasd:Parent>
+        <rasd:Template>00000000-0000-0000-0000-000000000000</rasd:Template>
+        <rasd:ApplicationList/>
+        <rasd:StorageId>06c1beeb-e517-422b-b368-83b30ba5c8b8</rasd:StorageId>
+        
<rasd:StoragePoolId>7b897695-9e6d-4b62-aa53-b5e5827109a3</rasd:StoragePoolId>
+        <rasd:CreationDate>2012/11/15 14:13:03</rasd:CreationDate>
+        <rasd:LastModified>2012/11/15 14:13:03</rasd:LastModified>
+        <rasd:last_modified_date>2012/11/18 08:26:34</rasd:last_modified_date>
+        <Type>disk</Type>
+        <Device>disk</Device>
+        <rasd:Address/>
+        <BootOrder>0</BootOrder>
+        <IsPlugged>true</IsPlugged>
+        <IsReadOnly>false</IsReadOnly>
+        <Alias/>
+      </Item>
+      <Item>
+        <rasd:Caption>USB Controller</rasd:Caption>
+        <rasd:InstanceId>3</rasd:InstanceId>
+        <rasd:ResourceType>23</rasd:ResourceType>
+        <rasd:UsbPolicy>DISABLED</rasd:UsbPolicy>
+      </Item>
+      <Item>
+        <rasd:Caption>Graphical Controller</rasd:Caption>
+        <rasd:InstanceId>ebd1dd4a-015c-4a02-9fb5-3feff33811e4</rasd:InstanceId>
+        <rasd:ResourceType>20</rasd:ResourceType>
+        <rasd:VirtualQuantity>1</rasd:VirtualQuantity>
+        <Type>video</Type>
+        <Device>qxl</Device>
+        <rasd:Address/>
+        <BootOrder>0</BootOrder>
+        <IsPlugged>true</IsPlugged>
+        <IsReadOnly>true</IsReadOnly>
+        <Alias/>
+        <SpecParams>
+          <vram>65536</vram>
+        </SpecParams>
+      </Item>
+      <Item>
+        <rasd:ResourceType>0</rasd:ResourceType>
+        <rasd:InstanceId>cc714556-ef46-4607-9791-28e13b57d1c0</rasd:InstanceId>
+        <Type>balloon</Type>
+        <Device>memballoon</Device>
+        <rasd:Address/>
+        <BootOrder>0</BootOrder>
+        <IsPlugged>true</IsPlugged>
+        <IsReadOnly>true</IsReadOnly>
+        <Alias/>
+        <SpecParams>
+          <model>virtio</model>
+        </SpecParams>
+      </Item>
+    </Section>
+    <Section xsi:type="ovf:SnapshotsSection_Type">
+      <Snapshot ovf:id="ca8128e0-abd3-472c-9208-727a33e3605b">
+        <Type>ACTIVE</Type>
+        <Description>Active VM</Description>
+        <CreationDate>2012/11/15 14:11:35</CreationDate>
+      </Snapshot>
+    </Section>
+  </Content>
+</ovf:Envelope>


--
To view, visit http://gerrit.ovirt.org/9308
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I38ad9c56f9b97e174807d3fcbe0b3e43355803ee
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Allon Mureinik <amure...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to