This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/master by this push:
     new a06530d  CLOUDSTACK-10007 Isolation method claim (#2249)
a06530d is described below

commit a06530ddd8d56a253bd787087f3487b5fff9c79e
Author: dahn <daan.hoogl...@gmail.com>
AuthorDate: Thu Sep 28 11:07:48 2017 +0200

    CLOUDSTACK-10007 Isolation method claim (#2249)
    
    CLOUDSTACK-10007 isolationMethod claiming
---
 .../com/cloud/network/guru/DirectNetworkGuru.java  | 24 +++++++++++++++++++---
 .../network/guru/DirectPodBasedNetworkGuru.java    |  5 +++--
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/server/src/com/cloud/network/guru/DirectNetworkGuru.java 
b/server/src/com/cloud/network/guru/DirectNetworkGuru.java
index 09afd6b..c92bb45 100644
--- a/server/src/com/cloud/network/guru/DirectNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/DirectNetworkGuru.java
@@ -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
diff --git a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java 
b/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
index 6301ca5..e984421 100644
--- a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
@@ -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");

-- 
To stop receiving notification emails like this one, please contact
['"commits@cloudstack.apache.org" <commits@cloudstack.apache.org>'].

Reply via email to