Tal Nisan has uploaded a new change for review.

Change subject: core: Prevent operations on the hosted engine disk
......................................................................

core: Prevent operations on the hosted engine disk

Prevent the hosted engine disk from being removed, attached to a VM or
updated

Change-Id: I75c1deee655278a8f575814aea22965be2bfee55
Signed-off-by: Tal Nisan <tni...@redhat.com>
Bug-Url: https://bugzilla.redhat.com/1167668
---
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/ImagesHandler.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/constants/StorageConstants.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, 27 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/35795/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 1821dd3..1781126 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
@@ -63,6 +63,10 @@
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IMAGE_DOES_NOT_EXIST);
         }
 
+        if (ImagesHandler.isHostedEngineDisk(disk)) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_HOSTED_ENGINE_DISK);
+        }
+
         disk.setReadOnly(getParameters().isReadOnly());
         DiskValidator diskValidator = getDiskValidator(disk);
 
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java
index fcbeff6..01cfa75 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java
@@ -41,6 +41,7 @@
 import org.ovirt.engine.core.common.businessentities.VolumeType;
 import org.ovirt.engine.core.common.businessentities.image_storage_domain_map;
 import 
org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface;
+import org.ovirt.engine.core.common.constants.StorageConstants;
 import org.ovirt.engine.core.common.errors.VdcBLLException;
 import org.ovirt.engine.core.common.errors.VdcBllErrors;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
@@ -843,4 +844,9 @@
         
dummy.getSnapshots().addAll(ImagesHandler.getAllImageSnapshots(dummy.getImageId()));
         return dummy;
     }
+
+    public static boolean isHostedEngineDisk(Disk disk) {
+        return disk.getDiskStorageType() == DiskStorageType.LUN &&
+                
StorageConstants.HOSTED_ENGINE_LUN_DISK_ALIAS.equals(disk.getDiskAlias());
+    }
 }
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 03a59e3..1c5e8d4 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
@@ -83,6 +83,10 @@
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IMAGE_DOES_NOT_EXIST);
         }
 
+        if (ImagesHandler.isHostedEngineDisk(getDisk())) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_HOSTED_ENGINE_DISK);
+        }
+
         return validateAllVmsForDiskAreDown() &&
                 canRemoveDiskBasedOnStorageTypeCheck();
     }
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 b5b1e3e..fd2c0fe 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
@@ -135,6 +135,10 @@
             return false;
         }
 
+        if (ImagesHandler.isHostedEngineDisk(getOldDisk())) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_HOSTED_ENGINE_DISK);
+        }
+
         if (!checkDiskUsedAsOvfStore(getOldDisk())) {
             return false;
         }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/StorageConstants.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/StorageConstants.java
index 58c1932..31be55e 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/StorageConstants.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/StorageConstants.java
@@ -3,4 +3,6 @@
 public class StorageConstants {
     public static final int SIZE_IS_NOT_AVAILABLE = -1;
     public static final int OVF_MAX_ITEMS_PER_SQL_STATEMENT = 100;
+
+    public static final String HOSTED_ENGINE_LUN_DISK_ALIAS = "hosted_engine";
 }
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 b35a856..95d633b 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
@@ -205,6 +205,7 @@
     ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE(ErrorType.CONFLICT),
     
ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_DISK_LUN_INVALID(ErrorType.BAD_PARAMETERS),
+    ACTION_TYPE_FAILED_HOSTED_ENGINE_DISK(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_UNSUPPORTED_DISK_STORAGE_TYPE(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_STORAGE_DOMAIN_UNAVAILABLE(ErrorType.BAD_PARAMETERS),
     
ACTION_TYPE_FAILED_STORAGE_DOMAIN_TYPE_UNSUPPORTED(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 e3233f7..5f7a6dc 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -221,6 +221,7 @@
 ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE=Cannot ${action} ${type}. The 
provided lun has no valid lun type.
 ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS=Cannot ${action} 
${type}. The provided lun is missing at least one connection parameter 
(address/port/iqn).
 ACTION_TYPE_FAILED_DISK_LUN_INVALID=Cannot ${action} ${type}. The provided LUN 
is not visible by the specified host, please check storage server connectivity.
+ACTION_TYPE_FAILED_HOSTED_ENGINE_DISK=Cannot ${action} ${type}. The disk 
contains the hosted engine.
 ACTION_TYPE_FAILED_MIGRATION_IN_PROGRESS=Cannot ${action} ${type}. VM 
migration is in progress
 ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST=Cannot ${action} ${type}. source and 
destination is the same.
 ACTION_TYPE_FAILED_DESTINATION_HOST_NOT_IN_DESTINATION_CLUSTER=Cannot 
${action} ${type}. Destination host is not present in destination cluster.
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 1ae6281..9576982 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
@@ -601,6 +601,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. The provided LUN is not 
visible by the specified host, please check storage server connectivity.")
     String ACTION_TYPE_FAILED_DISK_LUN_INVALID();
 
+    @DefaultStringValue("Cannot ${action} ${type}. The disk contains the 
hosted engine.")
+    String ACTION_TYPE_FAILED_HOSTED_ENGINE_DISK();
+
     @DefaultStringValue("Cannot ${action} ${type}. source and destination is 
the same.")
     String ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST();
 
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 1706555..e9101ae 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
@@ -207,6 +207,7 @@
 ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE=Cannot ${action} ${type}. The 
provided lun has no valid lun type.
 ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS=Cannot ${action} 
${type}. The provided lun is missing at least one connection parameter 
(address/port/iqn).
 ACTION_TYPE_FAILED_DISK_LUN_INVALID=Cannot ${action} ${type}. The provided LUN 
is not visible by the specified host, please check storage server connectivity.
+ACTION_TYPE_FAILED_HOSTED_ENGINE_DISK=Cannot ${action} ${type}. The disk 
contains the hosted engine.
 ACTION_TYPE_FAILED_MIGRATION_IN_PROGRESS=Cannot ${action} ${type}. VM 
migration is in progress
 ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST=Cannot ${action} ${type}. source and 
destination is the same.
 ACTION_TYPE_FAILED_DESTINATION_HOST_NOT_IN_DESTINATION_CLUSTER=Cannot 
${action} ${type}. Destination host is not present in destination cluster.
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 40585df..74b7d5f 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
@@ -218,6 +218,7 @@
 ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE=Cannot ${action} ${type}. The 
provided lun has no valid lun type.
 ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS=Cannot ${action} 
${type}. The provided lun is missing at least one connection parameter 
(address/port/iqn).
 ACTION_TYPE_FAILED_DISK_LUN_INVALID=Cannot ${action} ${type}. The provided LUN 
is not visible by the specified host, please check storage server connectivity.
+ACTION_TYPE_FAILED_HOSTED_ENGINE_DISK=Cannot ${action} ${type}. The disk 
contains the hosted engine.
 ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE=Cannot ${action} ${type}. The 
provided lun is used by another disk.
 ACTION_TYPE_FAILED_MIGRATION_IN_PROGRESS=Cannot ${action} ${type}. VM 
migration is in progress
 ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST=Cannot ${action} ${type}. source and 
destination is the same.


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I75c1deee655278a8f575814aea22965be2bfee55
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Tal Nisan <tni...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to