Skip to content
Merged
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,6 @@ 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 @@ -1067,12 +1067,6 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
Network.GuestType.Isolated, true, false, false, false, true, false);

defaultIsolatedSourceNatEnabledNetworkOffering.setState(NetworkOffering.State.Enabled);
// Default egress policy is Allow on fresh installations, consistent with the
// createNetworkOffering API default (egressdefaultpolicy=true when not specified).
// Existing installations are not affected: this method only runs on first boot
// (guarded by the "init" configuration flag) and persistDefaultNetworkOffering()
// never updates an already existing offering.
defaultIsolatedSourceNatEnabledNetworkOffering.setEgressDefaultPolicy(true);
defaultIsolatedSourceNatEnabledNetworkOffering.setSupportsVmAutoScaling(true);
defaultIsolatedSourceNatEnabledNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultIsolatedSourceNatEnabledNetworkOffering);
Comment on lines 1069 to 1071

Expand All @@ -1090,9 +1084,6 @@ 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);
// This offering carries no Firewall service, so the flag is not enforced anywhere;
// it is set for consistency so API responses do not advertise a misleading Deny policy.
defaultIsolatedEnabledNetworkOffering.setEgressDefaultPolicy(true);
defaultIsolatedEnabledNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultIsolatedEnabledNetworkOffering);

for (Service service : defaultIsolatedNetworkOfferingProviders.keySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import com.cloud.dc.dao.VlanDao;
import com.cloud.domain.dao.DomainDao;
import com.cloud.network.dao.NetworkDao;
import com.cloud.offering.NetworkOffering;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.offerings.dao.NetworkOfferingDao;
import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
import com.cloud.service.dao.ServiceOfferingDao;
Expand All @@ -37,16 +35,12 @@
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;

import java.util.HashMap;
import java.util.Map;

@RunWith(MockitoJUnitRunner.class)
public class ConfigurationServerImplTest {

Expand Down Expand Up @@ -128,37 +122,4 @@ public void testUpdateSystemvmPassword() {
//teardown
System.setProperty("user.name", realusername);
}

@Test
public void testCreateDefaultNetworkOfferingsSeedsIsolatedOfferingsWithEgressAllow() {
Mockito.when(_networkOfferingDao.persistDefaultNetworkOffering(Mockito.any(NetworkOfferingVO.class)))
.thenAnswer(invocation -> invocation.getArgument(0));

try (TransactionLegacy txn = TransactionLegacy.open("testCreateDefaultNetworkOfferings")) {
configurationServer.createDefaultNetworkOfferings();
}

ArgumentCaptor<NetworkOfferingVO> captor = ArgumentCaptor.forClass(NetworkOfferingVO.class);
Mockito.verify(_networkOfferingDao, Mockito.atLeastOnce()).persistDefaultNetworkOffering(captor.capture());

Map<String, NetworkOfferingVO> offeringsByName = new HashMap<>();
for (NetworkOfferingVO offering : captor.getAllValues()) {
offeringsByName.putIfAbsent(offering.getUniqueName(), offering);
}

NetworkOfferingVO isolatedSourceNatOffering = offeringsByName.get(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService);
Assert.assertNotNull(isolatedSourceNatOffering);
Assert.assertTrue("Built-in Isolated source-NAT offering must be seeded with egress default policy Allow on fresh installations",
isolatedSourceNatOffering.isEgressDefaultPolicy());

NetworkOfferingVO isolatedOffering = offeringsByName.get(NetworkOffering.DefaultIsolatedNetworkOffering);
Assert.assertNotNull(isolatedOffering);
Assert.assertTrue("Built-in Isolated (no source-NAT) offering must be seeded with egress default policy Allow on fresh installations",
isolatedOffering.isEgressDefaultPolicy());

NetworkOfferingVO sharedOffering = offeringsByName.get(NetworkOffering.DefaultSharedNetworkOffering);
Assert.assertNotNull(sharedOffering);
Assert.assertFalse("Built-in Shared offering seeding must remain unchanged",
sharedOffering.isEgressDefaultPolicy());
}
}
2 changes: 1 addition & 1 deletion ui/src/views/offering/AddNetworkOffering.vue
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ export default {
isolation: 'dedicated',
conservemode: true,
availability: 'optional',
egressdefaultpolicy: 'allow',
egressdefaultpolicy: 'deny',
ispublic: this.isPublic,
nsxsupportlb: true,
routingmode: 'static'
Expand Down
Loading