From 6ba9754201eeb96ec8f34c1b746c4dcf173a9b29 Mon Sep 17 00:00:00 2001 From: Sateesh Chodapuneedi Date: Tue, 31 Dec 2013 06:21:32 +0530 Subject: [PATCH] CLOUDSTACK-5447 [Automation] Volume migration failing with NullPointerException in vmware and KVM. Instead of injecting object of VolumeOrchestrationService into VmwareResource, we now populate the command object (MigrateVolumeCommand here) with required information. Thus we dont need volume orchestration service to query that information from resource. Signed-off-by: Sateesh Chodapuneedi --- .../agent/api/storage/MigrateVolumeCommand.java | 12 ++++++++++++ .../storage/motion/AncientDataMotionStrategy.java | 2 +- .../hypervisor/vmware/resource/VmwareResource.java | 8 ++------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/core/src/com/cloud/agent/api/storage/MigrateVolumeCommand.java b/core/src/com/cloud/agent/api/storage/MigrateVolumeCommand.java index b82d8481f2c..b73a48a1b37 100644 --- a/core/src/com/cloud/agent/api/storage/MigrateVolumeCommand.java +++ b/core/src/com/cloud/agent/api/storage/MigrateVolumeCommand.java @@ -25,6 +25,7 @@ public class MigrateVolumeCommand extends Command { long volumeId; String volumePath; StorageFilerTO pool; + String attachedVmName; public MigrateVolumeCommand(long volumeId, String volumePath, StoragePool pool) { this.volumeId = volumeId; @@ -32,6 +33,13 @@ public class MigrateVolumeCommand extends Command { this.pool = new StorageFilerTO(pool); } + public MigrateVolumeCommand(long volumeId, String volumePath, StoragePool pool, String attachedVmName) { + this.volumeId = volumeId; + this.volumePath = volumePath; + this.pool = new StorageFilerTO(pool); + this.attachedVmName = attachedVmName; + } + @Override public boolean executeInSequence() { return true; @@ -48,4 +56,8 @@ public class MigrateVolumeCommand extends Command { public StorageFilerTO getPool() { return pool; } + + public String getAttachedVmName() { + return attachedVmName; + } } \ No newline at end of file diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java index 315f279e41a..99f57142242 100644 --- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java +++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java @@ -361,7 +361,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { protected Answer migrateVolumeToPool(DataObject srcData, DataObject destData) { VolumeInfo volume = (VolumeInfo)srcData; StoragePool destPool = (StoragePool)dataStoreMgr.getDataStore(destData.getDataStore().getId(), DataStoreRole.Primary); - MigrateVolumeCommand command = new MigrateVolumeCommand(volume.getId(), volume.getPath(), destPool); + MigrateVolumeCommand command = new MigrateVolumeCommand(volume.getId(), volume.getPath(), destPool, volume.getAttachedVmName()); EndPoint ep = selector.select(volume.getDataStore()); Answer answer = null; if (ep == null) { 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 37ed0559a69..6582f46f85c 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 @@ -304,6 +304,7 @@ import com.cloud.network.rules.FirewallRule; import com.cloud.resource.ServerResource; import com.cloud.serializer.GsonHelper; import com.cloud.storage.Storage; +import com.cloud.storage.StoragePool; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.Volume; import com.cloud.storage.resource.StoragePoolResource; @@ -339,9 +340,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa protected final int _shutdownWaitMs = 300000; // wait up to 5 minutes for shutdown - @Inject - protected VolumeOrchestrationService volMgr; - // out an operation protected final int _retry = 24; protected final int _sleep = 10000; @@ -4360,7 +4358,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa s_logger.info("Executing resource MigrateVolumeCommand: " + _gson.toJson(cmd)); } - final String vmName = volMgr.getVmNameFromVolumeId(cmd.getVolumeId()); + final String vmName = cmd.getAttachedVmName(); VirtualMachineMO vmMo = null; VmwareHypervisorHost srcHyperHost = null; @@ -4372,13 +4370,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa VirtualMachineRelocateSpecDiskLocator diskLocator = null; String srcDiskName = ""; - String srcDsName = ""; String tgtDsName = ""; try { srcHyperHost = getHyperHost(getServiceContext()); morDc = srcHyperHost.getHyperHostDatacenter(); - srcDsName = volMgr.getStoragePoolOfVolume(cmd.getVolumeId()); tgtDsName = poolTo.getUuid().replace("-", ""); // find VM in this datacenter not just in this cluster.