Search in sources :

Example 16 with MoveOrCopyImageGroupParameters

use of org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters in project ovirt-engine by oVirt.

the class ImportVmCommand method buildMoveOrCopyImageGroupParametersForMemoryConfImage.

private MoveOrCopyImageGroupParameters buildMoveOrCopyImageGroupParametersForMemoryConfImage(Guid containerID, Guid storageId, Guid imageId, Guid volumeId) {
    MoveOrCopyImageGroupParameters params = new MoveOrCopyImageGroupParameters(containerID, imageId, volumeId, imageId, volumeId, storageId, ImageOperation.Copy);
    params.setParentCommand(getActionType());
    // This volume is always of type 'sparse' and format 'cow' so no need to convert,
    // and there're no snapshots for it so no reason to use copy collapse
    params.setUseCopyCollapse(false);
    params.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVm().getId()));
    params.setCopyVolumeType(CopyVolumeType.LeafVol);
    params.setForceOverride(getParameters().getForceOverride());
    params.setParentParameters(getParameters());
    params.setSourceDomainId(getParameters().getSourceDomainId());
    params.setStoragePoolId(getParameters().getStoragePoolId());
    params.setImportEntity(true);
    return params;
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo)

Example 17 with MoveOrCopyImageGroupParameters

use of org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters in project ovirt-engine by oVirt.

the class BackendDiskResource method copy.

@Override
public Response copy(Action action) {
    validateParameters(action, "storageDomain.id|name");
    Guid storageDomainId = getStorageDomainId(action);
    Disk disk = get();
    Guid imageId = getDiskImageId(disk.getImageId());
    Guid sourceStorageDomainId = getSourceStorageDomainId(disk);
    MoveOrCopyImageGroupParameters params = new MoveOrCopyImageGroupParameters(imageId, sourceStorageDomainId, storageDomainId, ImageOperation.Copy);
    params.setImageGroupID(asGuid(disk.getId()));
    params.setQuotaId(action.isSetQuota() ? asGuid(action.getQuota().getId()) : null);
    params.setDiskProfileId(action.isSetDiskProfile() ? asGuid(action.getDiskProfile().getId()) : null);
    Disk actionDisk = action.getDisk();
    if (actionDisk != null) {
        String name = actionDisk.getName();
        String alias = actionDisk.getAlias();
        if (name != null && !StringUtils.isEmpty(name)) {
            params.setNewAlias(name);
        } else if (alias != null && !StringUtils.isEmpty(alias)) {
            params.setNewAlias(alias);
        }
    }
    return doAction(ActionType.MoveOrCopyDisk, params, action);
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters) Guid(org.ovirt.engine.core.compat.Guid) Disk(org.ovirt.engine.api.model.Disk)

Aggregations

MoveOrCopyImageGroupParameters (org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters)17 EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)5 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)4 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)4 Guid (org.ovirt.engine.core.compat.Guid)4 Disk (org.ovirt.engine.api.model.Disk)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 DiskImageBase (org.ovirt.engine.core.common.businessentities.storage.DiskImageBase)1