Updated Branches: refs/heads/4.2 34f75b0a5 -> f4e928260
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/f4e92826 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f4e92826 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f4e92826 Branch: refs/heads/4.2 Commit: f4e9282609c43eb52e4f53ee158bde03bf6be57c Parents: 34f75b0 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:15:48 2013 +0530 ---------------------------------------------------------------------- .../api/command/user/address/AssociateIPAddrCmd.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f4e92826/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 c97a5e4..77e8621 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 @@ -49,6 +49,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; import com.cloud.user.UserContext; @@ -210,6 +211,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());