Updated Branches: refs/heads/4.2-forward a30a33c14 -> 995e193be
CLOUDSTACK-4458: Volume attach/detach command needs to sent to hypervisor resource even when target VM is in Stopped state Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/995e193b Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/995e193b Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/995e193b Branch: refs/heads/4.2-forward Commit: 995e193be2a1aad8ffe0eeb03357e23fb5c63769 Parents: a316ffa Author: Kelven Yang <kelv...@gmail.com> Authored: Wed Aug 28 18:37:45 2013 -0700 Committer: Kelven Yang <kelv...@gmail.com> Committed: Wed Aug 28 18:38:12 2013 -0700 ---------------------------------------------------------------------- .../storage/snapshot/SnapshotServiceImpl.java | 1 - .../src/com/cloud/hypervisor/guru/VMwareGuru.java | 2 +- .../cloud/storage/resource/VmwareStorageProcessor.java | 2 +- server/src/com/cloud/storage/VolumeManagerImpl.java | 12 +++++++++++- .../cloud/hypervisor/vmware/mo/VirtualMachineMO.java | 3 +-- 5 files changed, 14 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/995e193b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java ---------------------------------------------------------------------- diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java index e53bf9c..00d9631 100644 --- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java +++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java @@ -247,7 +247,6 @@ public class SnapshotServiceImpl implements SnapshotService { AsyncCallFuture<SnapshotResult> future = new AsyncCallFuture<SnapshotResult>(); SnapshotResult result = new SnapshotResult(snapshot, null); try { - snapObj.processEvent(Snapshot.Event.BackupToSecondary); DataStore imageStore = this.findSnapshotImageStore(snapshot); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/995e193b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java index c8e82ab..73cc8e3 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java @@ -351,7 +351,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru { } } } - + if(!needDelegation) { return new Pair<Boolean, Long>(Boolean.FALSE, new Long(hostId)); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/995e193b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java index 20c26fb..14fca3a 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java +++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java @@ -969,7 +969,7 @@ public class VmwareStorageProcessor implements StorageProcessor { throw new Exception("unable to prepare snapshot backup directory"); } } - } + } VirtualMachineMO clonedVm = null; try { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/995e193b/server/src/com/cloud/storage/VolumeManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java index 35fe72a..85a19ca 100644 --- a/server/src/com/cloud/storage/VolumeManagerImpl.java +++ b/server/src/com/cloud/storage/VolumeManagerImpl.java @@ -2026,6 +2026,16 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { String errorMsg = "Failed to detach volume: " + volume.getName() + " from VM: " + vm.getHostName(); boolean sendCommand = (vm.getState() == State.Running); + Long hostId = vm.getHostId(); + if (hostId == null) { + hostId = vm.getLastHostId(); + HostVO host = _hostDao.findById(hostId); + if (host != null + && host.getHypervisorType() == HypervisorType.VMware) { + sendCommand = true; + } + } + Answer answer = null; if (sendCommand) { @@ -2044,7 +2054,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { cmd.set_iScsiName(volume.get_iScsiName()); try { - answer = _agentMgr.send(vm.getHostId(), cmd); + answer = _agentMgr.send(hostId, cmd); } catch (Exception e) { throw new CloudRuntimeException(errorMsg + " due to: " + e.getMessage()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/995e193b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java index 7dd947c..6007bf0 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java @@ -1055,8 +1055,7 @@ public class VirtualMachineMO extends BaseMO { // VirtualDisk, we only perform prefix matching Pair<VirtualDisk, String> deviceInfo = getDiskDevice(vmdkDatastorePath, false); if(deviceInfo == null) { - if(s_logger.isTraceEnabled()) - s_logger.trace("vCenter API trace - detachDisk() done (failed)"); + s_logger.warn("vCenter API trace - detachDisk() done (failed)"); throw new Exception("No such disk device: " + vmdkDatastorePath); }