This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.15
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.15 by this push:
new f50cc27 server: fix list public ip returns duplicated records (#5464)
f50cc27 is described below
commit f50cc27a5c94705fc38a5134462730e2f2448577
Author: Wei Zhou <[email protected]>
AuthorDate: Mon Sep 20 07:19:53 2021 +0200
server: fix list public ip returns duplicated records (#5464)
* server: fix list public ip returns duplicated records
* update #5464: fix shared network
---
server/src/main/java/com/cloud/server/ManagementServerImpl.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java
b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
index 93c1e9b..2c52b67 100644
--- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
@@ -2128,7 +2128,7 @@ public class ManagementServerImpl extends ManagerBase
implements ManagementServe
_accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive,
permittedAccounts, listProjectResourcesCriteria);
}
- buildParameters(sb, cmd);
+ buildParameters(sb, cmd, vlanType == VlanType.VirtualNetwork ? true :
isAllocated);
SearchCriteria<IPAddressVO> sc = sb.create();
setParameters(sc, cmd, vlanType);
@@ -2190,7 +2190,7 @@ public class ManagementServerImpl extends ManagerBase
implements ManagementServe
}
if (freeAddrIds.size() > 0) {
final SearchBuilder<IPAddressVO> sb2 =
_publicIpAddressDao.createSearchBuilder();
- buildParameters(sb2, cmd);
+ buildParameters(sb2, cmd, false);
sb2.and("ids", sb2.entity().getId(), SearchCriteria.Op.IN);
SearchCriteria<IPAddressVO> sc2 = sb2.create();
@@ -2198,6 +2198,7 @@ public class ManagementServerImpl extends ManagerBase
implements ManagementServe
sc2.setParameters("ids", freeAddrIds.toArray());
addrs.addAll(_publicIpAddressDao.search(sc2, searchFilter)); //
Allocated + Free
}
+ Collections.sort(addrs, Comparator.comparing(IPAddressVO::getAddress));
List<? extends IpAddress> wPagination =
com.cloud.utils.StringUtils.applyPagination(addrs, cmd.getStartIndex(),
cmd.getPageSizeVal());
if (wPagination != null) {
return new Pair<List<? extends IpAddress>, Integer>(wPagination,
addrs.size());
@@ -2205,11 +2206,10 @@ public class ManagementServerImpl extends ManagerBase
implements ManagementServe
return new Pair<>(addrs, addrs.size());
}
- private void buildParameters(final SearchBuilder<IPAddressVO> sb, final
ListPublicIpAddressesCmd cmd) {
+ private void buildParameters(final SearchBuilder<IPAddressVO> sb, final
ListPublicIpAddressesCmd cmd, final Boolean isAllocated) {
final Object keyword = cmd.getKeyword();
final String address = cmd.getIpAddress();
final Boolean forLoadBalancing = cmd.isForLoadBalancing();
- Boolean isAllocated = cmd.isAllocatedOnly();
final Map<String, String> tags = cmd.getTags();
sb.and("dataCenterId", sb.entity().getDataCenterId(),
SearchCriteria.Op.EQ);