mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	CLOUDSTACK-4222: use new volume object in case of migrate volume
This commit is contained in:
		
							parent
							
								
									5034e8ee2d
								
							
						
					
					
						commit
						c58f15d867
					
				| @ -20,6 +20,7 @@ package com.cloud.storage; | ||||
| 
 | ||||
| import java.net.URISyntaxException; | ||||
| 
 | ||||
| import com.cloud.exception.StorageUnavailableException; | ||||
| import org.apache.cloudstack.api.command.user.volume.*; | ||||
| 
 | ||||
| import com.cloud.exception.ConcurrentOperationException; | ||||
|  | ||||
| @ -99,6 +99,7 @@ public class MigrateVolumeCmd extends BaseAsyncCmd { | ||||
|     @Override | ||||
|     public void execute(){ | ||||
|     	Volume result; | ||||
| 
 | ||||
|     	result = _volumeService.migrateVolume(this); | ||||
|     	if (result != null) { | ||||
|     		VolumeResponse response = _responseGenerator.createVolumeResponse(result); | ||||
|  | ||||
| @ -51,7 +51,7 @@ import com.cloud.vm.VirtualMachineProfile; | ||||
|  * to provision volumes. | ||||
|  */ | ||||
| public interface VolumeOrchestrationService { | ||||
|     VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType) throws ConcurrentOperationException; | ||||
|     VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType) throws ConcurrentOperationException, StorageUnavailableException; | ||||
| 
 | ||||
|     Volume allocateDuplicateVolume(Volume oldVol, Long templateId); | ||||
| 
 | ||||
| @ -61,7 +61,7 @@ public interface VolumeOrchestrationService { | ||||
| 
 | ||||
|     String getVmNameOnVolume(Volume volume); | ||||
| 
 | ||||
|     Volume migrateVolume(Volume volume, StoragePool destPool); | ||||
|     Volume migrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException; | ||||
| 
 | ||||
|     void destroyVolume(Volume volume); | ||||
| 
 | ||||
| @ -75,7 +75,7 @@ public interface VolumeOrchestrationService { | ||||
| 
 | ||||
|     void migrateVolumes(VirtualMachine vm, VirtualMachineTO vmTo, Host srcHost, Host destHost, Map<Volume, StoragePool> volumeToPool); | ||||
| 
 | ||||
|     boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool); | ||||
|     boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool) throws StorageUnavailableException; | ||||
| 
 | ||||
|     void prepareForMigration(VirtualMachineProfile vm, DeployDestination dest); | ||||
| 
 | ||||
|  | ||||
| @ -158,7 +158,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
| 
 | ||||
|     @Override | ||||
|     public VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType) | ||||
|             throws ConcurrentOperationException { | ||||
|             throws ConcurrentOperationException, StorageUnavailableException { | ||||
| 
 | ||||
|         // Find a destination storage pool with the specified criteria | ||||
|         DiskOffering diskOffering = _entityMgr.findById(DiskOffering.class, volume.getDiskOfferingId()); | ||||
| @ -754,14 +754,14 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
| 
 | ||||
|     @Override | ||||
|     @DB | ||||
|     public Volume migrateVolume(Volume volume, StoragePool destPool) { | ||||
|     public Volume migrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException { | ||||
|         VolumeInfo vol = volFactory.getVolume(volume.getId()); | ||||
|         AsyncCallFuture<VolumeApiResult> future = volService.copyVolume(vol, (DataStore)destPool); | ||||
|         try { | ||||
|             VolumeApiResult result = future.get(); | ||||
|             if (result.isFailed()) { | ||||
|                 s_logger.error("migrate volume failed:" + result.getResult()); | ||||
|                 return null; | ||||
|                 throw new StorageUnavailableException("migrate volume failed: " + result.getResult(), destPool.getId()); | ||||
|             } | ||||
|             return result.getVolume(); | ||||
|         } catch (InterruptedException e) { | ||||
| @ -830,7 +830,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool) { | ||||
|     public boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool) throws StorageUnavailableException { | ||||
|         List<VolumeVO> vols = _volsDao.findUsableVolumesForInstance(vm.getId()); | ||||
|         List<Volume> volumesNeedToMigrate = new ArrayList<Volume>(); | ||||
| 
 | ||||
| @ -1047,8 +1047,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|                 vol = task.volume; | ||||
|             } else if (task.type == VolumeTaskType.MIGRATE) { | ||||
|                 pool = (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), DataStoreRole.Primary); | ||||
|                 migrateVolume(task.volume, pool); | ||||
|                 vol = task.volume; | ||||
|                 vol = migrateVolume(task.volume, pool); | ||||
|             } else if (task.type == VolumeTaskType.RECREATE) { | ||||
|                 Pair<VolumeVO, DataStore> result = recreateVolume(task.volume, vm, dest); | ||||
|                 pool = (StoragePool)dataStoreMgr.getDataStore(result.second().getId(), DataStoreRole.Primary); | ||||
|  | ||||
| @ -35,6 +35,7 @@ import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import com.cloud.exception.StorageUnavailableException; | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; | ||||
| @ -1385,6 +1386,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac | ||||
|         } catch (InsufficientCapacityException e) { | ||||
|             s_logger.debug("Failed to migration: " + e.toString()); | ||||
|             throw new CloudRuntimeException("Failed to migration: " + e.toString()); | ||||
|         } catch (StorageUnavailableException e) { | ||||
|             s_logger.debug("Failed to migration: " + e.toString()); | ||||
|             throw new CloudRuntimeException("Failed to migration: " + e.toString()); | ||||
|         } finally { | ||||
|             try { | ||||
|                 stateTransitTo(vm, VirtualMachine.Event.AgentReportStopped, null); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user