mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	Bug 11962 - MigrateVirtualMachine fails with AgentUnavailableException when the targeted host for migration is under Maintenance
Bug 11964 - You are allowed to migrate a virtual machine on to the host that it already exists o Changes: Validations were missing in th MigrateVmCmd API, since from UI the validations are always done while listing hosts for migration as first step.
This commit is contained in:
		
							parent
							
								
									54f4ebf08c
								
							
						
					
					
						commit
						0dc7fb48a1
					
				@ -149,6 +149,7 @@ import com.cloud.org.Grouping;
 | 
				
			|||||||
import com.cloud.projects.Project;
 | 
					import com.cloud.projects.Project;
 | 
				
			||||||
import com.cloud.projects.ProjectManager;
 | 
					import com.cloud.projects.ProjectManager;
 | 
				
			||||||
import com.cloud.resource.ResourceManager;
 | 
					import com.cloud.resource.ResourceManager;
 | 
				
			||||||
 | 
					import com.cloud.resource.ResourceState;
 | 
				
			||||||
import com.cloud.server.Criteria;
 | 
					import com.cloud.server.Criteria;
 | 
				
			||||||
import com.cloud.service.ServiceOfferingVO;
 | 
					import com.cloud.service.ServiceOfferingVO;
 | 
				
			||||||
import com.cloud.service.dao.ServiceOfferingDao;
 | 
					import com.cloud.service.dao.ServiceOfferingDao;
 | 
				
			||||||
@ -3308,11 +3309,21 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            throw new InvalidParameterValueException("Unsupported operation, VM uses Local storage, cannot migrate");
 | 
					            throw new InvalidParameterValueException("Unsupported operation, VM uses Local storage, cannot migrate");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        //check if migrating to same host
 | 
				
			||||||
 | 
					        long srcHostId = vm.getHostId();
 | 
				
			||||||
 | 
					        if(destinationHost.getId() == srcHostId){
 | 
				
			||||||
 | 
					            throw new InvalidParameterValueException("Cannot migrate VM, VM is already presnt on this host, please specify valid destination host to migrate the VM");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        //check if host is UP
 | 
				
			||||||
 | 
					        if(destinationHost.getStatus() != com.cloud.host.Status.Up || destinationHost.getResourceState() != ResourceState.Enabled){
 | 
				
			||||||
 | 
					            throw new InvalidParameterValueException("Cannot migrate VM, destination host is not in correct state, has status: "+destinationHost.getStatus() + ", state: " +destinationHost.getResourceState());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // call to core process
 | 
					        // call to core process
 | 
				
			||||||
        DataCenterVO dcVO = _dcDao.findById(destinationHost.getDataCenterId());
 | 
					        DataCenterVO dcVO = _dcDao.findById(destinationHost.getDataCenterId());
 | 
				
			||||||
        HostPodVO pod = _podDao.findById(destinationHost.getPodId());
 | 
					        HostPodVO pod = _podDao.findById(destinationHost.getPodId());
 | 
				
			||||||
        long srcHostId = vm.getHostId();
 | 
					 | 
				
			||||||
        Cluster cluster = _clusterDao.findById(destinationHost.getClusterId());
 | 
					        Cluster cluster = _clusterDao.findById(destinationHost.getClusterId());
 | 
				
			||||||
        DeployDestination dest = new DeployDestination(dcVO, pod, cluster, destinationHost);
 | 
					        DeployDestination dest = new DeployDestination(dcVO, pod, cluster, destinationHost);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user