Updated Branches: refs/heads/master 098459432 -> 739f7cade
CLOUDSTACK-3764: [EIP/ELB] [BasicZone] Unable acquire IP as non-ROOT domain users Since the basic zone network is owned by 'Root' domain, domain access checkers will fail for the accounts in non-root domains while acquiring public IP. So add an exception for the 'Basic' zone shared network with EIP/ELB service. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/739f7cad Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/739f7cad Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/739f7cad Branch: refs/heads/master Commit: 739f7cadebb083b49d7ebdf11a0ed676a97ff262 Parents: 0984594 Author: Murali Reddy <muralimmre...@gmail.com> Authored: Thu Jul 25 19:10:00 2013 +0530 Committer: Murali Reddy <muralimmre...@gmail.com> Committed: Thu Jul 25 19:17:39 2013 +0530 ---------------------------------------------------------------------- .../api/command/user/address/AssociateIPAddrCmd.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/739f7cad/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java index d45d132..cb3da6b 100644 --- a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java @@ -51,6 +51,7 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.IpAddress; import com.cloud.network.Network; import com.cloud.network.vpc.Vpc; +import com.cloud.offering.NetworkOffering; import com.cloud.projects.Project; import com.cloud.user.Account; @@ -211,6 +212,20 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { } } else if (networkId != null){ Network network = _networkService.getNetwork(networkId); + if (network == null) { + throw new InvalidParameterValueException("Unable to find network by network id specified"); + } + + NetworkOffering offering = _configService.getNetworkOffering(network.getNetworkOfferingId()); + + DataCenter zone = _configService.getZone(network.getDataCenterId()); + if (zone.getNetworkType() == NetworkType.Basic && offering.getElasticIp() && offering.getElasticLb()) { + // Since the basic zone network is owned by 'Root' domain, domain access checkers will fail for the + // accounts in non-root domains while acquiring public IP. So add an exception for the 'Basic' zone + // shared network with EIP/ELB service. + return caller.getAccountId(); + } + return network.getAccountId(); } else if (vpcId != null) { Vpc vpc = _vpcService.getVpc(getVpcId());