mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
server: fix on changeServiceForVirtualMachine when updating read/write rate (#4491)
When changing the service offering of a VM the disk_offering_id is not updated in volumes DB table and VM could not start Fixes #4125
This commit is contained in:
parent
b84a675de9
commit
4a779deab2
@ -1035,6 +1035,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
// Check that the specified service offering ID is valid
|
// Check that the specified service offering ID is valid
|
||||||
_itMgr.checkIfCanUpgrade(vmInstance, newServiceOffering);
|
_itMgr.checkIfCanUpgrade(vmInstance, newServiceOffering);
|
||||||
|
|
||||||
|
resizeRootVolumeOfVmWithNewOffering(vmInstance, newServiceOffering);
|
||||||
|
|
||||||
_itMgr.upgradeVmDb(vmId, newServiceOffering, currentServiceOffering);
|
_itMgr.upgradeVmDb(vmId, newServiceOffering, currentServiceOffering);
|
||||||
|
|
||||||
// Increment or decrement CPU and Memory count accordingly.
|
// Increment or decrement CPU and Memory count accordingly.
|
||||||
@ -1139,19 +1141,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
// Check that the specified service offering ID is valid
|
// Check that the specified service offering ID is valid
|
||||||
_itMgr.checkIfCanUpgrade(vmInstance, newServiceOffering);
|
_itMgr.checkIfCanUpgrade(vmInstance, newServiceOffering);
|
||||||
|
|
||||||
DiskOfferingVO newROOTDiskOffering = _diskOfferingDao.findById(newServiceOffering.getId());
|
resizeRootVolumeOfVmWithNewOffering(vmInstance, newServiceOffering);
|
||||||
|
|
||||||
List<VolumeVO> vols = _volsDao.findReadyRootVolumesByInstance(vmInstance.getId());
|
|
||||||
|
|
||||||
for (final VolumeVO rootVolumeOfVm : vols) {
|
|
||||||
rootVolumeOfVm.setDiskOfferingId(newROOTDiskOffering.getId());
|
|
||||||
|
|
||||||
_volsDao.update(rootVolumeOfVm.getId(), rootVolumeOfVm);
|
|
||||||
|
|
||||||
ResizeVolumeCmd resizeVolumeCmd = new ResizeVolumeCmd(rootVolumeOfVm.getId(), newROOTDiskOffering.getMinIops(), newROOTDiskOffering.getMaxIops());
|
|
||||||
|
|
||||||
_volumeService.resizeVolume(resizeVolumeCmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the new service offering can be applied to vm instance
|
// Check if the new service offering can be applied to vm instance
|
||||||
ServiceOffering newSvcOffering = _offeringDao.findById(svcOffId);
|
ServiceOffering newSvcOffering = _offeringDao.findById(svcOffId);
|
||||||
@ -1177,6 +1167,23 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resizeRootVolumeOfVmWithNewOffering(VMInstanceVO vmInstance, ServiceOfferingVO newServiceOffering)
|
||||||
|
throws ResourceAllocationException {
|
||||||
|
DiskOfferingVO newROOTDiskOffering = _diskOfferingDao.findById(newServiceOffering.getId());
|
||||||
|
|
||||||
|
List<VolumeVO> vols = _volsDao.findReadyRootVolumesByInstance(vmInstance.getId());
|
||||||
|
|
||||||
|
for (final VolumeVO rootVolumeOfVm : vols) {
|
||||||
|
rootVolumeOfVm.setDiskOfferingId(newROOTDiskOffering.getId());
|
||||||
|
|
||||||
|
ResizeVolumeCmd resizeVolumeCmd = new ResizeVolumeCmd(rootVolumeOfVm.getId(), newROOTDiskOffering.getMinIops(), newROOTDiskOffering.getMaxIops());
|
||||||
|
|
||||||
|
_volumeService.resizeVolume(resizeVolumeCmd);
|
||||||
|
|
||||||
|
_volsDao.update(rootVolumeOfVm.getId(), rootVolumeOfVm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ActionEvent(eventType = EventTypes.EVENT_NIC_CREATE, eventDescription = "Creating Nic", async = true)
|
@ActionEvent(eventType = EventTypes.EVENT_NIC_CREATE, eventDescription = "Creating Nic", async = true)
|
||||||
public UserVm addNicToVirtualMachine(AddNicToVMCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, CloudRuntimeException {
|
public UserVm addNicToVirtualMachine(AddNicToVMCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, CloudRuntimeException {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user