You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2021/02/19 09:23:05 UTC

[cloudstack] branch 4.15 updated: api: add zone, vm name params in listVmSnapshot response (#4604)

This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch 4.15
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.15 by this push:
     new f489439  api: add zone, vm name params in listVmSnapshot response (#4604)
f489439 is described below

commit f489439a3ad130aad3985ae14e19d60beabf44bf
Author: Abhishek Kumar <ab...@gmail.com>
AuthorDate: Fri Feb 19 14:52:48 2021 +0530

    api: add zone, vm name params in listVmSnapshot response (#4604)
    
    * api: add zone, vm name params in listVmSnaphots response
    
    Signed-off-by: Abhishek Kumar <ab...@gmail.com>
---
 .../api/response/VMSnapshotResponse.java           | 36 ++++++++++++++++++----
 .../main/java/com/cloud/api/ApiResponseHelper.java |  9 ++++--
 2 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/api/src/main/java/org/apache/cloudstack/api/response/VMSnapshotResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/VMSnapshotResponse.java
index f5d7dbd..30709c4 100644
--- a/api/src/main/java/org/apache/cloudstack/api/response/VMSnapshotResponse.java
+++ b/api/src/main/java/org/apache/cloudstack/api/response/VMSnapshotResponse.java
@@ -21,11 +21,11 @@ import java.util.Date;
 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;
@@ -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")
@@ -154,12 +162,28 @@ public class VMSnapshotResponse extends BaseResponseWithTagInformation implement
         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) {
diff --git a/server/src/main/java/com/cloud/api/ApiResponseHelper.java b/server/src/main/java/com/cloud/api/ApiResponseHelper.java
index b03fa7d..473c501 100644
--- a/server/src/main/java/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/main/java/com/cloud/api/ApiResponseHelper.java
@@ -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;
@@ -349,8 +351,7 @@ import com.cloud.vm.dao.NicSecondaryIpVO;
 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 {
 
@@ -621,11 +622,13 @@ public class ApiResponseHelper implements ResponseGenerator {
         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());
             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) {