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));
}
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));
}
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;
}
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;
}
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;
}
Aggregations