Greg Padgett has uploaded a new change for review.

Change subject: webadmin, backend: control of hosted engine maintenance mode
......................................................................

webadmin, backend: control of hosted engine maintenance mode

Allow control of hosted engine local/global maintenance.  Global
maintenance is performed via right-clicking on the host, while local
maintenance is tied into the existing host vds maintenance operation.

Change-Id: I0f76f7ad63bcf6d7871c362b46cfa6e928eb9c74
Bug-Url: https://bugzilla.redhat.com/1047649
Signed-off-by: Greg Padgett <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ActivateVdsCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceVdsCommand.java
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetHaMaintenanceCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/SetHaMaintenanceParameters.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/HaMaintenanceMode.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/SetHaMaintenanceModeVDSCommandParameters.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
A 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetHaMaintenanceModeVDSCommand.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.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/vms/VmListModel.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
M 
frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVirtualMachineView.java
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
A packaging/dbscripts/upgrade/03_05_0040_add_ha_maintenance_events.sql
27 files changed, 404 insertions(+), 6 deletions(-)


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

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ActivateVdsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ActivateVdsCommand.java
index ac25c94..2d867b4 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ActivateVdsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ActivateVdsCommand.java
@@ -9,6 +9,7 @@
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.action.VdsActionParameters;
+import org.ovirt.engine.core.common.businessentities.HaMaintenanceMode;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.network.Network;
@@ -16,6 +17,7 @@
 import org.ovirt.engine.core.common.locks.LockingGroup;
 import org.ovirt.engine.core.common.utils.Pair;
 import 
org.ovirt.engine.core.common.vdscommands.ActivateVdsVDSCommandParameters;
+import 
org.ovirt.engine.core.common.vdscommands.SetHaMaintenanceModeVDSCommandParameters;
 import 
org.ovirt.engine.core.common.vdscommands.SetVdsStatusVDSCommandParameters;
 import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
 import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
@@ -28,8 +30,11 @@
 @NonTransactiveCommandAttribute
 public class ActivateVdsCommand<T extends VdsActionParameters> extends 
VdsCommand<T> {
 
+    private boolean haMaintenanceFailed;
+
     public ActivateVdsCommand(T parameters) {
         super(parameters);
+        haMaintenanceFailed = false;
     }
 
     /**
@@ -39,6 +44,7 @@
      */
     protected ActivateVdsCommand(Guid commandId) {
         super(commandId);
+        haMaintenanceFailed = false;
     }
 
     @Override
@@ -67,6 +73,14 @@
                         return null;
                     }
                 });
+
+                if (vds.getHighlyAvailableIsConfigured()) {
+                    SetHaMaintenanceModeVDSCommandParameters param
+                            = new 
SetHaMaintenanceModeVDSCommandParameters(vds, HaMaintenanceMode.LOCAL, false);
+                    if (!runVdsCommand(VDSCommandType.SetHaMaintenanceMode, 
param).getSucceeded()) {
+                        haMaintenanceFailed = true;
+                    }
+                }
             } else {
                 // We didn't manage to activate host. Set its status to Error
                 runVdsCommand(VDSCommandType.SetVdsStatus,
@@ -100,9 +114,17 @@
     @Override
     public AuditLogType getAuditLogTypeValue() {
         if (getParameters().isRunSilent()) {
-            return getSucceeded() ? AuditLogType.VDS_ACTIVATE_ASYNC : 
AuditLogType.VDS_ACTIVATE_FAILED_ASYNC;
+            return getSucceeded()
+                    ? (haMaintenanceFailed
+                            ? AuditLogType.VDS_ACTIVATE_MANUAL_HA_ASYNC
+                            : AuditLogType.VDS_ACTIVATE_ASYNC)
+                    : AuditLogType.VDS_ACTIVATE_FAILED_ASYNC;
         } else {
-            return getSucceeded() ? AuditLogType.VDS_ACTIVATE : 
AuditLogType.VDS_ACTIVATE_FAILED;
+            return getSucceeded()
+                    ? (haMaintenanceFailed
+                            ? AuditLogType.VDS_ACTIVATE_MANUAL_HA
+                            : AuditLogType.VDS_ACTIVATE)
+                    : AuditLogType.VDS_ACTIVATE_FAILED;
         }
     }
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java
index 4867e60..8d4eecb 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java
@@ -203,6 +203,10 @@
 
                         List<String> nonMigratableVmDescriptionsToFrontEnd = 
new ArrayList<String>();
                         for (VM vm : vms) {
+                            if (vm.isHostedEngine()) {
+                                // The Hosted Engine vm is migrated by the HA 
agent
+                                continue;
+                            }
                             if (vm.getMigrationSupport() != 
MigrationSupport.MIGRATABLE) {
                                 
nonMigratableVmDescriptionsToFrontEnd.add(vm.getName());
                             }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceVdsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceVdsCommand.java
index f6a25ab..8c62c03 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceVdsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceVdsCommand.java
@@ -16,6 +16,7 @@
 import org.ovirt.engine.core.common.action.MaintenanceVdsParameters;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.action.VdcReturnValueBase;
+import org.ovirt.engine.core.common.businessentities.HaMaintenanceMode;
 import org.ovirt.engine.core.common.businessentities.MigrationSupport;
 import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.core.common.businessentities.StoragePoolStatus;
@@ -32,6 +33,7 @@
 import org.ovirt.engine.core.common.job.Step;
 import org.ovirt.engine.core.common.job.StepEnum;
 import 
org.ovirt.engine.core.common.vdscommands.DisconnectStoragePoolVDSCommandParameters;
+import 
org.ovirt.engine.core.common.vdscommands.SetHaMaintenanceModeVDSCommandParameters;
 import 
org.ovirt.engine.core.common.vdscommands.SetVdsStatusVDSCommandParameters;
 import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
 import org.ovirt.engine.core.compat.Guid;
@@ -47,10 +49,12 @@
 
     private final boolean _isInternal;
     private List<VM> vms;
+    private boolean haMaintenanceFailed;
 
     public MaintenanceVdsCommand(T parameters) {
         super(parameters);
         _isInternal = parameters.getIsInternal();
+        haMaintenanceFailed = false;
     }
 
     @Override
@@ -60,6 +64,22 @@
             setSucceeded(true);
         } else {
             orderListOfRunningVmsOnVds(getVdsId());
+
+            if (getVds().getHighlyAvailableIsConfigured()) {
+                SetHaMaintenanceModeVDSCommandParameters params
+                        = new 
SetHaMaintenanceModeVDSCommandParameters(getVds(), HaMaintenanceMode.LOCAL, 
true);
+                if (!runVdsCommand(VDSCommandType.SetHaMaintenanceMode, 
params).getSucceeded()) {
+                    // HA maintenance failure is fatal only if the Hosted 
Engine vm is running on this host
+                    for (VM vm : vms) {
+                        if (vm.isHostedEngine()) {
+                            setSucceeded(false);
+                            return;
+                        }
+                    }
+                    haMaintenanceFailed = true;
+                }
+            }
+
             setSucceeded(migrateAllVms(getExecutionContext()));
 
             // if non responsive move directly to maintenance
@@ -103,6 +123,10 @@
         boolean succeeded = true;
 
         for (VM vm : vms) {
+            if (vm.isHostedEngine()) {
+                // The Hosted Engine vm is migrated by the HA agent
+                continue;
+            }
             // if HAOnly is true check that vm is HA (auto_startup should be 
true)
             if (vm.getStatus() != VMStatus.MigratingFrom && (!HAOnly || 
(HAOnly && vm.isAutoStartup()))) {
                 VdcReturnValueBase result =
@@ -145,14 +169,18 @@
     @Override
     public AuditLogType getAuditLogTypeValue() {
         if (_isInternal) {
-            if (getSucceeded()) {
+            if (getSucceeded() && !haMaintenanceFailed) {
                 return AuditLogType.VDS_MAINTENANCE;
+            } else if (getSucceeded()) {
+                return AuditLogType.VDS_MAINTENANCE_MANUAL_HA;
             } else {
                 return AuditLogType.VDS_MAINTENANCE_FAILED;
             }
         } else {
-            if (getSucceeded()) {
+            if (getSucceeded() && !haMaintenanceFailed) {
                 return AuditLogType.USER_VDS_MAINTENANCE;
+            } else if (getSucceeded()) {
+                return AuditLogType.USER_VDS_MAINTENANCE_MANUAL_HA;
             } else {
                 return AuditLogType.USER_VDS_MAINTENANCE_MIGRATION_FAILED;
             }
@@ -174,6 +202,10 @@
         orderListOfRunningVmsOnVds(vdsId);
 
         for (VM vm : vms) {
+            if (vm.isHostedEngine()) {
+                // The Hosted Engine vm is migrated by the HA agent
+                continue;
+            }
             if (vm.getMigrationSupport() != MigrationSupport.MIGRATABLE) {
                 
reasons.add(VdcBllMessages.VDS_CANNOT_MAINTENANCE_IT_INCLUDES_NON_MIGRATABLE_VM.toString());
                 return false;
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetHaMaintenanceCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetHaMaintenanceCommand.java
new file mode 100644
index 0000000..68a1acc
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetHaMaintenanceCommand.java
@@ -0,0 +1,77 @@
+package org.ovirt.engine.core.bll;
+
+
+import org.ovirt.engine.core.bll.utils.PermissionSubject;
+import org.ovirt.engine.core.common.AuditLogType;
+import org.ovirt.engine.core.common.VdcObjectType;
+import org.ovirt.engine.core.common.action.SetHaMaintenanceParameters;
+import org.ovirt.engine.core.common.errors.VdcBLLException;
+import org.ovirt.engine.core.common.errors.VdcBllMessages;
+import 
org.ovirt.engine.core.common.vdscommands.SetHaMaintenanceModeVDSCommandParameters;
+import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
+import org.ovirt.engine.core.compat.Version;
+
+import java.util.Collections;
+import java.util.List;
+
+@NonTransactiveCommandAttribute
+public class SetHaMaintenanceCommand extends 
VdsCommand<SetHaMaintenanceParameters> {
+
+    public SetHaMaintenanceCommand(SetHaMaintenanceParameters 
vdsActionParameters) {
+        super(vdsActionParameters);
+    }
+
+    @Override
+    protected void executeCommand() {
+        boolean succeeded = false;
+        SetHaMaintenanceParameters params = getParameters();
+        try {
+            succeeded = runVdsCommand(
+                    VDSCommandType.SetHaMaintenanceMode,
+                    new SetHaMaintenanceModeVDSCommandParameters(
+                            getVds(), params.getMode(), params.getIsEnabled()))
+                    .getSucceeded();
+        } catch (VdcBLLException e) {
+            log.errorFormat("Could not {0} {1} Hosted Engine HA maintenance 
mode on host {2}",
+                    (params.getIsEnabled() ? "enable" : "disable"),
+                    params.getMode().name().toLowerCase(),
+                    getVdsName());
+        }
+        getReturnValue().setSucceeded(succeeded);
+    }
+
+    @Override
+    protected boolean canDoAction() {
+        VdsValidator vdsValidator = new VdsValidator(getVds());
+
+        if (!validate(vdsValidator.exists())
+                || !validate(vdsValidator.isUp())) {
+            return false;
+        }
+        if (getVds().getVdsGroupCompatibilityVersion().compareTo(Version.v3_4) 
< 0) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VDS_HA_MAINT_NOT_SUPPORTED);
+        }
+        if (!getVds().getHighlyAvailableIsConfigured()) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VDS_HA_NOT_CONFIGURED);
+        }
+        return true;
+    }
+
+    @Override
+    public List<PermissionSubject> getPermissionCheckSubjects() {
+        return Collections.singletonList(new 
PermissionSubject(getParameters().getVdsId(),
+                VdcObjectType.VDS, getActionType().getActionGroup()));
+    }
+
+    @Override
+    public AuditLogType getAuditLogTypeValue() {
+        return getSucceeded() ? AuditLogType.USER_SET_HOSTED_ENGINE_MAINTENANCE
+                : AuditLogType.USER_FAILED_TO_SET_HOSTED_ENGINE_MAINTENANCE;
+    }
+
+    @Override
+    protected void setActionMessageParameters() {
+        addCanDoActionMessage(VdcBllMessages.VAR__TYPE__VM__CLUSTER);
+        addCanDoActionMessage(VdcBllMessages.VAR__ACTION__UPDATE);
+    }
+}
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 c68975e..bc0cb28 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
@@ -16,6 +16,7 @@
     VDS_RECOVER(14), // When VDS changes status down->up
     VDS_MAINTENANCE(15, AuditLogSeverity.WARNING), // When VDS is transferred 
to maintenance mode
     VDS_ACTIVATE(16), // When VDS is reactivated
+    VDS_ACTIVATE_MANUAL_HA(10454), // When VDS is reactivated
     VDS_MAINTENANCE_FAILED(17, AuditLogSeverity.ERROR,
             AuditLogTimeInterval.MINUTE.getValue()), // When VDS is 
transferred to maintenance mode
     VDS_ACTIVATE_FAILED(18, AuditLogSeverity.ERROR,
@@ -89,6 +90,8 @@
     CPU_FLAGS_NX_IS_MISSING(601, AuditLogSeverity.WARNING),
     // maintenance mode
     USER_VDS_MAINTENANCE_MIGRATION_FAILED(602, AuditLogSeverity.WARNING),
+    VDS_MAINTENANCE_MANUAL_HA(10452, AuditLogTimeInterval.MINUTE.getValue()),
+    USER_VDS_MAINTENANCE_MANUAL_HA(10453),
 
     SYSTEM_VDS_RESTART(121, AuditLogTimeInterval.MINUTE.getValue()),
     SYSTEM_FAILED_VDS_RESTART(122, AuditLogSeverity.ERROR,
@@ -825,6 +828,7 @@
     TASK_CLEARING_ASYNC_TASK(9501, AuditLogTimeInterval.MINUTE.getValue()),
 
     VDS_ACTIVATE_ASYNC(9502, AuditLogTimeInterval.HOUR.getValue() * 3), // 
When VDS is reactivated by autorecovery
+    VDS_ACTIVATE_MANUAL_HA_ASYNC(10455, AuditLogTimeInterval.HOUR.getValue() * 
3), // When VDS is reactivated by autorecovery
     VDS_ACTIVATE_FAILED_ASYNC(9503, AuditLogTimeInterval.HOUR.getValue() * 3), 
// When VDS is reactivated
     STORAGE_ACTIVATE_ASYNC(9504, AuditLogTimeInterval.HOUR.getValue() * 3), // 
When VDS is reactivated by autorecovery
 
@@ -932,7 +936,11 @@
     ISCSI_BOND_EDIT_SUCCESS(10402),
     ISCSI_BOND_EDIT_FAILED(10403, AuditLogSeverity.ERROR),
     ISCSI_BOND_REMOVE_SUCCESS(10404),
-    ISCSI_BOND_REMOVE_FAILED(10405, AuditLogSeverity.ERROR);
+    ISCSI_BOND_REMOVE_FAILED(10405, AuditLogSeverity.ERROR),
+
+    // Hosted Engine
+    USER_SET_HOSTED_ENGINE_MAINTENANCE(10450),
+    USER_FAILED_TO_SET_HOSTED_ENGINE_MAINTENANCE(10451);
 
     private int intValue;
     // indicates time interval in seconds on which identical events from same 
instance are suppressed.
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
index 932e774..05f8b2c 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
@@ -20,7 +20,9 @@
         // VDS
         AddEventNotificationEntry(EventNotificationEntity.Host, 
AuditLogType.VDS_FAILURE);
         AddEventNotificationEntry(EventNotificationEntity.Host, 
AuditLogType.USER_VDS_MAINTENANCE);
+        AddEventNotificationEntry(EventNotificationEntity.Host, 
AuditLogType.USER_VDS_MAINTENANCE_MANUAL_HA);
         AddEventNotificationEntry(EventNotificationEntity.Host, 
AuditLogType.USER_VDS_MAINTENANCE_MIGRATION_FAILED);
+        AddEventNotificationEntry(EventNotificationEntity.Host, 
AuditLogType.VDS_ACTIVATE_MANUAL_HA);
         AddEventNotificationEntry(EventNotificationEntity.Host, 
AuditLogType.VDS_ACTIVATE_FAILED);
         AddEventNotificationEntry(EventNotificationEntity.Host, 
AuditLogType.VDS_RECOVER_FAILED);
         AddEventNotificationEntry(EventNotificationEntity.Host, 
AuditLogType.VDS_APPROVE_FAILED);
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/SetHaMaintenanceParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/SetHaMaintenanceParameters.java
new file mode 100644
index 0000000..2b95188
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/SetHaMaintenanceParameters.java
@@ -0,0 +1,27 @@
+package org.ovirt.engine.core.common.action;
+
+import org.ovirt.engine.core.common.businessentities.HaMaintenanceMode;
+import org.ovirt.engine.core.compat.Guid;
+
+public class SetHaMaintenanceParameters extends VdsActionParameters {
+    private static final long serialVersionUID = -3296572537630656681L;
+    private HaMaintenanceMode mode;
+    private boolean enabled;
+
+    public SetHaMaintenanceParameters(Guid vdsId, HaMaintenanceMode mode, 
boolean enabled) {
+        super(vdsId);
+        this.mode = mode;
+        this.enabled = enabled;
+    }
+
+    public SetHaMaintenanceParameters() {
+    }
+
+    public HaMaintenanceMode getMode() {
+        return mode;
+    }
+
+    public boolean getIsEnabled() {
+        return enabled;
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
index bc781ea..ec15f33 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
@@ -332,8 +332,9 @@
     // ISCSI Bonds
     AddIscsiBond(2000, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, 
QuotaDependency.NONE),
     EditIscsiBond(2001, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, 
QuotaDependency.NONE),
-    RemoveIscsiBond(2002, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, 
QuotaDependency.NONE);
+    RemoveIscsiBond(2002, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, 
QuotaDependency.NONE),
 
+    SetHaMaintenance(2050, ActionGroup.MANIPULATE_HOST, false, 
QuotaDependency.NONE);
 
     private int intValue;
     private ActionGroup actionGroup;
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/HaMaintenanceMode.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/HaMaintenanceMode.java
new file mode 100644
index 0000000..c1dd681
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/HaMaintenanceMode.java
@@ -0,0 +1,14 @@
+package org.ovirt.engine.core.common.businessentities;
+
+public enum HaMaintenanceMode {
+    GLOBAL,
+    LOCAL;
+
+    public int getValue() {
+        return this.ordinal();
+    }
+
+    public static HaMaintenanceMode forValue(int value) {
+        return values()[value];
+    }
+}
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 bb30c0a..546d7f4 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
@@ -766,6 +766,8 @@
     ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_EMPTY(ErrorType.BAD_PARAMETERS),
     
ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_BASE_TEMPLATE_DOES_NOT_EXIST(ErrorType.BAD_PARAMETERS),
+    ACTION_TYPE_FAILED_VDS_HA_MAINT_NOT_SUPPORTED(ErrorType.BAD_PARAMETERS),
+    ACTION_TYPE_FAILED_VDS_HA_NOT_CONFIGURED(ErrorType.BAD_PARAMETERS),
     // Cluster Policy messages
     
ACTION_TYPE_FAILED_CLUSTER_POLICY_PARAMETERS_INVALID(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_CLUSTER_POLICY_NAME_INUSE(ErrorType.BAD_PARAMETERS),
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/SetHaMaintenanceModeVDSCommandParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/SetHaMaintenanceModeVDSCommandParameters.java
new file mode 100644
index 0000000..d4889be
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/SetHaMaintenanceModeVDSCommandParameters.java
@@ -0,0 +1,37 @@
+package org.ovirt.engine.core.common.vdscommands;
+
+import org.ovirt.engine.core.common.businessentities.HaMaintenanceMode;
+import org.ovirt.engine.core.common.businessentities.VDS;
+
+/**
+ * Parameters used to change Hosted Engine maintenance mode
+ */
+public class SetHaMaintenanceModeVDSCommandParameters extends 
VdsIdVDSCommandParametersBase {
+    private HaMaintenanceMode mode;
+    private boolean enabled;
+
+    public SetHaMaintenanceModeVDSCommandParameters(VDS vds, HaMaintenanceMode 
mode, boolean enabled) {
+        super(vds.getId());
+        this.mode = mode;
+        this.enabled = enabled;
+    }
+
+    public SetHaMaintenanceModeVDSCommandParameters() {
+    }
+
+    public HaMaintenanceMode getMode() {
+        return mode;
+    }
+
+    public void setMode(HaMaintenanceMode mode) {
+        this.mode = mode;
+    }
+
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    public void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
index 3b9aea0..60aab98 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
@@ -118,6 +118,7 @@
     ExtendImageSize("org.ovirt.engine.core.vdsbroker.irsbroker"),
     ExtendVmDiskSize("org.ovirt.engine.core.vdsbroker.vdsbroker"),
     SetMOMPolicyParameters("org.ovirt.engine.core.vdsbroker.vdsbroker"),
+    SetHaMaintenanceMode("org.ovirt.engine.core.vdsbroker.vdsbroker"),
     // Gluster VDS commands
     CreateGlusterVolume("org.ovirt.engine.core.vdsbroker.gluster"),
     SetGlusterVolumeOption("org.ovirt.engine.core.vdsbroker.gluster"),
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
index 1135b85..3522379 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
@@ -63,6 +63,7 @@
         initMomPoliciesSeverities();
         initPmPolicySeverities();
         initIscsiBondSeverities();
+        initHostedEngineSeverities();
     }
 
     private static void initProviderSeverities() {
@@ -300,12 +301,15 @@
         severities.put(AuditLogType.VDS_RECOVER_FAILED, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.VDS_RECOVER_FAILED_VMS_UNKNOWN, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.VDS_MAINTENANCE, AuditLogSeverity.WARNING);
+        severities.put(AuditLogType.VDS_MAINTENANCE_MANUAL_HA, 
AuditLogSeverity.WARNING);
         severities.put(AuditLogType.VDS_MAINTENANCE_FAILED, 
AuditLogSeverity.ERROR);
         
severities.put(AuditLogType.VDS_STATUS_CHANGE_FAILED_DUE_TO_STOP_SPM_FAILURE, 
AuditLogSeverity.WARNING);
+        severities.put(AuditLogType.USER_VDS_MAINTENANCE_MANUAL_HA, 
AuditLogSeverity.WARNING);
         severities.put(AuditLogType.USER_VDS_MAINTENANCE_MIGRATION_FAILED, 
AuditLogSeverity.WARNING);
         severities.put(AuditLogType.SYSTEM_VDS_RESTART, 
AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.SYSTEM_FAILED_VDS_RESTART, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.VDS_ACTIVATE, AuditLogSeverity.NORMAL);
+        severities.put(AuditLogType.VDS_ACTIVATE_MANUAL_HA, 
AuditLogSeverity.WARNING);
         severities.put(AuditLogType.VDS_ACTIVATE_FAILED, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.HOST_REFRESHED_CAPABILITIES, 
AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.HOST_REFRESH_CAPABILITIES_FAILED, 
AuditLogSeverity.ERROR);
@@ -359,6 +363,7 @@
         severities.put(AuditLogType.VDS_LOW_DISK_SPACE, 
AuditLogSeverity.WARNING);
         severities.put(AuditLogType.VDS_LOW_DISK_SPACE_ERROR, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.VDS_ACTIVATE_ASYNC, 
AuditLogSeverity.NORMAL);
+        severities.put(AuditLogType.VDS_ACTIVATE_MANUAL_HA_ASYNC, 
AuditLogSeverity.WARNING);
         severities.put(AuditLogType.VDS_ACTIVATE_FAILED_ASYNC, 
AuditLogSeverity.NORMAL);
         
severities.put(AuditLogType.VDS_SET_NON_OPERATIONAL_VM_NETWORK_IS_BRIDGELESS, 
AuditLogSeverity.WARNING);
         
severities.put(AuditLogType.EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER, 
AuditLogSeverity.WARNING);
@@ -513,6 +518,11 @@
         severities.put(AuditLogType.USER_FAILED_TO_UPDATE_MOM_POLICIES, 
AuditLogSeverity.WARNING);
     }
 
+    private static void initHostedEngineSeverities() {
+        severities.put(AuditLogType.USER_SET_HOSTED_ENGINE_MAINTENANCE, 
AuditLogSeverity.NORMAL);
+        
severities.put(AuditLogType.USER_FAILED_TO_SET_HOSTED_ENGINE_MAINTENANCE, 
AuditLogSeverity.WARNING);
+    }
+
     private static void initVMSeverities() {
         severities.put(AuditLogType.USER_ATTACH_VM_TO_AD_GROUP, 
AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.USER_ATTACH_VM_TO_AD_GROUP_FAILED, 
AuditLogSeverity.ERROR);
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 fdf8b12..eb91ca6 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -212,6 +212,8 @@
 VDC_STOP=Stopping oVirt Engine.
 VDS_ACTIVATE=Host ${VdsName} was activated by ${UserName}.
 VDS_ACTIVATE_ASYNC=Host ${VdsName} was autorecovered.
+VDS_ACTIVATE_MANUAL_HA=Host ${VdsName} was activated by ${UserName}, but the 
Hosted Engine HA service may still be in maintenance mode. If necessary, please 
correct this manually.
+VDS_ACTIVATE_MANUAL_HA_ASYNC=Host ${VdsName} was autorecovered, but the Hosted 
Engine HA service may still be in maintenance mode. If necessary, please 
correct this manually.
 VDS_ACTIVATE_FAILED=Failed to activate Host ${VdsName}.(User: ${UserName}).
 VDS_ACTIVATE_FAILED_ASYNC=Failed to autorecover Host ${VdsName}.
 HOST_REFRESHED_CAPABILITIES=Successfully refreshed the capabilities of host 
${VdsName}.
@@ -219,6 +221,7 @@
 VDS_DETECTED=Status of host ${VdsName} was set to ${HostStatus}.
 VDS_FAILURE=Host ${VdsName} is non responsive.
 VDS_MAINTENANCE=Host ${VdsName} was switched to Maintenance Mode.
+VDS_MAINTENANCE_MANUAL_HA=Host ${VdsName} was switched to Maintenance mode, 
but Hosted Engine HA maintenance could not be enabled. Please enable it 
manually.
 VDS_MAINTENANCE_FAILED=Failed to switch Host ${VdsName} to Maintenance mode.
 VDS_RECOVER=Host ${VdsName} is rebooting.
 VDS_RECOVER_FAILED=Host ${VdsName} failed to recover.
@@ -300,6 +303,7 @@
 USER_SUSPEND_VM_FINISH_FAILURE_WILL_TRY_AGAIN=Failed to complete suspending of 
VM ${VmName}, will try again.
 USER_FAILED_SUSPEND_VM=Failed to suspend VM ${VmName} (Host: ${VdsName}).
 USER_VDS_MAINTENANCE=Host ${VdsName} was switched to Maintenance mode by 
${UserName}.
+USER_VDS_MAINTENANCE_MANUAL_HA=Host ${VdsName} was switched to Maintenance 
mode by ${UserName}, but Hosted Engine HA maintenance could not be enabled. 
Please enable it manually.
 USER_VDS_MAINTENANCE_MIGRATION_FAILED=Host ${VdsName} cannot change into 
maintenance mode - not all Vms have been migrated successfully. Consider manual 
intervention: stopping/migrating Vms: ${failedVms} (User: ${UserName}).
 USER_EXPORT_VM=VM ${VmName} exported to ${ExportPath} by ${UserName}
 USER_EXPORT_VM_FAILED=Failed to export VM ${VmName} to ${ExportPath} (User: 
${UserName})
@@ -762,6 +766,8 @@
 USER_FAILED_TO_UPDATE_AFFINITY_GROUP=Failed to update Affinity Group 
${affinityGroupName}. (User: ${UserName})
 USER_REMOVED_AFFINITY_GROUP=Affinity Group ${affinityGroupName} was removed. 
(User: ${UserName})
 USER_FAILED_TO_REMOVE_AFFINITY_GROUP=Failed to remove Affinity Group 
${affinityGroupName}. (User: ${UserName})
+USER_SET_HOSTED_ENGINE_MAINTENANCE=Hosted Engine HA maintenance mode was 
updated on host ${VdsName}.
+USER_FAILED_TO_SET_HOSTED_ENGINE_MAINTENANCE=Hosted Engine HA maintenance mode 
could not be updated on host ${VdsName}.
 
 ISCSI_BOND_ADD_SUCCESS=iSCSI bond '${IscsiBondName}' was successfully created 
in Data Center '${StoragePoolName}'.
 ISCSI_BOND_ADD_FAILED=Failed to create iSCSI bond '${IscsiBondName}' in Data 
Center '${StoragePoolName}'.
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
index 173c9e6..d9bbe93 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
@@ -48,6 +48,8 @@
 
     StatusOnlyReturnForXmlRpc setMOMPolicyParameters(Map<String, Object> 
key_value_store);
 
+    StatusOnlyReturnForXmlRpc setHaMaintenanceMode(String mode, boolean 
enabled);
+
     StatusOnlyReturnForXmlRpc desktopLogin(String vmId, String domain, String 
user, String password);
 
     StatusOnlyReturnForXmlRpc desktopLogoff(String vmId, String force);
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetHaMaintenanceModeVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetHaMaintenanceModeVDSCommand.java
new file mode 100644
index 0000000..0ad63b8
--- /dev/null
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetHaMaintenanceModeVDSCommand.java
@@ -0,0 +1,22 @@
+package org.ovirt.engine.core.vdsbroker.vdsbroker;
+
+import 
org.ovirt.engine.core.common.vdscommands.SetHaMaintenanceModeVDSCommandParameters;
+import org.ovirt.engine.core.dal.dbbroker.DbFacade;
+
+/**
+ * Send variables that set Hosted Engine maintenance mode to VDSM
+ */
+public class SetHaMaintenanceModeVDSCommand extends 
VdsBrokerCommand<SetHaMaintenanceModeVDSCommandParameters> {
+
+    public 
SetHaMaintenanceModeVDSCommand(SetHaMaintenanceModeVDSCommandParameters 
parameters) {
+        super(parameters, 
DbFacade.getInstance().getVdsDao().get(parameters.getVdsId()));
+    }
+
+    @Override
+    protected void executeVdsBrokerCommand() {
+        if (getVds().getHighlyAvailableIsConfigured()) {
+            status = 
getBroker().setHaMaintenanceMode(getParameters().getMode().name(), 
getParameters().isEnabled());
+            proceedProxyReturnValue();
+        }
+    }
+}
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
index 816de0f..5ae6d27 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
@@ -36,6 +36,8 @@
 
     public Map<String, Object> setMOMPolicyParameters(Map<String, Object> 
key_value);
 
+    public Map<String, Object> setHaMaintenanceMode(String mode, boolean 
enabled);
+
     public Map<String, Object> getAllVmStats();
 
     public Map<String, Object> migrate(Map<String, String> migrationInfo);
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
index ae3727b..c3073cd 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
@@ -1379,6 +1379,17 @@
     }
 
     @Override
+    public StatusOnlyReturnForXmlRpc setHaMaintenanceMode(String mode, boolean 
enabled) {
+        try {
+            Map<String, Object> xmlRpcReturnValue = 
vdsServer.setHaMaintenanceMode(mode, enabled);
+            StatusOnlyReturnForXmlRpc wrapper = new 
StatusOnlyReturnForXmlRpc(xmlRpcReturnValue);
+            return wrapper;
+        } catch (UndeclaredThrowableException ute) {
+            throw new XmlRpcRunTimeException(ute);
+        }
+    }
+
+    @Override
     public GlusterTasksListReturnForXmlRpc glusterTasksList() {
         try {
             Map<String, Object> xmlRpcReturnValue = 
vdsServer.glusterTasksList();
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 91505d5..a208c60 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
@@ -1654,6 +1654,12 @@
     @DefaultStringValue("Cannot ${action} ${type}. The selected Template has 
undefined architecture")
     String 
ACTION_TYPE_FAILED_VM_CANNOT_IMPORT_TEMPLATE_WITH_NOT_SUPPORTED_ARCHITECTURE();
 
+    @DefaultStringValue("Cannot ${action} ${type}. Setting hosted engine 
maintenance mode is only supported on cluster version 3.4 and above.")
+    String ACTION_TYPE_FAILED_VDS_HA_MAINT_NOT_SUPPORTED();
+
+    @DefaultStringValue("Cannot ${action} ${type}. Hosted Engine is not 
configured on this host.")
+    String ACTION_TYPE_FAILED_VDS_HA_NOT_CONFIGURED();
+
     @DefaultStringValue("Cannot ${action} ${type}. The cluster's compatibility 
version doesn't support MoM Policy update.")
     String ACTION_TYPE_FAILED_MOM_UPDATE_VDS_VERSION();
 
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 05e6623..51de0cc 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
@@ -56,6 +56,7 @@
         <include name="common/businessentities/VmBalloonInfo.java" />
                <include name="common/businessentities/ArchitectureType.java" />
         <include name="common/businessentities/IscsiBond.java" />
+        <include name="common/businessentities/HaMaintenanceMode.java" />
 
                <!-- Network business entities -->
                <include 
name="common/businessentities/network/VdsNetworkInterface.java" />
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
index 0de36ce..5af8beb 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
@@ -20,6 +20,7 @@
 import org.ovirt.engine.core.common.action.MoveVmParameters;
 import org.ovirt.engine.core.common.action.RemoveVmParameters;
 import org.ovirt.engine.core.common.action.RunVmParams;
+import org.ovirt.engine.core.common.action.SetHaMaintenanceParameters;
 import org.ovirt.engine.core.common.action.ShutdownVmParameters;
 import org.ovirt.engine.core.common.action.StopVmParameters;
 import org.ovirt.engine.core.common.action.StopVmTypeEnum;
@@ -31,6 +32,7 @@
 import org.ovirt.engine.core.common.businessentities.Disk;
 import org.ovirt.engine.core.common.businessentities.Disk.DiskStorageType;
 import org.ovirt.engine.core.common.businessentities.DiskImage;
+import org.ovirt.engine.core.common.businessentities.HaMaintenanceMode;
 import org.ovirt.engine.core.common.businessentities.StorageDomain;
 import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.core.common.businessentities.Tags;
@@ -317,6 +319,30 @@
         privateAssignTagsCommand = value;
     }
 
+    private UICommand privateEnableGlobalHaMaintenanceCommand;
+
+    public UICommand getEnableGlobalHaMaintenanceCommand()
+    {
+        return privateEnableGlobalHaMaintenanceCommand;
+    }
+
+    private void setEnableGlobalHaMaintenanceCommand(UICommand value)
+    {
+        privateEnableGlobalHaMaintenanceCommand = value;
+    }
+
+    private UICommand privateDisableGlobalHaMaintenanceCommand;
+
+    public UICommand getDisableGlobalHaMaintenanceCommand()
+    {
+        return privateDisableGlobalHaMaintenanceCommand;
+    }
+
+    private void setDisableGlobalHaMaintenanceCommand(UICommand value)
+    {
+        privateDisableGlobalHaMaintenanceCommand = value;
+    }
+
     UICommand editConsoleCommand;
 
     public void setEditConsoleCommand(UICommand editConsoleCommand) {
@@ -426,6 +452,8 @@
         setRetrieveIsoImagesCommand(new UICommand("RetrieveIsoImages", this)); 
//$NON-NLS-1$
         setChangeCdCommand(new UICommand("ChangeCD", this)); //$NON-NLS-1$
         setAssignTagsCommand(new UICommand("AssignTags", this)); //$NON-NLS-1$
+        setEnableGlobalHaMaintenanceCommand(new 
UICommand("EnableGlobalHaMaintenance", this)); //$NON-NLS-1$
+        setDisableGlobalHaMaintenanceCommand(new 
UICommand("DisableGlobalHaMaintenance", this)); //$NON-NLS-1$
 
         setIsoImages(new ObservableCollection<ChangeCDModel>());
         ChangeCDModel tempVar = new ChangeCDModel();
@@ -1834,6 +1862,20 @@
                 }, model);
     }
 
+    private void setGlobalHaMaintenance(boolean enabled)
+    {
+        VM vm = (VM) getSelectedItem();
+        if (vm == null) {
+            return;
+        }
+        if (!vm.isHostedEngine()) {
+            return;
+        }
+
+        SetHaMaintenanceParameters params = new 
SetHaMaintenanceParameters(vm.getRunOnVds(), HaMaintenanceMode.GLOBAL, enabled);
+        Frontend.getInstance().runAction(VdcActionType.SetHaMaintenance, 
params);
+    }
+
     private void preSave()
     {
         final UnitVmModel model = (UnitVmModel) getWindow();
@@ -2246,6 +2288,8 @@
                 && VdcActionUtils.canExecute(items, VM.class, 
VdcActionType.ChangeDisk));
         getAssignTagsCommand().setIsExecutionAllowed(items.size() > 0);
 
+        updateHaMaintenanceAvailability(items);
+
         getGuideCommand().setIsExecutionAllowed(getGuideContext() != null
                 || (getSelectedItem() != null && getSelectedItems() != null && 
getSelectedItems().size() == 1));
 
@@ -2272,6 +2316,27 @@
 
         return false;
     }
+
+    private void updateHaMaintenanceAvailability(List items) {
+        if (items == null || items.size() != 1) {
+            setHaMaintenanceAvailability(false);
+            return;
+        }
+
+        VM vm = (VM) getSelectedItem();
+        if (vm == null || !vm.isHostedEngine()
+              || vm.getVdsGroupCompatibilityVersion().compareTo(Version.v3_4) 
< 0) {
+            setHaMaintenanceAvailability(false);
+        } else {
+            setHaMaintenanceAvailability(true);
+        }
+    }
+
+    private void setHaMaintenanceAvailability(boolean isAvailable) {
+        
getEnableGlobalHaMaintenanceCommand().setIsExecutionAllowed(isAvailable);
+        
getDisableGlobalHaMaintenanceCommand().setIsExecutionAllowed(isAvailable);
+    }
+
 
     /**
      * Return true if and only if one element is selected.
@@ -2373,6 +2438,14 @@
         {
             changeCD();
         }
+        else if (command == getEnableGlobalHaMaintenanceCommand())
+        {
+            setGlobalHaMaintenance(true);
+        }
+        else if (command == getDisableGlobalHaMaintenanceCommand())
+        {
+            setGlobalHaMaintenance(false);
+        }
         else if (command == getAssignTagsCommand())
         {
             assignTags();
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
index d02cbf6..470dde1 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
@@ -218,12 +218,20 @@
 
     String AuditLogType___USER_VDS_MAINTENANCE();
 
+    String AuditLogType___USER_VDS_MAINTENANCE_MANUAL_HA();
+
     String AuditLogType___USER_VDS_MAINTENANCE_MIGRATION_FAILED();
 
     String AuditLogType___VDS_MAINTENANCE();
 
+    String AuditLogType___VDS_MAINTENANCE_MANUAL_HA();
+
     String AuditLogType___VDS_MAINTENANCE_FAILED();
 
+    String AuditLogType___VDS_ACTIVATE_MANUAL_HA();
+
+    String AuditLogType___VDS_ACTIVATE_MANUAL_HA_ASYNC();
+
     String AuditLogType___VDS_ACTIVATE_FAILED();
 
     String AuditLogType___VDS_RECOVER_FAILED();
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
index f880ba9..351b423 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
+++ 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
@@ -105,10 +105,14 @@
 EventNotificationEntity___GlusterService=Gluster Service:
 AuditLogType___VDS_FAILURE=Host is non responsive
 AuditLogType___USER_VDS_MAINTENANCE=Host was switched to Maintenance Mode
+AuditLogType___USER_VDS_MAINTENANCE_MANUAL_HA=Host was switched to Maintenance 
Mode, but Hosted Engine HA maintenance mode could not be enabled
 AuditLogType___USER_VDS_MAINTENANCE_MIGRATION_FAILED=Failed to switch Host to 
Maintenance mode
 AuditLogType___VDS_MAINTENANCE=Host was switched to Maintenance Mode
+AuditLogType___VDS_MAINTENANCE_MANUAL_HA=Host was switched to Maintenance 
Mode, but Hosted Engine HA maintenance mode could not be enabled
 AuditLogType___VDS_MAINTENANCE_FAILED=Failed to switch Host to Maintenance mode
 AuditLogType___VDS_ACTIVATE_FAILED=Failed to activate Host
+AuditLogType___VDS_ACTIVATE_MANUAL_HA=Host was activated, but the Hosted 
Engine HA service may still be in maintenance mode
+AuditLogType___VDS_ACTIVATE_MANUAL_HA_ASYNC=Host was recovered, but the Hosted 
Engine HA service may still be in maintenance mode
 AuditLogType___VDS_RECOVER_FAILED=Host failed to recover
 AuditLogType___VDS_SLOW_STORAGE_RESPONSE_TIME=Slow storage response time
 AuditLogType___VDS_APPROVE_FAILED=Failed to approve Host
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
index 296eba7..60d08ec 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
@@ -1331,6 +1331,9 @@
     @DefaultStringValue("Refresh Capabilities")
     String refreshHostCapabilities();
 
+    @DefaultStringValue("Host HA Maintenance")
+    String hostHaMaintenance();
+
     // host- general
     @DefaultStringValue("OS Version")
     String osVersionHostGeneral();
@@ -1614,6 +1617,12 @@
     @DefaultStringValue("Assign Tags")
     String assignTagsVm();
 
+    @DefaultStringValue("Enable Global HA Maintenance")
+    String enableGlobalHaMaintenanceVm();
+
+    @DefaultStringValue("Disable Global HA Maintenance")
+    String disableGlobalHaMaintenanceVm();
+
     @DefaultStringValue("Show Report")
     String showReportVm();
 
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVirtualMachineView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVirtualMachineView.java
index 08c11c5..2f5771d 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVirtualMachineView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVirtualMachineView.java
@@ -294,6 +294,18 @@
                 return getMainModel().getAssignTagsCommand();
             }
         });
+        getTable().addActionButton(new 
WebAdminButtonDefinition<VM>(constants.enableGlobalHaMaintenanceVm(), 
CommandLocation.OnlyFromContext) {
+            @Override
+            protected UICommand resolveCommand() {
+                return getMainModel().getEnableGlobalHaMaintenanceCommand();
+            }
+        });
+        getTable().addActionButton(new 
WebAdminButtonDefinition<VM>(constants.disableGlobalHaMaintenanceVm(), 
CommandLocation.OnlyFromContext) {
+            @Override
+            protected UICommand resolveCommand() {
+                return getMainModel().getDisableGlobalHaMaintenanceCommand();
+            }
+        });
 
         if (ReportInit.getInstance().isReportsEnabled()) {
             List<ActionButtonDefinition<VM>> resourceSubActions =
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 5b4b96a..1abf348 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
@@ -826,6 +826,8 @@
 
ACTION_TYPE_FAILED_VM_CANNOT_IMPORT_TEMPLATE_ARCHITECTURE_NOT_SUPPORTED_BY_CLUSTER=Cannot
 ${action} ${type}. The selected cluster doesn't support Template's architecture
 ACTION_TYPE_FAILED_VM_CANNOT_IMPORT_VM_WITH_NOT_SUPPORTED_ARCHITECTURE=Cannot 
${action} ${type}. The selected VM has undefined architecture
 
ACTION_TYPE_FAILED_VM_CANNOT_IMPORT_TEMPLATE_WITH_NOT_SUPPORTED_ARCHITECTURE=Cannot
 ${action} ${type}. The selected Template has undefined architecture
+ACTION_TYPE_FAILED_VDS_HA_MAINT_NOT_SUPPORTED=Cannot ${action} ${type}. 
Setting hosted engine maintenance mode is only supported on cluster version 3.4 
and above.
+ACTION_TYPE_FAILED_VDS_HA_NOT_CONFIGURED=Cannot ${action} ${type}. Hosted 
Engine is not configured on this host.
 
 # Quota messages.
 ACTION_TYPE_FAILED_QUOTA_NOT_EXIST=Cannot ${action} ${type}. Quota doesn't 
exist.
diff --git 
a/packaging/dbscripts/upgrade/03_05_0040_add_ha_maintenance_events.sql 
b/packaging/dbscripts/upgrade/03_05_0040_add_ha_maintenance_events.sql
new file mode 100644
index 0000000..a14cf18
--- /dev/null
+++ b/packaging/dbscripts/upgrade/03_05_0040_add_ha_maintenance_events.sql
@@ -0,0 +1,3 @@
+
+INSERT INTO event_map(event_up_name, event_down_name) 
values('USER_VDS_MAINTENANCE_MANUAL_HA', 'VDS_ACTIVATE');
+


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

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

Reply via email to