From 3f53ada5f3f88d0bb53dba2f0f09f8ae0e169213 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Tue, 21 Aug 2012 10:51:32 -0700 Subject: [PATCH] PublicIpAddress api response: new parameter "associatednetworkname" - the name of the guest network associated with the ip address Reviewed-by: Frank Zhang --- api/src/com/cloud/api/ApiConstants.java | 1 + api/src/com/cloud/api/response/IPAddressResponse.java | 7 +++++++ server/src/com/cloud/api/ApiResponseHelper.java | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/api/src/com/cloud/api/ApiConstants.java b/api/src/com/cloud/api/ApiConstants.java index a44e70c1d49..6ddec6d6289 100755 --- a/api/src/com/cloud/api/ApiConstants.java +++ b/api/src/com/cloud/api/ApiConstants.java @@ -313,6 +313,7 @@ public class ApiConstants { public static final String FIREWALL_DEVICE_DEDICATED = "fwdevicededicated"; public static final String SERVICE = "service"; public static final String ASSOCIATED_NETWORK_ID = "associatednetworkid"; + public static final String ASSOCIATED_NETWORK_NAME = "associatednetworkname"; public static final String SOURCE_NAT_SUPPORTED = "sourcenatsupported"; public static final String RESOURCE_STATE = "resourcestate"; public static final String PROJECT_INVITE_REQUIRED = "projectinviterequired"; diff --git a/api/src/com/cloud/api/response/IPAddressResponse.java b/api/src/com/cloud/api/response/IPAddressResponse.java index ad59cf0917c..b54833bac55 100644 --- a/api/src/com/cloud/api/response/IPAddressResponse.java +++ b/api/src/com/cloud/api/response/IPAddressResponse.java @@ -82,6 +82,9 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR @SerializedName(ApiConstants.ASSOCIATED_NETWORK_ID) @Param(description="the ID of the Network associated with the IP address") private IdentityProxy associatedNetworkId = new IdentityProxy("networks"); + @SerializedName(ApiConstants.ASSOCIATED_NETWORK_NAME) @Param(description="the name of the Network associated with the IP address") + private String associatedNetworkName; + @SerializedName(ApiConstants.NETWORK_ID) @Param(description="the ID of the Network where ip belongs to") private IdentityProxy networkId = new IdentityProxy("networks"); @@ -218,4 +221,8 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR public void setTags(List tags) { this.tags = tags; } + + public void setAssociatedNetworkName(String associatedNetworkName) { + this.associatedNetworkName = associatedNetworkName; + } } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index a6a3ccc6e52..b019ad44414 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -814,7 +814,12 @@ public class ApiResponseHelper implements ResponseGenerator { } } - ipResponse.setAssociatedNetworkId(ipAddr.getAssociatedWithNetworkId()); + if (ipAddr.getAssociatedWithNetworkId() != null) { + Network ntwk = ApiDBUtils.findNetworkById(ipAddr.getAssociatedWithNetworkId()); + ipResponse.setAssociatedNetworkId(ipAddr.getAssociatedWithNetworkId()); + ipResponse.setAssociatedNetworkName(ntwk.getName()); + } + ipResponse.setVpcId(ipAddr.getVpcId()); // Network id the ip is associated with (if associated networkId is null, try to get this information from vlan)