Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/src/main/java/com/cloud/network/NetworkService.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ public interface NetworkService {
"allow.end.users.to.specify.vr.mtu", "false", "Allow end Users to specify VR MTU",
true, ConfigKey.Scope.Zone);

public static final ConfigKey<Boolean> DefaultEgressPolicyForIsolatedNetworksAllow = new ConfigKey<>("Network", Boolean.class,
"network.isolated.default.egress.policy.allow", "true",
"Default egress policy for Isolated guest networks when no policy is specified. When true (default), egress " +
"traffic is allowed unless explicitly denied by egress firewall rules, matching the behaviour of VPC tiers. When " +
"false, egress is denied unless explicitly allowed. Applies to the built-in default Isolated network offerings " +
"seeded on a fresh installation and to network offerings created via createNetworkOffering without an explicit " +
"egressdefaultpolicy. Existing network offerings and already-created networks are not affected.",
true, ConfigKey.Scope.Global);

List<? extends Network> getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner);

IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp, String ipaddress) throws ResourceAllocationException, InsufficientAddressCapacityException,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.Network;
import com.cloud.network.NetworkService;
import com.cloud.network.VirtualRouterProvider;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.Account;
Expand Down Expand Up @@ -335,7 +336,7 @@ public Boolean getForTungsten() {

public Boolean getEgressDefaultPolicy() {
if (egressDefaultPolicy == null) {
return true;
return NetworkService.DefaultEgressPolicyForIsolatedNetworksAllow.value();
}
return egressDefaultPolicy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ public boolean isEgressDefaultPolicy() {
return egressdefaultpolicy;
}

public void setEgressDefaultPolicy(boolean egressdefaultpolicy) {
this.egressdefaultpolicy = egressdefaultpolicy;
}

public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps,
Integer multicastRateMbps, boolean isDefault, Availability availability, String tags, Network.GuestType guestType, boolean conserveMode,
boolean specifyIpRanges, boolean isPersistent, boolean internalLb, boolean publicLb, boolean isForVpc) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6313,7 +6313,7 @@ public String getConfigComponentName() {

@Override
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {AllowDuplicateNetworkName, AllowEmptyStartEndIpAddress, AllowUsersToMakeNetworksRedundant, VRPrivateInterfaceMtu, VRPublicInterfaceMtu, AllowUsersToSpecifyVRMtu};
return new ConfigKey<?>[] {AllowDuplicateNetworkName, AllowEmptyStartEndIpAddress, AllowUsersToMakeNetworksRedundant, VRPrivateInterfaceMtu, VRPublicInterfaceMtu, AllowUsersToSpecifyVRMtu, DefaultEgressPolicyForIsolatedNetworksAllow};
}

public boolean isDefaultAcl(Long aclId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
import com.cloud.network.Network.State;
import com.cloud.network.NetworkService;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
Expand Down Expand Up @@ -1017,6 +1018,12 @@ protected void createDefaultNetworkOfferings() {
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
// Default egress policy for the built-in Isolated network offerings. Allow by default (matching VPC tiers),
// overridable via the global setting network.isolated.default.egress.policy.allow before first initialization.
final boolean isolatedNetworkEgressDefaultPolicyAllow = Boolean.parseBoolean(_configDao.getValueAndInitIfNotExist(
NetworkService.DefaultEgressPolicyForIsolatedNetworksAllow.key(), "Network",
NetworkService.DefaultEgressPolicyForIsolatedNetworksAllow.defaultValue()));

// Offering #1
NetworkOfferingVO defaultSharedSGNetworkOffering =
new NetworkOfferingVO(NetworkOffering.DefaultSharedNetworkOfferingWithSGService, "Offering for Shared Security group enabled networks",
Expand Down Expand Up @@ -1068,6 +1075,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {

defaultIsolatedSourceNatEnabledNetworkOffering.setState(NetworkOffering.State.Enabled);
defaultIsolatedSourceNatEnabledNetworkOffering.setSupportsVmAutoScaling(true);
defaultIsolatedSourceNatEnabledNetworkOffering.setEgressDefaultPolicy(isolatedNetworkEgressDefaultPolicyAllow);
defaultIsolatedSourceNatEnabledNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultIsolatedSourceNatEnabledNetworkOffering);

for (Service service : defaultIsolatedSourceNatEnabledNetworkOfferingProviders.keySet()) {
Expand All @@ -1084,6 +1092,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
false, true, null, null, true, Availability.Optional, null, Network.GuestType.Isolated, true, true, false, false, false, false);

defaultIsolatedEnabledNetworkOffering.setState(NetworkOffering.State.Enabled);
defaultIsolatedEnabledNetworkOffering.setEgressDefaultPolicy(isolatedNetworkEgressDefaultPolicyAllow);
defaultIsolatedEnabledNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultIsolatedEnabledNetworkOffering);

for (Service service : defaultIsolatedNetworkOfferingProviders.keySet()) {
Expand Down
Loading