Skip to content

Commit 9681a28

Browse files
authored
api: Display hypervisor type for VM snapshot (#4275)
The "hypervisor" field in listvmsnapshot response will be used in primate to enable/disable creating snapshot from vm snapshot functionality. Creating snpashot from vm snapshot will be enabled only if hypervisor is KVM
1 parent b68be66 commit 9681a28

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.LinkedHashSet;
2222
import java.util.Set;
2323

24+
import com.cloud.hypervisor.Hypervisor;
2425
import org.apache.cloudstack.api.ApiConstants;
2526
import org.apache.cloudstack.api.BaseResponseWithTagInformation;
2627
import org.apache.cloudstack.api.EntityReference;
@@ -100,6 +101,10 @@ public class VMSnapshotResponse extends BaseResponseWithTagInformation implement
100101
@Param(description = "the domain associated with the disk volume")
101102
private String domainName;
102103

104+
@SerializedName(ApiConstants.HYPERVISOR)
105+
@Param(description = "the type of hypervisor on which snapshot is stored")
106+
private Hypervisor.HypervisorType hypervisor;
107+
103108
public VMSnapshotResponse() {
104109
tags = new LinkedHashSet<ResourceTagResponse>();
105110
}
@@ -236,4 +241,12 @@ public void setDomainName(String domainName) {
236241
public void setTags(Set<ResourceTagResponse> tags) {
237242
this.tags = tags;
238243
}
244+
245+
public Hypervisor.HypervisorType getHypervisor() {
246+
return hypervisor;
247+
}
248+
249+
public void setHypervisor(Hypervisor.HypervisorType hypervisor) {
250+
this.hypervisor = hypervisor;
251+
}
239252
}

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ public VMSnapshotResponse createVMSnapshotResponse(VMSnapshot vmSnapshot) {
620620
UserVm vm = ApiDBUtils.findUserVmById(vmSnapshot.getVmId());
621621
if (vm != null) {
622622
vmSnapshotResponse.setVirtualMachineid(vm.getUuid());
623+
vmSnapshotResponse.setHypervisor(vm.getHypervisorType());
623624
DataCenterVO datacenter = ApiDBUtils.findZoneById(vm.getDataCenterId());
624625
if (datacenter != null) {
625626
vmSnapshotResponse.setZoneId(datacenter.getUuid());

0 commit comments

Comments
 (0)