3535import com .cloud .exception .InsufficientCapacityException ;
3636import com .cloud .exception .InsufficientVirtualNetworkCapacityException ;
3737import com .cloud .exception .InvalidParameterValueException ;
38+ import com .cloud .network .dao .PhysicalNetworkDao ;
39+ import com .cloud .network .dao .PhysicalNetworkVO ;
3840import com .cloud .network .IpAddressManager ;
3941import com .cloud .network .Ipv6AddressManager ;
4042import com .cloud .network .Network ;
4648import com .cloud .network .Networks .BroadcastDomainType ;
4749import com .cloud .network .Networks .Mode ;
4850import com .cloud .network .Networks .TrafficType ;
51+ import com .cloud .network .PhysicalNetwork ;
52+ import com .cloud .network .PhysicalNetwork .IsolationMethod ;
4953import com .cloud .network .dao .IPAddressDao ;
5054import com .cloud .network .dao .IPAddressVO ;
5155import com .cloud .network .dao .NetworkVO ;
@@ -99,8 +103,11 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
99103 IpAddressManager _ipAddrMgr ;
100104 @ Inject
101105 NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao ;
106+ @ Inject
107+ PhysicalNetworkDao _physicalNetworkDao ;
102108
103109 private static final TrafficType [] TrafficTypes = {TrafficType .Guest };
110+ protected IsolationMethod [] _isolationMethods ;
104111
105112 @ Override
106113 public boolean isMyTrafficType (TrafficType type ) {
@@ -112,14 +119,23 @@ public boolean isMyTrafficType(TrafficType type) {
112119 return false ;
113120 }
114121
122+ protected boolean isMyIsolationMethod (PhysicalNetwork physicalNetwork ) {
123+ for (IsolationMethod m : _isolationMethods ) {
124+ if (physicalNetwork .getIsolationMethods ().contains (m .toString ())) {
125+ return true ;
126+ }
127+ }
128+ return false ;
129+ }
130+
115131 @ Override
116132 public TrafficType [] getSupportedTrafficType () {
117133 return TrafficTypes ;
118134 }
119135
120- protected boolean canHandle (NetworkOffering offering , DataCenter dc ) {
136+ protected boolean canHandle (NetworkOffering offering , DataCenter dc , PhysicalNetwork physnet ) {
121137 // this guru handles only Guest networks in Advance zone with source nat service disabled
122- if (dc .getNetworkType () == NetworkType .Advanced && isMyTrafficType (offering .getTrafficType ()) && offering .getGuestType () == GuestType .Shared
138+ if (dc .getNetworkType () == NetworkType .Advanced && isMyTrafficType (offering .getTrafficType ()) && isMyIsolationMethod ( physnet ) && offering .getGuestType () == GuestType .Shared
123139 && !_ntwkOfferingSrvcDao .isProviderForNetworkOffering (offering .getId (), Network .Provider .NuageVsp )
124140 && !_ntwkOfferingSrvcDao .isProviderForNetworkOffering (offering .getId (), Network .Provider .NiciraNvp )) {
125141 return true ;
@@ -132,8 +148,9 @@ protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
132148 @ Override
133149 public Network design (NetworkOffering offering , DeploymentPlan plan , Network userSpecified , Account owner ) {
134150 DataCenter dc = _dcDao .findById (plan .getDataCenterId ());
151+ PhysicalNetworkVO physnet = _physicalNetworkDao .findById (plan .getPhysicalNetworkId ());
135152
136- if (!canHandle (offering , dc )) {
153+ if (!canHandle (offering , dc , physnet )) {
137154 return null ;
138155 }
139156
@@ -190,6 +207,7 @@ public Network design(NetworkOffering offering, DeploymentPlan plan, Network use
190207
191208 protected DirectNetworkGuru () {
192209 super ();
210+ _isolationMethods = new IsolationMethod [] { new IsolationMethod ("VLAN" ) };
193211 }
194212
195213 @ Override
0 commit comments