Skip to content

Commit 55486d6

Browse files
committed
minor UI fixes
1 parent 39ea6b7 commit 55486d6

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class ApiConstants {
6060
public static final String BACKUP_STORAGE_AVAILABLE = "backupstorageavailable";
6161
public static final String BACKUP_STORAGE_LIMIT = "backupstoragelimit";
6262
public static final String BACKUP_STORAGE_TOTAL = "backupstoragetotal";
63+
public static final String BACKUP_VM_OFFERING_REMOVED = "vmbackupofferingremoved";
6364
public static final String BACKUP_TOTAL = "backuptotal";
6465
public static final String BASE64_IMAGE = "base64image";
6566
public static final String BGP_PEERS = "bgppeers";

api/src/main/java/org/apache/cloudstack/api/response/BackupResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ public class BackupResponse extends BaseResponse {
119119
@Param(description = "the interval type of the backup schedule", since = "4.21.0")
120120
private String intervalType;
121121

122+
@SerializedName(ApiConstants.BACKUP_VM_OFFERING_REMOVED)
123+
@Param(description = "The backup offering corresponding to this backup was removed from the VM", since = "4.21.0")
124+
private Boolean vmOfferingRemoved;
125+
122126
public String getId() {
123127
return id;
124128
}
@@ -294,4 +298,8 @@ public String getIntervalType() {
294298
public void setIntervalType(String intervalType) {
295299
this.intervalType = intervalType;
296300
}
301+
302+
public void setVmOfferingRemoved(boolean vmOfferingRemoved) {
303+
this.vmOfferingRemoved = vmOfferingRemoved;
304+
}
297305
}

engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupDaoImpl.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.cloud.utils.db.Transaction;
4848
import com.cloud.utils.db.TransactionCallback;
4949
import com.cloud.vm.VMInstanceVO;
50+
import com.cloud.vm.VirtualMachine;
5051
import com.cloud.vm.dao.VMInstanceDao;
5152
import com.google.gson.Gson;
5253

@@ -281,10 +282,7 @@ public List<Long> listVmIdsWithBackupsInZone(Long zoneId) {
281282

282283
@Override
283284
public BackupResponse newBackupResponse(Backup backup, Boolean listVmDetails) {
284-
VMInstanceVO vm = null;
285-
if (backup.getVmId() != null) {
286-
vm = vmInstanceDao.findByIdIncludingRemoved(backup.getVmId());
287-
}
285+
VMInstanceVO vm = vmInstanceDao.findByIdIncludingRemoved(backup.getVmId());
288286
AccountVO account = accountDao.findByIdIncludingRemoved(backup.getAccountId());
289287
DomainVO domain = domainDao.findByIdIncludingRemoved(backup.getDomainId());
290288
DataCenterVO zone = dataCenterDao.findByIdIncludingRemoved(backup.getZoneId());
@@ -295,9 +293,12 @@ public BackupResponse newBackupResponse(Backup backup, Boolean listVmDetails) {
295293
response.setId(backup.getUuid());
296294
response.setName(backup.getName());
297295
response.setDescription(backup.getDescription());
298-
if (vm != null) {
296+
response.setVmName(vm.getHostName());
297+
if (vm.getState() != VirtualMachine.State.Expunging) {
299298
response.setVmId(vm.getUuid());
300-
response.setVmName(vm.getHostName());
299+
}
300+
if (vm.getBackupOfferingId() != backup.getBackupOfferingId()) {
301+
response.setVmOfferingRemoved(true);
301302
}
302303
response.setExternalId(backup.getExternalId());
303304
response.setType(backup.getType());
@@ -310,7 +311,7 @@ public BackupResponse newBackupResponse(Backup backup, Boolean listVmDetails) {
310311
}
311312
// ACS 4.20: For backups taken prior this release the backup.backed_volumes column would be empty hence use vm_instance.backup_volumes
312313
String backedUpVolumes;
313-
if (Objects.isNull(backup.getBackedUpVolumes()) && vm != null) {
314+
if (Objects.isNull(backup.getBackedUpVolumes())) {
314315
backedUpVolumes = new Gson().toJson(vm.getBackupVolumeList().toArray(), Backup.VolumeInfo[].class);
315316
} else {
316317
backedUpVolumes = new Gson().toJson(backup.getBackedUpVolumes().toArray(), Backup.VolumeInfo[].class);

ui/src/config/section/storage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ export default {
457457
label: 'label.backup.offering.remove',
458458
message: 'message.backup.offering.remove',
459459
dataView: true,
460-
show: (record) => { return record.state !== 'Destroyed' },
460+
show: (record) => { return record.state !== 'Destroyed' && record.vmbackupofferingremoved !== true },
461461
args: ['forced', 'virtualmachineid'],
462462
mapping: {
463463
forced: {

0 commit comments

Comments
 (0)