Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2128,7 +2128,7 @@ public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(final ListP
_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);
Expand Down Expand Up @@ -2190,26 +2190,26 @@ public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(final ListP
}
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();
setParameters(sc2, cmd, vlanType);
sc2.setParameters("ids", freeAddrIds.toArray());
addrs.addAll(_publicIpAddressDao.search(sc2, searchFilter)); // Allocated + Free
}
Collections.sort(addrs, Comparator.comparing(IPAddressVO::getAddress));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nvazquez @rhtyd
do we need to order public ip address ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it would be good

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

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());
}
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);
Expand Down