use of com.cloud.legacymodel.communication.command.MigrateWithStorageAcrossClustersCommand in project cosmic by MissionCriticalCloud.
the class KVMStorageMotionStrategy method migrateVmWithVolumesAcrossCluster.
@Override
protected Answer migrateVmWithVolumesAcrossCluster(final VMInstanceVO instanceTo, final VirtualMachineTO vmTo, final Host srcHost, final Host destHost, final Map<VolumeInfo, DataStore> volumeToPoolMap) throws AgentUnavailableException {
try {
final List<Pair<VolumeTO, StorageFilerTO>> volumeMapping = buildVolumeMapping(volumeToPoolMap);
final MigrateWithStorageAcrossClustersCommand command = new MigrateWithStorageAcrossClustersCommand(vmTo, volumeMapping, destHost.getPrivateIpAddress());
final MigrateWithStorageAcrossClustersAnswer answer = (MigrateWithStorageAcrossClustersAnswer) agentMgr.send(srcHost.getId(), command);
if (answer == null) {
final String errorMessage = String.format("Error when trying to migrate VM %s (with storage) to host %s", instanceTo, destHost);
s_logger.error(errorMessage);
throw new CloudRuntimeException(errorMessage);
} else if (!answer.getResult()) {
final String errorMessage = String.format("Error when trying to migrate VM %s (with storage) to host %s => Details: %s", instanceTo, destHost, answer.getDetails());
s_logger.error(errorMessage);
throw new CloudRuntimeException(errorMessage);
} else {
// Update the volume details after migration.
updateVolumePathsAfterMigration(volumeToPoolMap, answer.getVolumes());
}
return answer;
} catch (final OperationTimedoutException e) {
final String errorMessage = String.format("Operation timed out when attempting to migrate VM %s to host %s", instanceTo, destHost);
s_logger.error(errorMessage, e);
throw new AgentUnavailableException(errorMessage, srcHost.getId());
}
}
Aggregations