Ramesh N has uploaded a new change for review.

Change subject: gluster: Support for updating gluster volume and brick
......................................................................

gluster: Support for updating gluster volume and brick

  Adding UpdateGlusterVolume and UpdateGlusterVolumeBircks BLLs
and support for Rest API to update the gluster volume/brick.
Currently only volume/brick status can be updated through
this BLL/Rest API

Change-Id: I244f9023924deaf5afea1dc3d12f7be9087a8cd1
Signed-off-by: Ramesh Nachimuthu <[email protected]>
---
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterVolumeBricksCommand.java
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterVolumeCommand.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
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/UpdateGlusterVolumeParameters.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterStatus.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
M 
backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/gluster/GlusterBrickResource.java
M 
backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/gluster/GlusterVolumeResource.java
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResource.java
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterVolumeResource.java
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/GlusterBrickMapper.java
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/GlusterVolumeMapper.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
A 
packaging/dbscripts/upgrade/03_05_0110_gluster_update_gluster_volume_details-event_map.sql
17 files changed, 265 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/16/25716/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterVolumeBricksCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterVolumeBricksCommand.java
new file mode 100644
index 0000000..b433958
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterVolumeBricksCommand.java
@@ -0,0 +1,72 @@
+package org.ovirt.engine.core.bll.gluster;
+
+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.GlusterVolumeBricksParameters;
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity;
+import org.ovirt.engine.core.common.errors.VdcBllMessages;
+import org.ovirt.engine.core.compat.TransactionScopeOption;
+import org.ovirt.engine.core.utils.transaction.TransactionMethod;
+import org.ovirt.engine.core.utils.transaction.TransactionSupport;
+
+/**
+ * BLL command to update gluster volume bricks
+ */
+@NonTransactiveCommandAttribute
+@LockIdNameAttribute(isWait = true)
+public class UpdateGlusterVolumeBricksCommand extends 
GlusterVolumeCommandBase<GlusterVolumeBricksParameters> {
+
+    public UpdateGlusterVolumeBricksCommand(GlusterVolumeBricksParameters 
params) {
+        super(params);
+    }
+
+    @Override
+    protected void setActionMessageParameters() {
+        addCanDoActionMessage(VdcBllMessages.VAR__ACTION__UPDATE);
+        addCanDoActionMessage(VdcBllMessages.VAR__TYPE__GLUSTER_BRICK);
+    }
+
+    @Override
+    protected boolean canDoAction() {
+        if (!super.canDoAction()) {
+            return false;
+        }
+
+        if (getParameters().getBricks() == null || 
getParameters().getBricks().size() == 0) {
+            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_BRICKS_REQUIRED);
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    protected void executeCommand() {
+        final List<GlusterBrickEntity> bricksList = 
getParameters().getBricks();
+
+        // Update all bricks in a single transaction
+        if (bricksList != null && bricksList.size() > 0) {
+            TransactionSupport.executeInScope(TransactionScopeOption.Required,
+                    new TransactionMethod<Void>() {
+                        @Override
+                        public Void runInTransaction() {
+                            
getGlusterBrickDao().updateBrickStatuses(bricksList);
+                            return null;
+                        }
+                    });
+        }
+        setSucceeded(true);
+    }
+
+    @Override
+    public AuditLogType getAuditLogTypeValue() {
+        if (getSucceeded()) {
+            return AuditLogType.GLUSTER_VOLUME_BRICK_UPDATE;
+        } else {
+            return errorType == null ? 
AuditLogType.GLUSTER_VOLUME_BRICK_UPDATE_FAILED : errorType;
+        }
+    }
+}
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterVolumeCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterVolumeCommand.java
new file mode 100644
index 0000000..4bd4f84
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterVolumeCommand.java
@@ -0,0 +1,49 @@
+package org.ovirt.engine.core.bll.gluster;
+
+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.UpdateGlusterVolumeParameters;
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity;
+import org.ovirt.engine.core.common.errors.VdcBllMessages;
+import org.ovirt.engine.core.dao.gluster.GlusterDBUtils;
+
+/**
+ * BLL command to update a Gluster volume
+ */
+@NonTransactiveCommandAttribute
+@LockIdNameAttribute(isWait = true)
+public class UpdateGlusterVolumeCommand extends 
GlusterVolumeCommandBase<UpdateGlusterVolumeParameters> {
+
+    public UpdateGlusterVolumeCommand(UpdateGlusterVolumeParameters params) {
+        super(params);
+    }
+
+    @Override
+    protected void setActionMessageParameters() {
+        addCanDoActionMessage(VdcBllMessages.VAR__ACTION__UPDATE);
+        addCanDoActionMessage(VdcBllMessages.VAR__TYPE__GLUSTER_VOLUME);
+    }
+
+    @Override
+    protected boolean canDoAction() {
+        return super.canDoAction();
+    }
+
+    @Override
+    protected void executeCommand() {
+        GlusterVolumeEntity glusterVolumeEntity = getParameters().getVolume();
+        
GlusterDBUtils.getInstance().updateVolumeStatus(glusterVolumeEntity.getId(),
+                glusterVolumeEntity.getStatus());
+        setSucceeded(true);
+    }
+
+    @Override
+    public AuditLogType getAuditLogTypeValue() {
+        if (getSucceeded()) {
+            return AuditLogType.GLUSTER_VOLUME_UPDATE;
+        } else {
+            return errorType == null ? 
AuditLogType.GLUSTER_VOLUME_UPDATE_FAILED : 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 44bb1f2..c69074b 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
@@ -352,6 +352,10 @@
     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_UPDATE(4095),
+    GLUSTER_VOLUME_UPDATE_FAILED(4096, AuditLogSeverity.ERROR),
+    GLUSTER_VOLUME_BRICK_UPDATE(4097),
+    GLUSTER_VOLUME_BRICK_UPDATE_FAILED(4098, AuditLogSeverity.ERROR),
 
     USER_FORCE_SELECTED_SPM(159),
     USER_VDS_RESTART(41),
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 05f8b2c..87e676f 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
@@ -116,6 +116,10 @@
         AddEventNotificationEntry(EventNotificationEntity.GlusterService, 
AuditLogType.GLUSTER_SERVICE_RESTARTED);
         AddEventNotificationEntry(EventNotificationEntity.GlusterService, 
AuditLogType.GLUSTER_SERVICE_RESTART_FAILED);
         AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, 
AuditLogType.GLUSTER_BRICK_STATUS_CHANGED);
+        AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, 
AuditLogType.GLUSTER_VOLUME_UPDATE);
+        AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, 
AuditLogType.GLUSTER_VOLUME_UPDATE_FAILED);
+        AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, 
AuditLogType.GLUSTER_VOLUME_BRICK_UPDATE);
+        AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, 
AuditLogType.GLUSTER_VOLUME_BRICK_UPDATE_FAILED);
 
         // DWH
         AddEventNotificationEntry(EventNotificationEntity.DWH, 
AuditLogType.DWH_STOPPED);
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 f11de81..6fe2c2a 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
@@ -285,6 +285,8 @@
     StopRemoveGlusterVolumeBricks(1423, ActionGroup.MANIPULATE_GLUSTER_VOLUME, 
false, QuotaDependency.NONE),
     CommitRemoveGlusterVolumeBricks(1424, 
ActionGroup.MANIPULATE_GLUSTER_VOLUME, false, QuotaDependency.NONE),
     RefreshGlusterVolumeDetails(1425, ActionGroup.MANIPULATE_GLUSTER_VOLUME, 
QuotaDependency.NONE),
+    UpdateGlusterVolume(1426, ActionGroup.MANIPULATE_GLUSTER_VOLUME, 
QuotaDependency.NONE),
+    UpdateGlusterVolumeBricks(1427, 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/action/gluster/UpdateGlusterVolumeParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/UpdateGlusterVolumeParameters.java
new file mode 100644
index 0000000..59ebe4c
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/UpdateGlusterVolumeParameters.java
@@ -0,0 +1,35 @@
+package org.ovirt.engine.core.common.action.gluster;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity;
+
+/**
+ * Command parameters for the "Update Gluster Volume" action
+ */
+public class UpdateGlusterVolumeParameters extends GlusterVolumeParameters {
+    private static final long serialVersionUID = 2015321730118872954L;
+
+    @NotNull(message = "VALIDATION.GLUSTER.VOLUME.NOT_NULL")
+    @Valid
+    private GlusterVolumeEntity volume;
+
+    public UpdateGlusterVolumeParameters() {
+    }
+
+    public UpdateGlusterVolumeParameters(GlusterVolumeEntity volume) {
+        this.volume = volume;
+        if (volume != null) {
+            this.setVolumeId(volume.getId());
+        }
+    }
+
+    public GlusterVolumeEntity getVolume() {
+        return volume;
+    }
+
+    public void setVolume(GlusterVolumeEntity volume) {
+        this.volume = volume;
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterStatus.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterStatus.java
index 59442be..0745fa7 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterStatus.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterStatus.java
@@ -1,5 +1,6 @@
 package org.ovirt.engine.core.common.businessentities.gluster;
 
+
 /**
  * Enum of Gluster Statuses
  *
@@ -21,4 +22,8 @@
      * When the gluster status cannot be determined due to host being 
non-responsive
      */
     UNKNOWN;
+
+    public static GlusterStatus fromValue(String v) {
+            return valueOf(v.toUpperCase());
+    }
 }
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 8821f09..735b637 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -747,6 +747,11 @@
 GLUSTER_SERVICE_RESTART_FAILED=Could not re-start ${servicetype} service on 
host ${VdsName} on cluster ${VdsGroupName}.
 GLUSTER_VOLUME_BRICK_ADDED=Brick [${brickpath}] on host [${servername}] added 
to volume [${glusterVolumeName}]
 GLUSTER_BRICK_STATUS_CHANGED=Detected change in status of brick ${brickpath} 
of volume ${glusterVolumeName} from ${oldValue} to ${newValue}.
+GLUSTER_VOLUME_UPDATE=Volume ${glusterVolumeName} was updated.
+GLUSTER_VOLUME_UPDATE_FAILED=Failed to update Volume ${glusterVolumeName}.
+GLUSTER_VOLUME_BRICK_UPDATE = Updated the status of bricks in volume 
${glusterVolumeName}
+GLUSTER_VOLUME_BRICK_UPDATE_FAILED = Failed to update the status of bricks in 
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 ${NetworkQoSName} was added. (User: 
${UserName})
 USER_FAILED_TO_ADD_NETWORK_QOS=Failed to add Network QoS ${NetworkQoSName}. 
(User: ${UserName})
diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/gluster/GlusterBrickResource.java
 
b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/gluster/GlusterBrickResource.java
index 611d236..278fb6c 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/gluster/GlusterBrickResource.java
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/gluster/GlusterBrickResource.java
@@ -1,7 +1,6 @@
 package org.ovirt.engine.api.resource.gluster;
 
 import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
@@ -15,19 +14,16 @@
 import org.ovirt.engine.api.resource.ActionResource;
 import org.ovirt.engine.api.resource.ApiMediaType;
 import org.ovirt.engine.api.resource.MeasurableResource;
+import org.ovirt.engine.api.resource.UpdatableResource;
 
 /**
  * Resource interface for the 
"clusters/{cluster_id}/glustervolumes/{volume_id}/bricks/{brick_id}" resource
  */
 @Produces({ ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, 
ApiMediaType.APPLICATION_X_YAML })
-public interface GlusterBrickResource extends MeasurableResource{
+public interface GlusterBrickResource extends UpdatableResource<GlusterBrick>, 
MeasurableResource{
 
     @Path("{action: (replace)}/{oid}")
     public ActionResource getActionSubresource(@PathParam("action") String 
action, @PathParam("oid") String oid);
-
-    @GET
-    @Formatted
-    public GlusterBrick get();
 
     /**
      * Replaces this brick with a new one. The property {@link 
Action#getNewBrick()} is required.
diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/gluster/GlusterVolumeResource.java
 
b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/gluster/GlusterVolumeResource.java
index c538942..2a3dc43 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/gluster/GlusterVolumeResource.java
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/gluster/GlusterVolumeResource.java
@@ -1,7 +1,6 @@
 package org.ovirt.engine.api.resource.gluster;
 
 import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
@@ -15,15 +14,13 @@
 import org.ovirt.engine.api.resource.ActionResource;
 import org.ovirt.engine.api.resource.ApiMediaType;
 import org.ovirt.engine.api.resource.MeasurableResource;
+import org.ovirt.engine.api.resource.UpdatableResource;
 
 /**
  * Resource interface for the 
"clusters/{cluster_id}/glustervolumes/{volume_id}" resource
  */
 @Produces({ ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, 
ApiMediaType.APPLICATION_X_YAML })
-public interface GlusterVolumeResource extends MeasurableResource {
-    @GET
-    @Formatted
-    public GlusterVolume get();
+public interface GlusterVolumeResource extends 
UpdatableResource<GlusterVolume>, MeasurableResource {
 
     @Path("{action: 
(start|stop|rebalance|stoprebalance|setOption|resetOption|resetAllOptions)}/{oid}")
     public ActionResource getActionSubresource(@PathParam("action") String 
action, @PathParam("oid") String oid);
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResource.java
index 2b3b19a..67670a0 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResource.java
@@ -2,6 +2,9 @@
 
 import static 
org.ovirt.engine.api.restapi.resource.gluster.BackendGlusterBricksResource.SUB_COLLECTIONS;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.ws.rs.Path;
 import javax.ws.rs.core.Response;
 
@@ -13,7 +16,9 @@
 import org.ovirt.engine.api.restapi.resource.BackendStatisticsResource;
 import org.ovirt.engine.api.restapi.resource.BrickStatisticalQuery;
 import org.ovirt.engine.api.restapi.types.Mapper;
+import org.ovirt.engine.core.common.action.VdcActionParametersBase;
 import org.ovirt.engine.core.common.action.VdcActionType;
+import 
org.ovirt.engine.core.common.action.gluster.GlusterVolumeBricksParameters;
 import 
org.ovirt.engine.core.common.action.gluster.GlusterVolumeReplaceBrickActionParameters;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterTaskOperation;
@@ -117,5 +122,32 @@
         return inject(new BackendStatisticsResource<GlusterBrick, 
GlusterBrickEntity>(GlusterBrickEntity.class, guid, query));
     }
 
+    @Override
+    public GlusterBrick update(GlusterBrick incomingBrick) {
+        validateParameters(incomingBrick, "id", "status");
+        QueryIdResolver<Guid> brickResolver =
+                new QueryIdResolver<Guid>(VdcQueryType.GetGlusterBrickById, 
IdQueryParameters.class);
+        GlusterBrickEntity entity = getEntity(brickResolver, true);
+        return performUpdate(incomingBrick,
+                entity,
+                map(entity),
+                brickResolver,
+                VdcActionType.UpdateGlusterVolumeBricks,
+                new UpdateParametersProvider());
+    }
+
+    protected class UpdateParametersProvider implements 
ParametersProvider<GlusterBrick, GlusterBrickEntity> {
+        @Override
+        public VdcActionParametersBase getParameters(GlusterBrick incoming, 
GlusterBrickEntity entity) {
+            GlusterBrickEntity updated = getMapper(GlusterBrick.class, 
GlusterBrickEntity.class).map(incoming,
+                    entity);
+            List<GlusterBrickEntity> bricks = new 
ArrayList<GlusterBrickEntity>();
+            bricks.add(updated);
+
+            GlusterVolumeBricksParameters updateParams =
+                    new GlusterVolumeBricksParameters(asGuid(getVolumeId()), 
bricks);
+            return updateParams;
+        }
+    }
 
 }
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterVolumeResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterVolumeResource.java
index 4ab7f18..3d77940 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterVolumeResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterVolumeResource.java
@@ -12,11 +12,13 @@
 import org.ovirt.engine.api.restapi.resource.AbstractBackendActionableResource;
 import org.ovirt.engine.api.restapi.resource.BackendStatisticsResource;
 import org.ovirt.engine.api.restapi.resource.VolumeStatisticalQuery;
+import org.ovirt.engine.core.common.action.VdcActionParametersBase;
 import org.ovirt.engine.core.common.action.VdcActionType;
 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.action.gluster.ResetGlusterVolumeOptionsParameters;
+import 
org.ovirt.engine.core.common.action.gluster.UpdateGlusterVolumeParameters;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity;
 import org.ovirt.engine.core.common.queries.IdQueryParameters;
@@ -144,4 +146,28 @@
                 guid,
                 query));
     }
+
+    @Override
+    public GlusterVolume update(GlusterVolume incomingVolume) {
+        validateParameters(incomingVolume, "id", "status");
+        QueryIdResolver<Guid> volumeResolver = new 
QueryIdResolver<Guid>(VdcQueryType.GetGlusterVolumeById, 
IdQueryParameters.class);
+        GlusterVolumeEntity entity = getEntity(volumeResolver, true);
+        return performUpdate(incomingVolume,
+                entity,
+                map(entity),
+                volumeResolver,
+                VdcActionType.UpdateGlusterVolume,
+                new UpdateParametersProvider());
+    }
+
+    protected class UpdateParametersProvider implements 
ParametersProvider<GlusterVolume, GlusterVolumeEntity> {
+        @Override
+        public VdcActionParametersBase getParameters(GlusterVolume incoming, 
GlusterVolumeEntity entity) {
+            GlusterVolumeEntity updated = getMapper(GlusterVolume.class, 
GlusterVolumeEntity.class).map(incoming,
+                    entity);
+            UpdateGlusterVolumeParameters updateParams = new 
UpdateGlusterVolumeParameters(updated);
+            return updateParams;
+        }
+    }
+
 }
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/GlusterBrickMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/GlusterBrickMapper.java
index b10cef3..ad69ad1 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/GlusterBrickMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/GlusterBrickMapper.java
@@ -6,6 +6,7 @@
 import org.ovirt.engine.api.model.GlusterState;
 import org.ovirt.engine.api.model.GlusterVolume;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity;
+import org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus;
 import org.ovirt.engine.core.compat.Guid;
 
 /**
@@ -31,6 +32,11 @@
         if(fromBrick.isSetBrickDir()) {
             brick.setBrickDirectory(fromBrick.getBrickDir());
         }
+
+        if(fromBrick.isSetStatus()) {
+            
brick.setStatus(GlusterStatus.fromValue(fromBrick.getStatus().getState()));
+        }
+
         return brick;
     }
 
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/GlusterVolumeMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/GlusterVolumeMapper.java
index 201dd22..d5db1c5 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/GlusterVolumeMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/GlusterVolumeMapper.java
@@ -12,6 +12,7 @@
 import org.ovirt.engine.api.model.Options;
 import org.ovirt.engine.api.model.TransportType;
 import org.ovirt.engine.api.model.TransportTypes;
+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;
 import org.ovirt.engine.core.compat.Guid;
@@ -54,6 +55,10 @@
             volume.setStripeCount(fromVolume.getStripeCount());
         }
 
+        if(fromVolume.isSetStatus()) {
+            
volume.setStatus(GlusterStatus.fromValue(fromVolume.getStatus().getState()));
+        }
+
         if (fromVolume.isSetOptions()) {
             Options options = fromVolume.getOptions();
             if (options.isSetOptions()) {
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 a6128fa..e1d0a2a 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
@@ -403,6 +403,14 @@
 
     String AuditLogType___REMOVE_GLUSTER_VOLUME_BRICKS_NOT_FOUND_FROM_CLI();
 
+    String AuditLogType___GLUSTER_VOLUME_UPDATE();
+
+    String AuditLogType___GLUSTER_VOLUME_UPDATE_FAILED();
+
+    String AuditLogType___GLUSTER_VOLUME_BRICK_UPDATE();
+
+    String AuditLogType___GLUSTER_VOLUME_BRICK_UPDATE_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 c3c0a96..00c3b21 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
@@ -198,7 +198,10 @@
 AuditLogType___GLUSTER_BRICK_STATUS_CHANGED=Detected change in status of brick
 AuditLogType___GLUSTER_VOLUME_REBALANCE_NOT_FOUND_FROM_CLI=Could not find 
information for rebalance on volume from CLI. Marking it as unknown.
 AuditLogType___REMOVE_GLUSTER_VOLUME_BRICKS_NOT_FOUND_FROM_CLI=Could not find 
information for remove brick on volume from CLI. Marking it as unknown.
-
+AuditLogType___GLUSTER_VOLUME_UPDATE=Updated volume status
+AuditLogType___GLUSTER_VOLUME_UPDATE_FAILED=Failed to update volume status
+AuditLogType___GLUSTER_VOLUME_BRICK_UPDATE=Updated bricks status
+AuditLogType___GLUSTER_VOLUME_BRICK_UPDATE_FAILED=Failed to update brick status
 
 VdcActionType___ActivateVds=Activate Host
 VdcActionType___RecoveryStoragePool=Reinitialize Data Center
diff --git 
a/packaging/dbscripts/upgrade/03_05_0110_gluster_update_gluster_volume_details-event_map.sql
 
b/packaging/dbscripts/upgrade/03_05_0110_gluster_update_gluster_volume_details-event_map.sql
new file mode 100644
index 0000000..3f8b1d9
--- /dev/null
+++ 
b/packaging/dbscripts/upgrade/03_05_0110_gluster_update_gluster_volume_details-event_map.sql
@@ -0,0 +1,4 @@
+insert into event_map(event_up_name, event_down_name) 
values('GLUSTER_VOLUME_UPDATE', 'UNASSIGNED');
+insert into event_map(event_up_name, event_down_name) 
values('GLUSTER_VOLUME_UPDATE_FAILED', 'UNASSIGNED');
+insert into event_map(event_up_name, event_down_name) 
values('GLUSTER_VOLUME_BRICK_UPDATE', 'UNASSIGNED');
+insert into event_map(event_up_name, event_down_name) 
values('GLUSTER_VOLUME_BRICK_UPDATE_FAILED', 'UNASSIGNED');


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

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

Reply via email to