Hello anmolbabu,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/39614

to review the following change.

Change subject: engine : Bll command to start geo-rep session
......................................................................

engine : Bll command to start geo-rep session

Bll command to start geo-rep session

Change-Id: Ib74c515d23218bb2e30403e0e0042c84b74dc2bb
Signed-off-by: Anmol Babu <[email protected]>
---
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/StartGlusterVolumeGeoRepCommand.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/action/VdcActionType.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.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/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
10 files changed, 76 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/14/39614/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/StartGlusterVolumeGeoRepCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/StartGlusterVolumeGeoRepCommand.java
new file mode 100644
index 0000000..6d1a795
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/StartGlusterVolumeGeoRepCommand.java
@@ -0,0 +1,58 @@
+package org.ovirt.engine.core.bll.gluster;
+
+import org.ovirt.engine.core.common.AuditLogType;
+import 
org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters;
+import 
org.ovirt.engine.core.common.businessentities.gluster.GeoRepSessionStatus;
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession;
+import org.ovirt.engine.core.common.errors.VdcBllMessages;
+import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
+import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
+import 
org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters;
+
+public class StartGlusterVolumeGeoRepCommand extends 
GeoRepSessionCommandBase<GlusterVolumeGeoRepSessionParameters> {
+
+    public 
StartGlusterVolumeGeoRepCommand(GlusterVolumeGeoRepSessionParameters params) {
+        super(params);
+    }
+
+    @Override
+    protected void setActionMessageParameters() {
+        super.setActionMessageParameters();
+        addCanDoActionMessage(VdcBllMessages.VAR__ACTION__START);
+    }
+
+    @Override
+    protected void executeCommand() {
+        GlusterGeoRepSession session = getGeoRepSession();
+        VDSReturnValue returnValue = 
runVdsCommand(VDSCommandType.StartGlusterVolumeGeoRep, new 
GlusterVolumeGeoRepSessionVDSParameters(upServer.getId(), 
getGlusterVolumeName(), session.getSlaveHostName(), 
session.getSlaveVolumeName()));
+        setSucceeded(returnValue.getSucceeded());
+        if(getSucceeded()) {
+            getGeoRepSession().setStatus(GeoRepSessionStatus.ACTIVE);
+            getGlusterGeoRepDao().updateSession(getGeoRepSession());
+        } else {
+            
handleVdsError(AuditLogType.GLUSTER_VOLUME_GEO_REP_START_FAILED_EXCEPTION, 
returnValue.getVdsError().getMessage());
+            return;
+        }
+    }
+
+    @Override
+    protected boolean canDoAction() {
+        setGlusterVolumeId(getGeoRepSession().getMasterVolumeId());
+        if (!super.canDoAction()) {
+            return false;
+        }
+        if (getGeoRepSession().getStatus().equals(GeoRepSessionStatus.ACTIVE)) 
{
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_STARTED);
+        }
+        return true;
+    }
+
+    @Override
+    public AuditLogType getAuditLogTypeValue() {
+        if(getSucceeded()) {
+            return AuditLogType.GLUSTER_VOLUME_GEO_REP_START;
+        } else {
+            return errorType == null ? 
AuditLogType.GLUSTER_VOLUME_GEO_REP_START_FAILED_EXCEPTION : errorType;
+        }
+    }
+}
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 a7455f9..1f755e4 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
@@ -381,6 +381,8 @@
     REMOVE_GLUSTER_VOLUME_BRICKS_NOT_FOUND_FROM_CLI(4092, 
AuditLogSeverity.WARNING),
     GLUSTER_VOLUME_DETAILS_REFRESH(4093),
     GLUSTER_VOLUME_DETAILS_REFRESH_FAILED(4094, AuditLogSeverity.ERROR),
+    GLUSTER_VOLUME_GEO_REP_START(4596),
+    GLUSTER_VOLUME_GEO_REP_START_FAILED_EXCEPTION(4597, 
AuditLogSeverity.ERROR),
     USER_FORCE_SELECTED_SPM_STOP_FAILED(4096, AuditLogSeverity.ERROR),
     GLUSTER_GEOREP_SESSION_DELETED_FROM_CLI(4097, AuditLogSeverity.WARNING),
     GLUSTER_GEOREP_SESSION_DETECTED_FROM_CLI(4098, AuditLogSeverity.WARNING),
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 e81f5bf..ac07d40 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
@@ -307,6 +307,7 @@
     RefreshGeoRepSessions(1426, ActionGroup.MANIPULATE_GLUSTER_VOLUME, 
QuotaDependency.NONE),
     StopGeoRepSession(1427, ActionGroup.MANIPULATE_GLUSTER_VOLUME, 
QuotaDependency.NONE),
     DeleteGeoRepSession(1428, ActionGroup.MANIPULATE_GLUSTER_VOLUME, 
QuotaDependency.NONE),
+    StartGlusterVolumeGeoRep(1429, ActionGroup.MANIPULATE_GLUSTER_VOLUME, 
QuotaDependency.NONE),
 
     // Cluster Policy
     AddClusterPolicy(1450, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, 
QuotaDependency.NONE),
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 6378c73..997f87e 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
@@ -931,6 +931,7 @@
     ACTION_TYPE_FAILED_VOLUME_OPERATION_IN_PROGRESS(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_GLUSTER_OPERATION_INPROGRESS(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_GEOREP_SESSION_INVALID(ErrorType.BAD_PARAMETERS),
+    ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_STARTED(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_GEOREP_SESSION_LOCKED(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_GEOREP_SESSION_STOPPED(ErrorType.CONFLICT),
     // OpenStack Glance
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 d52bf65..5318af5 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -1138,6 +1138,7 @@
 ACTION_TYPE_FAILED_GEOREP_SESSION_INVALID=Cannot ${action} ${type}. 
Geo-replication session not found.
 ACTION_TYPE_FAILED_GEOREP_SESSION_LOCKED=Cannot ${action} ${type}. Another 
operation is in progress on this geo-replication session. Please try again.
 ACTION_TYPE_FAILED_GEOREP_SESSION_STOPPED=Cannot ${action} ${type}. 
Geo-replication session is stopped.
+ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_STARTED=Cannot ${action} ${type}. 
Geo-replication session is already started.
 
 ACTION_TYPE_FAILED_TAG_ID_REQUIRED=Cannot ${action} ${type}. Tag ID is 
required.
 ACTION_TYPE_FAILED_QOS_OUT_OF_RANGE_VALUES=Cannot ${action} ${type}. Values 
are out of range.
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 674d2a7..68948ce 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -812,7 +812,8 @@
 GEOREP_SESSION_STOP_FAILED=Failed to stop geo-replication session on volume 
${glusterVolumeName}
 GEOREP_SESSION_DELETED=Geo-replication session deleted on volume 
${glusterVolumeName}
 GEOREP_SESSION_DELETE_FAILED=Failed to delete geo-replication session on 
volume ${glusterVolumeName}
-
+GEOREP_SESSION_STARTED=Geo-replication session on volume ${glusterVolumeName} 
has been started.
+GEOREP_SESSION_START_FAILED=Failed to start geo-replication session on volume 
${glusterVolumeName}
 VDS_UNTRUSTED=Host ${VdsName} was set to non-operational. Host is not trusted 
by the attestation service.
 USER_ADDED_NETWORK_QOS=Network QoS ${QosName} was added. (User: ${UserName})
 USER_FAILED_TO_ADD_NETWORK_QOS=Failed to add Network QoS ${QosName}. (User: 
${UserName})
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 f05ee7e..8292d2a 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
@@ -3069,6 +3069,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. Geo-replication session not 
found.")
     String ACTION_TYPE_FAILED_GEOREP_SESSION_INVALID();
 
+    @DefaultStringValue("Cannot ${action} ${type}. Geo-replication session is 
already started.")
+    String ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_STARTED();
+
     @DefaultStringValue("Cannot ${action} ${type}. Another operation is in 
progress on this geo-replication session. Please try again.")
     String ACTION_TYPE_FAILED_GEOREP_SESSION_LOCKED();
 
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 e160adb..f249cd6 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
@@ -439,6 +439,10 @@
 
     String AuditLogType___GEOREP_SESSION_DELETE_FAILED();
 
+    String AuditLogType___GEOREP_SESSION_START();
+
+    String AuditLogType___GEOREP_SESSION_START_FAILED();
+
     String VdcActionType___ActivateVds();
 
     String VdcActionType___RecoveryStoragePool();
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 68f1ca8..82daf3f 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
@@ -216,6 +216,9 @@
 AuditLogType___GEOREP_SESSION_STOP_FAILED=Failed to stop geo-replication 
session on volume
 AuditLogType___GEOREP_SESSION_DELETE=Geo-replication session deleted on volume
 AuditLogType___GEOREP_SESSION_DELETE_FAILED=Failed to delete geo-replication 
session on volume
+AuditLogType___GEOREP_SESSION_START=Geo-replication session started on volume
+AuditLogType___GEOREP_SESSION_START_FAILED=Failed to start geo-replication 
session on volume
+
 
 VdcActionType___ActivateVds=Activate Host
 VdcActionType___RecoveryStoragePool=Reinitialize Data Center
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 6eab5a7..a4733d1 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
@@ -1107,7 +1107,7 @@
 ACTION_TYPE_FAILED_GEOREP_SESSION_INVALID=Cannot ${action} ${type}. 
Geo-replication session not found.
 ACTION_TYPE_FAILED_GEOREP_SESSION_LOCKED=Cannot ${action} ${type}. Another 
operation is in progress on this geo-replication session. Please try again.
 ACTION_TYPE_FAILED_GEOREP_SESSION_STOPPED=Cannot ${action} ${type}. 
Geo-replication session is stopped.
-
+ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_STARTED=Cannot ${action} ${type}. 
Geo-replication session is already started.
 ACTION_TYPE_FAILED_TAG_ID_REQUIRED=Cannot ${action} ${type}. Tag ID is 
required.
 
 ACTION_TYPE_FAILED_QOS_OUT_OF_RANGE_VALUES=Cannot ${action} ${type}. Values 
are out of range.


-- 
To view, visit https://gerrit.ovirt.org/39614
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib74c515d23218bb2e30403e0e0042c84b74dc2bb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5-gluster
Gerrit-Owner: Sahina Bose <[email protected]>
Gerrit-Reviewer: anmolbabu <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to