From 57cb023eb8493009982233bc2e0df869fb4f7b59 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 | 9 ++------- 3 files changed, 15 insertions(+), 8 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 e9c185a33c9..c2792c74dec 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 @@ -359,7 +359,7 @@ 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 45803b5cefa..f254c5c6164 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 @@ -112,7 +112,6 @@ import com.vmware.vim25.VirtualMachineRuntimeInfo; import com.vmware.vim25.VirtualSCSISharing; import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec; -import org.apache.cloudstack.engine.orchestration.VolumeOrchestrator; import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService; import org.apache.cloudstack.storage.command.DeleteCommand; import org.apache.cloudstack.storage.command.StorageSubSystemCommand; @@ -283,6 +282,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; @@ -318,9 +318,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa protected final int _shutdown_waitMs = 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; @@ -4357,7 +4354,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; @@ -4369,13 +4366,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.