use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMapId in project ovirt-engine by oVirt.
the class LiveMigrateDiskCommand method moveDiskInDB.
private void moveDiskInDB(final Guid sourceStorageDomainId, final Guid targetStorageDomainId, final Guid targetQuota, final Guid targetDiskProfile) {
if (isMoveDiskInDbSucceded(targetStorageDomainId)) {
return;
}
TransactionSupport.executeInScope(TransactionScopeOption.Required, () -> {
for (DiskImage di : diskImageDao.getAllSnapshotsForImageGroup(getParameters().getImageGroupID())) {
imageStorageDomainMapDao.remove(new ImageStorageDomainMapId(di.getImageId(), sourceStorageDomainId));
imageStorageDomainMapDao.save(new ImageStorageDomainMap(di.getImageId(), targetStorageDomainId, targetQuota, targetDiskProfile));
// an exception, we store locally the old quota and disk profile id.
if (sourceQuotaId == null) {
sourceQuotaId = di.getQuotaId();
}
if (sourceDiskProfileId == null) {
sourceDiskProfileId = di.getDiskProfileId();
}
}
return null;
});
}
use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMapId in project ovirt-engine by oVirt.
the class RemoveAllVmTemplateImageTemplatesCommand method executeCommand.
@SuppressWarnings("unchecked")
@Override
protected void executeCommand() {
List<DiskImage> imageTemplates = DisksFilter.filterImageDisks(diskDao.getAllForVm(getVmTemplateId()), ONLY_ACTIVE);
for (DiskImage template : imageTemplates) {
// remove this disk in all domain that were sent
for (Guid domain : (Collection<Guid>) CollectionUtils.intersection(getParameters().getStorageDomainsList(), template.getStorageIds())) {
ImagesContainterParametersBase tempVar = new ImagesContainterParametersBase(template.getImageId(), getVmTemplateId());
tempVar.setStorageDomainId(domain);
tempVar.setStoragePoolId(template.getStoragePoolId());
tempVar.setImageGroupID(template.getId());
tempVar.setEntityInfo(getParameters().getEntityInfo());
tempVar.setWipeAfterDelete(template.isWipeAfterDelete());
tempVar.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
tempVar.setParentCommand(getActionType());
tempVar.setParentParameters(getParameters());
ActionReturnValue actionReturnValue = runInternalActionWithTasksContext(ActionType.RemoveTemplateSnapshot, tempVar);
if (actionReturnValue.getSucceeded()) {
getReturnValue().getInternalVdsmTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList());
} else {
log.error("Can't remove image id '{}' for template id '{}' from domain id '{}' due to: {}.", template.getImageId(), getVmTemplateId(), domain, actionReturnValue.getFault().getMessage());
}
imageStorageDomainMapDao.remove(new ImageStorageDomainMapId(template.getImageId(), domain));
}
DiskImage diskImage = diskImageDao.get(template.getImageId());
if (diskImage != null) {
baseDiskDao.remove(template.getId());
vmDeviceDao.remove(new VmDeviceId(diskImage.getImageId(), getVmTemplateId()));
imageStorageDomainMapDao.remove(diskImage.getImageId());
imageDao.remove(template.getImageId());
}
}
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMapId in project ovirt-engine by oVirt.
the class CopyImageGroupCommand method endSuccessfully.
@Override
protected void endSuccessfully() {
if (shouldUpdateStorageDisk()) {
List<DiskImage> snapshots = diskImageDao.getAllSnapshotsForImageGroup(getParameters().getDestImageGroupId());
setSnapshotForShareableDisk(snapshots);
for (DiskImage snapshot : snapshots) {
imageStorageDomainMapDao.remove(new ImageStorageDomainMapId(snapshot.getImageId(), snapshot.getStorageIds().get(0)));
imageStorageDomainMapDao.save(new ImageStorageDomainMap(snapshot.getImageId(), getParameters().getStorageDomainId(), getParameters().getQuotaId(), getParameters().getDiskProfileId()));
setQcowCompatForSnapshot(snapshot, null);
}
}
super.endSuccessfully();
}
use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMapId in project ovirt-engine by oVirt.
the class CopyImageGroupCommand method endWithFailure.
@Override
protected void endWithFailure() {
if (!getParameters().isImportEntity()) {
unLockImage();
}
if (getParameters().getAddImageDomainMapping()) {
// remove image-storage mapping
imageStorageDomainMapDao.remove(new ImageStorageDomainMapId(getParameters().getImageId(), getParameters().getStorageDomainId()));
}
revertTasks();
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMapId in project ovirt-engine by oVirt.
the class ImageStorageDomainMapDaoTest method testRemoveById.
@Test
public void testRemoveById() {
dao.remove(new ImageStorageDomainMapId(EXISTING_IMAGE_ID, FixturesTool.STORAGE_DOMAIN_SCALE_SD5));
List<ImageStorageDomainMap> entries = dao.getAllByStorageDomainId(EXISTING_IMAGE_ID);
for (ImageStorageDomainMap entry : entries) {
assertFalse(entry.getStorageDomainId().equals(FixturesTool.STORAGE_DOMAIN_SCALE_SD5));
}
assertNotNull(entries);
assertTrue(entries.isEmpty());
}
Aggregations