diff --git a/api/src/com/cloud/api/ApiConstants.java b/api/src/com/cloud/api/ApiConstants.java index 825e276b4be..425b9fb645e 100755 --- a/api/src/com/cloud/api/ApiConstants.java +++ b/api/src/com/cloud/api/ApiConstants.java @@ -317,6 +317,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 da73b69ca3d..a9c1769406f 100644 --- a/api/src/com/cloud/api/response/IPAddressResponse.java +++ b/api/src/com/cloud/api/response/IPAddressResponse.java @@ -86,6 +86,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"); @@ -226,4 +229,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 a0a4c171da7..73344880bbf 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -806,7 +806,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) @@ -3918,4 +3923,4 @@ public class ApiResponseHelper implements ResponseGenerator { response.setObjectName("vpnconnection"); return response; } -} \ No newline at end of file +}