Search in sources :

Example 41 with EngineException

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);
    }
}
Also used : EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 42 with EngineException

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);
    }
}
Also used : EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 43 with EngineException

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;
}
Also used : GetImageInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetImageInfoVDSCommandParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 44 with EngineException

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);
    }
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 45 with EngineException

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;
    });
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

EngineException (org.ovirt.engine.core.common.errors.EngineException)107 Guid (org.ovirt.engine.core.compat.Guid)30 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)25 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)25 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)18 ArrayList (java.util.ArrayList)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)11 HashMap (java.util.HashMap)7 Pair (org.ovirt.engine.core.common.utils.Pair)7 HashSet (java.util.HashSet)6 List (java.util.List)6 Callable (java.util.concurrent.Callable)6 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)6 IOException (java.io.IOException)5 EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)5 Map (java.util.Map)4 PersistentHostSetupNetworksParameters (org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters)4 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 Set (java.util.Set)3 VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)3