Skip to content

Commit 63010c9

Browse files
author
Daan Hoogland
committed
check state instead of power state on change offering for ROOT volume
1 parent 21b2025 commit 63010c9

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,9 +2316,11 @@ private VolumeVO resizeVolumeInternal(VolumeVO volume, DiskOfferingVO newDiskOff
23162316
HypervisorType hypervisorType = _volsDao.getHypervisorType(volume.getId());
23172317

23182318
if (userVm != null) {
2319-
if (volume.getVolumeType().equals(Volume.Type.ROOT) && userVm.getPowerState() != VirtualMachine.PowerState.PowerOff && hypervisorType == HypervisorType.VMware) {
2320-
logger.error(" For ROOT volume resize VM should be in Power Off state.");
2321-
throw new InvalidParameterValueException("VM current state is : " + userVm.getPowerState() + ". But VM should be in " + VirtualMachine.PowerState.PowerOff + " state.");
2319+
if (Volume.Type.ROOT.equals(volume.getVolumeType())
2320+
&& ! State.Stopped.equals(userVm.getState())
2321+
&& HypervisorType.VMware.equals(hypervisorType)) {
2322+
logger.error("For ROOT volume resize VM should be in Stopped state.");
2323+
throw new InvalidParameterValueException("VM current state is : " + userVm.getState() + ". But VM should be in " + State.Stopped + " state.");
23222324
}
23232325
// serialize VM operation
23242326
AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
@@ -2396,9 +2398,11 @@ private void validateVolumeReadyStateAndHypervisorChecks(VolumeVO volume, long c
23962398

23972399
UserVmVO userVm = _userVmDao.findById(volume.getInstanceId());
23982400
if (userVm != null) {
2399-
if (volume.getVolumeType().equals(Volume.Type.ROOT) && userVm.getPowerState() != VirtualMachine.PowerState.PowerOff && hypervisorType == HypervisorType.VMware) {
2400-
logger.error(" For ROOT volume resize VM should be in Power Off state.");
2401-
throw new InvalidParameterValueException("VM current state is : " + userVm.getPowerState() + ". But VM should be in " + VirtualMachine.PowerState.PowerOff + " state.");
2401+
if (Volume.Type.ROOT.equals(volume.getVolumeType())
2402+
&& !State.Stopped.equals(userVm.getState())
2403+
&& hypervisorType == HypervisorType.VMware) {
2404+
logger.error("For ROOT volume resize VM should be in Stopped state.");
2405+
throw new InvalidParameterValueException("VM current state is : " + userVm.getState() + ". But VM should be in " + State.Stopped + " state.");
24022406
}
24032407
}
24042408
}

0 commit comments

Comments
 (0)