Search in sources :

Example 16 with FullEntityOvfData

use of org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData in project ovirt-engine by oVirt.

the class OvfManagerTest method testVmOvfImportWithoutDbGeneration.

@Test
public void testVmOvfImportWithoutDbGeneration() throws Exception {
    VM vm = createVM();
    String xml = manager.exportVm(vm, new FullEntityOvfData(vm), Version.v3_6);
    assertNotNull(xml);
    final VM newVm = new VM();
    assertTrue(xml.contains("Generation"));
    String replacedXml = xml.replaceAll("Generation", "test_replaced");
    FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(newVm);
    manager.importVm(replacedXml, newVm, fullEntityOvfData);
    assertVm(vm, newVm, 1);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) Test(org.junit.Test)

Example 17 with FullEntityOvfData

use of org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData in project ovirt-engine by oVirt.

the class OvfManagerTest method serializeAndDeserialize.

private VM serializeAndDeserialize(VM inputVm) throws OvfReaderException {
    String xml = manager.exportVm(inputVm, new FullEntityOvfData(inputVm), Version.v3_6);
    assertNotNull(xml);
    final VM resultVm = new VM();
    assertTrue(xml.contains("Generation"));
    String replacedXml = xml.replaceAll("Generation", "test_replaced");
    FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(resultVm);
    manager.importVm(replacedXml, resultVm, fullEntityOvfData);
    return resultVm;
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData)

Example 18 with FullEntityOvfData

use of org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData in project ovirt-engine by oVirt.

the class OvfManagerTest method testTemplateOvfCreation.

@Test
public void testTemplateOvfCreation() throws Exception {
    VmTemplate template = createVmTemplate();
    String xml = manager.exportTemplate(new FullEntityOvfData(template), Version.v3_6);
    assertNotNull(xml);
    final VmTemplate newtemplate = new VmTemplate();
    FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(newtemplate);
    manager.importTemplate(xml, fullEntityOvfData);
    assertEquals("imported template is different than expected", newtemplate, template);
    assertEquals("imported db generation is different than expected", template.getDbGeneration(), newtemplate.getDbGeneration());
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) Test(org.junit.Test)

Example 19 with FullEntityOvfData

use of org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData in project ovirt-engine by oVirt.

the class OvfManagerTest method testVmExportAndImportIdentical.

@Test
public void testVmExportAndImportIdentical() throws Exception {
    VM vm = createVM();
    ArrayList<DiskImage> disks = createDisksAndDiskVmElements(vm);
    FullEntityOvfData fullEntityOvfDataForExport = new FullEntityOvfData(vm);
    fullEntityOvfDataForExport.setDiskImages(disks);
    String xml = manager.exportVm(vm, fullEntityOvfDataForExport, Version.v4_0);
    assertNotNull(xml);
    VM newVm = new VM();
    FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(newVm);
    manager.importVm(xml, newVm, fullEntityOvfData);
    assertVm(vm, newVm, vm.getDbGeneration());
    assertCollection(vm.getInterfaces(), fullEntityOvfData.getInterfaces());
    assertCollection(disks, fullEntityOvfData.getDiskImages(), diskPair -> diskPair.getFirst().getDiskVmElementForVm(vm.getId()).equals(diskPair.getSecond().getDiskVmElementForVm(vm.getId())));
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Example 20 with FullEntityOvfData

use of org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData in project ovirt-engine by oVirt.

the class OvfManagerTest method testVmExportAndImportAndExportAgainSymmetrical.

@Test
public void testVmExportAndImportAndExportAgainSymmetrical() throws Exception {
    VM vm = createVM();
    ArrayList<DiskImage> disks = createDisksAndDiskVmElements(vm);
    FullEntityOvfData fullEntityOvfDataForExport = new FullEntityOvfData(vm);
    fullEntityOvfDataForExport.setDiskImages(disks);
    String xml = manager.exportVm(vm, fullEntityOvfDataForExport, Version.v4_0);
    assertNotNull(xml);
    VM newVm = new VM();
    FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(newVm);
    manager.importVm(xml, newVm, fullEntityOvfData);
    FullEntityOvfData fullEntityOvfDataForExportResult = new FullEntityOvfData(vm);
    fullEntityOvfDataForExportResult.setDiskImages(disks);
    String newXml = manager.exportVm(vm, fullEntityOvfDataForExportResult, Version.v4_0);
    assertEquals(deleteExportDateValueFromXml(xml), deleteExportDateValueFromXml(newXml));
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Aggregations

FullEntityOvfData (org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData)27 VM (org.ovirt.engine.core.common.businessentities.VM)17 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)13 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 Guid (org.ovirt.engine.core.compat.Guid)7 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)6 HashMap (java.util.HashMap)5 OvfReaderException (org.ovirt.engine.core.utils.ovf.OvfReaderException)5 OvfEntityData (org.ovirt.engine.core.common.businessentities.OvfEntityData)4 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)4 KeyValuePairCompat (org.ovirt.engine.core.compat.KeyValuePairCompat)4 HashSet (java.util.HashSet)3 List (java.util.List)2 Map (java.util.Map)2 Before (org.junit.Before)2 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 Label (org.ovirt.engine.core.common.businessentities.Label)2 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)2