mirror of https://github.com/apache/cloudstack.git
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 <sateesh@apache.org>
This commit is contained in:
parent
6c9b517929
commit
6ba9754201
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in New Issue