This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.11
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.11 by this push:
new b8522c9 server: allow dedicate ip range to a domain if ips are used
by an accout in the domain (#3206)
b8522c9 is described below
commit b8522c97cb9204e16a9dd4c138bdbf0046992820
Author: ustcweizhou <[email protected]>
AuthorDate: Fri May 31 08:54:33 2019 +0200
server: allow dedicate ip range to a domain if ips are used by an accout in
the domain (#3206)
when we dedicate public ip range to a domain but some ips are used by an
account in the domain,
the operation should be allowed but actually fails for now.
It is because cloudstack check if ips are used by same account by account
name,
However, accountName is null when dedicate public ip range to a domain.
Modify the code to check account id only when dedicate ip range to account.
---
.../com/cloud/configuration/ConfigurationManagerImpl.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 9075ee9..d023075 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -3601,9 +3601,9 @@ public class ConfigurationManagerImpl extends ManagerBase
implements Configurati
}
boolean isDomainSpecific = false;
- List<DomainVlanMapVO> domainVln =
_domainVlanMapDao.listDomainVlanMapsByVlan(vlanRange.getId());
+ List<DomainVlanMapVO> domainVlan =
_domainVlanMapDao.listDomainVlanMapsByVlan(vlanRange.getId());
// Check for domain wide pool. It will have an entry for
domain_vlan_map.
- if (domainVln != null && !domainVln.isEmpty()) {
+ if (domainVlan != null && !domainVlan.isEmpty()) {
isDomainSpecific = true;
}
@@ -3760,10 +3760,10 @@ public class ConfigurationManagerImpl extends
ManagerBase implements Configurati
forSystemVms = ip.isForSystemVms();
final Long allocatedToAccountId = ip.getAllocatedToAccountId();
if (allocatedToAccountId != null) {
- final Account accountAllocatedTo =
_accountMgr.getActiveAccountById(allocatedToAccountId);
- if
(!accountAllocatedTo.getAccountName().equalsIgnoreCase(accountName)) {
+ if (vlanOwner != null && allocatedToAccountId !=
vlanOwner.getId()) {
throw new InvalidParameterValueException(ip.getAddress() +
" Public IP address in range is allocated to another account ");
}
+ final Account accountAllocatedTo =
_accountMgr.getActiveAccountById(allocatedToAccountId);
if (vlanOwner == null && domain != null && domain.getId() !=
accountAllocatedTo.getDomainId()){
throw new InvalidParameterValueException(ip.getAddress()
+ " Public IP address in range is allocated to
another domain/account ");
@@ -3824,9 +3824,9 @@ public class ConfigurationManagerImpl extends ManagerBase
implements Configurati
}
boolean isDomainSpecific = false;
- final List<DomainVlanMapVO> domainVln =
_domainVlanMapDao.listDomainVlanMapsByVlan(vlanDbId);
+ final List<DomainVlanMapVO> domainVlan =
_domainVlanMapDao.listDomainVlanMapsByVlan(vlanDbId);
// Check for domain wide pool. It will have an entry for
domain_vlan_map.
- if (domainVln != null && !domainVln.isEmpty()) {
+ if (domainVlan != null && !domainVlan.isEmpty()) {
isDomainSpecific = true;
}
@@ -3879,7 +3879,7 @@ public class ConfigurationManagerImpl extends ManagerBase
implements Configurati
// decrement resource count for dedicated public ip's
_resourceLimitMgr.decrementResourceCount(acctVln.get(0).getAccountId(),
ResourceType.public_ip, new Long(ips.size()));
return true;
- } else if (isDomainSpecific &&
_domainVlanMapDao.remove(domainVln.get(0).getId())) {
+ } else if (isDomainSpecific &&
_domainVlanMapDao.remove(domainVlan.get(0).getId())) {
s_logger.debug("Remove the vlan from domain_vlan_map
successfully.");
return true;
} else {