Skip to content

Commit 05b75e9

Browse files
author
Sateesh Chodapuneedi
committed
CLOUDSTACK-659
Support for storage migration in Cloudstack deployment over VMware Added VmwareStorageMotionStrategy to deal with storage motion tasks. Added target host parameter to MigrateWithStorageCommand. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added Resource changes to perform VM live migration along with virtual disks across the clusters in a zone. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added VmwareStorageMotionStrategy to application context. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> Support for volume live migration across datastores Unit tests for vmware storage motion. These test the VmwareStorageMotionStrategy. CLOUDSTACK-659 Fixing migrate volume. CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added Resource changes to perform VM live migration along with virtual disks across the clusters in a zone. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> Support for volume live migration across datastores CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added Resource changes to perform VM live migration along with virtual disks across the clusters in a zone. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> Support for volume live migration across datastores CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added Resource changes to perform VM live migration along with virtual disks across the clusters in a zone. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> Support for volume live migration across datastores Added vm type to prepareNetworkFromNicInfo in MigrateWithStorageCommand implementation. CLOUDSTACK-2701 - Enable storage migration for VMware resources Fixing attach volume and delete volume cases for volumes that are moved off original path in datastore when created. If volume is not found in root directory or datastore, do search in sub folders. CLOUDSTACK-2701 - Enable storage migration for VMware resources Sending command MigrateWithStorageCommand to source host instead of target host for the case of migration of VM within cluster. CLOUDSTACK-2701 - Enable storage migration for VMware resources Searching for virtual disk during device tear down. Adding dependency of 'cloud-engine-storage' to vmware hypervisor plugin. Add hypervisor capability storage_motion_supported for VMware 5.0 and 5.1 CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added VmwareStorageMotionStrategy to deal with storage motion tasks. Added target host parameter to MigrateWithStorageCommand. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added Resource changes to perform VM live migration along with virtual disks across the clusters in a zone. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added VmwareStorageMotionStrategy to application context. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> Support for volume live migration across datastores Unit tests for vmware storage motion. These test the VmwareStorageMotionStrategy. CLOUDSTACK-659 Fixing migrate volume. CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added Resource changes to perform VM live migration along with virtual disks across the clusters in a zone. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> Support for volume live migration across datastores Added vm type to prepareNetworkFromNicInfo in MigrateWithStorageCommand implementation. Adding dependency of 'cloud-engine-storage' to vmware hypervisor plugin. Add hypervisor capability storage_motion_supported for VMware 5.0 and 5.1 CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added VmwareStorageMotionStrategy to deal with storage motion tasks. Added target host parameter to MigrateWithStorageCommand. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added Resource changes to perform VM live migration along with virtual disks across the clusters in a zone. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added VmwareStorageMotionStrategy to application context. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> Support for volume live migration across datastores Unit tests for vmware storage motion. These test the VmwareStorageMotionStrategy. CLOUDSTACK-659 Fixing migrate volume. Adding dependency of 'cloud-engine-storage' to vmware hypervisor plugin. Add hypervisor capability storage_motion_supported for VMware 5.0 and 5.1 Adding dependency of 'cloud-engine-storage' to vmware hypervisor plugin. CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added VmwareStorageMotionStrategy to deal with storage motion tasks. Added target host parameter to MigrateWithStorageCommand. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added Resource changes to perform VM live migration along with virtual disks across the clusters in a zone. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> CLOUDSTACK-659 Support for storage migration in Cloudstack deployment over VMware Added VmwareStorageMotionStrategy to application context. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org> Support for volume live migration across datastores CLOUDSTACK-659 Fixing migrate volume. Unit tests for vmware storage motion. These test the VmwareStorageMotionStrategy. CLOUDSTACK-2701 - Enable storage migration for VMware resources Sending command MigrateWithStorageCommand to source host instead of target host for the case of migration of VM within cluster. CLOUDSTACK-2701 - Enable storage migration for VMware resources Moved 2 methods that are not specific to VMware but Volume are moved to VolumeManager from VmwareManager. Moved datastore volume path constructing code to separate method. Added check for source and target host, if they are from different DCs/vCenter instances. Updated error message & removed stale comment CLOUDSTACK-2701 - Enable storage migration for VMware resources Injecting component VolumeManager into VmwareResource. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org>
1 parent b6cd27f commit 05b75e9

15 files changed

Lines changed: 931 additions & 15 deletions

File tree

client/tomcatconf/applicationContext.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@
733733
<bean id="agentMonitor" class="com.cloud.agent.manager.AgentMonitor" />
734734
<bean id="alertGenerator" class="com.cloud.event.AlertGenerator" />
735735
<bean id="ancientDataMotionStrategy" class="org.apache.cloudstack.storage.motion.AncientDataMotionStrategy" />
736+
<bean id="vmwareStorageMotionStrategy" class="org.apache.cloudstack.storage.motion.VmwareStorageMotionStrategy"/>
736737
<bean id="xenserverStorageMotionStrategy" class="org.apache.cloudstack.storage.motion.XenServerStorageMotionStrategy" />
737738
<bean id="ancientImageDataStoreProvider" class="org.apache.cloudstack.storage.image.store.AncientImageDataStoreProvider" />
738739
<bean id="ancientSnapshotStrategy" class="org.apache.cloudstack.storage.snapshot.strategy.AncientSnapshotStrategy" />

core/src/com/cloud/agent/api/MigrateWithStorageCommand.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,18 @@
2424
public class MigrateWithStorageCommand extends Command {
2525
VirtualMachineTO vm;
2626
Map<VolumeTO, StorageFilerTO> volumeToFiler;
27+
String tgtHost;
2728

2829
public MigrateWithStorageCommand(VirtualMachineTO vm, Map<VolumeTO, StorageFilerTO> volumeToFiler) {
2930
this.vm = vm;
3031
this.volumeToFiler = volumeToFiler;
32+
this.tgtHost = null;
33+
}
34+
35+
public MigrateWithStorageCommand(VirtualMachineTO vm, Map<VolumeTO, StorageFilerTO> volumeToFiler, String tgtHost) {
36+
this.vm = vm;
37+
this.volumeToFiler = volumeToFiler;
38+
this.tgtHost = tgtHost;
3139
}
3240

3341
public VirtualMachineTO getVirtualMachine() {
@@ -38,6 +46,10 @@ public Map<VolumeTO, StorageFilerTO> getVolumeToFiler() {
3846
return volumeToFiler;
3947
}
4048

49+
public String getTargetHost() {
50+
return tgtHost;
51+
}
52+
4153
@Override
4254
public boolean executeInSequence() {
4355
return true;

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.List;
2121
import java.util.Map;
2222

23+
import com.cloud.agent.api.to.VolumeTO;
2324
import com.cloud.hypervisor.Hypervisor.HypervisorType;
2425
import com.cloud.hypervisor.vmware.manager.VmwareStorageManager;
2526
import com.cloud.hypervisor.vmware.mo.HostMO;

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import javax.inject.Inject;
3636
import javax.naming.ConfigurationException;
3737

38+
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
39+
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
3840
import org.apache.log4j.Logger;
3941

4042
import com.cloud.agent.AgentManager;
@@ -45,6 +47,8 @@
4547
import com.cloud.agent.api.Command;
4648
import com.cloud.agent.api.StartupCommand;
4749
import com.cloud.agent.api.StartupRoutingCommand;
50+
import com.cloud.agent.api.storage.MigrateVolumeAnswer;
51+
import com.cloud.agent.api.to.VolumeTO;
4852
import com.cloud.cluster.ClusterManager;
4953
import com.cloud.configuration.Config;
5054
import com.cloud.configuration.dao.ConfigurationDao;
@@ -79,6 +83,9 @@
7983
import com.cloud.server.ConfigurationServer;
8084
import com.cloud.storage.JavaStorageLayer;
8185
import com.cloud.storage.StorageLayer;
86+
import com.cloud.storage.StoragePool;
87+
import com.cloud.storage.VolumeVO;
88+
import com.cloud.storage.dao.VolumeDao;
8289
import com.cloud.storage.secondary.SecondaryStorageVmManager;
8390
import com.cloud.utils.FileUtil;
8491
import com.cloud.utils.NumbersUtil;
@@ -92,6 +99,8 @@
9299
import com.cloud.utils.script.Script;
93100
import com.cloud.utils.ssh.SshHelper;
94101
import com.cloud.vm.DomainRouterVO;
102+
import com.cloud.vm.VMInstanceVO;
103+
import com.cloud.vm.dao.VMInstanceDao;
95104
import com.google.gson.Gson;
96105
import com.vmware.vim25.AboutInfo;
97106
import com.vmware.vim25.HostConnectSpec;
@@ -124,6 +133,9 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
124133
@Inject ConfigurationDao _configDao;
125134
@Inject ConfigurationServer _configServer;
126135
@Inject HypervisorCapabilitiesDao _hvCapabilitiesDao;
136+
@Inject VMInstanceDao _vmDao;
137+
@Inject VolumeDao _volDao;
138+
@Inject DataStoreManager dataStoreMgr;
127139

128140
String _mountParent;
129141
StorageLayer _storage;

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ public Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd)
328328
workerVm = vmMo;
329329

330330
// attach volume to worker VM
331-
String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), volumePath);
331+
String datastoreVolumePath = getVolumePathInDatastore(dsMo, volumePath + ".vmdk");
332332
vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
333333
}
334334
}
@@ -1060,7 +1060,7 @@ private Pair<String, String> copyVolumeToSecStorage(VmwareHostService hostServic
10601060
}
10611061

10621062
//attach volume to worker VM
1063-
String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), volumePath);
1063+
String datastoreVolumePath = getVolumePathInDatastore(dsMo, volumePath + ".vmdk");
10641064
workerVm.attachDisk(new String[] { datastoreVolumePath }, morDs);
10651065
vmMo = workerVm;
10661066
}
@@ -1081,6 +1081,12 @@ private Pair<String, String> copyVolumeToSecStorage(VmwareHostService hostServic
10811081
}
10821082
}
10831083

1084+
private String getVolumePathInDatastore(DatastoreMO dsMo, String volumeFileName) throws Exception {
1085+
String datastoreVolumePath = dsMo.searchFileInSubFolders(volumeFileName, true);
1086+
assert (datastoreVolumePath != null) : "Virtual disk file missing from datastore.";
1087+
return datastoreVolumePath;
1088+
}
1089+
10841090
private Pair<String, String> copyVolumeFromSecStorage(VmwareHypervisorHost hyperHost, long volumeId,
10851091
DatastoreMO dsMo, String secStorageUrl, String exportName) throws Exception {
10861092

0 commit comments

Comments
 (0)