Skip to content

Commit 77e9125

Browse files
committed
show use IP Address from Backup button when orignal instance is expunged
1 parent 35ea878 commit 77e9125

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-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
@@ -63,6 +63,7 @@ public class ApiConstants {
6363
public static final String BACKUP_STORAGE_LIMIT = "backupstoragelimit";
6464
public static final String BACKUP_STORAGE_TOTAL = "backupstoragetotal";
6565
public static final String BACKUP_VM_OFFERING_REMOVED = "vmbackupofferingremoved";
66+
public static final String BACKUP_VM_EXPUNGED = "backupvmexpunged";
6667
public static final String BACKUP_TOTAL = "backuptotal";
6768
public static final String BASE64_IMAGE = "base64image";
6869
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
@@ -123,6 +123,10 @@ public class BackupResponse extends BaseResponse {
123123
@Param(description = "The backup offering corresponding to this backup was removed from the VM", since = "4.21.0")
124124
private Boolean vmOfferingRemoved;
125125

126+
@SerializedName(ApiConstants.BACKUP_VM_EXPUNGED)
127+
@Param(description = "The VM from which the backup was taken is expunged", since = "4.22.0")
128+
private Boolean vmExpunged;
129+
126130
public String getId() {
127131
return id;
128132
}
@@ -306,4 +310,8 @@ public Boolean getVmOfferingRemoved() {
306310
public void setVmOfferingRemoved(Boolean vmOfferingRemoved) {
307311
this.vmOfferingRemoved = vmOfferingRemoved;
308312
}
313+
314+
public void setVmExpunged(Boolean vmExpunged) {
315+
this.vmExpunged = vmExpunged;
316+
}
309317
}

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,10 +2136,15 @@ public BackupResponse createBackupResponse(Backup backup, Boolean listVmDetails)
21362136
response.setId(backup.getUuid());
21372137
response.setName(backup.getName());
21382138
response.setDescription(backup.getDescription());
2139-
response.setVmName(vm.getHostName());
2140-
response.setVmId(vm.getUuid());
2141-
if (vm.getBackupOfferingId() == null || vm.getBackupOfferingId() != backup.getBackupOfferingId()) {
2142-
response.setVmOfferingRemoved(true);
2139+
if (vm != null) {
2140+
response.setVmName(vm.getHostName());
2141+
response.setVmId(vm.getUuid());
2142+
if (vm.getBackupOfferingId() == null || vm.getBackupOfferingId() != backup.getBackupOfferingId()) {
2143+
response.setVmOfferingRemoved(true);
2144+
}
2145+
}
2146+
if (vm == null || VirtualMachine.State.Expunging.equals(vm.getState())) {
2147+
response.setVmExpunged(true);
21432148
}
21442149
response.setExternalId(backup.getExternalId());
21452150
response.setType(backup.getType());
@@ -2155,9 +2160,11 @@ public BackupResponse createBackupResponse(Backup backup, Boolean listVmDetails)
21552160
}
21562161
}
21572162
// ACS 4.20: For backups taken prior this release the backup.backed_volumes column would be empty hence use vm_instance.backup_volumes
2158-
String backedUpVolumes;
2163+
String backedUpVolumes = "";
21592164
if (Objects.isNull(backup.getBackedUpVolumes())) {
2160-
backedUpVolumes = new Gson().toJson(vm.getBackupVolumeList().toArray(), Backup.VolumeInfo[].class);
2165+
if (vm != null) {
2166+
backedUpVolumes = new Gson().toJson(vm.getBackupVolumeList().toArray(), Backup.VolumeInfo[].class);
2167+
}
21612168
} else {
21622169
backedUpVolumes = new Gson().toJson(backup.getBackedUpVolumes().toArray(), Backup.VolumeInfo[].class);
21632170
}

ui/src/views/storage/CreateVMFromBackup.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<a-form-item :label="$t('label.name.optional')" name="name">
3030
<a-input v-model:value="form.name" />
3131
</a-form-item>
32-
<a-form-item v-if="!resource.virtualmachineid" name="preserveIpAddresses" style="margin-top: 8px">
32+
<a-form-item v-if="resource.backupvmexpunged" name="preserveIpAddresses" style="margin-top: 8px">
3333
<a-switch v-model:checked="form.preserveIpAddresses" />
3434
<template #label>
3535
<tooltip-label :title="$t('label.use.backup.ip.address')" :tooltip="$t('label.use.backup.ip.address.tooltip')"/>
@@ -128,7 +128,7 @@ export default {
128128
this.dataPreFill.templateid = this.vmdetails.templateid
129129
this.dataPreFill.allowtemplateisoselection = true
130130
this.dataPreFill.isoid = this.vmdetails.templateid
131-
this.dataPreFill.allowIpAddressesFetch = !this.resource.virtualmachineid
131+
this.dataPreFill.allowIpAddressesFetch = this.resource.backupvmexpunged
132132
if (this.vmdetails.nics) {
133133
const nics = JSON.parse(this.vmdetails.nics)
134134
this.dataPreFill.networkids = nics.map(nic => nic.networkid)

0 commit comments

Comments
 (0)