mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Check if source nat service is enabled before acquiring the source nat ip address
This commit is contained in:
parent
07591807af
commit
1c430aad44
@ -1266,9 +1266,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
network.setMode(result.getMode());
|
||||
_networksDao.update(networkId, network);
|
||||
|
||||
// If this is a guest virtual network and the network offering does not support a shared source NAT rule,
|
||||
// If this is a 1) guest virtual network 2) network has sourceNat service 3) network offering does not support a Shared source NAT rule,
|
||||
// associate a source NAT IP (if one isn't already associated with the network)
|
||||
if (network.getType() == Network.Type.Isolated && !offering.isSharedSourceNatService()) {
|
||||
if (network.getType() == Network.Type.Isolated && isServiceSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.SourceNat) && !offering.isSharedSourceNatService()) {
|
||||
List<IPAddressVO> ips = _ipAddressDao.listByAssociatedNetwork(networkId, true);
|
||||
|
||||
if (ips.isEmpty()) {
|
||||
|
||||
@ -118,6 +118,7 @@ import com.cloud.network.LoadBalancerVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
@ -1038,18 +1039,22 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
if (routers.size() >= routerCount) {
|
||||
return routers;
|
||||
}
|
||||
|
||||
PublicIp sourceNatIp = _networkMgr.assignSourceNatIpAddress(owner, guestNetwork, _accountService.getSystemUser().getId());
|
||||
|
||||
NicProfile defaultNic = new NicProfile();
|
||||
defaultNic.setDefaultNic(true);
|
||||
defaultNic.setIp4Address(sourceNatIp.getAddress().addr());
|
||||
defaultNic.setGateway(sourceNatIp.getGateway());
|
||||
defaultNic.setNetmask(sourceNatIp.getNetmask());
|
||||
defaultNic.setMacAddress(sourceNatIp.getMacAddress());
|
||||
defaultNic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||
defaultNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(sourceNatIp.getVlanTag()));
|
||||
defaultNic.setIsolationUri(IsolationType.Vlan.toUri(sourceNatIp.getVlanTag()));
|
||||
defaultNic.setDeviceId(2);
|
||||
//if source nat service is supported by the network, get the source nat ip address
|
||||
if (_networkMgr.isServiceSupportedByNetworkOffering(guestNetwork.getNetworkOfferingId(), Service.SourceNat)) {
|
||||
PublicIp sourceNatIp = _networkMgr.assignSourceNatIpAddress(owner, guestNetwork, _accountService.getSystemUser().getId());
|
||||
defaultNic.setDefaultNic(true);
|
||||
defaultNic.setIp4Address(sourceNatIp.getAddress().addr());
|
||||
defaultNic.setGateway(sourceNatIp.getGateway());
|
||||
defaultNic.setNetmask(sourceNatIp.getNetmask());
|
||||
defaultNic.setMacAddress(sourceNatIp.getMacAddress());
|
||||
defaultNic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||
defaultNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(sourceNatIp.getVlanTag()));
|
||||
defaultNic.setIsolationUri(IsolationType.Vlan.toUri(sourceNatIp.getVlanTag()));
|
||||
defaultNic.setDeviceId(2);
|
||||
}
|
||||
|
||||
int count = routerCount - routers.size();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user