CLOUDSTACK-659 Fixing migrate volume.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6fcc94f7 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6fcc94f7 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6fcc94f7 Branch: refs/heads/vmware-storage-motion Commit: 6fcc94f78f724fcda391355ef8945cf6d7e79533 Parents: 9769460 Author: Sateesh Chodapuneedi <[email protected]> Authored: Thu May 23 16:23:09 2013 +0530 Committer: Sateesh Chodapuneedi <[email protected]> Committed: Fri May 24 15:24:07 2013 +0530 ---------------------------------------------------------------------- .../hypervisor/vmware/resource/VmwareResource.java | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6fcc94f7/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index e47aac6..996ff84 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -3608,11 +3608,13 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa String srcDiskName = ""; String srcDsName = ""; + String tgtDsName = ""; try { srcHyperHost = getHyperHost(getServiceContext()); morDc = srcHyperHost.getHyperHostDatacenter(); srcDsName = mgr.getStoragePoolOfVolume(cmd.getVolumeId()); + tgtDsName = poolTo.getUuid().replace("-", ""); // find VM through datacenter (VM is not at the target host yet) vmMo = srcHyperHost.findVmOnPeerHyperHost(vmName); @@ -3621,6 +3623,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa s_logger.error(msg); throw new Exception(msg); } + morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(srcHyperHost, tgtDsName); + if (morDs == null) { + String msg = "Unable to find the mounted datastore with name " + tgtDsName + " to execute MigrateVolumeCommand"; + s_logger.error(msg); + throw new Exception(msg); + } srcDiskName = String.format("[%s] %s.vmdk", srcDsName, volumePath); diskLocator = new VirtualMachineRelocateSpecDiskLocator(); @@ -3634,7 +3642,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa if (!vmMo.changeDatastore(relocateSpec)) { throw new Exception("Change datastore operation failed during volume migration"); } else { - s_logger.debug("Successfully migrated volume " + vmName + " to target datastore"); + s_logger.debug("Successfully migrated volume " + volumePath + " to target datastore " + tgtDsName); } return new MigrateVolumeAnswer(cmd, true, null, volumePath);
