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
This commit is contained in:
Murali Reddy 2013-10-16 18:15:26 +05:30
parent 4cc8af0532
commit 4d07493a5e
1 changed files with 17 additions and 8 deletions

View File

@ -970,14 +970,23 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
}
}
// 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());