Skip to content

Commit b8522c9

Browse files
ustcweizhouyadvr
authored andcommitted
server: allow dedicate ip range to a domain if ips are used by an accout in the domain (apache#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.
1 parent bd78030 commit b8522c9

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

server/src/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3601,9 +3601,9 @@ public boolean deleteVlanAndPublicIpRange(final long userId, final long vlanDbId
36013601
}
36023602

36033603
boolean isDomainSpecific = false;
3604-
List<DomainVlanMapVO> domainVln = _domainVlanMapDao.listDomainVlanMapsByVlan(vlanRange.getId());
3604+
List<DomainVlanMapVO> domainVlan = _domainVlanMapDao.listDomainVlanMapsByVlan(vlanRange.getId());
36053605
// Check for domain wide pool. It will have an entry for domain_vlan_map.
3606-
if (domainVln != null && !domainVln.isEmpty()) {
3606+
if (domainVlan != null && !domainVlan.isEmpty()) {
36073607
isDomainSpecific = true;
36083608
}
36093609

@@ -3760,10 +3760,10 @@ public Vlan dedicatePublicIpRange(final DedicatePublicIpRangeCmd cmd) throws Res
37603760
forSystemVms = ip.isForSystemVms();
37613761
final Long allocatedToAccountId = ip.getAllocatedToAccountId();
37623762
if (allocatedToAccountId != null) {
3763-
final Account accountAllocatedTo = _accountMgr.getActiveAccountById(allocatedToAccountId);
3764-
if (!accountAllocatedTo.getAccountName().equalsIgnoreCase(accountName)) {
3763+
if (vlanOwner != null && allocatedToAccountId != vlanOwner.getId()) {
37653764
throw new InvalidParameterValueException(ip.getAddress() + " Public IP address in range is allocated to another account ");
37663765
}
3766+
final Account accountAllocatedTo = _accountMgr.getActiveAccountById(allocatedToAccountId);
37673767
if (vlanOwner == null && domain != null && domain.getId() != accountAllocatedTo.getDomainId()){
37683768
throw new InvalidParameterValueException(ip.getAddress()
37693769
+ " Public IP address in range is allocated to another domain/account ");
@@ -3824,9 +3824,9 @@ public boolean releasePublicIpRange(final long vlanDbId, final long userId, fina
38243824
}
38253825

38263826
boolean isDomainSpecific = false;
3827-
final List<DomainVlanMapVO> domainVln = _domainVlanMapDao.listDomainVlanMapsByVlan(vlanDbId);
3827+
final List<DomainVlanMapVO> domainVlan = _domainVlanMapDao.listDomainVlanMapsByVlan(vlanDbId);
38283828
// Check for domain wide pool. It will have an entry for domain_vlan_map.
3829-
if (domainVln != null && !domainVln.isEmpty()) {
3829+
if (domainVlan != null && !domainVlan.isEmpty()) {
38303830
isDomainSpecific = true;
38313831
}
38323832

@@ -3879,7 +3879,7 @@ public boolean releasePublicIpRange(final long vlanDbId, final long userId, fina
38793879
// decrement resource count for dedicated public ip's
38803880
_resourceLimitMgr.decrementResourceCount(acctVln.get(0).getAccountId(), ResourceType.public_ip, new Long(ips.size()));
38813881
return true;
3882-
} else if (isDomainSpecific && _domainVlanMapDao.remove(domainVln.get(0).getId())) {
3882+
} else if (isDomainSpecific && _domainVlanMapDao.remove(domainVlan.get(0).getId())) {
38833883
s_logger.debug("Remove the vlan from domain_vlan_map successfully.");
38843884
return true;
38853885
} else {

0 commit comments

Comments
 (0)