|
32 | 32 | import java.util.concurrent.Executors; |
33 | 33 | import java.util.concurrent.ScheduledExecutorService; |
34 | 34 | import java.util.concurrent.TimeUnit; |
| 35 | + |
35 | 36 | import javax.inject.Inject; |
36 | 37 | import javax.naming.ConfigurationException; |
37 | 38 |
|
38 | | -import com.cloud.network.dao.NetworkDetailsDao; |
39 | | -import com.cloud.network.dao.RemoteAccessVpnDao; |
40 | | -import com.cloud.network.dao.RemoteAccessVpnVO; |
41 | | -import com.cloud.network.dao.VpnUserDao; |
42 | | -import com.cloud.network.element.RedundantResource; |
43 | | -import com.cloud.network.router.VirtualRouter; |
44 | | -import com.cloud.vm.DomainRouterVO; |
45 | | -import com.cloud.vm.dao.DomainRouterDao; |
46 | | -import org.apache.log4j.Logger; |
47 | 39 | import org.apache.cloudstack.acl.ControlledEntity.ACLType; |
48 | 40 | import org.apache.cloudstack.context.CallContext; |
49 | 41 | import org.apache.cloudstack.engine.cloud.entity.api.db.VMNetworkMapVO; |
|
58 | 50 | import org.apache.cloudstack.framework.messagebus.PublishScope; |
59 | 51 | import org.apache.cloudstack.managed.context.ManagedContextRunnable; |
60 | 52 | import org.apache.cloudstack.region.PortableIpDao; |
| 53 | +import org.apache.log4j.Logger; |
| 54 | + |
61 | 55 | import com.cloud.agent.AgentManager; |
62 | 56 | import com.cloud.agent.Listener; |
63 | 57 | import com.cloud.agent.api.AgentControlAnswer; |
|
129 | 123 | import com.cloud.network.dao.NetworkAccountDao; |
130 | 124 | import com.cloud.network.dao.NetworkAccountVO; |
131 | 125 | import com.cloud.network.dao.NetworkDao; |
| 126 | +import com.cloud.network.dao.NetworkDetailsDao; |
132 | 127 | import com.cloud.network.dao.NetworkDomainDao; |
133 | 128 | import com.cloud.network.dao.NetworkDomainVO; |
134 | 129 | import com.cloud.network.dao.NetworkServiceMapDao; |
|
139 | 134 | import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao; |
140 | 135 | import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO; |
141 | 136 | import com.cloud.network.dao.PhysicalNetworkVO; |
| 137 | +import com.cloud.network.dao.RemoteAccessVpnDao; |
| 138 | +import com.cloud.network.dao.RemoteAccessVpnVO; |
| 139 | +import com.cloud.network.dao.VpnUserDao; |
142 | 140 | import com.cloud.network.element.AggregatedCommandExecutor; |
143 | 141 | import com.cloud.network.element.DhcpServiceProvider; |
144 | 142 | import com.cloud.network.element.DnsServiceProvider; |
145 | 143 | import com.cloud.network.element.IpDeployer; |
146 | 144 | import com.cloud.network.element.LoadBalancingServiceProvider; |
147 | 145 | import com.cloud.network.element.NetworkElement; |
| 146 | +import com.cloud.network.element.RedundantResource; |
148 | 147 | import com.cloud.network.element.StaticNatServiceProvider; |
149 | 148 | import com.cloud.network.element.UserDataServiceProvider; |
150 | 149 | import com.cloud.network.guru.NetworkGuru; |
151 | 150 | import com.cloud.network.guru.NetworkGuruAdditionalFunctions; |
152 | 151 | import com.cloud.network.lb.LoadBalancingRulesManager; |
| 152 | +import com.cloud.network.router.VirtualRouter; |
153 | 153 | import com.cloud.network.rules.FirewallManager; |
154 | 154 | import com.cloud.network.rules.FirewallRule; |
155 | 155 | import com.cloud.network.rules.FirewallRule.Purpose; |
|
197 | 197 | import com.cloud.utils.fsm.NoTransitionException; |
198 | 198 | import com.cloud.utils.fsm.StateMachine2; |
199 | 199 | import com.cloud.utils.net.NetUtils; |
| 200 | +import com.cloud.vm.DomainRouterVO; |
200 | 201 | import com.cloud.vm.Nic; |
201 | 202 | import com.cloud.vm.Nic.ReservationStrategy; |
202 | 203 | import com.cloud.vm.NicIpAlias; |
|
209 | 210 | import com.cloud.vm.VirtualMachine; |
210 | 211 | import com.cloud.vm.VirtualMachine.Type; |
211 | 212 | import com.cloud.vm.VirtualMachineProfile; |
| 213 | +import com.cloud.vm.dao.DomainRouterDao; |
212 | 214 | import com.cloud.vm.dao.NicDao; |
213 | 215 | import com.cloud.vm.dao.NicIpAliasDao; |
214 | 216 | import com.cloud.vm.dao.NicIpAliasVO; |
@@ -2017,9 +2019,9 @@ public void expungeNics(final VirtualMachineProfile vm) { |
2017 | 2019 | @Override |
2018 | 2020 | @DB |
2019 | 2021 | public Network createGuestNetwork(final long networkOfferingId, final String name, final String displayText, final String gateway, final String cidr, String vlanId, |
2020 | | - String networkDomain, final Account owner, final Long domainId, final PhysicalNetwork pNtwk, final long zoneId, final ACLType aclType, Boolean subdomainAccess, |
2021 | | - final Long vpcId, final String ip6Gateway, final String ip6Cidr, final Boolean isDisplayNetworkEnabled, final String isolatedPvlan) |
2022 | | - throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException { |
| 2022 | + boolean bypassVlanOverlapCheck, String networkDomain, final Account owner, final Long domainId, final PhysicalNetwork pNtwk, |
| 2023 | + final long zoneId, final ACLType aclType, Boolean subdomainAccess, final Long vpcId, final String ip6Gateway, final String ip6Cidr, |
| 2024 | + final Boolean isDisplayNetworkEnabled, final String isolatedPvlan) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException { |
2023 | 2025 |
|
2024 | 2026 | final NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId); |
2025 | 2027 | // this method supports only guest network creation |
@@ -2136,19 +2138,19 @@ public Network createGuestNetwork(final long networkOfferingId, final String nam |
2136 | 2138 | } |
2137 | 2139 |
|
2138 | 2140 | if (vlanSpecified) { |
| 2141 | + URI uri = BroadcastDomainType.fromString(vlanId); |
2139 | 2142 | //don't allow to specify vlan tag used by physical network for dynamic vlan allocation |
2140 | | - if (_dcDao.findVnet(zoneId, pNtwk.getId(), vlanId).size() > 0) { |
| 2143 | + if (!(bypassVlanOverlapCheck && ntwkOff.getGuestType() == GuestType.Shared) && _dcDao.findVnet(zoneId, pNtwk.getId(), BroadcastDomainType.getValue(uri)).size() > 0) { |
2141 | 2144 | throw new InvalidParameterValueException("The VLAN tag " + vlanId + " is already being used for dynamic vlan allocation for the guest network in zone " |
2142 | 2145 | + zone.getName()); |
2143 | 2146 | } |
2144 | 2147 | if (! UuidUtils.validateUUID(vlanId)){ |
2145 | | - final String uri = BroadcastDomainType.fromString(vlanId).toString(); |
2146 | 2148 | // For Isolated networks, don't allow to create network with vlan that already exists in the zone |
2147 | 2149 | if (ntwkOff.getGuestType() == GuestType.Isolated) { |
2148 | | - if (_networksDao.countByZoneAndUri(zoneId, uri) > 0) { |
2149 | | - throw new InvalidParameterValueException("Network with vlan " + vlanId + " already exists in zone " + zoneId); |
| 2150 | + if (_networksDao.listByZoneAndUriAndGuestType(zoneId, uri.toString(), null).size() > 0) { |
| 2151 | + throw new InvalidParameterValueException("Network with vlan " + vlanId + " already exists or overlaps with other network vlans in zone " + zoneId); |
2150 | 2152 | } else { |
2151 | | - final List<DataCenterVnetVO> dcVnets = _datacenterVnetDao.findVnet(zoneId, vlanId.toString()); |
| 2153 | + final List<DataCenterVnetVO> dcVnets = _datacenterVnetDao.findVnet(zoneId, BroadcastDomainType.getValue(uri)); |
2152 | 2154 | //for the network that is created as part of private gateway, |
2153 | 2155 | //the vnet is not coming from the data center vnet table, so the list can be empty |
2154 | 2156 | if (!dcVnets.isEmpty()) { |
@@ -2177,8 +2179,8 @@ public Network createGuestNetwork(final long networkOfferingId, final String nam |
2177 | 2179 | } else { |
2178 | 2180 | // don't allow to creating shared network with given Vlan ID, if there already exists a isolated network or |
2179 | 2181 | // shared network with same Vlan ID in the zone |
2180 | | - if (_networksDao.countByZoneUriAndGuestType(zoneId, uri, GuestType.Isolated) > 0 ) { |
2181 | | - throw new InvalidParameterValueException("There is a isolated/shared network with vlan id: " + vlanId + " already exists " + "in zone " + zoneId); |
| 2182 | + if (!bypassVlanOverlapCheck && _networksDao.listByZoneAndUriAndGuestType(zoneId, uri.toString(), GuestType.Isolated).size() > 0 ) { |
| 2183 | + throw new InvalidParameterValueException("There is an existing isolated/shared network that overlaps with vlan id:" + vlanId + " in zone " + zoneId); |
2182 | 2184 | } |
2183 | 2185 | } |
2184 | 2186 | } |
@@ -3663,6 +3665,8 @@ public String getConfigComponentName() { |
3663 | 3665 |
|
3664 | 3666 | @Override |
3665 | 3667 | public ConfigKey<?>[] getConfigKeys() { |
3666 | | - return new ConfigKey<?>[] {NetworkGcWait, NetworkGcInterval, NetworkLockTimeout, GuestDomainSuffix, NetworkThrottlingRate, MinVRVersion}; |
| 3668 | + return new ConfigKey<?>[] {NetworkGcWait, NetworkGcInterval, NetworkLockTimeout, |
| 3669 | + GuestDomainSuffix, NetworkThrottlingRate, MinVRVersion, |
| 3670 | + PromiscuousMode, MacAddressChanges, ForgedTransmits}; |
3667 | 3671 | } |
3668 | 3672 | } |
0 commit comments