use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class ImportVmCommand method createMemoryDisk.
private DiskImage createMemoryDisk(Snapshot snapshot) {
StorageDomainStatic sd = validateStorageDomainExistsInDb(snapshot, memoryDiskDomainMap.get(snapshot.getMemoryDiskId()));
DiskImage disk = isMemoryDiskAlreadyExistsInDb(snapshot, snapshot.getMemoryDiskId());
if (sd == null || disk != null) {
return null;
}
VM vm = snapshotVmConfigurationHelper.getVmFromConfiguration(snapshot.getVmConfiguration(), snapshot.getVmId(), snapshot.getId());
DiskImage memoryDisk = MemoryUtils.createSnapshotMemoryDisk(vm, sd.getStorageType(), vmOverheadCalculator, MemoryUtils.generateMemoryDiskDescription(vm, snapshot.getDescription()));
memoryDisk.setId(snapshot.getMemoryDiskId());
memoryDisk.setImageId(getMemoryDiskImageId(snapshot.getMemoryDiskId()));
memoryDisk.setStorageIds(new ArrayList<>(Collections.singletonList(sd.getId())));
memoryDisk.setStoragePoolId(getStoragePoolId());
memoryDisk.setCreationDate(snapshot.getCreationDate());
memoryDisk.setActive(true);
memoryDisk.setWipeAfterDelete(vm.getDiskList().stream().anyMatch(DiskImage::isWipeAfterDelete));
return memoryDisk;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class ImportVmCommand method buildMoveOrCopyImageGroupParametersForMemoryDumpImage.
private MoveOrCopyImageGroupParameters buildMoveOrCopyImageGroupParametersForMemoryDumpImage(Guid containerID, Guid storageId, Guid imageId, Guid volumeId) {
MoveOrCopyImageGroupParameters params = new MoveOrCopyImageGroupParameters(containerID, imageId, volumeId, imageId, volumeId, storageId, ImageOperation.Copy);
params.setParentCommand(getActionType());
params.setCopyVolumeType(CopyVolumeType.LeafVol);
params.setForceOverride(getParameters().getForceOverride());
params.setSourceDomainId(getParameters().getSourceDomainId());
params.setStoragePoolId(getParameters().getStoragePoolId());
params.setImportEntity(true);
params.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVm().getId()));
params.setParentParameters(getParameters());
StorageDomainStatic storageDomain = storageDomainStaticDao.get(storageId);
if (storageDomain.getStorageType().isBlockDomain()) {
params.setUseCopyCollapse(true);
params.setVolumeType(VolumeType.Preallocated);
params.setVolumeFormat(VolumeFormat.RAW);
}
return params;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class ImportVmCommand method createMetadataDisk.
private DiskImage createMetadataDisk(VM vm, Snapshot snapshot) {
StorageDomainStatic sd = validateStorageDomainExistsInDb(snapshot, memoryDiskDomainMap.get(snapshot.getMetadataDiskId()));
DiskImage disk = isMemoryDiskAlreadyExistsInDb(snapshot, snapshot.getMetadataDiskId());
if (sd == null || disk != null) {
return null;
}
DiskImage memoryDisk = MemoryUtils.createSnapshotMetadataDisk(MemoryUtils.generateMemoryDiskDescription(vm, snapshot.getDescription()));
memoryDisk.setId(snapshot.getMetadataDiskId());
memoryDisk.setImageId(getMemoryDiskImageId(snapshot.getMetadataDiskId()));
memoryDisk.setStorageIds(new ArrayList<>(Collections.singletonList(sd.getId())));
memoryDisk.setStoragePoolId(getStoragePoolId());
memoryDisk.setCreationDate(snapshot.getCreationDate());
memoryDisk.setActive(true);
memoryDisk.setWipeAfterDelete(vm.getDiskList().stream().anyMatch(DiskImage::isWipeAfterDelete));
return memoryDisk;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class AbstractOpenStackStorageProviderProxy method onModification.
@Override
public void onModification() {
// updating storage domain information
Guid storageDomainId = getProviderStorageDomain().getId();
StorageDomainStatic domainStaticEntry = getDbFacade().getStorageDomainStaticDao().get(storageDomainId);
domainStaticEntry.setStorageName(provider.getName());
domainStaticEntry.setDescription(provider.getDescription());
getDbFacade().getStorageDomainStaticDao().update(domainStaticEntry);
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class AddStoragePoolWithStoragesCommand method updateStorageDomainsInDb.
private boolean updateStorageDomainsInDb() {
boolean result = TransactionSupport.executeInNewTransaction(() -> {
for (Guid storageDomainId : getParameters().getStorages()) {
StorageDomain storageDomain = storageDomainDao.get(storageDomainId);
if (storageDomain != null) {
StoragePoolIsoMap mapFromDB = storagePoolIsoMapDao.get(new StoragePoolIsoMapId(storageDomain.getId(), getStoragePool().getId()));
boolean existingInDb = mapFromDB != null;
if (existingInDb) {
getCompensationContext().snapshotEntity(mapFromDB);
}
final StorageDomainStatic staticDomain = storageDomain.getStorageStaticData();
boolean staticDomainChanged = false;
StorageFormatType requiredFormatType = VersionStorageFormatUtil.getForVersion(getStoragePool().getCompatibilityVersion());
if (staticDomain.getStorageFormat().compareTo(requiredFormatType) < 0) {
if (!staticDomainChanged) {
getCompensationContext().snapshotEntity(staticDomain);
}
staticDomain.setStorageFormat(requiredFormatType);
staticDomainChanged = true;
}
storageDomain.setStoragePoolId(getStoragePool().getId());
if (masterStorageDomain == null && storageDomain.getStorageDomainType() == StorageDomainType.Data) {
if (!staticDomainChanged) {
getCompensationContext().snapshotEntity(staticDomain);
}
storageDomain.setStorageDomainType(StorageDomainType.Master);
staticDomainChanged = true;
masterStorageDomain = storageDomain;
// The update of storage pool should be without compensation,
// this is why we run it in a different SUPRESS transaction.
updateStoragePoolMasterDomainVersionInDiffTransaction();
}
if (staticDomainChanged) {
storageDomainStaticDao.update(staticDomain);
}
storageDomain.setStatus(StorageDomainStatus.Locked);
if (existingInDb) {
storagePoolIsoMapDao.update(storageDomain.getStoragePoolIsoMapData());
} else {
storagePoolIsoMapDao.save(storageDomain.getStoragePoolIsoMapData());
getCompensationContext().snapshotNewEntity(storageDomain.getStoragePoolIsoMapData());
}
} else {
return false;
}
}
getCompensationContext().stateChanged();
return true;
});
return result && masterStorageDomain != null;
}
Aggregations