PaulAngus closed pull request #1037: Fix for CLOUDSTACK-8937 - XenServer
migrations with storage failing i…
URL: https://github.com/apache/cloudstack/pull/1037
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageCommandWrapper.java
b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageCommandWrapper.java
index 2a79d26b045..195ea6a9835 100644
---
a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageCommandWrapper.java
+++
b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageCommandWrapper.java
@@ -41,6 +41,7 @@
import com.cloud.resource.CommandWrapper;
import com.cloud.resource.ResourceWrapper;
import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.Pair;
import com.xensource.xenapi.Connection;
import com.xensource.xenapi.Host;
import com.xensource.xenapi.Network;
@@ -60,7 +61,7 @@
public Answer execute(final MigrateWithStorageCommand command, final
XenServer610Resource xenServer610Resource) {
final Connection connection = xenServer610Resource.getConnection();
final VirtualMachineTO vmSpec = command.getVirtualMachine();
- final Map<VolumeTO, StorageFilerTO> volumeToFiler =
command.getVolumeToFiler();
+ final List<Pair<VolumeTO, StorageFilerTO>> volToFiler =
command.getVolumeToFilerAsList();
final String vmName = vmSpec.getName();
Task task = null;
@@ -83,10 +84,8 @@ public Answer execute(final MigrateWithStorageCommand
command, final XenServer61
// Create the vif map. The vm stays in the same cluster so we have
to pass an empty vif map.
final Map<VIF, Network> vifMap = new HashMap<VIF, Network>();
final Map<VDI, SR> vdiMap = new HashMap<VDI, SR>();
- for (final Map.Entry<VolumeTO, StorageFilerTO> entry :
volumeToFiler.entrySet()) {
- final VolumeTO volume = entry.getKey();
- final StorageFilerTO sotrageFiler = entry.getValue();
- vdiMap.put(xenServer610Resource.getVDIbyUuid(connection,
volume.getPath()), xenServer610Resource.getStorageRepository(connection,
sotrageFiler.getUuid()));
+ for (final Pair<VolumeTO, StorageFilerTO> entry : volToFiler) {
+ vdiMap.put(xenServer610Resource.getVDIbyUuid(connection,
entry.first().getPath()), xenServer610Resource.getStorageRepository(connection,
entry.second().getUuid()));
}
// Get the vm to migrate.
@@ -136,4 +135,4 @@ public Answer execute(final MigrateWithStorageCommand
command, final XenServer61
}
}
}
-}
\ No newline at end of file
+}
diff --git
a/plugins/hypervisors/xenserver/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java
b/plugins/hypervisors/xenserver/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java
index c8367dd3ac1..99174e221f4 100644
---
a/plugins/hypervisors/xenserver/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java
+++
b/plugins/hypervisors/xenserver/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java
@@ -19,6 +19,7 @@
package org.apache.cloudstack.storage.motion;
import java.util.HashMap;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -59,6 +60,7 @@
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.Pair;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.dao.VMInstanceDao;
@@ -193,15 +195,14 @@ private Answer
migrateVmWithVolumesWithinCluster(VMInstanceVO vm, VirtualMachine
// Initiate migration of a virtual machine with it's volumes.
try {
- Map<VolumeTO, StorageFilerTO> volumeToFilerto = new
HashMap<VolumeTO, StorageFilerTO>();
+ List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerto = new
ArrayList<Pair<VolumeTO, StorageFilerTO>>();
for (Map.Entry<VolumeInfo, DataStore> entry :
volumeToPool.entrySet()) {
VolumeInfo volume = entry.getKey();
VolumeTO volumeTo = new VolumeTO(volume,
storagePoolDao.findById(volume.getPoolId()));
StorageFilerTO filerTo = new
StorageFilerTO((StoragePool)entry.getValue());
- volumeToFilerto.put(volumeTo, filerTo);
+ volumeToFilerto.add(new Pair<VolumeTO,
StorageFilerTO>(volumeTo, filerTo));
}
-
- MigrateWithStorageCommand command = new
MigrateWithStorageCommand(to, volumeToFilerto);
+ MigrateWithStorageCommand command = new
MigrateWithStorageCommand(to, volumeToFilerto,destHost.getGuid());
MigrateWithStorageAnswer answer =
(MigrateWithStorageAnswer)agentMgr.send(destHost.getId(), command);
if (answer == null) {
s_logger.error("Migration with storage of vm " + vm + "
failed.");
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services