Selvasundaram has uploaded a new change for review.

Change subject: engine: Enable gluster hook command
......................................................................

engine: Enable gluster hook command

  Bll command enable the gluster hook in all available up servers in the 
gluster cluster.
  - New Bll & vds command

Change-Id: Icc6f9c77393ebed2803ec2a1b295a09f61642c31
Signed-off-by: Selvasundaram <sesub...@redhat.com>
---
A backend/manager/dbscripts/upgrade/03_02_0320_add_gluster_hooks_roles.sql
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/EnableGlusterHookCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterCommandBase.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/ClusterUtils.java
A 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/EnableGlusterHookCommandTest.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/EventNotificationEntity.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcObjectType.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/action/gluster/GlusterHookParameters.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionGroup.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/GlusterHookVDSParameters.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.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/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
M 
backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties
M backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties
M 
backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/model/PermitType.java
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermitMapper.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
A 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/EnableGlusterHookVDSCommand.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.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/frontend/src/main/java/org/ovirt/engine/ui/frontend/VdsmErrors.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/volumes/VolumeListModel.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
35 files changed, 532 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/06/10906/1

diff --git 
a/backend/manager/dbscripts/upgrade/03_02_0320_add_gluster_hooks_roles.sql 
b/backend/manager/dbscripts/upgrade/03_02_0320_add_gluster_hooks_roles.sql
new file mode 100644
index 0000000..11c1e3b
--- /dev/null
+++ b/backend/manager/dbscripts/upgrade/03_02_0320_add_gluster_hooks_roles.sql
@@ -0,0 +1,26 @@
+Create or replace FUNCTION __temp_insert_predefined_gluster_hooks_roles()
+RETURNS VOID
+   AS $procedure$
+   DECLARE
+      v_super_user_id_0001 UUID;
+      v_GLUSTER_ADMIN_ROLE_ID UUID;
+BEGIN
+      v_super_user_id_0001 := '00000000-0000-0000-0000-000000000001';
+      v_GLUSTER_ADMIN_ROLE_ID := 'DEF0000b-0000-0000-0000-DEF00000000b';
+
+--MANIPULATE_GLUSTER_HOOK
+INSERT INTO roles_groups(role_id,action_group_id) SELECT v_super_user_id_0001, 
1003
+WHERE not exists (SELECT role_id, action_group_id FROM roles_groups
+        WHERE role_id=v_super_user_id_0001 and action_group_id=1003);
+
+-- Map all manipulate gluster hook action groups to the gluster admin role
+INSERT INTO roles_groups(role_id,action_group_id) SELECT 
v_GLUSTER_ADMIN_ROLE_ID, 1003
+WHERE not exists (SELECT role_id, action_group_id FROM roles_groups
+        WHERE role_id=v_GLUSTER_ADMIN_ROLE_ID and action_group_id=1003);
+
+RETURN;
+END; $procedure$
+LANGUAGE plpgsql;
+
+select __temp_insert_predefined_gluster_hooks_roles();
+drop function __temp_insert_predefined_gluster_hooks_roles();
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/EnableGlusterHookCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/EnableGlusterHookCommand.java
new file mode 100644
index 0000000..4687992
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/EnableGlusterHookCommand.java
@@ -0,0 +1,117 @@
+package org.ovirt.engine.core.bll.gluster;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.ovirt.engine.core.bll.LockIdNameAttribute;
+import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
+import org.ovirt.engine.core.common.AuditLogType;
+import org.ovirt.engine.core.common.action.gluster.GlusterHookParameters;
+import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStatus;
+import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
+import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
+import 
org.ovirt.engine.core.common.vdscommands.gluster.GlusterHookVDSParameters;
+import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.dal.VdcBllMessages;
+
+/**
+ * BLL command to enable Gluster hook
+ */
+@NonTransactiveCommandAttribute
+@LockIdNameAttribute(isWait = true)
+public class EnableGlusterHookCommand extends 
GlusterCommandBase<GlusterHookParameters> {
+    private static final long serialVersionUID = 1738006110968897175L;
+
+    public EnableGlusterHookCommand(GlusterHookParameters params) {
+        super(params);
+        setVdsGroupId(params.getClusterId());
+    }
+
+    @Override
+    protected void setActionMessageParameters() {
+        addCanDoActionMessage(VdcBllMessages.VAR__ACTION__ENABLE_GLUSTER_HOOK);
+        addCanDoActionMessage(VdcBllMessages.VAR__TYPE__GLUSTER_HOOK);
+    }
+
+    @Override
+    protected boolean canDoAction() {
+        if (!super.canDoAction()) {
+            return false;
+        }
+        if (getParameters().getClusterId() == null) {
+            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CLUSTER_IS_NOT_VALID);
+            return false;
+        }
+
+        if (getParameters().getHookName() == null || 
getParameters().getHookName().isEmpty()) {
+            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_HOOK_NAME_IS_REQUIRED);
+            return false;
+        }
+        if (getParameters().getGlusterCommand() == null || 
getParameters().getGlusterCommand().isEmpty()) {
+            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_COMMAND_IS_REQUIRED);
+            return false;
+        }
+        if (getParameters().getLevel() == null) {
+            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_HOOK_LEVEL_IS_REQUIRED);
+            return false;
+        }
+
+        if (getParameters().getLevel() == null) {
+            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_HOOK_LEVEL_IS_REQUIRED);
+            return false;
+        }
+
+        List<Guid> upServerIds = getUpServerIds();
+        if (upServerIds == null || upServerIds.isEmpty()) {
+            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NO_UP_SERVER_FOUND);
+            return false;
+        }
+        return true;
+    }
+
+    public List<Guid> getUpServerIds() {
+        List<Guid> upServerIds = new ArrayList<Guid>();
+        for (VDS server : getAllUpServers(getParameters().getClusterId())) {
+            upServerIds.add(server.getId());
+        }
+        return upServerIds;
+    }
+
+    @Override
+    protected void executeCommand() {
+        List<String> errors = new ArrayList<String>();
+        for (Guid upServerId : getUpServerIds()) {
+            VDSReturnValue returnValue =
+                    runVdsCommand(
+                            VDSCommandType.EnableGlusterHook,
+                            new GlusterHookVDSParameters(upServerId,
+                                    getParameters().getGlusterCommand(),
+                                    getParameters().getLevel(),
+                                    getParameters().getHookName()));
+            if (!returnValue.getSucceeded()) {
+                errors.add(returnValue.getVdsError().getMessage());
+            }
+        }
+
+        if (!errors.isEmpty()) {
+            handleVdsErrors(AuditLogType.GLUSTER_HOOK_ENABLE_FAILED, errors);
+        }
+
+        if (getUpServerIds().size() > errors.size()) {
+            UpdateHookStatusInDb(getParameters().getClusterId(),
+                    getParameters().getHookName(), GlusterHookStatus.ENABLED);
+            setSucceeded(true);
+        }
+    }
+
+    @Override
+    public AuditLogType getAuditLogTypeValue() {
+        if (getSucceeded()) {
+            return AuditLogType.GLUSTER_HOOK_ENABLE;
+        } else {
+            return errorType == null ? AuditLogType.GLUSTER_HOOK_ENABLE_FAILED 
: errorType;
+        }
+    }
+
+}
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterCommandBase.java
index ca705dc..79b788d 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterCommandBase.java
@@ -18,7 +18,9 @@
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VdsStatic;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity;
+import org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStatus;
 import org.ovirt.engine.core.common.locks.LockingGroup;
+import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.VdcBllMessages;
 import org.ovirt.engine.core.dao.VdsStaticDAO;
 
@@ -63,6 +65,10 @@
      */
     protected VDS getUpServer() {
         return getClusterUtils().getUpServer(getVdsGroupId());
+    }
+
+    protected List<VDS> getAllUpServers(Guid clusterId) {
+        return getClusterUtils().getAllUpServers(clusterId);
     }
 
     private ClusterUtils getClusterUtils() {
@@ -133,4 +139,9 @@
     public VdsStaticDAO getVdsStaticDao() {
         return getDbFacade().getVdsStaticDao();
     }
+
+    protected void UpdateHookStatusInDb(Guid clusterId, String hookName, 
GlusterHookStatus status) {
+    getGlusterHookDao().updateGlusterHookStatusByName(clusterId, hookName, 
status);
+}
+
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/ClusterUtils.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/ClusterUtils.java
index 66376cb..17a3a0b 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/ClusterUtils.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/ClusterUtils.java
@@ -25,15 +25,17 @@
      * @return One of the servers in up status
      */
     public VDS getUpServer(Guid clusterId) {
-        List<VDS> servers = getVdsDao()
-                .getAllForVdsGroupWithStatus(clusterId, VDSStatus.Up);
-
+        List<VDS> servers = getAllUpServers(clusterId);
         if (servers == null || servers.isEmpty()) {
             return null;
         }
         return RandomUtils.instance().pickRandom(servers);
     }
 
+    public List<VDS> getAllUpServers(Guid clusterId) {
+        return getVdsDao().getAllForVdsGroupWithStatus(clusterId, 
VDSStatus.Up);
+    }
+
     public boolean hasMultipleServers(Guid clusterId) {
         return getServerCount(clusterId) > 1;
     }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/EnableGlusterHookCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/EnableGlusterHookCommandTest.java
new file mode 100644
index 0000000..cafa45d
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/EnableGlusterHookCommandTest.java
@@ -0,0 +1,117 @@
+package org.ovirt.engine.core.bll.gluster;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.ovirt.engine.core.common.action.gluster.GlusterHookParameters;
+import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.businessentities.VDSStatus;
+import org.ovirt.engine.core.common.businessentities.gluster.GlusterHookLevel;
+import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.utils.RandomUtils;
+
+@RunWith(MockitoJUnitRunner.class)
+public class EnableGlusterHookCommandTest {
+
+    private static final Guid CLUSTER_ID = new 
Guid("b399944a-81ab-4ec5-8266-e19ba7c3c9d1");
+    private static final String HOOK_NAME = "samba-config";
+    private static final String GLUSTER_COMMAND = "create";
+    private static final GlusterHookLevel LEVEL = GlusterHookLevel.POST;
+
+    /**
+     * The command under test.
+     */
+    @Mock
+    private EnableGlusterHookCommand cmd;
+
+    private List<Guid> getGlusterServers() {
+        List<Guid> servers = new ArrayList<Guid>();
+        
servers.add(Guid.createGuidFromString("afce7a39-8e8c-4819-ba9c-796d316592e6"));
+        
servers.add(Guid.createGuidFromString("afce7a39-8e8c-4819-ba9c-796d316592e7"));
+        
servers.add(Guid.createGuidFromString("23f6d691-5dfb-472b-86dc-9e1d2d3c18f3"));
+        
servers.add(Guid.createGuidFromString("2001751e-549b-4e7a-aff6-32d36856c125"));
+        return servers;
+    }
+
+    private VDS getUpServer() {
+        VDS vds = new VDS();
+        vds.setId(RandomUtils.instance().pickRandom(getGlusterServers()));
+        vds.setvds_name("gfs1");
+        vds.setvds_group_id(CLUSTER_ID);
+        vds.setstatus(VDSStatus.Up);
+        return vds;
+    }
+
+    private void prepareMocks(EnableGlusterHookCommand command, List<Guid> 
serverIds) {
+        doReturn(getUpServer()).when(command).getUpServer();
+        doReturn(serverIds).when(command).getUpServerIds();
+        doReturn(serverIds).when(command).getAllUpServers(CLUSTER_ID);
+    }
+
+    @Test
+    public void canDoActionSucceeds() {
+        cmd = spy(new EnableGlusterHookCommand(new 
GlusterHookParameters(CLUSTER_ID,
+                HOOK_NAME,
+                GLUSTER_COMMAND,
+                LEVEL)));
+        prepareMocks(cmd, getGlusterServers());
+        assertTrue(cmd.canDoAction());
+    }
+
+    @Test
+    public void canDoActionFailsOnNullCluster() {
+        cmd = spy(new EnableGlusterHookCommand(new GlusterHookParameters(null,
+                HOOK_NAME,
+                GLUSTER_COMMAND,
+                LEVEL)));
+        prepareMocks(cmd, getGlusterServers());
+        assertFalse(cmd.canDoAction());
+    }
+
+    @Test
+    public void canDoActionFailsOnNullHookName() {
+        cmd = spy(new EnableGlusterHookCommand(new 
GlusterHookParameters(CLUSTER_ID,
+                null,
+                GLUSTER_COMMAND,
+                LEVEL)));
+        prepareMocks(cmd, getGlusterServers());
+        assertFalse(cmd.canDoAction());
+    }
+
+    @Test
+    public void canDoActionFailsOnNullGlusterCommand() {
+        cmd = spy(new EnableGlusterHookCommand(new 
GlusterHookParameters(CLUSTER_ID,
+                HOOK_NAME,
+                null,
+                LEVEL)));
+        prepareMocks(cmd, getGlusterServers());
+        assertFalse(cmd.canDoAction());
+    }
+
+    @Test
+    public void canDoActionFailsOnNullLevel() {
+        cmd = spy(new EnableGlusterHookCommand(new 
GlusterHookParameters(CLUSTER_ID,
+                HOOK_NAME,
+                GLUSTER_COMMAND,
+                null)));
+        prepareMocks(cmd, getGlusterServers());
+        assertFalse(cmd.canDoAction());
+    }
+
+    @Test
+    public void canDoActionFailsOnNull() {
+        cmd = spy(new EnableGlusterHookCommand(new GlusterHookParameters(null, 
null, null, null)));
+        prepareMocks(cmd, null);
+        assertFalse(cmd.canDoAction());
+    }
+
+}
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 2c92003..a5003e2 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
@@ -228,6 +228,9 @@
     GLUSTER_SERVER_ADD_FAILED(4436),
     GLUSTER_SERVERS_LIST_FAILED(4437),
     GLUSTER_SERVER_REMOVE(4038),
+    GLUSTER_HOOK_ENABLE(4039),
+    GLUSTER_HOOK_ENABLE_FAILED(4040),
+
 
     USER_VDS_RESTART(41),
     USER_FAILED_VDS_RESTART(107),
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/EventNotificationEntity.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/EventNotificationEntity.java
index 72d00dc..b09ea4a 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/EventNotificationEntity.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/EventNotificationEntity.java
@@ -10,8 +10,10 @@
     Storage(ApplicationMode.VirtOnly),
     Engine(ApplicationMode.AllModes),
     GlusterVolume(ApplicationMode.GlusterOnly),
+    GlusterHook(ApplicationMode.GlusterOnly),
     DWH(ApplicationMode.VirtOnly);
 
+
     private int availableInModes;
 
     private EventNotificationEntity(ApplicationMode applicationMode) {
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 8d7d155..96f3fc4 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
@@ -65,6 +65,8 @@
         AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, 
AuditLogType.GLUSTER_VOLUME_PROFILE_START_FAILED);
         AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, 
AuditLogType.GLUSTER_VOLUME_PROFILE_STOP);
         AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, 
AuditLogType.GLUSTER_VOLUME_PROFILE_STOP_FAILED);
+        AddEventNotificationEntry(EventNotificationEntity.GlusterHook, 
AuditLogType.GLUSTER_HOOK_ENABLE);
+        AddEventNotificationEntry(EventNotificationEntity.GlusterHook, 
AuditLogType.GLUSTER_HOOK_ENABLE_FAILED);
 
         // DWH
         AddEventNotificationEntry(EventNotificationEntity.DWH, 
AuditLogType.DWH_STOPPED);
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcObjectType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcObjectType.java
index 7144607..e1e9644 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcObjectType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcObjectType.java
@@ -29,7 +29,8 @@
     Disk(19, "Disk"),
     Network(20, "Network"),
     Snapshot(21, "Snapshot"),
-    Event(22, "Event");
+    Event(22, "Event"),
+    GlusterHook(23, "GlusterHook");
 
     private int value;
     private String vdcObjectTranslationVal;
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 5a144c8..eb66f52 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
@@ -263,6 +263,7 @@
     StartGlusterVolumeProfile(1410, ActionGroup.MANIPULATE_GLUSTER_VOLUME, 
QuotaDependency.NONE),
     StopGlusterVolumeProfile(1411, ActionGroup.MANIPULATE_GLUSTER_VOLUME, 
QuotaDependency.NONE),
     RemoveGlusterServer(1412, ActionGroup.DELETE_HOST, QuotaDependency.NONE),
+    EnableGlusterHook(1413, ActionGroup.MANIPULATE_GLUSTER_HOOK, 
QuotaDependency.NONE),
 
     // External events
     AddExternalEvent(1500, ActionGroup.INJECT_EXTERNAL_EVENTS, 
QuotaDependency.NONE),
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/GlusterHookParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/GlusterHookParameters.java
new file mode 100644
index 0000000..4ba825d
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/GlusterHookParameters.java
@@ -0,0 +1,67 @@
+package org.ovirt.engine.core.common.action.gluster;
+
+import javax.validation.constraints.NotNull;
+
+import org.ovirt.engine.core.common.action.VdcActionParametersBase;
+import org.ovirt.engine.core.common.businessentities.gluster.GlusterHookLevel;
+import org.ovirt.engine.core.compat.Guid;
+
+/**
+ * Parameter class with Gluster cluster id, hook name, gluster command and 
level as parameters. <br>
+ * This will be used by enable and disable gluster hook commands. <br>
+ */
+public class GlusterHookParameters extends VdcActionParametersBase {
+    private static final long serialVersionUID = 3398376087476446699L;
+
+    @NotNull(message = "VALIDATION.GLUSTER.VOLUME.CLUSTER_ID.NOT_NULL")
+    private Guid clusterId;
+
+    private String hookName;
+
+    private String glusterCommand;
+
+    private GlusterHookLevel level;
+
+    public GlusterHookParameters(Guid clusterId,
+            String hookName,
+            String glusterCommand,
+            GlusterHookLevel level) {
+        setClusterId(clusterId);
+        setHookName(hookName);
+        setGlusterCommand(glusterCommand);
+        setLevel(level);
+    }
+
+    public void setClusterId(Guid clusterId) {
+        this.clusterId = clusterId;
+    }
+
+    public Guid getClusterId() {
+        return clusterId;
+    }
+
+    public String getHookName() {
+        return hookName;
+    }
+
+    public void setHookName(String hookName) {
+        this.hookName = hookName;
+    }
+
+    public String getGlusterCommand() {
+        return glusterCommand;
+    }
+
+    public void setGlusterCommand(String glusterCommand) {
+        this.glusterCommand = glusterCommand;
+    }
+
+    public GlusterHookLevel getLevel() {
+        return level;
+    }
+
+    public void setLevel(GlusterHookLevel level) {
+        this.level = level;
+    }
+
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionGroup.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionGroup.java
index 43eceaf..c2ecf8d 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionGroup.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionGroup.java
@@ -88,6 +88,7 @@
     CREATE_GLUSTER_VOLUME(1000, RoleType.ADMIN, VdcObjectType.GlusterVolume, 
true, ApplicationMode.GlusterOnly),
     MANIPULATE_GLUSTER_VOLUME(1001, RoleType.ADMIN, 
VdcObjectType.GlusterVolume, true, ApplicationMode.GlusterOnly),
     DELETE_GLUSTER_VOLUME(1002, RoleType.ADMIN, VdcObjectType.GlusterVolume, 
true, ApplicationMode.GlusterOnly),
+    MANIPULATE_GLUSTER_HOOK(1003, RoleType.ADMIN, VdcObjectType.GlusterHook, 
true, ApplicationMode.GlusterOnly),
 
     // Disks action groups
     CREATE_DISK(1100, RoleType.USER, VdcObjectType.Disk, false, 
ApplicationMode.VirtOnly),
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
index 58adad3..dbdb786 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
@@ -348,7 +348,12 @@
     GlusterAddHostFailed(4404),
     RemoveGlusterServerFailed(4406),
     GlusterPeerListFailed(4407),
-
+    GlusterHookFailed(4500),
+    GlusterHookEnableFailed(4501),
+    GlusterHookAlreadyEnabled(4503),
+    GlusterHookNotFound(4505),
+    GlusterHookReadFailed(4506),
+    GlusterHookUpdateFailed(4507),
 
     UnicodeArgumentException(4900),
 
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 16a2b7a..cc65080 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
@@ -142,6 +142,7 @@
     GetGlusterVolumeAdvancedDetails("org.ovirt.engine.core.vdsbroker.gluster"),
     GlusterVolumesList("org.ovirt.engine.core.vdsbroker.gluster"),
     GetGlusterVolumeProfileInfo("org.ovirt.engine.core.vdsbroker.gluster"),
+    EnableGlusterHook("org.ovirt.engine.core.vdsbroker.gluster"),
     ;
 
     String packageName;
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/GlusterHookVDSParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/GlusterHookVDSParameters.java
new file mode 100644
index 0000000..385c334
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/GlusterHookVDSParameters.java
@@ -0,0 +1,48 @@
+package org.ovirt.engine.core.common.vdscommands.gluster;
+
+import org.ovirt.engine.core.common.businessentities.gluster.GlusterHookLevel;
+import org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase;
+import org.ovirt.engine.core.compat.Guid;
+
+/**
+ * Gluster Hook VDS parameter class with gluster command, hook name, and level 
as parameters. <br>
+ * This will be used directly by Enable and Disable Gluster Hook VDS commands 
<br>
+ */
+public class GlusterHookVDSParameters extends VdsIdVDSCommandParametersBase {
+
+    private String glusterCommand;
+    private String hookName;
+    private GlusterHookLevel level;
+
+    public GlusterHookVDSParameters(Guid serverId, String glusterCommand, 
GlusterHookLevel level, String hookName) {
+        super(serverId);
+        setGlusterCommand(glusterCommand);
+        setLevel(level);
+        setHookName(hookName);
+    }
+
+    public String getGlusterCommand() {
+        return glusterCommand;
+    }
+
+    public void setGlusterCommand(String glusterCommand) {
+        this.glusterCommand = glusterCommand;
+    }
+
+    public String getHookName() {
+        return hookName;
+    }
+
+    public void setHookName(String hookName) {
+        this.hookName = hookName;
+    }
+
+    public GlusterHookLevel getLevel() {
+        return level;
+    }
+
+    public void setLevel(GlusterHookLevel level) {
+        this.level = level;
+    }
+
+}
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 506547c..3666b22 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
@@ -29,6 +29,7 @@
     VAR__TYPE__GLUSTER_VOLUME_OPTION,
     VAR__TYPE__GLUSTER_BRICK,
     VAR__TYPE__GLUSTER_SERVER,
+    VAR__TYPE__GLUSTER_HOOK,
 
     // External Event
     VAR__TYPE__EXTERNAL_EVENT,
@@ -70,6 +71,7 @@
     VAR__ACTION__ASSIGN,
     VAR__ACTION__START_PROFILE,
     VAR__ACTION__STOP_PROFILE,
+    VAR__ACTION__ENABLE_GLUSTER_HOOK,
 
     // Host statuses replacements
     VAR__HOST_STATUS__UP,
@@ -691,6 +693,9 @@
     MIGRATE_PAUSED_VM_IS_UNSUPPORTED,
     ACTION_TYPE_FAILED_SERVER_NAME_REQUIRED,
     SERVER_ALREADY_EXISTS_IN_ANOTHER_CLUSTER,
+    ACTION_TYPE_FAILED_GLUSTER_HOOK_NAME_IS_REQUIRED,
+    ACTION_TYPE_FAILED_GLUSTER_COMMAND_IS_REQUIRED,
+    ACTION_TYPE_FAILED_GLUSTER_HOOK_LEVEL_IS_REQUIRED,
 
     VM_INTERFACE_NOT_EXIST,
     ACTION_TYPE_FAILED_CANNOT_REMOVE_ACTIVE_DEVICE,
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 badfa07..7373d28 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
@@ -97,6 +97,9 @@
         mSeverities.put(AuditLogType.GLUSTER_VOLUME_BRICK_ADDED_FROM_CLI, 
AuditLogSeverity.WARNING);
         mSeverities.put(AuditLogType.GLUSTER_VOLUME_BRICK_REMOVED_FROM_CLI, 
AuditLogSeverity.WARNING);
         mSeverities.put(AuditLogType.GLUSTER_SERVER_REMOVED_FROM_CLI, 
AuditLogSeverity.WARNING);
+        mSeverities.put(AuditLogType.GLUSTER_HOOK_ENABLE, 
AuditLogSeverity.NORMAL);
+        mSeverities.put(AuditLogType.GLUSTER_HOOK_ENABLE_FAILED, 
AuditLogSeverity.ERROR);
+
     }
 
     private static void initDefaultSeverities() {
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
index 8014b61..c748a9e 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
@@ -35,6 +35,7 @@
 import org.ovirt.engine.core.dao.VmStaticDAO;
 import org.ovirt.engine.core.dao.VmStatisticsDAO;
 import org.ovirt.engine.core.dao.VmTemplateDAO;
+import org.ovirt.engine.core.dao.gluster.GlusterHookDao;
 import org.ovirt.engine.core.dao.gluster.GlusterVolumeDao;
 import org.ovirt.engine.core.dao.network.NetworkClusterDao;
 import org.ovirt.engine.core.dao.network.NetworkDao;
@@ -97,7 +98,7 @@
         this.glusterVolumeId = auditLog.getGlusterVolumeId();
         this.glusterVolumeName = auditLog.getGlusterVolumeName();
         this.jobId = auditLog.getJobId();
-        this.mUserId = (NGuid) auditLog.getuser_id();
+        this.mUserId = auditLog.getuser_id();
         this.mUserName = auditLog.getuser_name();
         this.mVdsGroupId = (Guid) auditLog.getvds_group_id();
         this.mVdsId = auditLog.getvds_id();
@@ -518,6 +519,10 @@
         return getDbFacade().getGlusterVolumeDao();
     }
 
+    public GlusterHookDao getGlusterHookDao() {
+        return getDbFacade().getGlusterHookDao();
+    }
+
     public StorageDomainDAO getStorageDomainDAO() {
         return getDbFacade().getStorageDomainDao();
     }
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 3bd9a4e..006013b 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -766,6 +766,7 @@
 VAR__TYPE__GLUSTER_VOLUME_OPTION=$type Gluster Volume Option
 VAR__TYPE__GLUSTER_BRICK=$type Gluster Brick
 VAR__TYPE__GLUSTER_SERVER=$type Gluster Server
+VAR__TYPE__GLUSTER_HOOK=$type Gluster Hook
 VALIDATION.GLUSTER.VOLUME.ID.NOT_NULL=Volume ID is required.
 VALIDATION.GLUSTER.VOLUME.CLUSTER_ID.NOT_NULL=Cluster ID is required.
 VALIDATION.GLUSTER.VOLUME.NAME.NOT_NULL=Volume Name is required.
@@ -820,6 +821,9 @@
 ACTION_TYPE_FAILED_NO_UP_SERVER_FOUND=Cannot ${action} ${type}. No up server 
found in ${clusterName}.
 ACTION_TYPE_FAILED_BRICK_ALREADY_EXISTS_IN_VOLUME=Cannot ${action} ${type}. 
Brick ${brick} already used by the volume ${volumeName}.
 ACTION_TYPE_FAILED_NO_UP_SERVER_FOUND=Cannot ${action} ${type}. No server 
found in Up state.
+ACTION_TYPE_FAILED_GLUSTER_HOOK_NAME_IS_REQUIRED=Cannot ${action} ${type}. 
Gluster hook name is required.
+ACTION_TYPE_FAILED_GLUSTER_COMMAND_IS_REQUIRED=Cannot ${action} ${type}. 
Gluster command is required.
+ACTION_TYPE_FAILED_GLUSTER_HOOK_LEVEL_IS_REQUIRED=Cannot ${action} ${type}. 
Gluster hook level is required.
 ERROR_GET_STORAGE_DOMAIN_LIST=Cannot get Storage Domains list.
 VDS_CANNOT_REMOVE_HOST_HAVING_GLUSTER_VOLUME=Cannot remove gluster server. 
Server having Gluster volume(s).
 ACTION_TYPE_FAILED_VM_CANNOT_BE_PINNED_TO_CPU_AND_MIGRATABLE=Migratable VM's 
cannot be pinned to CPU.
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 9e4c247..713a079 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -579,3 +579,5 @@
 GLUSTER_VOLUME_BRICK_ADDED_FROM_CLI=Brick ${brick} was added to Volume 
${glusterVolumeName} from gluster CLI. Now added in engine DB as well.
 GLUSTER_VOLUME_BRICK_REMOVED_FROM_CLI=Brick ${brick} was removed from Volume 
${glusterVolumeName} from gluster CLI. Now removed in engine DB as well.
 GLUSTER_SERVER_REMOVED_FROM_CLI=Server ${VdsName} was removed from Cluster 
${VdsGroupName} from gluster CLI. Now removed in engine DB as well.
+GLUSTER_HOOK_ENABLE=Gluster Hook enabled on ${VdsName}.
+GLUSTER_HOOK_ENABLE_FAILED=Failed to enable Gluster Hook on ${VdsName}.
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties
index 165f4ec..a37a3d4 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties
@@ -83,6 +83,7 @@
 job.ReplaceGlusterVolumeBrick=Replacing Brick in Gluster Volume 
${GlusterVolume}
 job.AddBricksToGlusterVolume=Adding Bricks to Gluster Volume ${GlusterVolume}
 job.RemoveGlusterServer=Removing Gluster Server ${VDS}
+job.EnableGlusterHook=Enabling Gluster Hook on ${VDS}
 
 # Step types
 step.VALIDATING=Validating
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties
index 5af093c..95bfb8b 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties
@@ -327,7 +327,13 @@
 GlusterHostRemoveFailed=Gluster Server Remove Failed
 GlusterPeerListFailed=Gluster Peer List Failed
 GlusterVolumeStatusFailed=Could not fetch advanced volume details
-GlusterVolumeProfileInfoFailed=Gluster Volume Profile Info Failed
+GlusterVolumeProfileInfoFailed=Gluster Volume Profile Info Failed
+GlusterHookFailed=Gluster hook operation  failed
+GlusterHookEnableFailed=Failed to enable gluster hook
+GlusterHookAlreadyEnabled=Gluster hook already enabled
+GlusterHookNotFound=Gluster hook not found
+GlusterHookReadFailed=Failed to read Gluster hook
+GlusterHookUpdateFailed=Failed to update gluster hook
 CANT_RECONSTRUCT_WHEN_A_DOMAIN_IN_POOL_IS_LOCKED=Can't reconstruct the Master 
Domain when the Data Center contains Domains in Locked state.\nPlease wait 
until the operation for these Domains ends before trying to reconstruct the 
Master Domain again.
 NO_IMPLEMENTATION=Not implemented
 FailedToPlugDisk=Failed to hot-plug disk
diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/model/PermitType.java
 
b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/model/PermitType.java
index 472913a..360098a 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/model/PermitType.java
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/model/PermitType.java
@@ -83,6 +83,7 @@
     CREATE_GLUSTER_VOLUME,
     MANIPULATE_GLUSTER_VOLUME,
     DELETE_GLUSTER_VOLUME,
+    MANIPULATE_GLUSTER_HOOK,
 
     // Disks action groups
     CREATE_DISK,
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermitMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermitMapper.java
index 094b77a..12046e6 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermitMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermitMapper.java
@@ -144,6 +144,8 @@
             return PermitType.MANIPULATE_GLUSTER_VOLUME;
         case DELETE_GLUSTER_VOLUME:
             return PermitType.DELETE_GLUSTER_VOLUME;
+        case MANIPULATE_GLUSTER_HOOK:
+            return PermitType.MANIPULATE_GLUSTER_HOOK;
         case CREATE_DISK:
             return PermitType.CREATE_DISK;
         case ATTACH_DISK:
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
index b2ec324..dcd02ca 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
@@ -37,6 +37,12 @@
         case GlusterPeerListFailed:
         case GlusterVolumeStatusFailed:
         case GlusterVolumeProfileInfoFailed:
+        case GlusterHookFailed:
+        case GlusterHookEnableFailed:
+        case GlusterHookAlreadyEnabled:
+        case GlusterHookNotFound:
+        case GlusterHookReadFailed:
+        case GlusterHookUpdateFailed:
             // Capture error from gluster command and record failure
             getVDSReturnValue().setVdsError(new VDSError(returnStatus, 
getReturnStatus().mMessage));
             getVDSReturnValue().setSucceeded(false);
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/EnableGlusterHookVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/EnableGlusterHookVDSCommand.java
new file mode 100644
index 0000000..d0a08a5
--- /dev/null
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/EnableGlusterHookVDSCommand.java
@@ -0,0 +1,20 @@
+package org.ovirt.engine.core.vdsbroker.gluster;
+
+import 
org.ovirt.engine.core.common.vdscommands.gluster.GlusterHookVDSParameters;
+
+public class EnableGlusterHookVDSCommand<P extends GlusterHookVDSParameters> 
extends AbstractGlusterBrokerCommand<P> {
+
+    public EnableGlusterHookVDSCommand(P parameters) {
+        super(parameters);
+    }
+
+    @Override
+    protected void ExecuteVdsBrokerCommand() {
+        status =
+                
getBroker().glusterHookEnable(getParameters().getGlusterCommand(),
+                        getParameters().getLevel().toString(),
+                        getParameters().getHookName());
+
+        ProceedProxyReturnValue();
+    }
+}
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 532dcd6..03c774e 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
@@ -247,4 +247,6 @@
     GlusterVolumesListReturnForXmlRpc glusterVolumesList(Guid clusterId);
 
     GlusterVolumeProfileInfoReturnForXmlRpc glusterVolumeProfileInfo(Guid 
clusterId, String volumeName);
+
+    StatusOnlyReturnForXmlRpc glusterHookEnable(String glusterCommand, String 
level, String hookName);
 }
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 2a0aa59..0afe382 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
@@ -236,4 +236,6 @@
     public Map<String, Object> glusterVolumeStatus(String volumeName, String 
brickName, String volumeStatusOption);
 
     public Map<String, Object> glusterVolumeProfileInfo(String volumeName);
+
+    public Map<String, Object> glusterHookEnable(String glusterCommand, String 
level, String hookName);
 }
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 13ea1f6..c3754ca 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
@@ -1215,4 +1215,17 @@
             throw new XmlRpcRunTimeException(ute);
         }
     }
+
+    @Override
+    public StatusOnlyReturnForXmlRpc glusterHookEnable(String glusterCommand, 
String level, String hookName) {
+        try {
+
+            Map<String, Object> xmlRpcReturnValue = 
vdsServer.glusterHookEnable(glusterCommand, level, hookName);
+            StatusOnlyReturnForXmlRpc wrapper = new 
StatusOnlyReturnForXmlRpc(xmlRpcReturnValue);
+            return wrapper;
+        } catch (UndeclaredThrowableException ute) {
+            throw new XmlRpcRunTimeException(ute);
+        }
+    }
+
 }
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 f85b09d..5b3acf5 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
@@ -762,6 +762,9 @@
     @DefaultStringValue("$type Gluster Server")
     String VAR__TYPE__GLUSTER_SERVER();
 
+    @DefaultStringValue("$type Gluster Hook")
+    String VAR__TYPE__GLUSTER_HOOK();
+
     @DefaultStringValue("Cannot ${action} ${type}. The chosen disk drive 
letter is already in use, please select a free one.")
     String ACTION_TYPE_FAILED_DISK_LETTER_ALREADY_IN_USE();
 
@@ -2195,4 +2198,14 @@
 
     @DefaultStringValue("One or more servers are already part of an existing 
cluster")
     String SERVER_ALREADY_EXISTS_IN_ANOTHER_CLUSTER();
+
+    @DefaultStringValue("Cannot ${action} ${type}. Gluster hook name is 
required.")
+    String ACTION_TYPE_FAILED_GLUSTER_HOOK_NAME_IS_REQUIRED();
+
+    @DefaultStringValue("Cannot ${action} ${type}. Gluster command is 
required.")
+    String ACTION_TYPE_FAILED_GLUSTER_COMMAND_IS_REQUIRED();
+
+    @DefaultStringValue("Cannot ${action} ${type}. Gluster hook level is 
required.")
+    String  ACTION_TYPE_FAILED_GLUSTER_HOOK_LEVEL_IS_REQUIRED();
+
 }
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/VdsmErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/VdsmErrors.java
index d9ba84b..3995233 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/VdsmErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/VdsmErrors.java
@@ -703,4 +703,23 @@
 
     @DefaultStringValue("Failed to update VM Network Interface.")
     String UPDATE_VNIC_FAILED();
+
+    @DefaultStringValue("Gluster hook operation  failed")
+    String GlusterHookFailed();
+
+    @DefaultStringValue("Failed to enable gluster hook.")
+    String GlusterHookEnableFailed();
+
+    @DefaultStringValue("Gluster Hook already enabled.")
+    String GlusterHookAlreadyEnabled();
+
+    @DefaultStringValue("Gluster hook not found")
+    String GlusterHookNotFound();
+
+    @DefaultStringValue("Failed to read Gluster hook")
+    String GlusterHookReadFailed();
+
+    @DefaultStringValue("Failed to update gluster hook")
+    String GlusterHookUpdateFailed();
+
 }
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 a0b2b17..795364f 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
@@ -307,6 +307,7 @@
                <include 
name="common/businessentities/gluster/MemoryStatus.java"/>
                <include name="common/businessentities/gluster/Mempool.java"/>
                <include 
name="common/businessentities/gluster/ServiceType.java"/>
+               <include 
name="common/businessentities/gluster/GlusterHookLevel.java"/>
                <include name="common/action/gluster/*.java"/>
                <include name="common/queries/gluster/*.java"/>
                <include name="common/constants/gluster/GlusterConstants.java"/>
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java
index ce8354b..1f43424 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java
@@ -7,12 +7,14 @@
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.action.VdcReturnValueBase;
 import 
org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeParameters;
+import org.ovirt.engine.core.common.action.gluster.GlusterHookParameters;
 import 
org.ovirt.engine.core.common.action.gluster.GlusterVolumeActionParameters;
 import 
org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters;
 import 
org.ovirt.engine.core.common.action.gluster.GlusterVolumeRebalanceParameters;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.storage_pool;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity;
+import org.ovirt.engine.core.common.businessentities.gluster.GlusterHookLevel;
 import org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity;
@@ -557,6 +559,12 @@
             return;
         }
 
+        Frontend.RunAction(VdcActionType.EnableGlusterHook,
+                new GlusterHookParameters(((GlusterVolumeEntity) 
getSelectedItem()).getClusterId(),
+                        "_testhook.sh", //$NON-NLS-1$
+                        "add-brick",  //$NON-NLS-1$
+                        GlusterHookLevel.PRE));
+        /**
         ArrayList<VdcActionParametersBase> list = new 
java.util.ArrayList<VdcActionParametersBase>();
         for (Object item : getSelectedItems())
         {
@@ -564,6 +572,7 @@
             list.add(new GlusterVolumeActionParameters(volume.getId(), false));
         }
         Frontend.RunMultipleAction(VdcActionType.StartGlusterVolume, list);
+        */
     }
 
 
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 a9cd57b..10822f5 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
@@ -149,6 +149,8 @@
 
        String ActionGroup___DELETE_GLUSTER_VOLUME();
 
+       String ActionGroup___MANIPULATE_GLUSTER_HOOK();
+
        String EventNotificationEntity___Host();
 
        String EventNotificationEntity___Vm();
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 7715dff..02e6d02 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
@@ -70,12 +70,14 @@
 ActionGroup___CONFIGURE_DISK_STORAGE=Edit Storage
 ActionGroup___DELETE_DISK=Delete
 ActionGroup___PORT_MIRRORING=Port Mirroring
+ActionGroup___MANIPULATE_GLUSTER_HOOK=Manipulate Gluster Hook
 EventNotificationEntity___Host=Host Events:
 EventNotificationEntity___Vm=VM Events:
 EventNotificationEntity___Storage=Storage Management Events:
 EventNotificationEntity___Engine=General Management Events:
 EventNotificationEntity___GlusterVolume=Gluster Volume Events:
 EventNotificationEntity___DWH=Data Warehouse Events:
+EventNotificationEntity___GlusterHook=Gluster Hook:
 AuditLogType___VDS_FAILURE=Host is non-responsive
 AuditLogType___USER_VDS_MAINTENANCE=Host was switched to Maintenance Mode
 AuditLogType___USER_VDS_MAINTENANCE_MIGRATION_FAILED=Failed to switch Host to 
Maintenance mode
@@ -123,6 +125,8 @@
 AuditLogType___GLUSTER_VOLUME_PROFILE_START_FAILED=Failed to start Gluster 
Volume Profile
 AuditLogType___GLUSTER_VOLUME_PROFILE_STOP=Gluster Volume Profile stopped
 AuditLogType___GLUSTER_VOLUME_PROFILE_STOP_FAILED=Failed to stop Gluster 
Volume Profile
+AuditLogType___GLUSTER_HOOK_ENABLE=Gluster Hook Enabled
+AuditLogType___GLUSTER_HOOK_ENABLE_FAILED=Failed to Enable Gluster Hook
 
 VdcActionType___ActivateVds=Activate Host
 VdcActionType___RecoveryStoragePool=Reinitialize Data Center
@@ -291,6 +295,7 @@
 VdcObjectType___VmTemplate=VM Template
 VdcObjectType___EventNotification=Event Notification
 VdcObjectType___ImportExport=Import/Export
+VdcObjectType___GlusterHook=Gluster Hook
 VdsSelectionAlgorithm___None=None
 VdsSelectionAlgorithm___EvenlyDistribute=Even Distribution
 VdsSelectionAlgorithm___PowerSave=Power Saving


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

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

Reply via email to