Arik Hadas has uploaded a new change for review. Change subject: core: introduce DiskContentType ......................................................................
core: introduce DiskContentType Change-Id: I410a346cf0be32a99e10e503c26eb29b3688e748 Signed-off-by: Arik Hadas <aha...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/DiskValidator.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommandTest.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/RemoveDiskCommandTest.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/Disk.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/DiskContentType.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DiskImageDAODbFacadeImpl.java M frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/disks/DiskListModel.java 10 files changed, 30 insertions(+), 14 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/43/39143/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskCommand.java index d124de1..06c352d 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskCommand.java @@ -36,6 +36,7 @@ import org.ovirt.engine.core.common.businessentities.VmTemplate; import org.ovirt.engine.core.common.businessentities.VmTemplateStatus; import org.ovirt.engine.core.common.businessentities.storage.Disk; +import org.ovirt.engine.core.common.businessentities.storage.DiskContentType; import org.ovirt.engine.core.common.businessentities.storage.DiskStorageType; import org.ovirt.engine.core.common.businessentities.storage.DiskImage; import org.ovirt.engine.core.common.businessentities.storage.ImageDbOperationScope; @@ -127,7 +128,7 @@ DiskImage diskImage = getDiskImage(); DiskImagesValidator diskImagesValidator = new DiskImagesValidator(Collections.singletonList(diskImage)); - if (diskImage.isOvfStore() + if (diskImage.getContentType() == DiskContentType.OVF_STORE && !validate(diskImagesValidator.disksInStatus(ImageStatus.ILLEGAL, VdcBllMessages.ACTION_TYPE_FAILED_OVF_DISK_NOT_IN_APPLICABLE_STATUS))) { return false; diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/DiskValidator.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/DiskValidator.java index a6436ad..012f5b9 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/DiskValidator.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/DiskValidator.java @@ -14,6 +14,7 @@ import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.businessentities.VmDevice; import org.ovirt.engine.core.common.businessentities.storage.Disk; +import org.ovirt.engine.core.common.businessentities.storage.DiskContentType; import org.ovirt.engine.core.common.businessentities.storage.DiskStorageType; import org.ovirt.engine.core.common.businessentities.storage.DiskInterface; import org.ovirt.engine.core.common.businessentities.storage.LUNs; @@ -127,7 +128,7 @@ } public ValidationResult isDiskUsedAsOvfStore() { - if (disk.isOvfStore()) { + if (disk.getContentType() == DiskContentType.OVF_STORE) { return new ValidationResult((VdcBllMessages.ACTION_TYPE_FAILED_OVF_DISK_NOT_SUPPORTED)); } return ValidationResult.VALID; diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommandTest.java index c5c666e..ea26e00 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommandTest.java @@ -27,6 +27,7 @@ import org.ovirt.engine.core.common.businessentities.VmDevice; import org.ovirt.engine.core.common.businessentities.VmEntityType; import org.ovirt.engine.core.common.businessentities.VmTemplate; +import org.ovirt.engine.core.common.businessentities.storage.DiskContentType; import org.ovirt.engine.core.common.businessentities.storage.DiskImage; import org.ovirt.engine.core.common.businessentities.storage.ImageOperation; import org.ovirt.engine.core.common.businessentities.storage.ImageStatus; @@ -189,7 +190,7 @@ public void canDoActionDiskIsOvfStore() throws Exception { initializeCommand(ImageOperation.Move); initVmDiskImage(false); - command.getImage().setOvfStore(true); + command.getImage().setContentType(DiskContentType.OVF_STORE); CanDoActionTestUtils.runAndAssertCanDoActionFailure(command, VdcBllMessages.ACTION_TYPE_FAILED_OVF_DISK_NOT_SUPPORTED); } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/RemoveDiskCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/RemoveDiskCommandTest.java index 1420d02..d127fcf 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/RemoveDiskCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/RemoveDiskCommandTest.java @@ -19,6 +19,7 @@ import org.ovirt.engine.core.common.businessentities.VmDevice; import org.ovirt.engine.core.common.businessentities.VmDeviceId; import org.ovirt.engine.core.common.businessentities.VmEntityType; +import org.ovirt.engine.core.common.businessentities.storage.DiskContentType; import org.ovirt.engine.core.common.businessentities.storage.DiskImage; import org.ovirt.engine.core.common.businessentities.storage.ImageStatus; import org.ovirt.engine.core.common.errors.VdcBllMessages; @@ -96,7 +97,7 @@ @Test public void testCanDoActionOvfDiskNotIllegal() { disk.setImageStatus(ImageStatus.OK); - disk.setOvfStore(true); + disk.setContentType(DiskContentType.OVF_STORE); CanDoActionTestUtils.runAndAssertCanDoActionFailure(cmd, VdcBllMessages.ACTION_TYPE_FAILED_OVF_DISK_NOT_IN_APPLICABLE_STATUS); } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java index 0ab92f7..9c440e2 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java @@ -49,6 +49,7 @@ import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType; import org.ovirt.engine.core.common.businessentities.VmDeviceId; import org.ovirt.engine.core.common.businessentities.storage.Disk; +import org.ovirt.engine.core.common.businessentities.storage.DiskContentType; import org.ovirt.engine.core.common.businessentities.storage.DiskImage; import org.ovirt.engine.core.common.businessentities.storage.DiskInterface; import org.ovirt.engine.core.common.businessentities.storage.StorageType; @@ -504,7 +505,7 @@ DiskImage diskFromDB = createDiskImage(); diskFromDB.setReadOnly(false); diskFromDB.setDiskInterface(DiskInterface.IDE); - diskFromDB.setOvfStore(true); + diskFromDB.setContentType(DiskContentType.OVF_STORE); when(diskDao.get(diskImageGuid)).thenReturn(diskFromDB); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/Disk.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/Disk.java index eede883..0b91401 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/Disk.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/Disk.java @@ -25,7 +25,7 @@ private VmEntityType vmEntityType; private int numberOfVms; private ArrayList<String> vmNames; - private boolean ovfStore; + private DiskContentType contentType; /** * Plugged and readOnly are of type Boolean (as opposed to boolean) since they are optional. @@ -128,11 +128,11 @@ return false; } - public boolean isOvfStore() { - return ovfStore; + public DiskContentType getContentType() { + return contentType; } - public void setOvfStore(boolean ovfStore) { - this.ovfStore = ovfStore; + public void setContentType(DiskContentType contentType) { + this.contentType = contentType; } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/DiskContentType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/DiskContentType.java new file mode 100644 index 0000000..f50419a --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/DiskContentType.java @@ -0,0 +1,7 @@ +package org.ovirt.engine.core.common.businessentities.storage; + +public enum DiskContentType{ + DATA, + OVF_STORE; +} + diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DiskImageDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DiskImageDAODbFacadeImpl.java index aa221c1..b47604c 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DiskImageDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DiskImageDAODbFacadeImpl.java @@ -10,6 +10,7 @@ import org.apache.commons.lang.StringUtils; import org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum; import org.ovirt.engine.core.common.businessentities.storage.CinderDisk; +import org.ovirt.engine.core.common.businessentities.storage.DiskContentType; import org.ovirt.engine.core.common.businessentities.storage.DiskImage; import org.ovirt.engine.core.common.businessentities.storage.DiskStorageType; import org.ovirt.engine.core.common.businessentities.storage.ImageStatus; @@ -197,7 +198,7 @@ entity.setBoot(rs.getBoolean("boot")); entity.setReadRate(rs.getInt("read_rate")); entity.setWriteRate(rs.getInt("write_rate")); - entity.setOvfStore(rs.getBoolean("ovf_store")); + entity.setContentType(rs.getBoolean("ovf_store") ? DiskContentType.OVF_STORE : DiskContentType.DATA); entity.setReadLatency(rs.getObject("read_latency_seconds") != null ? rs.getDouble("read_latency_seconds") : null); entity.setWriteLatency(rs.getObject("write_latency_seconds") != null ? rs.getDouble("write_latency_seconds") diff --git a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml index 26dfb12..1ba0644 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml @@ -214,6 +214,7 @@ <include name="common/businessentities/storage/CopyVolumeType.java" /> <include name="common/businessentities/storage/Disk.java" /> <include name="common/businessentities/storage/DiskAlignment.java" /> + <include name="common/businessentities/storage/DiskContentType.java" /> <include name="common/businessentities/storage/DiskImage.java" /> <include name="common/businessentities/storage/DiskImageBase.java" /> <include name="common/businessentities/storage/DiskImageDynamic.java" /> diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/disks/DiskListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/disks/DiskListModel.java index b2a66b4..18ed910 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/disks/DiskListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/disks/DiskListModel.java @@ -10,6 +10,7 @@ import org.ovirt.engine.core.common.action.VdcActionParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.businessentities.storage.Disk; +import org.ovirt.engine.core.common.businessentities.storage.DiskContentType; import org.ovirt.engine.core.common.businessentities.storage.DiskStorageType; import org.ovirt.engine.core.common.businessentities.storage.DiskImage; import org.ovirt.engine.core.common.businessentities.storage.ImageStatus; @@ -479,7 +480,7 @@ ArrayList<Disk> disks = getSelectedItems() != null ? (ArrayList) getSelectedItems() : null; boolean shouldAllowEdit = true; if (disk != null) { - shouldAllowEdit = !disk.isOvfStore() && !(disk.getDiskStorageType() == DiskStorageType.IMAGE && + shouldAllowEdit = disk.getContentType() != DiskContentType.OVF_STORE && !(disk.getDiskStorageType() == DiskStorageType.IMAGE && ((DiskImage) disk).getImageStatus() == ImageStatus.LOCKED); } @@ -515,7 +516,8 @@ } DiskImage diskImage = (DiskImage) disk; - if (diskImage.getImageStatus() != ImageStatus.OK || !datacenterId.equals(diskImage.getStoragePoolId()) || diskImage.isOvfStore()) { + if (diskImage.getImageStatus() != ImageStatus.OK || !datacenterId.equals(diskImage.getStoragePoolId()) || + diskImage.getContentType() == DiskContentType.OVF_STORE) { disableMoveAndCopyCommands(); return; } @@ -554,7 +556,7 @@ return false; } - if (disk.isOvfStore() && imageStatus != ImageStatus.ILLEGAL) { + if (disk.getContentType() == DiskContentType.OVF_STORE && imageStatus != ImageStatus.ILLEGAL) { return false; } } -- To view, visit https://gerrit.ovirt.org/39143 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I410a346cf0be32a99e10e503c26eb29b3688e748 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <aha...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches