use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class ImagesHandler method removeDiskImage.
public void removeDiskImage(DiskImage diskImage, Guid vmId) {
try {
removeDiskFromVm(vmId, diskImage.getId());
removeImage(diskImage);
} catch (RuntimeException ex) {
log.error("Failed to remove disk image and related entities from db: {}", ex.getMessage());
log.debug("Exception", ex);
throw new EngineException(EngineError.DB, ex);
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class ImagesHandler method addDiskImageWithNoVmDevice.
/**
* Adds a disk image (Adds image, disk, and relevant entities , but not VmDevice) This may be useful for Clone VMs,
* where besides adding images it is required to copy all vm devices (VmDeviceUtils.copyVmDevices) from the source
* VM
*
* @param image
* image to add
* @param active
* true if to add as active image
* @param imageStorageDomainMap
* entry of image storagte domain map
*/
public void addDiskImageWithNoVmDevice(DiskImage image, boolean active, ImageStorageDomainMap imageStorageDomainMap) {
try {
addImage(image, active, imageStorageDomainMap);
addDisk(image);
} catch (RuntimeException ex) {
log.error("Failed adding new disk image and related entities to db: {}", ex.getMessage());
log.debug("Exception", ex);
throw new EngineException(EngineError.DB, ex);
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class ExtendImageSizeCommand method getImageInfo.
private DiskImage getImageInfo() {
DiskImage diskImage = null;
GetImageInfoVDSCommandParameters params = new GetImageInfoVDSCommandParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getImageGroupID(), getParameters().getImageId());
try {
diskImage = (DiskImage) runVdsCommand(VDSCommandType.GetImageInfo, params).getReturnValue();
} catch (EngineException e) {
log.error("Failed to retrieve image '{}' info: {}", params.getImageId(), e.getMessage());
log.debug("Exception", e);
}
return diskImage;
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class ExportVmCommand method endCopyCollapseOperations.
private void endCopyCollapseOperations(VM vm) {
vm.setVmtGuid(VmTemplateHandler.BLANK_VM_TEMPLATE_ID);
vm.setVmtName(null);
Snapshot activeSnapshot = snapshotDao.get(snapshotDao.getId(vm.getId(), SnapshotType.ACTIVE));
vm.setSnapshots(Collections.singletonList(activeSnapshot));
try {
updateCopyVmInSpm(getVm().getStoragePoolId(), vm, getParameters().getStorageDomainId());
} catch (EngineException e) {
log.error("Updating VM OVF in export domain failed.", e);
auditLogDirector.log(this, AuditLogType.IMPORTEXPORT_IMPORT_VM_FAILED_UPDATING_OVF);
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class ExportVmTemplateCommand method moveOrCopyAllImageGroups.
@Override
protected void moveOrCopyAllImageGroups(final Guid containerID, final Iterable<DiskImage> disks) {
TransactionSupport.executeInNewTransaction(() -> {
for (DiskImage disk : disks) {
// we force export template image to COW+Sparse but we don't update
// the ovf so the import
// will set the original format
MoveOrCopyImageGroupParameters p = new MoveOrCopyImageGroupParameters(containerID, disk.getId(), disk.getImageId(), getParameters().getStorageDomainId(), ImageOperation.Copy);
p.setParentCommand(getActionType());
p.setParentParameters(getParameters());
p.setEntityInfo(getParameters().getEntityInfo());
p.setUseCopyCollapse(true);
p.setCopyVolumeType(CopyVolumeType.SharedVol);
p.setVolumeFormat(disk.getVolumeFormat());
p.setVolumeType(disk.getVolumeType());
p.setForceOverride(getParameters().getForceOverride());
p.setRevertDbOperationScope(ImageDbOperationScope.NONE);
p.setShouldLockImageOnRevert(false);
p.setSourceDomainId(imageFromSourceDomainMap.get(disk.getId()).getStorageIds().get(0));
ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, p);
if (!vdcRetValue.getSucceeded()) {
throw new EngineException(vdcRetValue.getFault().getError(), vdcRetValue.getFault().getMessage());
}
getReturnValue().getVdsmTaskIdList().addAll(vdcRetValue.getInternalVdsmTaskIdList());
}
return null;
});
}
Aggregations