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 setServiceOffering(ServiceOffering offering);
|
||||
|
||||
public static class Param {
|
||||
|
||||
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.network.element.NetworkElement;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
|
||||
import com.cloud.user.Account;
|
||||
@ -260,7 +259,8 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile {
|
||||
return _params;
|
||||
}
|
||||
|
||||
public void setServiceOffering(ServiceOfferingVO offering) {
|
||||
@Override
|
||||
public void setServiceOffering(ServiceOffering offering) {
|
||||
_offering = offering;
|
||||
}
|
||||
|
||||
|
||||
@ -898,6 +898,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
||||
if (!hostSupportsServiceOfferingAndTemplate(sourceHost, serviceOffering, template)) {
|
||||
logger.debug(String.format("VM %s needs to be migrated", vm.getUuid()));
|
||||
final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm, template, serviceOffering, owner, null);
|
||||
profile.setServiceOffering(serviceOfferingDao.findById(vm.getId(), serviceOffering.getId()));
|
||||
DeploymentPlanner.ExcludeList excludeList = new DeploymentPlanner.ExcludeList();
|
||||
excludeList.addHost(sourceHost.getId());
|
||||
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;
|
||||
|
||||
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
|
||||
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);
|
||||
ServiceOfferingVO dummyOffering = serviceOfferingDao.findById(userVm.getId(), serviceOffering.getId());
|
||||
profile.setServiceOffering(dummyOffering);
|
||||
DeploymentPlanner.ExcludeList excludeList = new DeploymentPlanner.ExcludeList();
|
||||
final DataCenterDeployment plan = new DataCenterDeployment(zone.getId(), null, null, null, null, null);
|
||||
DeployDestination dest = null;
|
||||
@ -2273,7 +2271,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
||||
cleanupFailedImportVM(userVm);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -2285,11 +2283,6 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
||||
UserVm userVm = null;
|
||||
|
||||
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;
|
||||
|
||||
@ -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);
|
||||
|
||||
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();
|
||||
final DataCenterDeployment plan = new DataCenterDeployment(zone.getId(), null, null, hostId, poolId, 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())));
|
||||
}
|
||||
networkOrchestrationService.importNic(macAddress, 0, network, true, userVm, requestedIpPair, zone, true);
|
||||
publishVMUsageUpdateResourceCount(userVm, serviceOffering, template);
|
||||
publishVMUsageUpdateResourceCount(userVm, dummyOffering, template);
|
||||
return userVm;
|
||||
}
|
||||
|
||||
|
||||
@ -333,6 +333,7 @@ public class UnmanagedVMsManagerImplTest {
|
||||
when(serviceOffering.getRamSize()).thenReturn(instance.getMemory());
|
||||
when(serviceOffering.getSpeed()).thenReturn(instance.getCpuSpeed());
|
||||
when(serviceOfferingDao.findById(anyLong())).thenReturn(serviceOffering);
|
||||
when(serviceOfferingDao.findById(anyLong(), anyLong())).thenReturn(Mockito.mock(ServiceOfferingVO.class));
|
||||
DiskOfferingVO diskOfferingVO = Mockito.mock(DiskOfferingVO.class);
|
||||
when(diskOfferingDao.findById(anyLong())).thenReturn(diskOfferingVO);
|
||||
UserVmVO userVm = Mockito.mock(UserVmVO.class);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user