Skip to content

Commit

Permalink
CLOUDSTACK-10007 Isolation method claim (apache#2249)
Browse files Browse the repository at this point in the history
CLOUDSTACK-10007 isolationMethod claiming
  • Loading branch information
DaanHoogland authored Sep 28, 2017
1 parent b130e55 commit a06530d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
24 changes: 21 additions & 3 deletions server/src/com/cloud/network/guru/DirectNetworkGuru.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
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;
Expand All @@ -46,6 +48,8 @@
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;
Expand Down Expand Up @@ -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) {
Expand All @@ -112,14 +119,23 @@ public boolean isMyTrafficType(TrafficType type) {
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;
Expand All @@ -132,8 +148,9 @@ protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
@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;
}

Expand Down Expand Up @@ -190,6 +207,7 @@ public Network design(NetworkOffering offering, DeploymentPlan plan, Network use

protected DirectNetworkGuru() {
super();
_isolationMethods = new IsolationMethod[] { new IsolationMethod("VLAN") };
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit a06530d

Please sign in to comment.