CLOUDSTACK-4717: associate IP does not work on shared networks with out source nat service
relax the restriction that the source nat service should be avaiable in the network inorder to associate a public ip to the network Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/df3b0994 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/df3b0994 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/df3b0994 Branch: refs/heads/ui-restyle Commit: df3b09944968718111d9b6b29d4c7f5a5cfaf630 Parents: 0844066 Author: Murali Reddy <[email protected]> Authored: Wed Oct 16 18:46:37 2013 +0530 Committer: Murali Reddy <[email protected]> Committed: Wed Oct 16 18:46:37 2013 +0530 ---------------------------------------------------------------------- .../com/cloud/network/IpAddressManagerImpl.java | 23 +++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/df3b0994/server/src/com/cloud/network/IpAddressManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/IpAddressManagerImpl.java b/server/src/com/cloud/network/IpAddressManagerImpl.java index 9cc5e5d..74f316b 100644 --- a/server/src/com/cloud/network/IpAddressManagerImpl.java +++ b/server/src/com/cloud/network/IpAddressManagerImpl.java @@ -1198,12 +1198,23 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage } } - // In Advance zone only allow to do IP assoc - // - for Isolated networks with source nat service enabled - // - for shared networks with source nat service enabled - if (zone.getNetworkType() == NetworkType.Advanced && !(_networkModel.areServicesSupportedInNetwork(network.getId(), Service.SourceNat))) { - throw new InvalidParameterValueException("In zone of type " + NetworkType.Advanced + " ip address can be associated only to the network of guest type " + - GuestType.Isolated + " with the " + Service.SourceNat.getName() + " enabled"); + if (zone.getNetworkType() == NetworkType.Advanced) { + // In Advance zone allow to do IP assoc only for Isolated networks with source nat service enabled + if (network.getGuestType() == GuestType.Isolated && + !(_networkModel.areServicesSupportedInNetwork(network.getId(), Service.SourceNat))) { + throw new InvalidParameterValueException("In zone of type " + NetworkType.Advanced + + " ip address can be associated only to the network of guest type " + GuestType.Isolated + + " with the " + Service.SourceNat.getName() + " enabled"); + } + + // In Advance zone allow to do IP assoc only for shared networks with source nat/static nat/lb/pf services enabled + if (network.getGuestType() == GuestType.Shared && + !isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) { + throw new InvalidParameterValueException("In zone of type " + NetworkType.Advanced + + " ip address can be associated with network of guest type " + GuestType.Shared + "only if at " + + "least one of the services " + Service.SourceNat.getName() + "/" + Service.StaticNat.getName() + "/" + + Service.Lb.getName() + "/" + Service.PortForwarding.getName() + " is enabled"); + } } NetworkOffering offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
