Skip to content

Commit 6c6f40f

Browse files
shwstppryadvr
authored andcommitted
server: fix for public IP addresses filtering (#3368)
Added missing parameter in listPublicIpAddresses API. Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 28d7eef commit 6c6f40f

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ public class ListPublicIpAddressesCmd extends BaseListTaggedResourcesCmd {
8686
description = "lists all public IP addresses associated to the network specified")
8787
private Long associatedNetworkId;
8888

89+
@Parameter(name = ApiConstants.NETWORK_ID,
90+
type = CommandType.UUID,
91+
entityType = NetworkResponse.class,
92+
description = "lists all public IP addresses by source network ID",
93+
since = "4.13.0")
94+
private Long networkId;
95+
8996
@Parameter(name = ApiConstants.IS_SOURCE_NAT, type = CommandType.BOOLEAN, description = "list only source NAT IP addresses")
9097
private Boolean isSourceNat;
9198

@@ -133,6 +140,10 @@ public Long getAssociatedNetworkId() {
133140
return associatedNetworkId;
134141
}
135142

143+
public Long getNetworkId() {
144+
return networkId;
145+
}
146+
136147
public Boolean isSourceNat() {
137148
return isSourceNat;
138149
}

server/src/main/java/com/cloud/server/ManagementServerImpl.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import javax.inject.Inject;
3838
import javax.naming.ConfigurationException;
3939

40-
import com.cloud.storage.ScopeType;
4140
import org.apache.cloudstack.acl.ControlledEntity;
4241
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
4342
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
@@ -217,10 +216,10 @@
217216
import org.apache.cloudstack.api.command.admin.usage.DeleteTrafficMonitorCmd;
218217
import org.apache.cloudstack.api.command.admin.usage.DeleteTrafficTypeCmd;
219218
import org.apache.cloudstack.api.command.admin.usage.GenerateUsageRecordsCmd;
220-
import org.apache.cloudstack.api.command.admin.usage.ListUsageRecordsCmd;
221219
import org.apache.cloudstack.api.command.admin.usage.ListTrafficMonitorsCmd;
222220
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
223221
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypesCmd;
222+
import org.apache.cloudstack.api.command.admin.usage.ListUsageRecordsCmd;
224223
import org.apache.cloudstack.api.command.admin.usage.ListUsageTypesCmd;
225224
import org.apache.cloudstack.api.command.admin.usage.RemoveRawUsageRecordsCmd;
226225
import org.apache.cloudstack.api.command.admin.usage.UpdateTrafficTypeCmd;
@@ -634,6 +633,7 @@
634633
import com.cloud.storage.GuestOSHypervisorVO;
635634
import com.cloud.storage.GuestOSVO;
636635
import com.cloud.storage.GuestOsCategory;
636+
import com.cloud.storage.ScopeType;
637637
import com.cloud.storage.StorageManager;
638638
import com.cloud.storage.StoragePool;
639639
import com.cloud.storage.Volume;
@@ -1848,6 +1848,7 @@ public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(final ListP
18481848
final Object keyword = cmd.getKeyword();
18491849
final Long physicalNetworkId = cmd.getPhysicalNetworkId();
18501850
final Long associatedNetworkId = cmd.getAssociatedNetworkId();
1851+
final Long sourceNetworkId = cmd.getNetworkId();
18511852
final Long zone = cmd.getZoneId();
18521853
final String address = cmd.getIpAddress();
18531854
final Long vlan = cmd.getVlanId();
@@ -1893,7 +1894,8 @@ public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(final ListP
18931894
sb.and("vlanDbId", sb.entity().getVlanId(), SearchCriteria.Op.EQ);
18941895
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
18951896
sb.and("physicalNetworkId", sb.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ);
1896-
sb.and("associatedNetworkIdEq", sb.entity().getAssociatedWithNetworkId(), SearchCriteria.Op.EQ);
1897+
sb.and("associatedNetworkId", sb.entity().getAssociatedWithNetworkId(), SearchCriteria.Op.EQ);
1898+
sb.and("sourceNetworkId", sb.entity().getSourceNetworkId(), SearchCriteria.Op.EQ);
18971899
sb.and("isSourceNat", sb.entity().isSourceNat(), SearchCriteria.Op.EQ);
18981900
sb.and("isStaticNat", sb.entity().isOneToOneNat(), SearchCriteria.Op.EQ);
18991901
sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ);
@@ -1991,7 +1993,11 @@ public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(final ListP
19911993
}
19921994

19931995
if (associatedNetworkId != null) {
1994-
sc.setParameters("associatedNetworkIdEq", associatedNetworkId);
1996+
sc.setParameters("associatedNetworkId", associatedNetworkId);
1997+
}
1998+
1999+
if (sourceNetworkId != null) {
2000+
sc.setParameters("sourceNetworkId", sourceNetworkId);
19952001
}
19962002

19972003
if (forDisplay != null) {

0 commit comments

Comments
 (0)