Skip to content

Commit e091aad

Browse files
committed
Merge branch '4.19' of https://github.com/apache/cloudstack into 4.20
2 parents f8adedc + 35e809e commit e091aad

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/VeeamBackupProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ public boolean assignVMToBackupOffering(final VirtualMachine vm, final BackupOff
200200
public boolean removeVMFromBackupOffering(final VirtualMachine vm) {
201201
final VeeamClient client = getClient(vm.getDataCenterId());
202202
final VmwareDatacenter vmwareDC = findVmwareDatacenterForVM(vm);
203+
if (vm.getBackupExternalId() == null) {
204+
throw new CloudRuntimeException("The VM does not have a backup job assigned.");
205+
}
203206
try {
204207
if (!client.removeVMFromVeeamJob(vm.getBackupExternalId(), vm.getInstanceName(), vmwareDC.getVcenterHost())) {
205208
logger.warn("Failed to remove VM from Veeam Job id: " + vm.getBackupExternalId());

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,10 @@ public boolean removeVMFromBackupOffering(final Long vmId, final boolean forced)
380380

381381
boolean result = false;
382382
try {
383+
result = backupProvider.removeVMFromBackupOffering(vm);
383384
vm.setBackupOfferingId(null);
384-
vm.setBackupExternalId(null);
385385
vm.setBackupVolumes(null);
386-
result = backupProvider.removeVMFromBackupOffering(vm);
386+
vm.setBackupExternalId(null);
387387
if (result && backupProvider.willDeleteBackupsOnOfferingRemoval()) {
388388
final List<Backup> backups = backupDao.listByVmId(null, vm.getId());
389389
for (final Backup backup : backups) {

0 commit comments

Comments
 (0)