Search in sources :

Example 1 with VmDiskOperationParameterBase

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

the class BackendDiskAttachmentResource method update.

@Override
public DiskAttachment update(DiskAttachment attachment) {
    if (attachment.isSetActive()) {
        DiskAttachment attachmentFromDb = get();
        if (!attachmentFromDb.isActive().equals(attachment.isActive())) {
            ActionType actionType = attachment.isActive() ? ActionType.HotPlugDiskToVm : ActionType.HotUnPlugDiskFromVm;
            VmDiskOperationParameterBase params = new VmDiskOperationParameterBase(new DiskVmElement(guid, vmId));
            try {
                doAction(actionType, params);
            } catch (BackendFailureException e) {
                return handleError(e, false);
            }
        }
    }
    return performUpdate(attachment, new AddDiskResolver(), ActionType.UpdateVmDisk, new UpdateParametersProvider());
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) VmDiskOperationParameterBase(org.ovirt.engine.core.common.action.VmDiskOperationParameterBase)

Example 2 with VmDiskOperationParameterBase

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

the class UpdateVmDiskCommand method buildExtendCinderDiskParameters.

private ActionParametersBase buildExtendCinderDiskParameters(CinderDisk newCinderDisk) {
    VmDiskOperationParameterBase parameters = new VmDiskOperationParameterBase(DiskVmElement.copyOf(getOldDiskVmElement()), newCinderDisk);
    parameters.setParametersCurrentUser(getParameters().getParametersCurrentUser());
    parameters.setEndProcedure(EndProcedure.COMMAND_MANAGED);
    return parameters;
}
Also used : VmDiskOperationParameterBase(org.ovirt.engine.core.common.action.VmDiskOperationParameterBase)

Example 3 with VmDiskOperationParameterBase

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

the class AddDiskCommand method plugDiskToVmIfNeeded.

private void plugDiskToVmIfNeeded() {
    if (Boolean.TRUE.equals(getParameters().getPlugDiskToVm()) && getVm() != null && getVm().getStatus() != VMStatus.Down) {
        VmDiskOperationParameterBase params = new VmDiskOperationParameterBase(new DiskVmElement(getParameters().getDiskInfo().getId(), getVmId()));
        params.setShouldBeLogged(false);
        ActionReturnValue returnValue = runInternalAction(ActionType.HotPlugDiskToVm, params);
        if (!returnValue.getSucceeded()) {
            auditLogDirector.log(this, AuditLogType.USER_FAILED_HOTPLUG_DISK);
        }
    }
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) VmDiskOperationParameterBase(org.ovirt.engine.core.common.action.VmDiskOperationParameterBase)

Example 4 with VmDiskOperationParameterBase

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

the class ExtendCinderDiskCommandCallback method childCommandsExecutionEnded.

@Override
protected void childCommandsExecutionEnded(CommandBase<?> command, boolean anyFailed, List<Guid> childCmdIds, CommandExecutionStatus status, int completedChildren) {
    ExtendCinderDiskCommand<VmDiskOperationParameterBase> extendCinderDiskCommand = (ExtendCinderDiskCommand<VmDiskOperationParameterBase>) command;
    ImageStatus imageStatus = extendCinderDiskCommand.getCinderBroker().getDiskStatus(getDiskId(extendCinderDiskCommand));
    if (imageStatus != null && imageStatus != getDisk(extendCinderDiskCommand).getImageStatus()) {
        switch(imageStatus) {
            case OK:
                setCommandEndStatus(command, false, status, childCmdIds);
                break;
            case ILLEGAL:
                setCommandEndStatus(command, true, status, childCmdIds);
                break;
        }
    }
}
Also used : ImageStatus(org.ovirt.engine.core.common.businessentities.storage.ImageStatus) VmDiskOperationParameterBase(org.ovirt.engine.core.common.action.VmDiskOperationParameterBase)

Example 5 with VmDiskOperationParameterBase

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

the class EditDiskModel method store.

@Override
public void store(IFrontendActionAsyncCallback callback) {
    if (getProgress() != null || !validate()) {
        return;
    }
    startProgress();
    VmDiskOperationParameterBase parameters = new VmDiskOperationParameterBase(getDiskVmElement(), getDisk());
    IFrontendActionAsyncCallback onFinished = callback != null ? callback : result -> {
        EditDiskModel diskModel = (EditDiskModel) result.getState();
        diskModel.stopProgress();
        diskModel.cancel();
    };
    Frontend.getInstance().runAction(ActionType.UpdateVmDisk, parameters, onFinished, this);
}
Also used : IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) VmDiskOperationParameterBase(org.ovirt.engine.core.common.action.VmDiskOperationParameterBase)

Aggregations

VmDiskOperationParameterBase (org.ovirt.engine.core.common.action.VmDiskOperationParameterBase)6 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)3 ArrayList (java.util.ArrayList)1 DiskAttachment (org.ovirt.engine.api.model.DiskAttachment)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)1 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)1 ImageStatus (org.ovirt.engine.core.common.businessentities.storage.ImageStatus)1 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)1