use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class SnapshotsManager method generateVmConfiguration.
/**
* Generate a string containing the given VM's configuration.
*
* @param vm
* The VM to generate configuration from.
* @return A String containing the VM configuration.
*/
protected String generateVmConfiguration(VM vm, List<DiskImage> disks, Map<Guid, VmDevice> vmDevices) {
if (vm.getInterfaces() == null || vm.getInterfaces().isEmpty()) {
vm.setInterfaces(vmNetworkInterfaceDao.getAllForVm(vm.getId()));
}
if (StringUtils.isEmpty(vm.getVmtName())) {
VmTemplate t = vmTemplateDao.get(vm.getVmtGuid());
vm.setVmtName(t.getName());
}
if (vmDevices == null) {
vmDeviceUtils.setVmDevices(vm.getStaticData());
} else {
vm.getStaticData().setManagedDeviceMap(vmDevices);
}
if (disks == null) {
disks = DisksFilter.filterImageDisks(diskDao.getAllForVm(vm.getId()), ONLY_SNAPABLE, ONLY_ACTIVE);
disks.addAll(imagesHandler.getCinderLeafImages(diskDao.getAllForVm(vm.getId())));
}
populateDisksWithVmData(disks, vm.getId());
disks.forEach(image -> image.setStorageIds(null));
FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(vm);
fullEntityOvfData.setDiskImages(disks);
return ovfManager.exportVm(vm, fullEntityOvfData, clusterUtils.getCompatibilityVersion(vm));
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class StorageHandlingCommandBase method removeEntitiesFromStorageDomain.
/**
* Remove all related entities of the Storage Domain from the DB.
*/
private void removeEntitiesFromStorageDomain(final List<VM> vmsForStorageDomain, final List<VmTemplate> vmTemplatesForStorageDomain, final List<DiskImage> disksForStorageDomain, final Guid storageDomainId) {
if (!vmsForStorageDomain.isEmpty() || !vmTemplatesForStorageDomain.isEmpty() || !disksForStorageDomain.isEmpty()) {
TransactionSupport.executeInNewTransaction(() -> {
for (VM vm : vmsForStorageDomain) {
removeEntityLeftOver(vm.getId(), vm.getName(), storageDomainId);
unregisteredOVFDataDao.saveOVFData(new OvfEntityData(vm.getId(), vm.getName(), VmEntityType.VM, vm.getClusterArch(), vm.getCompatibilityVersion(), storageDomainId, null, null));
}
for (VmTemplate vmTemplate : vmTemplatesForStorageDomain) {
removeEntityLeftOver(vmTemplate.getId(), vmTemplate.getName(), storageDomainId);
unregisteredOVFDataDao.saveOVFData(new OvfEntityData(vmTemplate.getId(), vmTemplate.getName(), VmEntityType.TEMPLATE, vmTemplate.getClusterArch(), clusterDao.get(vmTemplate.getClusterId()).getCompatibilityVersion(), storageDomainId, null, null));
}
storageDomainDao.removeEntitesFromStorageDomain(storageDomainId);
return null;
});
}
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class VmTemplateHandlerTest method testUpdateFieldsQuotaEnforcementType.
@Test
public void testUpdateFieldsQuotaEnforcementType() {
VmTemplate src = new VmTemplate();
src.setQuotaEnforcementType(QuotaEnforcementTypeEnum.DISABLED);
VmTemplate dest = new VmTemplate();
dest.setQuotaEnforcementType(QuotaEnforcementTypeEnum.HARD_ENFORCEMENT);
assertTrue("Update should be valid for different quota enforcement types", vmTemplateHandler.isUpdateValid(src, dest));
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class VmTemplateHandlerTest method testUpdateFieldsIsQuotaDefault.
@Test
public void testUpdateFieldsIsQuotaDefault() {
VmTemplate src = new VmTemplate();
src.setQuotaDefault(true);
VmTemplate dest = new VmTemplate();
dest.setQuotaDefault(false);
assertTrue("Update should be valid for different quota default statuses", vmTemplateHandler.isUpdateValid(src, dest));
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class ImportVmTemplateCommandTest method createParameters.
protected ImportVmTemplateParameters createParameters() {
VmTemplate t = new VmTemplate();
t.setName("testTemplate");
return new ImportVmTemplateParameters(Guid.newGuid(), Guid.newGuid(), Guid.newGuid(), Guid.newGuid(), t);
}
Aggregations