mirror of https://github.com/apache/cloudstack.git
Added a new service to enabled zone-wide, shared source NAT rules.
This commit is contained in:
parent
d043c36890
commit
435e178eef
|
|
@ -93,6 +93,7 @@ public interface Network extends ControlledEntity {
|
|||
public static final Provider F5BigIp = new Provider("F5BigIp");
|
||||
public static final Provider ExternalDhcpServer = new Provider("ExternalDhcpServer");
|
||||
public static final Provider ExternalGateWay = new Provider("ExternalGateWay");
|
||||
public static final Provider None = new Provider("None");
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,8 @@ public interface NetworkOffering {
|
|||
boolean isVpnService();
|
||||
|
||||
boolean isDhcpService();
|
||||
|
||||
boolean isSharedSourceNatService();
|
||||
|
||||
GuestIpType getGuestType();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -560,11 +560,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
boolean isSourceNat = false;
|
||||
|
||||
txn.start();
|
||||
// First IP address should be source nat when it's being associated with Guest Virtual network
|
||||
List<IPAddressVO> addrs = listPublicIpAddressesInVirtualNetwork(ownerId, zoneId, true, networkId);
|
||||
|
||||
NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
|
||||
if (!offering.isSharedSourceNatService()) {
|
||||
// First IP address should be source nat when it's being associated with Guest Virtual network
|
||||
List<IPAddressVO> addrs = listPublicIpAddressesInVirtualNetwork(ownerId, zoneId, true, networkId);
|
||||
|
||||
if (addrs.isEmpty() && network.getGuestType() == GuestIpType.Virtual) {
|
||||
isSourceNat = true;
|
||||
if (addrs.isEmpty() && network.getGuestType() == GuestIpType.Virtual) {
|
||||
isSourceNat = true;
|
||||
}
|
||||
}
|
||||
|
||||
ip = fetchNewPublicIp(zoneId, null, null, ipOwner, VlanType.VirtualNetwork, network.getId(), isSourceNat, false);
|
||||
|
|
@ -1119,8 +1123,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
network.setMode(result.getMode());
|
||||
_networksDao.update(networkId, network);
|
||||
|
||||
// If network if guest virtual and there is no source nat ip, associate a new one
|
||||
if (network.getGuestType() == GuestIpType.Virtual) {
|
||||
// If this is a guest virtual network and the 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.getGuestType() == GuestIpType.Virtual && !offering.isSharedSourceNatService()) {
|
||||
List<IPAddressVO> ips = _ipAddressDao.listByAssociatedNetwork(networkId, true);
|
||||
|
||||
if (ips.isEmpty()) {
|
||||
|
|
@ -2618,11 +2623,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
DataCenterVO zone = _dcDao.findById(zoneId);
|
||||
|
||||
if (zone.getNetworkType() == NetworkType.Advanced) {
|
||||
return (zone.getGatewayProvider() != null && zone.getGatewayProvider().equals(Network.Provider.JuniperSRX.getName()) && zone.getFirewallProvider() != null
|
||||
&& zone.getFirewallProvider().equals(Network.Provider.JuniperSRX.getName()) && zone.getLoadBalancerProvider() != null && zone.getLoadBalancerProvider().equals(
|
||||
Network.Provider.F5BigIp.getName()));
|
||||
return (zone.getGatewayProvider() != null && zone.getGatewayProvider().equals(Network.Provider.JuniperSRX.getName()) &&
|
||||
zone.getFirewallProvider() != null && zone.getGatewayProvider().equals(Network.Provider.JuniperSRX.getName()));
|
||||
} else {
|
||||
return (zone.getFirewallProvider() != null && zone.getFirewallProvider().equals(Network.Provider.JuniperSRX.getName()));
|
||||
return (zone.getFirewallProvider() != null && zone.getFirewallProvider().equals(Network.Provider.JuniperSRX.getName()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,6 +107,9 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
@Column(name="dhcp_service")
|
||||
boolean dhcpService;
|
||||
|
||||
@Column(name="shared_source_nat_service")
|
||||
boolean sharedSourceNatService;
|
||||
|
||||
@Column(name="guest_type")
|
||||
GuestIpType guestType;
|
||||
|
||||
|
|
@ -296,6 +299,15 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
this.dhcpService = dhcpService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSharedSourceNatService() {
|
||||
return sharedSourceNatService;
|
||||
}
|
||||
|
||||
public void setSharedSourceNatService(boolean sharedSourceNatService) {
|
||||
this.sharedSourceNatService = sharedSourceNatService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuestIpType getGuestType() {
|
||||
return guestType;
|
||||
|
|
|
|||
|
|
@ -253,6 +253,7 @@ CREATE TABLE `cloud`.`network_offerings` (
|
|||
`userdata_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if network offering provides user data service',
|
||||
`vpn_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if network offering provides vpn service',
|
||||
`dhcp_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if network offering provides dhcp service',
|
||||
`shared_source_nat_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the network offering provides the shared source nat service',
|
||||
`guest_type` char(32) COMMENT 'guest ip type of network offering',
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `i_network_offerings__removed`(`removed`)
|
||||
|
|
|
|||
Loading…
Reference in New Issue