Skip to content

Commit 3e688b0

Browse files
author
Daan Hoogland
committed
Merge tag '4.22.0.1' into 4.22
2 parents 5b9a3d7 + 2eef7aa commit 3e688b0

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImpl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,14 +1663,14 @@ public Extension getExtensionForCluster(long clusterId) {
16631663
public List<String> getExtensionReservedResourceDetails(long extensionId) {
16641664
ExtensionDetailsVO detailsVO = extensionDetailsDao.findDetail(extensionId,
16651665
ApiConstants.RESERVED_RESOURCE_DETAILS);
1666-
if (detailsVO == null || !StringUtils.isNotBlank(detailsVO.getValue())) {
1667-
return Collections.emptyList();
1668-
}
16691666
List<String> reservedDetails = new ArrayList<>();
1670-
String[] parts = detailsVO.getValue().split(",");
1671-
for (String part : parts) {
1672-
if (StringUtils.isNotBlank(part)) {
1673-
reservedDetails.add(part.trim());
1667+
if (detailsVO != null && StringUtils.isNotBlank(detailsVO.getValue())) {
1668+
String[] parts = detailsVO.getValue().split(",");
1669+
for (String part : parts) {
1670+
String trimmedPart = part.trim();
1671+
if (StringUtils.isNotBlank(trimmedPart)) {
1672+
reservedDetails.add(trimmedPart);
1673+
}
16741674
}
16751675
}
16761676
addInbuiltExtensionReservedResourceDetails(extensionId, reservedDetails);

server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,13 @@ public UserVm revertToSnapshot(Long vmSnapshotId) throws InsufficientCapacityExc
764764
"In order to revert to a Snapshot without memory you need to first stop the Instance.");
765765
}
766766

767+
if (userVm.getState() == VirtualMachine.State.Running && vmSnapshotVo.getType() == VMSnapshot.Type.Disk) {
768+
throw new InvalidParameterValueException(
769+
"Reverting to the Instance Snapshot is not allowed for running Instances as this would result in an Instance state change. " +
770+
"For running Instances only Snapshots with memory can be reverted. " +
771+
"In order to revert to a Snapshot without memory you need to first stop the Instance.");
772+
}
773+
767774
if (userVm.getState() == VirtualMachine.State.Stopped && vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory) {
768775
throw new InvalidParameterValueException(
769776
"Reverting to the Instance Snapshot is not allowed for stopped Instances when the Snapshot contains memory as this would result in an Instance state change. " +

server/src/test/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@
169169
import com.cloud.vm.NicProfile;
170170
import com.cloud.vm.UserVmManager;
171171
import com.cloud.vm.UserVmVO;
172+
import com.cloud.vm.VmDetailConstants;
172173
import com.cloud.vm.VMInstanceDetailVO;
173174
import com.cloud.vm.VMInstanceVO;
174175
import com.cloud.vm.VirtualMachine;
175-
import com.cloud.vm.VmDetailConstants;
176176
import com.cloud.vm.dao.NicDao;
177177
import com.cloud.vm.dao.UserVmDao;
178178
import com.cloud.vm.dao.VMInstanceDao;

0 commit comments

Comments
 (0)