Search in sources :

Example 1 with MoveDiskParameters

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

the class BackendVmDiskResource method move.

@Override
public Response move(Action action) {
    validateParameters(action, "storageDomain.id|name");
    Guid storageDomainId = getStorageDomainId(action);
    Disk disk = getDisk();
    Guid sourceStorageDomainId = getSourceStorageDomainId(disk);
    Guid imageId = getDiskImageId(disk.getImageId());
    MoveDiskParameters innerParams = new MoveDiskParameters(imageId, sourceStorageDomainId, storageDomainId);
    innerParams.setImageGroupID(asGuid(disk.getId()));
    MoveDisksParameters params = new MoveDisksParameters(Collections.singletonList(innerParams));
    return doAction(ActionType.MoveDisk, params, action);
}
Also used : MoveDiskParameters(org.ovirt.engine.core.common.action.MoveDiskParameters) MoveDisksParameters(org.ovirt.engine.core.common.action.MoveDisksParameters) Guid(org.ovirt.engine.core.compat.Guid) Disk(org.ovirt.engine.api.model.Disk)

Example 2 with MoveDiskParameters

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

the class MoveDiskCommand method executeCommand.

@Override
protected void executeCommand() {
    List<DiskVmElement> diskVmElements = diskVmElementDao.getAllDiskVmElementsByDiskId(getParameters().getImageGroupID());
    ActionType actionType = getMoveActionType(diskVmElements);
    if (actionType == ActionType.MoveOrCopyDisk) {
        MoveDiskParameters moveDiskParameters = getParameters();
        // This is required to make MoveDiskCommand and MoveOrCopyDiskCommand have
        // different a commandId. Having the same commandId will make CommandsCache
        // return the wrong command and lead to unexpected results
        moveDiskParameters.setCommandId(null);
        setReturnValue(runInternalAction(actionType, moveDiskParameters, ExecutionHandler.createInternalJobContext(getContext(), getLock())));
    } else {
        Guid vmId = diskVmElements.get(0).getVmId();
        engineLock = lockVmWithWait(vmId);
        setReturnValue(runInternalAction(actionType, createLiveMigrateDiskParameters(getParameters(), vmId), ExecutionHandler.createInternalJobContext(getContext(), engineLock)));
    }
    setSucceeded(true);
}
Also used : MoveDiskParameters(org.ovirt.engine.core.common.action.MoveDiskParameters) ActionType(org.ovirt.engine.core.common.action.ActionType) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid)

Example 3 with MoveDiskParameters

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

the class BackendDiskResource method move.

@Override
public Response move(Action action) {
    validateParameters(action, "storageDomain.id|name");
    Guid storageDomainId = getStorageDomainId(action);
    Disk disk = get();
    Guid imageId = getDiskImageId(disk.getImageId());
    Guid sourceStorageDomainId = getSourceStorageDomainId(disk);
    MoveDiskParameters params = new MoveDiskParameters(imageId, sourceStorageDomainId, storageDomainId);
    params.setImageGroupID(asGuid(disk.getId()));
    params.setQuotaId(action.isSetQuota() ? asGuid(action.getQuota().getId()) : null);
    params.setDiskProfileId(action.isSetDiskProfile() ? asGuid(action.getDiskProfile().getId()) : null);
    return doAction(ActionType.MoveDisk, params, action);
}
Also used : MoveDiskParameters(org.ovirt.engine.core.common.action.MoveDiskParameters) Guid(org.ovirt.engine.core.compat.Guid) Disk(org.ovirt.engine.api.model.Disk)

Example 4 with MoveDiskParameters

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

the class MoveDiskModel method createParameters.

@Override
protected MoveOrCopyImageGroupParameters createParameters(Guid sourceStorageDomainGuid, Guid destStorageDomainGuid, DiskImage disk) {
    MoveDiskParameters moveDiskParameters = new MoveDiskParameters(disk.getImageId(), sourceStorageDomainGuid, destStorageDomainGuid);
    moveDiskParameters.setImageGroupID(disk.getId());
    return moveDiskParameters;
}
Also used : MoveDiskParameters(org.ovirt.engine.core.common.action.MoveDiskParameters)

Aggregations

MoveDiskParameters (org.ovirt.engine.core.common.action.MoveDiskParameters)4 Guid (org.ovirt.engine.core.compat.Guid)3 Disk (org.ovirt.engine.api.model.Disk)2 ActionType (org.ovirt.engine.core.common.action.ActionType)1 MoveDisksParameters (org.ovirt.engine.core.common.action.MoveDisksParameters)1 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)1