Liron Ar has uploaded a new change for review.

Change subject: blockopsforovfdisks
......................................................................

blockopsforovfdisks

Change-Id: Ic2b7b9f39dcf5da76be75c1106e062ff41ca8068
Signed-off-by: Liron Aravot <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AttachDiskToVmCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommand.java
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/UpdateVmDiskCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
10 files changed, 44 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/64/23564/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java
index f1a802d..c3f6bcc 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java
@@ -192,6 +192,14 @@
         return true;
     }
 
+    protected boolean isDiskUsedAsOvfStore(Disk disk) {
+        if (disk.isOvfStore()) {
+            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_OVF_DISK_NOT_SUPPORTED);
+            return true;
+        }
+        return false;
+    }
+
     private boolean isDiskExistInVm(Disk disk) {
         List<VM> listVms = getVmDAO().getVmsListForDisk(disk.getId(), true);
         for (VM vm : listVms) {
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 40a5eb8..dad6f50 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
@@ -57,6 +57,10 @@
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IMAGE_DOES_NOT_EXIST);
         }
 
+        if (isDiskUsedAsOvfStore(disk)) {
+            return false;
+        }
+
         if (isOperationPerformedOnDiskSnapshot()
                 && 
(!validate(getSnapshotsValidator().snapshotExists(getSnapshot())) || 
!validate(getSnapshotsValidator().snapshotTypeSupported(getSnapshot(),
                 Collections.singletonList(SnapshotType.REGULAR))))) {
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommand.java
index 4da4fe8..bcd3ae8 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommand.java
@@ -79,6 +79,7 @@
                 && checkOperationIsCorrect()
                 && canFindVmOrTemplate()
                 && isImageNotLocked()
+                && !isDiskUsedAsOvfStore()
                 && isSourceAndDestTheSame()
                 && validateSourceStorageDomain()
                 && validateDestStorage()
@@ -117,6 +118,14 @@
         return true;
     }
 
+    protected boolean isDiskUsedAsOvfStore() {
+        if (getImage().isOvfStore()) {
+            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_OVF_DISK_NOT_SUPPORTED);
+            return true;
+        }
+        return false;
+    }
+
     /**
      * The following method will perform a check for correctness of operation
      * It is allow to copy only if it is image that belongs to template and
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 c7e874b..c18d10c 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
@@ -112,6 +112,11 @@
     private boolean canRemoveDiskBasedOnImageStorageCheck() {
         boolean retValue = true;
         DiskImage diskImage = getDiskImage();
+
+        if (diskImage.isOvfStore() && diskImage.getImageStatus() != 
ImageStatus.ILLEGAL) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_OVF_DISK_NOT_IN_APPLICABLE_STATUS);
+        }
+
         if (diskImage.getVmEntityType() != null && 
diskImage.getVmEntityType().isTemplateType()) {
             // Temporary fix until re factoring vm_images_view and 
image_storage_domain_view
             
diskImage.setStorageIds(getDiskImageDao().get(diskImage.getImageId()).getStorageIds());
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java
index 778c183..4ee5261 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java
@@ -129,6 +129,10 @@
             return false;
         }
 
+        if (isDiskUsedAsOvfStore(getOldDisk())) {
+            return false;
+        }
+
         if (!canRunActionOnNonManagedVm()) {
             return false;
         }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
index 854d605..9835847 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
@@ -605,6 +605,8 @@
     
ACTION_TYPE_FAILED_VM_IS_NON_MIGRTABLE_AND_IS_NOT_FORCED_BY_USER_TO_MIGRATE(ErrorType.CONFLICT),
     VDS_CANNOT_MAINTENANCE_IT_INCLUDES_NON_MIGRATABLE_VM(ErrorType.CONFLICT),
     VDS_CANNOT_MAINTENANCE_VM_HAS_PLUGGED_DISK_SNAPSHOT(ErrorType.CONFLICT),
+    ACTION_TYPE_FAILED_OVF_DISK_NOT_SUPPORTED(ErrorType.CONFLICT),
+    ACTION_TYPE_FAILED_OVF_DISK_NOT_IN_APPLICABLE_STATUS(ErrorType.CONFLICT),
     
ACTION_TYPE_FAILED_VM_CANNOT_BE_HIGHLY_AVAILABLE_AND_PINNED_TO_HOST(ErrorType.CONFLICT),
     
ACTION_TYPE_FAILED_VM_CANNOT_BE_PINNED_TO_CPU_AND_MIGRATABLE(ErrorType.CONFLICT),
     
ACTION_TYPE_FAILED_VM_CANNOT_BE_PINNED_TO_CPU_WITH_UNDEFINED_HOST(ErrorType.BAD_PARAMETERS),
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 16c849b..f4029de 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -80,6 +80,8 @@
 The following VMs cannot be migrated because they have activated Disk Snapshot 
attached: \n \n\
  ${disksInfo} \n \n\
 please deactivate/detach the Disk snapshots or turn off those VMs and try 
again.
+ACTION_TYPE_FAILED_OVF_DISK_NOT_SUPPORTED=Cannot ${action} ${type}. The 
operation is currently not supported for disks used as OVF store.
+ACTION_TYPE_FAILED_OVF_DISK_NOT_IN_APPLICABLE_STATUS=Cannot ${action} ${type}. 
The operation cannot be performed for disks used as OVF store that are in the 
given status.
 VDS_CANNOT_REMOVE_DEFAULT_VDS_GROUP=Cannot remove default Host Cluster.
 VDS_CANNOT_REMOVE_VDS_DETECTED_RUNNING_VM=Cannot ${action} ${type}. One or 
more VMs are still running on this Host. 
 VDS_CANNOT_REMOVE_VDS_GROUP_VDS_DETECTED=Cannot ${action} ${type}. Host 
Cluster contains one or more Hosts.
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 c9820af..fe357c3 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
@@ -178,6 +178,12 @@
     @DefaultStringValue("Cannot switch the following Hosts to Maintenance 
mode: ${HostsList}.\nThe following VMs cannot be migrated because they have 
activated Disk Snapshot attached: \n \n ${disksInfo} \n \nplease 
deactivate/detach the Disk snapshots or turn off those VMs and try again.")
     String VDS_CANNOT_MAINTENANCE_VM_HAS_PLUGGED_DISK_SNAPSHOT();
 
+    @DefaultStringValue("Cannot ${action} ${type}. The operation is currently 
not supported for disks used as OVF store.")
+    String ACTION_TYPE_FAILED_OVF_DISK_NOT_SUPPORTED();
+
+    @DefaultStringValue("Cannot ${action} ${type}. The operation cannot be 
performed for disks used as OVF store that are in the given status.")
+    String ACTION_TYPE_FAILED_OVF_DISK_NOT_IN_APPLICABLE_STATUS();
+
     @DefaultStringValue("Cannot remove default Host Cluster.")
     String VDS_CANNOT_REMOVE_DEFAULT_VDS_GROUP();
 
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index a731ca6..46926df 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -80,6 +80,8 @@
 The following VMs cannot be migrated because they have activated Disk Snapshot 
attached: \n \n\
  ${disksInfo} \n \n
 please deactivate/detach the Disk snapshots or turn off those VMs and try 
again.
+ACTION_TYPE_FAILED_OVF_DISK_NOT_SUPPORTED=Cannot ${action} ${type}. The 
operation is currently not supported for disks used as OVF store.
+ACTION_TYPE_FAILED_OVF_DISK_NOT_IN_APPLICABLE_STATUS=Cannot ${action} ${type}. 
The operation cannot be performed for disks used as OVF store that are in the 
given status.
 VDS_CANNOT_REMOVE_DEFAULT_VDS_GROUP=Cannot remove default Host Cluster.
 VDS_CANNOT_REMOVE_VDS_DETECTED_RUNNING_VM=Cannot ${action} ${type}. One or 
more VMs are still running on this Host. 
 VDS_CANNOT_REMOVE_VDS_GROUP_VDS_DETECTED=Cannot ${action} ${type}. Host 
Cluster contains one or more Hosts.
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index c58f7b7..c2b4fe8 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -80,6 +80,8 @@
 The following VMs cannot be migrated because they have activated Disk Snapshot 
attached: \n \n\
  ${disksInfo} \n \n\
 please deactivate/detach the Disk snapshots or turn off those VMs and try 
again.
+ACTION_TYPE_FAILED_OVF_DISK_NOT_SUPPORTED=Cannot ${action} ${type}. The 
operation is currently not supported for disks used as OVF store.
+ACTION_TYPE_FAILED_OVF_DISK_NOT_IN_APPLICABLE_STATUS=Cannot ${action} ${type}. 
The operation cannot be performed for disks used as OVF store that are in the 
given status.
 VDS_CANNOT_REMOVE_DEFAULT_VDS_GROUP=Cannot remove default Host Cluster.
 VDS_CANNOT_REMOVE_VDS_DETECTED_RUNNING_VM=Cannot ${action} ${type}. One or 
more VMs are still running on this Host. 
 VDS_CANNOT_REMOVE_VDS_GROUP_VDS_DETECTED=Cannot ${action} ${type}. Host 
Cluster contains one or more Hosts.


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

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

Reply via email to