mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	CLOUDSTACK-8721: Fixed Setting details of VM through API results in removal of all other details except the one passed in API
This commit is contained in:
		
							parent
							
								
									cd02a59841
								
							
						
					
					
						commit
						728635a3d3
					
				| @ -94,7 +94,7 @@ public class UpdateVMCmd extends BaseCustomIdCmd { | ||||
|     private String instanceName; | ||||
| 
 | ||||
|     @Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, description = "Details in key/value pairs.") | ||||
|     protected Map details; | ||||
|     protected Map<String, String> details; | ||||
| 
 | ||||
|     ///////////////////////////////////////////////////// | ||||
|     /////////////////// Accessors /////////////////////// | ||||
| @ -136,13 +136,13 @@ public class UpdateVMCmd extends BaseCustomIdCmd { | ||||
|         return instanceName; | ||||
|     } | ||||
| 
 | ||||
|     public Map getDetails() { | ||||
|     public Map<String, String> getDetails() { | ||||
|         if (this.details == null || this.details.isEmpty()) { | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         Collection paramsCollection = this.details.values(); | ||||
|         return (Map) (paramsCollection.toArray())[0]; | ||||
|         Collection<String> paramsCollection = this.details.values(); | ||||
|         return (Map<String, String>) (paramsCollection.toArray())[0]; | ||||
|     } | ||||
| 
 | ||||
| ///////////////////////////////////////////////////// | ||||
|  | ||||
| @ -2147,7 +2147,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir | ||||
|         String userData = cmd.getUserData(); | ||||
|         Boolean isDynamicallyScalable = cmd.isDynamicallyScalable(); | ||||
|         String hostName = cmd.getHostName(); | ||||
|         Map details = cmd.getDetails(); | ||||
|         Map<String,String> details = cmd.getDetails(); | ||||
|         Account caller = CallContext.current().getCallingAccount(); | ||||
| 
 | ||||
|         // Input validation and permission checks | ||||
| @ -2188,7 +2188,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir | ||||
|         } | ||||
| 
 | ||||
|         if (details != null && !details.isEmpty()) { | ||||
|             vmInstance.setDetails(details); | ||||
|             _vmDao.loadDetails(vmInstance); | ||||
| 
 | ||||
|             for(Map.Entry<String,String> entry : details.entrySet()) { | ||||
|                 if(entry instanceof Map.Entry) { | ||||
|                     vmInstance.setDetail(entry.getKey(), entry.getValue()); | ||||
|                 } | ||||
|             } | ||||
|             _vmDao.saveDetails(vmInstance); | ||||
|         } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user