Search in sources :

Example 11 with VmTemplate

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

the class GetUnregisteredVmTemplatesQueryTest method setUpQueryEntities.

private void setUpQueryEntities() throws OvfReaderException {
    // Set up the expected result
    VmTemplate VmTemplateReturnForOvf = new VmTemplate();
    VmTemplateReturnForOvf.setId(newVmTemplateGuid);
    VmTemplateReturnForOvf.setName("Name");
    String ovfData = new String("OVF data for the first Template");
    OvfEntityData ovfEntityData = new OvfEntityData(VmTemplateReturnForOvf.getId(), VmTemplateReturnForOvf.getName(), VmEntityType.TEMPLATE, null, null, storageDomainId, ovfData, null);
    List<OvfEntityData> expectedResult = new ArrayList<>();
    List<OvfEntityData> expectedResultQuery1 = new ArrayList<>();
    expectedResultQuery1.add(ovfEntityData);
    expectedResult.add(ovfEntityData);
    VmTemplate VmTemplateReturnForOvf2 = new VmTemplate();
    VmTemplateReturnForOvf2.setId(newVmTemplateGuid2);
    VmTemplateReturnForOvf2.setName("Name2");
    String ovfData2 = new String("OVF data for the second Template");
    OvfEntityData ovfEntityData2 = new OvfEntityData(VmTemplateReturnForOvf2.getId(), VmTemplateReturnForOvf2.getName(), VmEntityType.TEMPLATE, null, null, storageDomainId, ovfData2, null);
    expectedResult.add(ovfEntityData2);
    List<OvfEntityData> expectedResultQuery2 = new ArrayList<>();
    expectedResultQuery2.add(ovfEntityData);
    // Mock the Daos
    when(unregisteredOVFDataDaoMock.getAllForStorageDomainByEntityType(storageDomainId, entityType)).thenReturn(expectedResult);
    when(unregisteredOVFDataDaoMock.getByEntityIdAndStorageDomain(newVmTemplateGuid, storageDomainId)).thenReturn(expectedResultQuery1);
    when(unregisteredOVFDataDaoMock.getByEntityIdAndStorageDomain(newVmTemplateGuid2, storageDomainId)).thenReturn(expectedResultQuery2);
    // Mock OVF
    when(ovfHelperMock.readVmTemplateFromOvf(ovfData)).thenReturn(new FullEntityOvfData(VmTemplateReturnForOvf));
    when(ovfHelperMock.readVmTemplateFromOvf(ovfData2)).thenReturn(new FullEntityOvfData(VmTemplateReturnForOvf2));
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) OvfEntityData(org.ovirt.engine.core.common.businessentities.OvfEntityData) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData)

Example 12 with VmTemplate

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

the class NetworkValidatorTest method networkInUseByManyTemplates.

@Test
public void networkInUseByManyTemplates() throws Exception {
    VmTemplate template1 = mock(VmTemplate.class);
    when(template1.getName()).thenReturn(NAMEABLE_NAME + 1);
    VmTemplate template2 = mock(VmTemplate.class);
    when(template2.getName()).thenReturn(NAMEABLE_NAME + 2);
    networkNotUsedByTemplatesTest(failsWithManyNetworkInUse(), Arrays.asList(template1, template2));
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Test(org.junit.Test)

Example 13 with VmTemplate

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

the class ProcessOvfUpdateForStoragePoolCommandTest method generateVmTemplatesMapByGuids.

private Map<Guid, VmTemplate> generateVmTemplatesMapByGuids(List<Guid> ids, int diskCount, VmTemplateStatus templateStatus, ImageStatus diskStatus) {
    Map<Guid, VmTemplate> toReturn = new HashMap<>();
    for (Guid id : ids) {
        VmTemplate template = createVmTemplate(id, templateStatus);
        for (int i = 0; i < diskCount; i++) {
            DiskImage image = createDiskImage(diskStatus);
            template.getDiskTemplateMap().put(image.getId(), image);
            template.getDiskList().add(image);
        }
        toReturn.put(template.getId(), template);
    }
    return toReturn;
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 14 with VmTemplate

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

the class ProcessOvfUpdateForStoragePoolCommandTest method createVmTemplate.

private VmTemplate createVmTemplate(Guid id, VmTemplateStatus templateStatus) {
    VmTemplate template = new VmTemplate();
    template.setStatus(templateStatus);
    template.setDbGeneration(1L);
    template.setId(id);
    return template;
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Example 15 with VmTemplate

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

the class Cloner method cloneVmTemplate.

private static VmTemplate cloneVmTemplate(VmTemplate instance) {
    VmTemplate obj = new VmTemplate();
    obj.setStoragePoolId(instance.getStoragePoolId());
    obj.setStoragePoolName(instance.getStoragePoolName());
    obj.setDefaultDisplayType(instance.getDefaultDisplayType());
    obj.setPriority(instance.getPriority());
    obj.setIsoPath(instance.getIsoPath());
    obj.setOrigin(instance.getOrigin());
    // TODO: see comments above on DiskImageMap
    obj.setDiskImageMap(instance.getDiskImageMap());
    obj.setInterfaces(instance.getInterfaces());
    obj.setAutoStartup(instance.isAutoStartup());
    obj.setChildCount(instance.getChildCount());
    obj.setCpuPerSocket(instance.getCpuPerSocket());
    obj.setThreadsPerCpu(instance.getThreadsPerCpu());
    obj.setCreationDate(instance.getCreationDate());
    obj.setDefaultBootSequence(instance.getDefaultBootSequence());
    obj.setComment(instance.getComment());
    obj.setCustomEmulatedMachine(instance.getCustomEmulatedMachine());
    obj.setCustomCpuName(instance.getCustomCpuName());
    obj.setCustomCompatibilityVersion(instance.getCustomCompatibilityVersion());
    obj.setFailBack(instance.isFailBack());
    obj.setStateless(instance.isStateless());
    obj.setMemSizeMb(instance.getMemSizeMb());
    obj.setMaxMemorySizeMb(instance.getMaxMemorySizeMb());
    obj.setName(instance.getName());
    obj.setNiceLevel(instance.getNiceLevel());
    obj.setNumOfMonitors(instance.getNumOfMonitors());
    obj.setAllowConsoleReconnect(instance.isAllowConsoleReconnect());
    obj.setNumOfSockets(instance.getNumOfSockets());
    obj.setStatus(instance.getStatus());
    obj.setTimeZone(instance.getTimeZone());
    obj.setUsbPolicy(instance.getUsbPolicy());
    obj.setClusterId(instance.getClusterId());
    obj.setClusterName(instance.getClusterName());
    obj.setClusterCompatibilityVersion(instance.getClusterCompatibilityVersion());
    obj.setVmType(instance.getVmType());
    obj.setId(instance.getId());
    obj.setDiskList(instance.getDiskList());
    obj.setRunAndPause(instance.isRunAndPause());
    obj.setClusterArch(instance.getClusterArch());
    obj.setTemplateVersionNumber(instance.getTemplateVersionNumber());
    obj.setBaseTemplateId(instance.getBaseTemplateId());
    obj.setTemplateVersionName(instance.getTemplateVersionName());
    obj.setSerialNumberPolicy(instance.getSerialNumberPolicy());
    obj.setCustomSerialNumber(instance.getCustomSerialNumber());
    obj.setBootMenuEnabled(instance.isBootMenuEnabled());
    obj.setCreatedByUserId(instance.getCreatedByUserId());
    obj.setSpiceFileTransferEnabled(instance.isSpiceFileTransferEnabled());
    obj.setSpiceCopyPasteEnabled(instance.isSpiceCopyPasteEnabled());
    obj.setCpuProfileId(instance.getCpuProfileId());
    obj.setAutoConverge(instance.getAutoConverge());
    obj.setMigrateCompressed(instance.getMigrateCompressed());
    obj.setPredefinedProperties(instance.getPredefinedProperties());
    obj.setUserDefinedProperties(instance.getUserDefinedProperties());
    obj.setCustomProperties(instance.getCustomProperties());
    obj.setSmallIconId(instance.getSmallIconId());
    obj.setLargeIconId(instance.getLargeIconId());
    return obj;
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Aggregations

VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)149 ArrayList (java.util.ArrayList)42 Guid (org.ovirt.engine.core.compat.Guid)40 Test (org.junit.Test)30 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)23 HashMap (java.util.HashMap)22 List (java.util.List)20 VM (org.ovirt.engine.core.common.businessentities.VM)19 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)16 Map (java.util.Map)13 QueryType (org.ovirt.engine.core.common.queries.QueryType)13 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)12 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)11 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)11 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)11 Frontend (org.ovirt.engine.ui.frontend.Frontend)10 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)9 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)9 Collection (java.util.Collection)8 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)8