DaanHoogland commented on code in PR #11222:
URL: https://github.com/apache/cloudstack/pull/11222#discussion_r2210649674
##########
server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java:
##########
@@ -515,24 +516,44 @@ public List<BackupSchedule> listBackupSchedule(final Long
vmId) {
public boolean deleteBackupSchedule(DeleteBackupScheduleCmd cmd) {
Long vmId = cmd.getVmId();
Long id = cmd.getId();
- if (Objects.isNull(vmId) && Objects.isNull(id)) {
- throw new InvalidParameterValueException("Either instance ID or ID
of backup schedule needs to be specified");
+ if (ObjectUtils.allNull(vmId, id)) {
+ throw new InvalidParameterValueException("Either instance ID or ID
of backup schedule needs to be specified.");
}
+
if (Objects.nonNull(vmId)) {
- final VMInstanceVO vm = findVmById(vmId);
- validateForZone(vm.getDataCenterId());
-
accountManager.checkAccess(CallContext.current().getCallingAccount(), null,
true, vm);
- return deleteAllVMBackupSchedules(vm.getId());
- } else {
- final BackupSchedule schedule = backupScheduleDao.findById(id);
- if (schedule == null) {
- throw new CloudRuntimeException("Could not find the requested
backup schedule.");
- }
- return backupScheduleDao.remove(schedule.getId());
+ checkCallerAccessToBackupScheduleVm(vmId);
+ return deleteAllVmBackupSchedules(vmId);
+ }
Review Comment:
shouldn’t we check if the schedule id is passed first?
passing vm id and schedule id as a user I would expect the specific schedule
to be deleted and not everything foer this vm.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]