From bc544d31e7e45cf5e87894b9c852b0165abf9f30 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Fri, 18 Nov 2011 15:56:41 -0800 Subject: [PATCH] listPublicIpAddresses by associatedNetworkId --- api/src/com/cloud/api/ApiConstants.java | 1 + .../cloud/api/commands/ListPublicIpAddressesCmd.java | 11 +++++++++-- api/src/com/cloud/api/response/IPAddressResponse.java | 2 +- server/src/com/cloud/server/ManagementServerImpl.java | 6 ++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/api/src/com/cloud/api/ApiConstants.java b/api/src/com/cloud/api/ApiConstants.java index 1d036a68956..e0c70935714 100755 --- a/api/src/com/cloud/api/ApiConstants.java +++ b/api/src/com/cloud/api/ApiConstants.java @@ -303,6 +303,7 @@ public class ApiConstants { public static final String FIREWALL_DEVICE_STATE = "fwdevicestate"; public static final String FIREWALL_DEVICE_CAPACITY = "fwdevicecapacity"; public static final String SERVICE = "service"; + public static final String ASSOCIATED_NETWORK_ID = "associatednetworkid"; public enum HostDetails { all, capacity, events, stats, min; diff --git a/api/src/com/cloud/api/commands/ListPublicIpAddressesCmd.java b/api/src/com/cloud/api/commands/ListPublicIpAddressesCmd.java index b54cbc81375..d14d2e76a59 100644 --- a/api/src/com/cloud/api/commands/ListPublicIpAddressesCmd.java +++ b/api/src/com/cloud/api/commands/ListPublicIpAddressesCmd.java @@ -81,6 +81,10 @@ public class ListPublicIpAddressesCmd extends BaseListCmd { @IdentityMapper(entityTableName="physical_network") @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="lists all public IP addresses by physical network id") private Long physicalNetworkId; + + @IdentityMapper(entityTableName="networks") + @Parameter(name=ApiConstants.ASSOCIATED_NETWORK_ID, type=CommandType.LONG, description="lists all public IP addresses associated to the network specified") + private Long associatedNetworkId; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -124,12 +128,15 @@ public class ListPublicIpAddressesCmd extends BaseListCmd { public Long getPhysicalNetworkId() { return physicalNetworkId; } + + public Long getAssociatedNetworkId() { + return associatedNetworkId; + } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// - - @Override + @Override public String getCommandName() { return s_name; } diff --git a/api/src/com/cloud/api/response/IPAddressResponse.java b/api/src/com/cloud/api/response/IPAddressResponse.java index 3bfb77779f6..5bad090f8ec 100644 --- a/api/src/com/cloud/api/response/IPAddressResponse.java +++ b/api/src/com/cloud/api/response/IPAddressResponse.java @@ -80,7 +80,7 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR @SerializedName("virtualmachinedisplayname") @Param(description="virutal machine display name the ip address is assigned to (not null only for static nat Ip)") private String virtualMachineDisplayName; - @SerializedName("associatednetworkid") @Param(description="the ID of the Network associated with the IP address") + @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.NETWORK_ID) @Param(description="the ID of the Network where ip belongs to") diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index ede2d729e60..7077a6e232f 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -2045,6 +2045,7 @@ public class ManagementServerImpl implements ManagementServer { Object keyword = cmd.getKeyword(); Long projectId = cmd.getProjectId(); Long physicalNetworkId = cmd.getPhysicalNetworkId(); + Long associatedNetworkId = cmd.getAssociatedNetworkId(); List permittedAccounts = new ArrayList(); @@ -2115,6 +2116,7 @@ public class ManagementServerImpl implements ManagementServer { sb.and("vlanDbId", sb.entity().getVlanId(), SearchCriteria.Op.EQ); sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); sb.and("physicalNetworkId", sb.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ); + sb.and("associatedNetworkId", sb.entity().getAssociatedWithNetworkId(), SearchCriteria.Op.EQ); if ((permittedAccounts.isEmpty()) && (domainId != null)) { // if accountId isn't specified, we can do a domain match for the admin case @@ -2181,6 +2183,10 @@ public class ManagementServerImpl implements ManagementServer { if (physicalNetworkId != null) { sc.setParameters("physicalNetworkId", physicalNetworkId); } + + if (associatedNetworkId != null) { + sc.setParameters("associatedNetworkId", associatedNetworkId); + } return _publicIpAddressDao.search(sc, searchFilter); }