cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [6/8] git commit: updated refs/heads/4.3 to 2b264e6
Date Wed, 26 Nov 2014 13:21:26 GMT
CLOUDSTACK-6172: Volume is not retaining same uuid when migrating from one storage to another.

(cherry picked from commit 624139d8ef9ea9462ba81d2d3941ee5ac9467b20)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/77446d27
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/77446d27
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/77446d27

Branch: refs/heads/4.3
Commit: 77446d2716a4d174c4505123758310ba0fe48e2d
Parents: a88c3dd
Author: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Authored: Wed Feb 26 14:41:48 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Wed Nov 26 18:23:04 2014 +0530

----------------------------------------------------------------------
 .../src/com/cloud/storage/dao/VolumeDao.java    |  8 ++++++++
 .../com/cloud/storage/dao/VolumeDaoImpl.java    | 20 ++++++++++++++++++++
 .../storage/volume/VolumeServiceImpl.java       |  1 +
 3 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/77446d27/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
index 24ade51..47f1990 100755
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
@@ -103,4 +103,12 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>,
StateDao<Volume.S
      * @return the scope of the storage pool where the volume is present (ZONE/CLUSTER)
      */
     ScopeType getVolumeStoragePoolScope(long volumeId);
+
+    /***
+     * Updates the destVol uuid with srcVol uuid and sets the srcVol uuid as null.
+     * @param srcVolId
+     * @param destVolId
+     * @return returns true if transaction is successful.
+     */
+    boolean updateUuid(long srcVolId, long destVolId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/77446d27/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
index 2fb9dba..697983c 100755
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
@@ -555,6 +555,26 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long>
implements Vol
     }
 
     @Override
+    @DB
+    public boolean updateUuid(long srcVolId, long destVolId) {
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        txn.start();
+        try {
+            VolumeVO srcVol = findById(srcVolId);
+            VolumeVO destVol = findById(destVolId);
+            String uuid = srcVol.getUuid();
+            srcVol.setUuid(null);
+            destVol.setUuid(uuid);
+            update(srcVolId, srcVol);
+            update(destVolId, destVol);
+        } catch (Exception e) {
+            throw new CloudRuntimeException("Unable to persist the sequence number for this
host");
+        }
+        txn.commit();
+        return true;
+    }
+
+    @Override
     public ScopeType getVolumeStoragePoolScope(long volumeId) {
         // finding the storage scope where the volume is present
         TransactionLegacy txn = TransactionLegacy.currentTxn();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/77446d27/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 4e07edd..18972ef 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -886,6 +886,7 @@ public class VolumeServiceImpl implements VolumeService {
             }
             srcVolume.processEvent(Event.OperationSuccessed);
             destVolume.processEvent(Event.OperationSuccessed, result.getAnswer());
+            _volumeDao.updateUuid(srcVolume.getId(), destVolume.getId());
             destroyVolume(srcVolume.getId());
             srcVolume = volFactory.getVolume(srcVolume.getId());
             AsyncCallFuture<VolumeApiResult> destroyFuture = expungeVolumeAsync(srcVolume);


Mime
View raw message