You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by nv...@apache.org on 2022/04/06 03:17:36 UTC
[cloudstack] branch main updated: server: fix list reserved/free public ips in project (#6198)
This is an automated email from the ASF dual-hosted git repository.
nvazquez pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push:
new e4b6992def server: fix list reserved/free public ips in project (#6198)
e4b6992def is described below
commit e4b6992def467701d8dfdbcf91f84e590ff5e63d
Author: Wei Zhou <we...@apache.org>
AuthorDate: Wed Apr 6 05:17:31 2022 +0200
server: fix list reserved/free public ips in project (#6198)
---
.../java/com/cloud/server/ManagementServerImpl.java | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
index 2dcb9d85e8..4477eb85d8 100644
--- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
@@ -2228,10 +2228,14 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
final Filter searchFilter = new Filter(IPAddressVO.class, "address", false, null, null);
final SearchBuilder<IPAddressVO> sb = _publicIpAddressDao.createSearchBuilder();
Long domainId = null;
- Boolean isRecursive = null;
+ Boolean isRecursive = cmd.isRecursive();
final List<Long> permittedAccounts = new ArrayList<>();
ListProjectResourcesCriteria listProjectResourcesCriteria = null;
- if (isAllocated || (vlanType == VlanType.VirtualNetwork && (caller.getType() != Account.Type.ADMIN || cmd.getDomainId() != null))) {
+ Boolean isAllocatedOrReserved = false;
+ if (isAllocated || IpAddress.State.Reserved.name().equalsIgnoreCase(state)) {
+ isAllocatedOrReserved = true;
+ }
+ if (isAllocatedOrReserved || (vlanType == VlanType.VirtualNetwork && (caller.getType() != Account.Type.ADMIN || cmd.getDomainId() != null))) {
final Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(),
null);
_accountMgr.buildACLSearchParameters(caller, cmd.getId(), cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false);
@@ -2246,7 +2250,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
SearchCriteria<IPAddressVO> sc = sb.create();
setParameters(sc, cmd, vlanType, isAllocated);
- if (isAllocated || (vlanType == VlanType.VirtualNetwork && (caller.getType() != Account.Type.ADMIN || cmd.getDomainId() != null))) {
+ if (isAllocatedOrReserved || (vlanType == VlanType.VirtualNetwork && (caller.getType() != Account.Type.ADMIN || cmd.getDomainId() != null))) {
_accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
}
@@ -2263,9 +2267,14 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
// Free IP addresses in system IP ranges
List<Long> freeAddrIds = new ArrayList<>();
- if (!(isAllocated || vlanType == VlanType.DirectAttached)) {
+ if (!(isAllocatedOrReserved || vlanType == VlanType.DirectAttached)) {
Long zoneId = zone;
- Account owner = _accountMgr.finalizeOwner(CallContext.current().getCallingAccount(), cmd.getAccountName(), cmd.getDomainId(), cmd.getProjectId());
+ Account owner;
+ if (cmd.getProjectId() != null && cmd.getProjectId() != -1) {
+ owner = _accountMgr.finalizeOwner(CallContext.current().getCallingAccount(), cmd.getAccountName(), cmd.getDomainId(), cmd.getProjectId());
+ } else {
+ owner = _accountMgr.finalizeOwner(CallContext.current().getCallingAccount(), cmd.getAccountName(), cmd.getDomainId(), null);
+ }
if (associatedNetworkId != null) {
NetworkVO guestNetwork = _networkDao.findById(associatedNetworkId);
if (zoneId == null) {