From 923c0cd89f9ba35a1cdbc1c4502a04620e9eff79 Mon Sep 17 00:00:00 2001 From: Jayapal Date: Thu, 12 Jun 2014 16:50:17 +0530 Subject: [PATCH] CLOUDSTACK-6899: Added vmId in listnics response --- .../org/apache/cloudstack/api/response/NicResponse.java | 8 ++++++++ server/src/com/cloud/api/ApiResponseHelper.java | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/api/src/org/apache/cloudstack/api/response/NicResponse.java b/api/src/org/apache/cloudstack/api/response/NicResponse.java index 3dd8b297a2b..2f79d7ff477 100644 --- a/api/src/org/apache/cloudstack/api/response/NicResponse.java +++ b/api/src/org/apache/cloudstack/api/response/NicResponse.java @@ -98,6 +98,14 @@ public class NicResponse extends BaseResponse { @Param(description = "device id for the network when plugged into the virtual machine", since = "4.4") private String deviceId; + @SerializedName(ApiConstants.VIRTUAL_MACHINE_ID) + @Param(description = "Id of the vm to which the nic belongs") + private String vmId; + + public void setVmId(String vmId) { + this.vmId = vmId; + } + public String getId() { return id; } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 682b617d413..f1f0d2cfd5a 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -3302,9 +3302,15 @@ public class ApiResponseHelper implements ResponseGenerator { public NicResponse createNicResponse(Nic result) { NicResponse response = new NicResponse(); NetworkVO network = _entityMgr.findById(NetworkVO.class, result.getNetworkId()); + VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, result.getInstanceId()); response.setId(result.getUuid()); response.setNetworkid(network.getUuid()); + + if (vm != null) { + response.setVmId(vm.getUuid()); + } + response.setIpaddress(result.getIp4Address()); if (result.getSecondaryIp()) {