mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	When creating a template from a managed-storage snapshot, put the snapshot in the Copying state before performing the copy (don't want to do anything with the snapshot until this process has completed)
This commit is contained in:
		
							parent
							
								
									f23c5ded0b
								
							
						
					
					
						commit
						8204a44890
					
				| @ -177,6 +177,13 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private Void handleCreateTemplateFromSnapshot(SnapshotInfo snapshotInfo, TemplateInfo templateInfo, AsyncCompletionCallback<CopyCommandResult> callback) { |     private Void handleCreateTemplateFromSnapshot(SnapshotInfo snapshotInfo, TemplateInfo templateInfo, AsyncCompletionCallback<CopyCommandResult> callback) { | ||||||
|  |         try { | ||||||
|  |             snapshotInfo.processEvent(Event.CopyingRequested); | ||||||
|  |         } | ||||||
|  |         catch (Exception ex) { | ||||||
|  |             throw new CloudRuntimeException("This snapshot is not currently in a state where it can be used to create a template."); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         HostVO hostVO = getHost(snapshotInfo.getDataStore().getId()); |         HostVO hostVO = getHost(snapshotInfo.getDataStore().getId()); | ||||||
|         DataStore srcDataStore = snapshotInfo.getDataStore(); |         DataStore srcDataStore = snapshotInfo.getDataStore(); | ||||||
| 
 | 
 | ||||||
| @ -184,6 +191,8 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { | |||||||
|         int primaryStorageDownloadWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue())); |         int primaryStorageDownloadWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue())); | ||||||
|         CopyCommand copyCommand = new CopyCommand(snapshotInfo.getTO(), templateInfo.getTO(), primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value()); |         CopyCommand copyCommand = new CopyCommand(snapshotInfo.getTO(), templateInfo.getTO(), primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value()); | ||||||
| 
 | 
 | ||||||
|  |         String errMsg = null; | ||||||
|  | 
 | ||||||
|         CopyCmdAnswer copyCmdAnswer = null; |         CopyCmdAnswer copyCmdAnswer = null; | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
| @ -205,9 +214,6 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { | |||||||
|             catch (Exception ex) { |             catch (Exception ex) { | ||||||
|                 s_logger.debug(ex.getMessage(), ex); |                 s_logger.debug(ex.getMessage(), ex); | ||||||
|             } |             } | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         String errMsg = null; |  | ||||||
| 
 | 
 | ||||||
|             if (copyCmdAnswer == null || !copyCmdAnswer.getResult()) { |             if (copyCmdAnswer == null || !copyCmdAnswer.getResult()) { | ||||||
|                 if (copyCmdAnswer != null && copyCmdAnswer.getDetails() != null && !copyCmdAnswer.getDetails().isEmpty()) { |                 if (copyCmdAnswer != null && copyCmdAnswer.getDetails() != null && !copyCmdAnswer.getDetails().isEmpty()) { | ||||||
| @ -218,6 +224,19 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  |             try { | ||||||
|  |                 if (errMsg == null) { | ||||||
|  |                     snapshotInfo.processEvent(Event.OperationSuccessed); | ||||||
|  |                 } | ||||||
|  |                 else { | ||||||
|  |                     snapshotInfo.processEvent(Event.OperationFailed); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) { | ||||||
|  |                 s_logger.debug(ex.getMessage(), ex); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         CopyCommandResult result = new CopyCommandResult(null, copyCmdAnswer); |         CopyCommandResult result = new CopyCommandResult(null, copyCmdAnswer); | ||||||
| 
 | 
 | ||||||
|         result.setResult(errMsg); |         result.setResult(errMsg); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user