Skip to content

Commit 1732f67

Browse files
committed
Merge branch '4.20' of https://github.com/apache/cloudstack
2 parents 9c6f2a9 + e091aad commit 1732f67

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
@@ -191,6 +191,9 @@ public boolean assignVMToBackupOffering(final VirtualMachine vm, final BackupOff
191191
public boolean removeVMFromBackupOffering(final VirtualMachine vm) {
192192
final VeeamClient client = getClient(vm.getDataCenterId());
193193
final VmwareDatacenter vmwareDC = findVmwareDatacenterForVM(vm);
194+
if (vm.getBackupExternalId() == null) {
195+
throw new CloudRuntimeException("The VM does not have a backup job assigned.");
196+
}
194197
try {
195198
if (!client.removeVMFromVeeamJob(vm.getBackupExternalId(), vm.getInstanceName(), vmwareDC.getVcenterHost())) {
196199
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
@@ -394,10 +394,10 @@ public boolean removeVMFromBackupOffering(final Long vmId, final boolean forced)
394394

395395
boolean result = false;
396396
try {
397+
result = backupProvider.removeVMFromBackupOffering(vm);
397398
vm.setBackupOfferingId(null);
398-
vm.setBackupExternalId(null);
399399
vm.setBackupVolumes(null);
400-
result = backupProvider.removeVMFromBackupOffering(vm);
400+
vm.setBackupExternalId(null);
401401
if (result && backupProvider.willDeleteBackupsOnOfferingRemoval()) {
402402
final List<Backup> backups = backupDao.listByVmId(null, vm.getId());
403403
for (final Backup backup : backups) {

0 commit comments

Comments
 (0)