mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-10007 Isolation method claim (#2249)
CLOUDSTACK-10007 isolationMethod claiming
This commit is contained in:
parent
b130e55088
commit
a06530ddd8
@ -35,6 +35,8 @@ import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkVO;
|
||||
import com.cloud.network.IpAddressManager;
|
||||
import com.cloud.network.Ipv6AddressManager;
|
||||
import com.cloud.network.Network;
|
||||
@ -46,6 +48,8 @@ import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetwork.IsolationMethod;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.IPAddressVO;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
@ -99,8 +103,11 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
IpAddressManager _ipAddrMgr;
|
||||
@Inject
|
||||
NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
|
||||
@Inject
|
||||
PhysicalNetworkDao _physicalNetworkDao;
|
||||
|
||||
private static final TrafficType[] TrafficTypes = {TrafficType.Guest};
|
||||
protected IsolationMethod[] _isolationMethods;
|
||||
|
||||
@Override
|
||||
public boolean isMyTrafficType(TrafficType type) {
|
||||
@ -112,14 +119,23 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isMyIsolationMethod(PhysicalNetwork physicalNetwork) {
|
||||
for (IsolationMethod m : _isolationMethods) {
|
||||
if (physicalNetwork.getIsolationMethods().contains(m.toString())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrafficType[] getSupportedTrafficType() {
|
||||
return TrafficTypes;
|
||||
}
|
||||
|
||||
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||
protected boolean canHandle(NetworkOffering offering, DataCenter dc, PhysicalNetwork physnet) {
|
||||
// this guru handles only Guest networks in Advance zone with source nat service disabled
|
||||
if (dc.getNetworkType() == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() == GuestType.Shared
|
||||
if (dc.getNetworkType() == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && isMyIsolationMethod(physnet) && offering.getGuestType() == GuestType.Shared
|
||||
&& !_ntwkOfferingSrvcDao.isProviderForNetworkOffering(offering.getId(), Network.Provider.NuageVsp)
|
||||
&& !_ntwkOfferingSrvcDao.isProviderForNetworkOffering(offering.getId(), Network.Provider.NiciraNvp)) {
|
||||
return true;
|
||||
@ -132,8 +148,9 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
@Override
|
||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
||||
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
|
||||
PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
|
||||
|
||||
if (!canHandle(offering, dc)) {
|
||||
if (!canHandle(offering, dc, physnet)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -190,6 +207,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
|
||||
protected DirectNetworkGuru() {
|
||||
super();
|
||||
_isolationMethods = new IsolationMethod[] { new IsolationMethod("VLAN") };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -47,6 +47,7 @@ import com.cloud.network.Networks.IsolationType;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.IPAddressVO;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.utils.db.DB;
|
||||
@ -83,9 +84,9 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
|
||||
IpAddressManager _ipAddrMgr;
|
||||
|
||||
@Override
|
||||
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||
protected boolean canHandle(NetworkOffering offering, DataCenter dc, PhysicalNetwork physnet) {
|
||||
// this guru handles system Direct pod based network
|
||||
if (dc.getNetworkType() == NetworkType.Basic && isMyTrafficType(offering.getTrafficType())) {
|
||||
if (dc.getNetworkType() == NetworkType.Basic && isMyTrafficType(offering.getTrafficType()) && isMyIsolationMethod(physnet)) {
|
||||
return true;
|
||||
} else {
|
||||
s_logger.trace("We only take care of Guest Direct Pod based networks");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user