Maor Lipchuk has uploaded a new change for review.

Change subject: core: attach of Illegal disk should not be allowed (#848074)
......................................................................

core: attach of Illegal disk should not be allowed (#848074)

https://bugzilla.redhat.com/show_bug.cgi?id=848074

Illegal disk should not be allowed to be attached to VMs, only to be
deleted, since we can't know if this disk is valid in the storage or
not.

Change-Id: I35fe4123c40de371a6f338bc3655923ab51400e1
Signed-off-by: Maor Lipchuk <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AttachDiskToVmCommand.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M backend/manager/modules/utils/src/test/resources/AppErrors.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
5 files changed, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/05/7205/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AttachDiskToVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AttachDiskToVmCommand.java
index 3c136c5..24be7e4 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AttachDiskToVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AttachDiskToVmCommand.java
@@ -16,6 +16,7 @@
 import org.ovirt.engine.core.common.businessentities.Disk.DiskStorageType;
 import org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType;
 import org.ovirt.engine.core.common.businessentities.DiskImage;
+import org.ovirt.engine.core.common.businessentities.ImageStatus;
 import org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
 import org.ovirt.engine.core.common.businessentities.VmDevice;
@@ -78,6 +79,10 @@
         }
         if (retValue && disk.getDiskStorageType() == DiskStorageType.IMAGE) {
             retValue = validate(new 
SnapshotsValidator().vmNotDuringSnapshot(getVm().getId()));
+            if (((DiskImage) disk).getimageStatus() == ImageStatus.ILLEGAL) {
+                retValue = false;
+                
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_ILLEGAL_DISK_OPERATION);
+            }
         }
         if (retValue && getParameters().isPlugUnPlug()
                 && getVm().getstatus() != VMStatus.Down) {
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
index 9171781..15fb3d1 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
@@ -98,6 +98,7 @@
     ACTION_TYPE_FAILED_DISK_BOOT_IN_USE,
     ACTION_TYPE_FAILED_DISK_ALREADY_ATTACHED,
     ACTION_TYPE_FAILED_DISK_ALREADY_DETACHED,
+    ACTION_TYPE_FAILED_ILLEGAL_DISK_OPERATION,
     ACTION_TYPE_FAILED_DISK_SPACE_LOW,
     ACTION_TYPE_FAILED_DEDICATED_VDS_NOT_IN_SAME_CLUSTER,
     ACTION_TYPE_FAILED_DISK_MAX_SIZE_EXCEEDED,
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index 3e31491..fd64faa 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -261,6 +261,7 @@
 
 ACTION_TYPE_FAILED_DISK_ALREADY_ATTACHED=Cannot ${action} ${type}. The disk is 
already attached to VM.
 ACTION_TYPE_FAILED_DISK_ALREADY_DETACHED=Cannot ${action} ${type}. The disk is 
already detached from VM.
+ACTION_TYPE_FAILED_ILLEGAL_DISK_OPERATION=Cannot ${action} ${type}. Disk is at 
Illegal. Illegal disk can only be deleted.
 ACTION_TYPE_FAILED_VM_MAX_RESOURCE_EXEEDED=Cannot ${action} ${type}. Maximum 
value for concurrently running VMs exceeded.
 ACTION_TYPE_FAILED_CPU_NOT_FOUND=Cannot ${action} ${type}. The chosen CPU is 
not supported.
 ACTION_TYPE_FAILED_EXCEEDED_MAX_PCI_SLOTS=Cannot ${action} ${type}. Maximum 
PCI devices exceeded.
diff --git 
a/backend/manager/modules/utils/src/test/resources/AppErrors.properties 
b/backend/manager/modules/utils/src/test/resources/AppErrors.properties
index 53d6b35..4ab3c69 100644
--- a/backend/manager/modules/utils/src/test/resources/AppErrors.properties
+++ b/backend/manager/modules/utils/src/test/resources/AppErrors.properties
@@ -177,6 +177,7 @@
 VAR__ACTION__CHANGE_CD=$Change CD
 VAR__ACTION__ALLOCATE_AND_RUN=$action allocate and run
 ACTION_TYPE_FAILED_DISK_LETTER_ALREADY_IN_USE=Cannot ${action} ${type}. The 
chosen drive letter is already in use, please select another.
+ACTION_TYPE_FAILED_ILLEGAL_DISK_OPERATION=Cannot ${action} ${type}. Disk is at 
Illegal. Illegal disk can only be deleted.
 ACTION_TYPE_FAILED_DISK_LIMITATION_EXCEEDED=Cannot ${action} ${type}. The VM 
has exceeded maximum number of available disks.
 ACTION_TYPE_FAILED_VM_MAX_RESOURCE_EXEEDED=Cannot ${action} ${type}. Maximum 
value for concurrently running VMs exceeded. See Help About for details.
 ACTION_TYPE_FAILED_CPU_NOT_FOUND=Cannot ${action} ${type}. The chosen CPU 
could not be found.
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index 54bea2c..2c69d31 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -709,6 +709,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. The disk is already 
attached to VM.")
     String ACTION_TYPE_FAILED_DISK_ALREADY_ATTACHED();
 
+    @DefaultStringValue("Cannot ${action} ${type}. Disk is at Illegal. Illegal 
disk can only be deleted.")
+    String ACTION_TYPE_FAILED_ILLEGAL_DISK_OPERATION();
+
     @DefaultStringValue("Cannot ${action} ${type}. The disk is already 
detached from VM.")
     String ACTION_TYPE_FAILED_DISK_ALREADY_DETACHED();
 


--
To view, visit http://gerrit.ovirt.org/7205
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35fe4123c40de371a6f338bc3655923ab51400e1
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Maor Lipchuk <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to