mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge branch '4.19'
This commit is contained in:
commit
a44f28bb31
@ -60,6 +60,8 @@ public interface VirtualMachineProfile {
|
|||||||
|
|
||||||
void setConfigDriveLocation(NetworkElement.Location location);
|
void setConfigDriveLocation(NetworkElement.Location location);
|
||||||
|
|
||||||
|
void setServiceOffering(ServiceOffering offering);
|
||||||
|
|
||||||
public static class Param {
|
public static class Param {
|
||||||
|
|
||||||
public static final Param VmPassword = new Param("VmPassword");
|
public static final Param VmPassword = new Param("VmPassword");
|
||||||
|
|||||||
@ -26,7 +26,6 @@ import com.cloud.host.Host;
|
|||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.network.element.NetworkElement;
|
import com.cloud.network.element.NetworkElement;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
|
||||||
import com.cloud.template.VirtualMachineTemplate;
|
import com.cloud.template.VirtualMachineTemplate;
|
||||||
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
|
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
@ -260,7 +259,8 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile {
|
|||||||
return _params;
|
return _params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServiceOffering(ServiceOfferingVO offering) {
|
@Override
|
||||||
|
public void setServiceOffering(ServiceOffering offering) {
|
||||||
_offering = offering;
|
_offering = offering;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -898,6 +898,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
|||||||
if (!hostSupportsServiceOfferingAndTemplate(sourceHost, serviceOffering, template)) {
|
if (!hostSupportsServiceOfferingAndTemplate(sourceHost, serviceOffering, template)) {
|
||||||
logger.debug(String.format("VM %s needs to be migrated", vm.getUuid()));
|
logger.debug(String.format("VM %s needs to be migrated", vm.getUuid()));
|
||||||
final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm, template, serviceOffering, owner, null);
|
final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm, template, serviceOffering, owner, null);
|
||||||
|
profile.setServiceOffering(serviceOfferingDao.findById(vm.getId(), serviceOffering.getId()));
|
||||||
DeploymentPlanner.ExcludeList excludeList = new DeploymentPlanner.ExcludeList();
|
DeploymentPlanner.ExcludeList excludeList = new DeploymentPlanner.ExcludeList();
|
||||||
excludeList.addHost(sourceHost.getId());
|
excludeList.addHost(sourceHost.getId());
|
||||||
final DataCenterDeployment plan = new DataCenterDeployment(sourceHost.getDataCenterId(), sourceHost.getPodId(), sourceHost.getClusterId(), null, null, null);
|
final DataCenterDeployment plan = new DataCenterDeployment(sourceHost.getDataCenterId(), sourceHost.getPodId(), sourceHost.getClusterId(), null, null, null);
|
||||||
@ -2164,11 +2165,6 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
|||||||
UserVm userVm = null;
|
UserVm userVm = null;
|
||||||
|
|
||||||
Map<String, String> allDetails = new HashMap<>(details);
|
Map<String, String> allDetails = new HashMap<>(details);
|
||||||
if (serviceOffering.isDynamic()) {
|
|
||||||
allDetails.put(VmDetailConstants.CPU_NUMBER, String.valueOf(serviceOffering.getCpu()));
|
|
||||||
allDetails.put(VmDetailConstants.MEMORY, String.valueOf(serviceOffering.getRamSize()));
|
|
||||||
allDetails.put(VmDetailConstants.CPU_SPEED, String.valueOf(serviceOffering.getSpeed()));
|
|
||||||
}
|
|
||||||
// Check disks and supplied disk offerings
|
// Check disks and supplied disk offerings
|
||||||
List<UnmanagedInstanceTO.Disk> unmanagedInstanceDisks = unmanagedInstance.getDisks();
|
List<UnmanagedInstanceTO.Disk> unmanagedInstanceDisks = unmanagedInstance.getDisks();
|
||||||
|
|
||||||
@ -2222,6 +2218,8 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final VirtualMachineProfile profile = new VirtualMachineProfileImpl(userVm, template, serviceOffering, owner, null);
|
final VirtualMachineProfile profile = new VirtualMachineProfileImpl(userVm, template, serviceOffering, owner, null);
|
||||||
|
ServiceOfferingVO dummyOffering = serviceOfferingDao.findById(userVm.getId(), serviceOffering.getId());
|
||||||
|
profile.setServiceOffering(dummyOffering);
|
||||||
DeploymentPlanner.ExcludeList excludeList = new DeploymentPlanner.ExcludeList();
|
DeploymentPlanner.ExcludeList excludeList = new DeploymentPlanner.ExcludeList();
|
||||||
final DataCenterDeployment plan = new DataCenterDeployment(zone.getId(), null, null, null, null, null);
|
final DataCenterDeployment plan = new DataCenterDeployment(zone.getId(), null, null, null, null, null);
|
||||||
DeployDestination dest = null;
|
DeployDestination dest = null;
|
||||||
@ -2273,7 +2271,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
|||||||
cleanupFailedImportVM(userVm);
|
cleanupFailedImportVM(userVm);
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Failed to import NICs while importing vm: %s. %s", instanceName, StringUtils.defaultString(e.getMessage())));
|
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Failed to import NICs while importing vm: %s. %s", instanceName, StringUtils.defaultString(e.getMessage())));
|
||||||
}
|
}
|
||||||
publishVMUsageUpdateResourceCount(userVm, serviceOffering, template);
|
publishVMUsageUpdateResourceCount(userVm, dummyOffering, template);
|
||||||
return userVm;
|
return userVm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2285,11 +2283,6 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
|||||||
UserVm userVm = null;
|
UserVm userVm = null;
|
||||||
|
|
||||||
Map<String, String> allDetails = new HashMap<>(details);
|
Map<String, String> allDetails = new HashMap<>(details);
|
||||||
if (serviceOffering.isDynamic()) {
|
|
||||||
allDetails.put(VmDetailConstants.CPU_NUMBER, String.valueOf(serviceOffering.getCpu()));
|
|
||||||
allDetails.put(VmDetailConstants.MEMORY, String.valueOf(serviceOffering.getRamSize()));
|
|
||||||
allDetails.put(VmDetailConstants.CPU_SPEED, String.valueOf(serviceOffering.getSpeed()));
|
|
||||||
}
|
|
||||||
|
|
||||||
VirtualMachine.PowerState powerState = VirtualMachine.PowerState.PowerOff;
|
VirtualMachine.PowerState powerState = VirtualMachine.PowerState.PowerOff;
|
||||||
|
|
||||||
@ -2356,6 +2349,8 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
|||||||
DiskProfile diskProfile = volumeManager.allocateRawVolume(Volume.Type.ROOT, rootVolumeName, diskOffering, null, null, null, userVm, template, owner, null);
|
DiskProfile diskProfile = volumeManager.allocateRawVolume(Volume.Type.ROOT, rootVolumeName, diskOffering, null, null, null, userVm, template, owner, null);
|
||||||
|
|
||||||
final VirtualMachineProfile profile = new VirtualMachineProfileImpl(userVm, template, serviceOffering, owner, null);
|
final VirtualMachineProfile profile = new VirtualMachineProfileImpl(userVm, template, serviceOffering, owner, null);
|
||||||
|
ServiceOfferingVO dummyOffering = serviceOfferingDao.findById(userVm.getId(), serviceOffering.getId());
|
||||||
|
profile.setServiceOffering(dummyOffering);
|
||||||
DeploymentPlanner.ExcludeList excludeList = new DeploymentPlanner.ExcludeList();
|
DeploymentPlanner.ExcludeList excludeList = new DeploymentPlanner.ExcludeList();
|
||||||
final DataCenterDeployment plan = new DataCenterDeployment(zone.getId(), null, null, hostId, poolId, null);
|
final DataCenterDeployment plan = new DataCenterDeployment(zone.getId(), null, null, hostId, poolId, null);
|
||||||
DeployDestination dest = null;
|
DeployDestination dest = null;
|
||||||
@ -2407,7 +2402,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
|||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Failed to import volumes while importing vm: %s. %s", instanceName, StringUtils.defaultString(e.getMessage())));
|
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Failed to import volumes while importing vm: %s. %s", instanceName, StringUtils.defaultString(e.getMessage())));
|
||||||
}
|
}
|
||||||
networkOrchestrationService.importNic(macAddress, 0, network, true, userVm, requestedIpPair, zone, true);
|
networkOrchestrationService.importNic(macAddress, 0, network, true, userVm, requestedIpPair, zone, true);
|
||||||
publishVMUsageUpdateResourceCount(userVm, serviceOffering, template);
|
publishVMUsageUpdateResourceCount(userVm, dummyOffering, template);
|
||||||
return userVm;
|
return userVm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -333,6 +333,7 @@ public class UnmanagedVMsManagerImplTest {
|
|||||||
when(serviceOffering.getRamSize()).thenReturn(instance.getMemory());
|
when(serviceOffering.getRamSize()).thenReturn(instance.getMemory());
|
||||||
when(serviceOffering.getSpeed()).thenReturn(instance.getCpuSpeed());
|
when(serviceOffering.getSpeed()).thenReturn(instance.getCpuSpeed());
|
||||||
when(serviceOfferingDao.findById(anyLong())).thenReturn(serviceOffering);
|
when(serviceOfferingDao.findById(anyLong())).thenReturn(serviceOffering);
|
||||||
|
when(serviceOfferingDao.findById(anyLong(), anyLong())).thenReturn(Mockito.mock(ServiceOfferingVO.class));
|
||||||
DiskOfferingVO diskOfferingVO = Mockito.mock(DiskOfferingVO.class);
|
DiskOfferingVO diskOfferingVO = Mockito.mock(DiskOfferingVO.class);
|
||||||
when(diskOfferingDao.findById(anyLong())).thenReturn(diskOfferingVO);
|
when(diskOfferingDao.findById(anyLong())).thenReturn(diskOfferingVO);
|
||||||
UserVmVO userVm = Mockito.mock(UserVmVO.class);
|
UserVmVO userVm = Mockito.mock(UserVmVO.class);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user