Repository: cloudstack
Updated Branches:
  refs/heads/master ff37fa5de -> a75a43137


CLOUDSTACK-8107. Failed to create snapshot from volume when the task is 
performed repeatedly in zone wide primary Storage.
While taking a snapshot of a volume, CS chooses the endpoint to perform backup 
snapshot operation by selecting any host that has the storage containing the 
volume mounted on it.
Instead, if the volume is attached to a VM, the endpoint chosen by CS should be 
the host that contains the VM.


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

Branch: refs/heads/master
Commit: a75a43137316a60b20760aa5015d97f55520fd16
Parents: ff37fa5
Author: Likitha Shetty <likitha.she...@citrix.com>
Authored: Mon Oct 13 16:26:47 2014 +0530
Committer: Sanjay Tripathi <sanjay.tripa...@citrix.com>
Committed: Tue Dec 23 09:48:35 2014 +0530

----------------------------------------------------------------------
 .../storage/endpoint/DefaultEndPointSelector.java       | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a75a4313/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
----------------------------------------------------------------------
diff --git 
a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
 
b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
index 18c8991..7067b8c 100644
--- 
a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
+++ 
b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
@@ -205,13 +205,21 @@ public class DefaultEndPointSelector implements 
EndPointSelector {
     public EndPoint select(DataObject srcData, DataObject destData, 
StorageAction action) {
         if (action == StorageAction.BACKUPSNAPSHOT && 
srcData.getDataStore().getRole() == DataStoreRole.Primary) {
             SnapshotInfo srcSnapshot = (SnapshotInfo)srcData;
+            VolumeInfo volumeInfo = srcSnapshot.getBaseVolume();
+            VirtualMachine vm = volumeInfo.getAttachedVM();
             if (srcSnapshot.getHypervisorType() == 
Hypervisor.HypervisorType.KVM) {
-                VolumeInfo volumeInfo = srcSnapshot.getBaseVolume();
-                VirtualMachine vm = volumeInfo.getAttachedVM();
                 if (vm != null && vm.getState() == 
VirtualMachine.State.Running) {
                     return getEndPointFromHostId(vm.getHostId());
                 }
             }
+            if (srcSnapshot.getHypervisorType() == 
Hypervisor.HypervisorType.VMware) {
+                if (vm != null) {
+                    Long hostId = vm.getHostId() != null ? vm.getHostId() : 
vm.getLastHostId();
+                    if (hostId != null) {
+                        return getEndPointFromHostId(hostId);
+                    }
+                }
+            }
         }
         return select(srcData, destData);
     }

Reply via email to