Sergey Gotliv has uploaded a new change for review.

Change subject: engine: Warn user when a boot disk is configured as read-only
......................................................................

engine: Warn user when a boot disk is configured as read-only

VM may fail to boot from a read-only disk unless its filesystem supports
it like an ISO. So in case user configured a boot disk as read-only we
warn him about possible consequences in UI and in the audit log.

Change-Id: I89dfc4492352b650eeafd89723e3d50de19bd5eb
Bug-Url:https://bugzilla.redhat.com/1057658
Signed-off-by: Sergey Gotliv <sgot...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.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/AuditLogType.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
6 files changed, 66 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/83/24883/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java
index ef115a1..9c7d866 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java
@@ -344,6 +344,10 @@
 
     @Override
     protected void executeVmCommand() {
+        if (getParameters().getDiskInfo().isBoot() && 
getParameters().getDiskInfo().getReadOnly()) {
+            AuditLogDirector.log(this, AuditLogType.BOOT_DISK_IS_READ_ONLY);
+        }
+
         getParameters().getDiskInfo().setId(Guid.newGuid());
         getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, 
getParameters().getDiskInfo().getId()));
         ImagesHandler.setDiskAlias(getParameters().getDiskInfo(), getVm());
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 385fecf..f3c479e 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
@@ -43,6 +43,7 @@
 import org.ovirt.engine.core.common.locks.LockingGroup;
 import org.ovirt.engine.core.common.utils.Pair;
 import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector;
 import org.ovirt.engine.core.utils.transaction.TransactionMethod;
 import org.ovirt.engine.core.utils.transaction.TransactionSupport;
 
@@ -112,6 +113,10 @@
     protected void executeVmCommand() {
         ImagesHandler.setDiskAlias(getParameters().getDiskInfo(), getVm());
 
+        if (getNewDisk().isBoot() && getNewDisk().getReadOnly()) {
+            AuditLogDirector.log(this, AuditLogType.BOOT_DISK_IS_READ_ONLY);
+        }
+
         if (shouldResizeDiskImage()) {
             extendDiskImageSize();
         } else {
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
index 2e23d58..e751d6a 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
@@ -942,7 +942,9 @@
 
     // Hosted Engine
     USER_SET_HOSTED_ENGINE_MAINTENANCE(10450),
-    USER_FAILED_TO_SET_HOSTED_ENGINE_MAINTENANCE(10451, 
AuditLogSeverity.ERROR);
+    USER_FAILED_TO_SET_HOSTED_ENGINE_MAINTENANCE(10451, 
AuditLogSeverity.ERROR),
+
+    BOOT_DISK_IS_READ_ONLY(10500, AuditLogSeverity.WARNING);
 
     private int intValue;
     // indicates time interval in seconds on which identical events from same 
instance are suppressed.
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
index eb91ca6..a1deabb 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -775,3 +775,5 @@
 ISCSI_BOND_EDIT_FAILED=Failed to update iSCSI bond '${IscsiBondName}'.
 ISCSI_BOND_REMOVE_SUCCESS=iSCSI bond '${IscsiBondName}' was removed from Data 
Center '${StoragePoolName}'
 ISCSI_BOND_REMOVE_FAILED=Failed to remove iSCSI bond '${IscsiBondName}' from 
Data Center '${StoragePoolName}'
+
+BOOT_DISK_IS_READ_ONLY=Boot disk is read-only. VM may fail to boot from the 
read-only disk.
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java
index 34d69d2..b45e97a 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java
@@ -83,6 +83,7 @@
     private String hash;
     private UICommand cancelCommand;
     private int queryCounter;
+    private boolean force;
 
     public EntityModel getIsWipeAfterDelete() {
         return isWipeAfterDelete;
@@ -253,6 +254,14 @@
 
     public void setCancelCommand(UICommand cancelCommand) {
         this.cancelCommand = cancelCommand;
+    }
+
+    public boolean isForce() {
+        return force;
+    }
+
+    public void setForce(boolean force) {
+        this.force = force;
     }
 
     public AbstractDiskModel() {
@@ -771,6 +780,11 @@
             }
         }});
 
+        if (Boolean.TRUE.equals(getIsReadOnly().getEntity()) && 
Boolean.TRUE.equals(getIsBootable().getEntity()) && !isForce()) {
+            confirmBootReadOnlyDisk();
+            return false;
+        }
+
         return getAlias().getIsValid() && getDescription().getIsValid() && 
getQuota().getIsValid() && getDiskInterface().getIsValid();
     }
 
@@ -795,6 +809,24 @@
         confirmationModel.getCommands().add(cancelconfirmCommand);
     }
 
+    private void confirmBootReadOnlyDisk() {
+        ConfirmationModel confirmationModel = new ConfirmationModel();
+        confirmationModel.setTitle(CONSTANTS.bootDiskIsReadOnly());
+        confirmationModel.setMessage(CONSTANTS.bootDiskIsReadOnlyWarning());
+        confirmationModel.setHashName("boot_readonly_disk"); //$NON-NLS-1$
+        setConfirmWindow(confirmationModel);
+
+        UICommand confirmCommand = new UICommand("OnConfirmBootReadOnlyDisk", 
this); //$NON-NLS-1$
+        confirmCommand.setTitle(CONSTANTS.ok());
+        confirmCommand.setIsDefault(true);
+        confirmationModel.getCommands().add(confirmCommand);
+
+        UICommand cancelConfirm = new UICommand("CancelConfirm", this); 
//$NON-NLS-1$
+        cancelConfirm.setTitle(CONSTANTS.cancel());
+        cancelConfirm.setIsDefault(true);
+        confirmationModel.getCommands().add(cancelConfirm);
+    }
+
     private void onForceSave() {
         ConfirmationModel confirmationModel = (ConfirmationModel) 
getConfirmWindow();
         if (confirmationModel != null && !confirmationModel.validate()) {
@@ -803,6 +835,17 @@
         cancelConfirm();
 
         getSanStorageModel().setForce(true);
+        onSave();
+    }
+
+    private void onConfirmBootReadOnlyDisk() {
+        ConfirmationModel confirmationModel = (ConfirmationModel) 
getConfirmWindow();
+        if (confirmationModel != null && !confirmationModel.validate()) {
+            return;
+        }
+        cancelConfirm();
+
+        setForce(true);
         onSave();
     }
 
@@ -867,6 +910,9 @@
         else if ("CancelConfirm".equals(command.getName())) { //$NON-NLS-1$
             cancelConfirm();
         }
+        else if ("OnConfirmBootReadOnlyDisk".equals(command.getName())) { 
//$NON-NLS-1$
+            onConfirmBootReadOnlyDisk();
+        }
     }
 
     @Override
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
index b3ca124..c8cc34e 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
@@ -2208,5 +2208,11 @@
 
     @DefaultStringValue("Not Active")
     String haNotActive();
+
+    @DefaultStringValue("NOTE: Boot disk is read-only. VM may fail to boot 
from the read-only disk.")
+    String bootDiskIsReadOnlyWarning();
+
+    @DefaultStringValue("Boot disk is a read-only")
+    String bootDiskIsReadOnly();
 }
 


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

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

Reply via email to