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.
This commit is contained in:
Likitha Shetty 2014-10-13 16:26:47 +05:30 committed by Sanjay Tripathi
parent ff37fa5de0
commit a75a431373

View File

@ -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;
if (srcSnapshot.getHypervisorType() == Hypervisor.HypervisorType.KVM) {
VolumeInfo volumeInfo = srcSnapshot.getBaseVolume();
VirtualMachine vm = volumeInfo.getAttachedVM();
if (srcSnapshot.getHypervisorType() == Hypervisor.HypervisorType.KVM) {
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);
}