Search in sources :

Example 6 with RemoveDiskParameters

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

the class TemplateStorageListModel method onRemove.

private void onRemove() {
    ConfirmationModel model = (ConfirmationModel) getWindow();
    List<ActionParametersBase> parameters = new ArrayList<>();
    List<? extends Object> disks = getSelectedItems() != null ? getSelectedItems() : new ArrayList<DiskModel>();
    for (Object o : disks) {
        DiskModel diskModel = (DiskModel) o;
        RemoveDiskParameters params = new RemoveDiskParameters(diskModel.getDisk().getId(), diskModel.getStorageDomain().getSelectedItem().getId());
        parameters.add(params);
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.RemoveDisk, parameters, result -> {
        ConfirmationModel localModel = (ConfirmationModel) result.getState();
        localModel.stopProgress();
        cancel();
    }, model);
    cancel();
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) ArrayList(java.util.ArrayList) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) RemoveDiskParameters(org.ovirt.engine.core.common.action.RemoveDiskParameters)

Example 7 with RemoveDiskParameters

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

the class StorageDiskListModel method onRemove.

private void onRemove() {
    RemoveDiskModel model = (RemoveDiskModel) getWindow();
    List<ActionParametersBase> paramerterList = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        DiskImage disk = (DiskImage) item;
        ActionParametersBase parameters = new RemoveDiskParameters(disk.getId(), getEntity().getId());
        paramerterList.add(parameters);
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.RemoveDisk, paramerterList, result -> {
        StorageDiskListModel localModel = (StorageDiskListModel) result.getState();
        localModel.stopProgress();
        cancel();
    }, this);
}
Also used : RemoveDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.RemoveDiskModel) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) RemoveDiskParameters(org.ovirt.engine.core.common.action.RemoveDiskParameters)

Example 8 with RemoveDiskParameters

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

the class RemoveDiskModel method onRemove.

public void onRemove(final ICommandTarget target) {
    boolean removeDisk = getLatch().getEntity();
    ActionType actionType = removeDisk ? ActionType.RemoveDisk : ActionType.DetachDiskFromVm;
    List<ActionParametersBase> parameterList = disksToRemove.stream().map(disk -> removeDisk ? new RemoveDiskParameters(disk.getId()) : new AttachDetachVmDiskParameters(new DiskVmElement(disk.getId(), vm.getId()))).collect(Collectors.toList());
    startProgress();
    Frontend.getInstance().runMultipleAction(actionType, parameterList, result -> {
        stopProgress();
        target.executeCommand(cancelCommand);
    }, this);
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) Collectors(java.util.stream.Collectors) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) AttachDetachVmDiskParameters(org.ovirt.engine.core.common.action.AttachDetachVmDiskParameters) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) RemoveDiskParameters(org.ovirt.engine.core.common.action.RemoveDiskParameters) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) ICommandTarget(org.ovirt.engine.ui.uicommonweb.ICommandTarget) AttachDetachVmDiskParameters(org.ovirt.engine.core.common.action.AttachDetachVmDiskParameters) ActionType(org.ovirt.engine.core.common.action.ActionType) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) RemoveDiskParameters(org.ovirt.engine.core.common.action.RemoveDiskParameters)

Aggregations

RemoveDiskParameters (org.ovirt.engine.core.common.action.RemoveDiskParameters)8 ArrayList (java.util.ArrayList)4 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)4 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)2 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)2 RemoveDiskModel (org.ovirt.engine.ui.uicommonweb.models.vms.RemoveDiskModel)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 AttachDetachVmDiskParameters (org.ovirt.engine.core.common.action.AttachDetachVmDiskParameters)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 BaseDisk (org.ovirt.engine.core.common.businessentities.storage.BaseDisk)1 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)1 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)1 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)1 Frontend (org.ovirt.engine.ui.frontend.Frontend)1 ICommandTarget (org.ovirt.engine.ui.uicommonweb.ICommandTarget)1 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)1 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)1