Skip to content

Commit 07f24cb

Browse files
committed
Throw exception if diskOffering stored in the backup is not present.
1 parent f4f0655 commit 07f24cb

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8812,7 +8812,7 @@ public UserVm allocateVMFromBackup(CreateVMFromBackupCmd cmd) throws Insufficien
88128812
} else {
88138813
String serviceOfferingUuid = backup.getDetail(ApiConstants.SERVICE_OFFERING_ID);
88148814
if (serviceOfferingUuid == null) {
8815-
throw new CloudRuntimeException("Backup doesn't contain service offering uuid. Please specify a valid service offering id while creating instance");
8815+
throw new CloudRuntimeException("Backup doesn't contain service offering uuid. Please specify a valid service offering id while creating the instance");
88168816
}
88178817
serviceOffering = serviceOfferingDao.findByUuid(serviceOfferingUuid);
88188818
if (serviceOffering == null) {
@@ -8852,7 +8852,7 @@ public UserVm allocateVMFromBackup(CreateVMFromBackupCmd cmd) throws Insufficien
88528852
}
88538853
template = _templateDao.findByUuid(templateUuid);
88548854
if (template == null) {
8855-
throw new CloudRuntimeException("Unable to find template with the uuid stored in backup. Please specify a valid template id while creating instance");
8855+
throw new CloudRuntimeException("Unable to find template with the uuid stored in backup. Please specify a valid template id while creating the instance");
88568856
}
88578857
}
88588858

@@ -8902,7 +8902,7 @@ public UserVm allocateVMFromBackup(CreateVMFromBackupCmd cmd) throws Insufficien
89028902
for (String networkUuid: networkUuids) {
89038903
Network network = _networkDao.findByUuid(networkUuid);
89048904
if (network == null) {
8905-
throw new CloudRuntimeException("Unable to find network with the uuid " + networkUuid + "stored in backup. Please specify a valid network id while creating instance");
8905+
throw new CloudRuntimeException("Unable to find network with the uuid " + networkUuid + "stored in backup. Please specify a valid network id while creating the instance");
89068906
}
89078907
Long networkId = network.getId();
89088908
ipToNetworkMap.put(networkId, null);

server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,13 @@ public List<DiskOfferingInfo> getDataDiskOfferingListFromBackup(Backup backup) {
835835
}
836836

837837
diskOfferings = Stream.of(diskOfferingIds.split(","))
838-
.map(uuid -> diskOfferingDao.findByUuid(uuid))
839-
.collect(Collectors.toList());
838+
.map(uuid -> {
839+
DiskOfferingVO diskOffering = diskOfferingDao.findByUuid(uuid);
840+
if (diskOffering == null) {
841+
throw new CloudRuntimeException("Unable to find disk offering with uuid (" + uuid + ") stored in backup. Please specify a valid disk offering id while creating the instance");
842+
}
843+
return diskOffering;
844+
}).collect(Collectors.toList());
840845
diskSizes = Stream.of(backup.getDetail(ApiConstants.DISK_SIZES).split(","))
841846
.map(Long::valueOf)
842847
.collect(Collectors.toList());

0 commit comments

Comments
 (0)