Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import java.util.LinkedHashSet;
import java.util.Set;

import com.cloud.hypervisor.Hypervisor;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponseWithTagInformation;
import org.apache.cloudstack.api.EntityReference;

import com.cloud.hypervisor.Hypervisor;
import com.cloud.serializer.Param;
import com.cloud.vm.snapshot.VMSnapshot;
import com.google.gson.annotations.SerializedName;
Expand Down Expand Up @@ -57,9 +57,17 @@ public class VMSnapshotResponse extends BaseResponseWithTagInformation implement
@Param(description = "the Zone ID of the vm snapshot")
private String zoneId;

@SerializedName(ApiConstants.ZONE_NAME)
@Param(description = "the Zone name of the vm snapshot", since = "4.15.1")
private String zoneName;

@SerializedName(ApiConstants.VIRTUAL_MACHINE_ID)
@Param(description = "the vm ID of the vm snapshot")
private String virtualMachineid;
private String virtualMachineId;

@SerializedName(ApiConstants.VIRTUAL_MACHINE_NAME)
@Param(description = "the vm name of the vm snapshot", since = "4.15.1")
private String virtualMachineName;

@SerializedName("parent")
@Param(description = "the parent ID of the vm snapshot")
Expand Down Expand Up @@ -154,12 +162,28 @@ public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}

public String getVirtualMachineid() {
return virtualMachineid;
public String getZoneName() {
return zoneName;
}

public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}

public String getVirtualMachineId() {
return virtualMachineId;
}

public void setVirtualMachineId(String virtualMachineId) {
this.virtualMachineId = virtualMachineId;
}

public String getVirtualMachineName() {
return virtualMachineName;
}

public void setVirtualMachineid(String virtualMachineid) {
this.virtualMachineid = virtualMachineid;
public void setVirtualMachineName(String virtualMachineName) {
this.virtualMachineName = virtualMachineName;
}

public void setName(String name) {
Expand Down
9 changes: 6 additions & 3 deletions server/src/main/java/com/cloud/api/ApiResponseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// under the License.
package com.cloud.api;

import static com.cloud.utils.NumbersUtil.toHumanReadableSize;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
Expand Down Expand Up @@ -349,8 +351,7 @@
import com.cloud.vm.snapshot.VMSnapshot;
import com.cloud.vm.snapshot.VMSnapshotVO;
import com.cloud.vm.snapshot.dao.VMSnapshotDao;

import static com.cloud.utils.NumbersUtil.toHumanReadableSize;
import com.google.common.base.Strings;

public class ApiResponseHelper implements ResponseGenerator {

Expand Down Expand Up @@ -621,11 +622,13 @@ public VMSnapshotResponse createVMSnapshotResponse(VMSnapshot vmSnapshot) {
vmSnapshotResponse.setDisplayName(vmSnapshot.getDisplayName());
UserVm vm = ApiDBUtils.findUserVmById(vmSnapshot.getVmId());
if (vm != null) {
vmSnapshotResponse.setVirtualMachineid(vm.getUuid());
vmSnapshotResponse.setVirtualMachineId(vm.getUuid());
vmSnapshotResponse.setVirtualMachineName(Strings.isNullOrEmpty(vm.getDisplayName()) ? vm.getHostName() : vm.getDisplayName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - we need one check if for normal user/account it leaks the internal hostname (is hostname the i-x-y-VM?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked hostname would return name from the Db table, lgtm

vmSnapshotResponse.setHypervisor(vm.getHypervisorType());
DataCenterVO datacenter = ApiDBUtils.findZoneById(vm.getDataCenterId());
if (datacenter != null) {
vmSnapshotResponse.setZoneId(datacenter.getUuid());
vmSnapshotResponse.setZoneName(datacenter.getName());
}
}
if (vmSnapshot.getParent() != null) {
Expand Down