Tomas Jelinek has uploaded a new change for review. Change subject: webadmin: it is possible to attach the same disk twice ......................................................................
webadmin: it is possible to attach the same disk twice Problem happend in the "instance image flow" only. The problem was that the disks which can not be attached (e.g. the ones already attached) were returned only from server. But in the instance image flow the disks are first configured in the new/edit vm dialog and than submitted at once. Fixed by removing the this disks from the list of disks to be attached. Change-Id: I3eb3b0608e957c88c98c264e87dbb651b179c8e3 Bug-Url: https://bugzilla.redhat.com/1228975 Signed-off-by: Tomas Jelinek <tjeli...@redhat.com> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImageLineModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImagesAttachDiskModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImagesModel.java 3 files changed, 63 insertions(+), 11 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/54/42154/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImageLineModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImageLineModel.java index 3a8f2a1..d09130e 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImageLineModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImageLineModel.java @@ -193,6 +193,11 @@ protected void updateBootableDiskAvailable() { updateBootableFrom(parentModel.getAllCurrentDisks()); } + + @Override + protected List<Disk> getAttachedNotSubmittedDisks() { + return parentModel.getNotYetAttachedNotAttachableDisks(); + } }; VM realOrFakeVm = vm; diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImagesAttachDiskModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImagesAttachDiskModel.java index 343fb33..6806c47 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImagesAttachDiskModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImagesAttachDiskModel.java @@ -2,12 +2,14 @@ import org.ovirt.engine.core.common.businessentities.storage.Disk; import org.ovirt.engine.core.common.businessentities.storage.DiskStorageType; +import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.Version; import org.ovirt.engine.ui.frontend.AsyncQuery; import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; import org.ovirt.engine.ui.uicommonweb.models.EntityModel; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class InstanceImagesAttachDiskModel extends AttachDiskModel { @@ -73,20 +75,19 @@ @Override protected List<Disk> adjustReturnValue(Object returnValue) { List<Disk> disksFromServer = (List<Disk>) returnValue; - - if (prevSelectedDisk == null) { - return disksFromServer; - } - - if (prevSelectedDisk.getDiskStorageType() != diskStorageType) { - return disksFromServer; - } + List<Guid> inDialogIds = asIds(getAttachedNotSubmittedDisks()); List<Disk> res = new ArrayList<>(); for (Disk diskFromServer : disksFromServer) { - if (!diskFromServer.getId().equals(prevSelectedDisk.getId())) { - res.add(diskFromServer); + boolean selectedDisk = prevSelectedDisk != null && + diskFromServer.getId().equals(prevSelectedDisk.getId()) && + prevSelectedDisk.getDiskStorageType() != diskStorageType; + + if (!selectedDisk) { + if (!inDialogIds.contains(diskFromServer.getId())) { + res.add(diskFromServer); + } } else { res.add(prevSelectedDisk); } @@ -94,7 +95,19 @@ return res; } + + private List<Guid> asIds(List<Disk> attachedNotSubmittedDisks) { + List<Guid> res = new ArrayList<>(); + + for (Disk disk : attachedNotSubmittedDisks) { + res.add(disk.getId()); + } + + return res; + } } - + protected List<Disk> getAttachedNotSubmittedDisks() { + return Collections.EMPTY_LIST; + } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImagesModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImagesModel.java index 439f733..3f7b023 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImagesModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/InstanceImagesModel.java @@ -7,6 +7,7 @@ import org.ovirt.engine.ui.uicommonweb.ICommandTarget; import org.ovirt.engine.ui.uicommonweb.UICommand; import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; +import org.ovirt.engine.ui.uicommonweb.models.EntityModel; import org.ovirt.engine.ui.uicommonweb.models.ListModel; import org.ovirt.engine.ui.uicommonweb.models.Model; import org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult; @@ -248,6 +249,39 @@ return res; } + /** + * Returns a list of non-sharable disks which have been set as to attach in the new/edit VM dialog but the dialog has not yet been submitted + * @return + */ + public List<Disk> getNotYetAttachedNotAttachableDisks() { + List<Disk> res = new ArrayList<>(); + for (InstanceImageLineModel line : getItems()) { + if (line.isGhost()) { + continue; + } + + EntityModel<AbstractDiskModel> diskModel = line.getDiskModel(); + if (diskModel == null) { + continue; + } + + // it will be InstanceImagesAttachDiskModel only if not yet submitted + if (!(diskModel.getEntity() instanceof InstanceImagesAttachDiskModel)) { + continue; + } + + Disk disk = line.getDisk(); + if (disk == null || disk.isShareable()) { + continue; + } + + res.add(disk); + + } + + return res; + } + public void updateActionsAvailability() { boolean clusterSelected = unitVmModel.getSelectedCluster() != null; boolean osSelected = unitVmModel.getOSType().getSelectedItem() != null; -- To view, visit https://gerrit.ovirt.org/42154 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3eb3b0608e957c88c98c264e87dbb651b179c8e3 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tomas Jelinek <tjeli...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches