Reword KVM snapshot without memory error message (#6387)

This commit is contained in:
Nicolas Vazquez 2022-05-13 08:19:54 -03:00 committed by GitHub
parent 07cabb5890
commit ea37d757d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -17,6 +17,7 @@
package org.apache.cloudstack.api.command.user.vmsnapshot;
import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
@ -90,7 +91,13 @@ public class CreateVMSnapshotCmd extends BaseAsyncCreateCmd {
@Override
public void create() throws ResourceAllocationException {
VMSnapshot vmsnapshot = _vmSnapshotService.allocVMSnapshot(getVmId(), getDisplayName(), getDescription(), snapshotMemory());
VMSnapshot vmsnapshot;
try {
vmsnapshot = _vmSnapshotService.allocVMSnapshot(getVmId(), getDisplayName(), getDescription(), snapshotMemory());
} catch (CloudRuntimeException e) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create vm snapshot: " + e.getMessage(), e);
}
if (vmsnapshot != null) {
setEntityId(vmsnapshot.getId());
} else {

View File

@ -384,7 +384,9 @@ public class VMSnapshotManagerImpl extends MutualExclusiveIdsManagerBase impleme
VMSnapshotStrategy snapshotStrategy = storageStrategyFactory.getVmSnapshotStrategy(userVmVo.getId(), rootVolumePool.getId(), snapshotMemory);
if (snapshotStrategy == null) {
throw new CloudRuntimeException("Could not find snapshot strategy for VM snapshot");
String message = "KVM does not support the type of snapshot requested";
s_logger.debug(message);
throw new CloudRuntimeException(message);
}
}